Commit dd3c8fe8 authored by David Roger's avatar David Roger Committed by Commit Bot

[Dice] Reuse existing NTP for signin

This logic existed pre-dice, and was not ported to Dice.
This is required to enable Dice by default in all tests.

Bug: 825173
Change-Id: If3e4c7a0aebbb735be45875342d66a5436ef5f35
Reviewed-on: https://chromium-review.googlesource.com/980172Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546764}
parent a12debda
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/signin_view_controller_delegate.h" #include "chrome/browser/ui/signin_view_controller_delegate.h"
#include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
...@@ -147,7 +148,8 @@ void SigninViewController::ShowDiceSigninTab( ...@@ -147,7 +148,8 @@ void SigninViewController::ShowDiceSigninTab(
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false); ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false);
active_contents->OpenURL(params); active_contents->OpenURL(params);
} else { } else {
ShowSingletonTab(browser, signin_url); NavigateParams params = GetSingletonTabNavigateParams(browser, signin_url);
ShowSingletonTabOverwritingNTP(browser, params);
active_contents = browser->tab_strip_model()->GetActiveWebContents(); active_contents = browser->tab_strip_model()->GetActiveWebContents();
} }
DCHECK(active_contents); DCHECK(active_contents);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/test_extension_service.h" #include "chrome/browser/extensions/test_extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/signin/core/browser/account_info.h" #include "components/signin/core/browser/account_info.h"
#include "components/signin/core/browser/profile_management_switches.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
...@@ -32,6 +34,31 @@ ...@@ -32,6 +34,31 @@
#include "chrome/browser/ui/views/profiles/profile_chooser_view.h" #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
#endif #endif
namespace {
// Returns true if signin happens in a modal dialog and false if it happens in a
// regular tab.
bool IsSigninModal(Profile* profile) {
#if defined(OS_CHROMEOS)
return false;
#else
return AccountConsistencyModeManager::GetMethodForProfile(profile) ==
signin::AccountConsistencyMethod::kDiceFixAuthErrors;
#endif
}
// Returns whether the signin modal dialog is displayed.
bool ShowsModalDialog(Browser* browser) {
#if defined(OS_CHROMEOS)
NOTREACHED();
return false;
#else
return browser->signin_view_controller()->ShowsModalDialog();
#endif
}
} // namespace
class BookmarkBubbleSignInDelegateTest : public InProcessBrowserTest { class BookmarkBubbleSignInDelegateTest : public InProcessBrowserTest {
public: public:
BookmarkBubbleSignInDelegateTest() {} BookmarkBubbleSignInDelegateTest() {}
...@@ -68,12 +95,12 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) { ...@@ -68,12 +95,12 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
int starting_tab_count = browser()->tab_strip_model()->count(); int starting_tab_count = browser()->tab_strip_model()->count();
SignInBrowser(browser()); SignInBrowser(browser());
#if !defined(OS_CHROMEOS) if (IsSigninModal(profile())) {
EXPECT_TRUE(browser()->signin_view_controller()->ShowsModalDialog()); EXPECT_TRUE(ShowsModalDialog(browser()));
EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
#else } else {
EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count());
#endif }
} }
IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
...@@ -81,9 +108,9 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, ...@@ -81,9 +108,9 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
int starting_tab_count = browser()->tab_strip_model()->count(); int starting_tab_count = browser()->tab_strip_model()->count();
SignInBrowser(browser()); SignInBrowser(browser());
#if !defined(OS_CHROMEOS) if (IsSigninModal(profile())) {
EXPECT_TRUE(browser()->signin_view_controller()->ShowsModalDialog()); EXPECT_TRUE(ShowsModalDialog(browser()));
#endif }
EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
} }
...@@ -99,19 +126,21 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, ...@@ -99,19 +126,21 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
SignInBrowser(incognito_browser); SignInBrowser(incognito_browser);
int tab_count = browser()->tab_strip_model()->count(); int tab_count = browser()->tab_strip_model()->count();
if (IsSigninModal(profile())) {
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
// ProfileChooser doesn't show in an incognito window. // ProfileChooser doesn't show in an incognito window.
EXPECT_FALSE(ProfileChooserView::IsShowing()); EXPECT_FALSE(ProfileChooserView::IsShowing());
// Sign-in dialog is shown when there is at least one tab in the non-incognito
// browser.
EXPECT_EQ(starting_tab_count, tab_count);
EXPECT_TRUE(browser()->signin_view_controller()->ShowsModalDialog());
#else
// On ChromeOS, the full-tab signin page is used.
EXPECT_EQ(starting_tab_count + 1, tab_count);
#endif #endif
// Sign-in dialog is shown when there is at least one tab in the
// non-incognito browser.
EXPECT_EQ(starting_tab_count, tab_count);
EXPECT_TRUE(ShowsModalDialog(browser()));
} else {
// On ChromeOS, the full-tab signin page is used.
EXPECT_EQ(starting_tab_count + 1, tab_count);
}
// No effect is expected on the incognito browser. // No effect is expected on the incognito browser.
int tab_count_incognito = incognito_browser->tab_strip_model()->count(); int tab_count_incognito = incognito_browser->tab_strip_model()->count();
EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito); EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito);
...@@ -130,10 +159,9 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, ...@@ -130,10 +159,9 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
// Signing in fom incognito should create a new non-incognito browser. // Signing in fom incognito should create a new non-incognito browser.
Browser* new_regular_browser = chrome::FindTabbedBrowser( Browser* new_regular_browser = chrome::FindTabbedBrowser(
incognito_browser->profile()->GetOriginalProfile(), false); incognito_browser->profile()->GetOriginalProfile(), false);
#if !defined(OS_CHROMEOS) if (IsSigninModal(new_regular_browser->profile())) {
EXPECT_FALSE( EXPECT_FALSE(ShowsModalDialog(new_regular_browser));
new_regular_browser->signin_view_controller()->ShowsModalDialog()); }
#endif
// The full-tab sign-in page should be shown in the newly created browser. // The full-tab sign-in page should be shown in the newly created browser.
EXPECT_EQ(1, new_regular_browser->tab_strip_model()->count()); EXPECT_EQ(1, new_regular_browser->tab_strip_model()->count());
...@@ -165,12 +193,12 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) { ...@@ -165,12 +193,12 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) {
delegate->OnEnableSync(AccountInfo()); delegate->OnEnableSync(AccountInfo());
int tab_count = extra_browser->tab_strip_model()->count(); int tab_count = extra_browser->tab_strip_model()->count();
#if !defined(OS_CHROMEOS) if (IsSigninModal(extra_browser->profile())) {
EXPECT_TRUE(extra_browser->signin_view_controller()->ShowsModalDialog()); EXPECT_TRUE(ShowsModalDialog(extra_browser));
EXPECT_EQ(starting_tab_count, tab_count); EXPECT_EQ(starting_tab_count, tab_count);
#else } else {
// A new tab should have been opened in the extra browser, which should be // A new tab should have been opened in the extra browser, which should be
// visible. // visible.
EXPECT_EQ(starting_tab_count + 1, tab_count); EXPECT_EQ(starting_tab_count + 1, tab_count);
#endif }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment