Chromium Code Reviews| Index: chrome/browser/ui/views/bookmarks/bookmark_bubble_sign_in_delegate_browsertest.cc |
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_sign_in_delegate_browsertest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_sign_in_delegate_browsertest.cc |
| index 253378424b4c308f5e24e7fc537dd6af29e20a6f..beaa839a0d9fb9d97fd95ba491c6a607d9134924 100644 |
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_sign_in_delegate_browsertest.cc |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_sign_in_delegate_browsertest.cc |
| @@ -18,7 +18,6 @@ |
| #include "chrome/browser/ui/singleton_tabs.h" |
| #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| -#include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/testing_profile.h" |
| @@ -28,10 +27,8 @@ |
| #include "ui/events/event_constants.h" |
| #include "ui/gfx/range/range.h" |
| -#if defined(OS_CHROMEOS) |
| -const bool kHasProfileChooser = false; |
| -#else |
| -const bool kHasProfileChooser = true; |
| +#if !defined(OS_CHROMEOS) |
| +#include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
| #endif |
| class BookmarkBubbleSignInDelegateTest : public InProcessBrowserTest { |
| @@ -42,6 +39,8 @@ class BookmarkBubbleSignInDelegateTest : public InProcessBrowserTest { |
| void ReplaceBlank(Browser* browser); |
| + void SignInBrowser(Browser* browser); |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleSignInDelegateTest); |
| }; |
| @@ -57,73 +56,67 @@ void BookmarkBubbleSignInDelegateTest::ReplaceBlank(Browser* browser) { |
| chrome::ShowSingletonTabOverwritingNTP(browser, params); |
| } |
| +void BookmarkBubbleSignInDelegateTest::SignInBrowser(Browser* browser) { |
| + std::unique_ptr<BubbleSyncPromoDelegate> delegate; |
| + delegate.reset(new BookmarkBubbleSignInDelegate(browser)); |
| + delegate->OnSignInLinkClicked(); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) { |
| ReplaceBlank(browser()); |
| int starting_tab_count = browser()->tab_strip_model()->count(); |
| + SignInBrowser(browser()); |
| - std::unique_ptr<BubbleSyncPromoDelegate> delegate; |
| - delegate.reset(new BookmarkBubbleSignInDelegate(browser())); |
| +#if !defined(OS_CHROMEOS) |
| + if (switches::UsePasswordSeparatedSigninFlow()) |
| + EXPECT_TRUE(browser()->signin_view_controller()->delegate()); |
| + else |
| + EXPECT_TRUE(ProfileChooserView::IsShowing()); |
| - delegate->OnSignInLinkClicked(); |
| - |
| - if (kHasProfileChooser) { |
| - if (switches::UsePasswordSeparatedSigninFlow()) { |
| - EXPECT_TRUE(browser()->signin_view_controller()->delegate()); |
| - } else { |
| - EXPECT_TRUE(ProfileChooserView::IsShowing()); |
| - } |
| - |
| - EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
| - } else { |
| - EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); |
| - } |
| + EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
| +#else |
| + EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); |
| +#endif |
| } |
| IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, |
| OnSignInLinkClickedReusesBlank) { |
| int starting_tab_count = browser()->tab_strip_model()->count(); |
| + SignInBrowser(browser()); |
| - std::unique_ptr<BubbleSyncPromoDelegate> delegate; |
| - delegate.reset(new BookmarkBubbleSignInDelegate(browser())); |
| - |
| - delegate->OnSignInLinkClicked(); |
| +#if !defined(OS_CHROMEOS) |
| + if (switches::UsePasswordSeparatedSigninFlow()) |
| + EXPECT_TRUE(browser()->signin_view_controller()->delegate()); |
| + else |
| + EXPECT_TRUE(ProfileChooserView::IsShowing()); |
| - if (kHasProfileChooser) { |
| - if (switches::UsePasswordSeparatedSigninFlow()) { |
| - EXPECT_TRUE(browser()->signin_view_controller()->delegate()); |
| - } else { |
| - EXPECT_TRUE(ProfileChooserView::IsShowing()); |
| - } |
| - |
| - EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
| - } else { |
| - EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
| - } |
| + EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
|
msw
2016/07/19 21:42:04
optional nit: move this and line 95 outside the pr
Jane
2016/07/19 23:15:11
Done.
|
| +#else |
| + EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); |
| +#endif |
| } |
| IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, |
| OnSignInLinkClickedIncognito) { |
| ReplaceBlank(browser()); |
| Browser* incognito_browser = CreateIncognitoBrowser(); |
| - |
| int starting_tab_count_normal = browser()->tab_strip_model()->count(); |
| int starting_tab_count_incognito = |
| incognito_browser->tab_strip_model()->count(); |
| - std::unique_ptr<BubbleSyncPromoDelegate> delegate; |
| - delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser)); |
| - |
| - delegate->OnSignInLinkClicked(); |
| + SignInBrowser(incognito_browser); |
| - if (kHasProfileChooser) { |
| - // ProfileChooser doesn't show in an incognito window. |
| - EXPECT_FALSE(ProfileChooserView::IsShowing()); |
| - } else { |
| - // A new tab should have been opened in the normal browser, which should be |
| - // visible. |
| - int tab_count_normal = browser()->tab_strip_model()->count(); |
| - EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal); |
| - } |
| + int tab_count_normal = browser()->tab_strip_model()->count(); |
| +#if !defined(OS_CHROMEOS) |
| + // ProfileChooser doesn't show in an incognito window. |
| + EXPECT_FALSE(ProfileChooserView::IsShowing()); |
| + // No new tab should have been opened in the normal browser. |
| + EXPECT_EQ(starting_tab_count_normal, tab_count_normal); |
| +#else |
| + // A new tab should have been opened in the normal browser, which should be |
| + // visible. |
| + EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal); |
| +#endif |
| // No effect is expected on the incognito browser. |
| int tab_count_incognito = incognito_browser->tab_strip_model()->count(); |
| EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito); |
| @@ -150,16 +143,16 @@ IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) { |
| delegate->OnSignInLinkClicked(); |
| - if (kHasProfileChooser) { |
| - if (switches::UsePasswordSeparatedSigninFlow()) { |
| - EXPECT_TRUE(extra_browser->signin_view_controller()->delegate()); |
| - } else { |
| - EXPECT_TRUE(ProfileChooserView::IsShowing()); |
| - } |
| - } else { |
| - // A new tab should have been opened in the extra browser, which should be |
| - // visible. |
| - int tab_count = extra_browser->tab_strip_model()->count(); |
| - EXPECT_EQ(starting_tab_count + 1, tab_count); |
| - } |
| + int tab_count = extra_browser->tab_strip_model()->count(); |
| +#if !defined(OS_CHROMEOS) |
| + if (switches::UsePasswordSeparatedSigninFlow()) |
| + EXPECT_TRUE(extra_browser->signin_view_controller()->delegate()); |
| + else |
| + EXPECT_TRUE(ProfileChooserView::IsShowing()); |
| + EXPECT_EQ(starting_tab_count, tab_count); |
| +#else |
| + // A new tab should have been opened in the extra browser, which should be |
| + // visible. |
| + EXPECT_EQ(starting_tab_count + 1, tab_count); |
| +#endif |
| } |