Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bubble_sign_in_delegate_browsertest.cc

Issue 1038423004: Reland of: Change default code flag to NewAvatarMenu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unneeded code from ProfileInfoCacheTest Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" 5 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/test_extension_service.h" 11 #include "chrome/browser/extensions/test_extension_service.h"
12 #include "chrome/browser/extensions/test_extension_system.h" 12 #include "chrome/browser/extensions/test_extension_system.h"
13 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" 13 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/singleton_tabs.h" 16 #include "chrome/browser/ui/singleton_tabs.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
21 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
22 #include "content/public/test/test_utils.h" 23 #include "content/public/test/test_utils.h"
23 #include "ui/events/event_constants.h" 24 #include "ui/events/event_constants.h"
24 #include "ui/gfx/range/range.h" 25 #include "ui/gfx/range/range.h"
25 26
27 #if defined(OS_CHROMEOS)
28 const bool kHasProfileChooser = false;
29 #else
30 const bool kHasProfileChooser = true;
31 #endif
32
26 class BookmarkBubbleSignInDelegateTest : public InProcessBrowserTest { 33 class BookmarkBubbleSignInDelegateTest : public InProcessBrowserTest {
27 public: 34 public:
28 BookmarkBubbleSignInDelegateTest() {} 35 BookmarkBubbleSignInDelegateTest() {}
29 36
30 Profile* profile() { return browser()->profile(); } 37 Profile* profile() { return browser()->profile(); }
31 38
32 void ReplaceBlank(Browser* browser); 39 void ReplaceBlank(Browser* browser);
33 40
34 private: 41 private:
35 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleSignInDelegateTest); 42 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleSignInDelegateTest);
(...skipping 12 matching lines...) Expand all
48 55
49 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) { 56 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
50 ReplaceBlank(browser()); 57 ReplaceBlank(browser());
51 int starting_tab_count = browser()->tab_strip_model()->count(); 58 int starting_tab_count = browser()->tab_strip_model()->count();
52 59
53 scoped_ptr<BookmarkBubbleDelegate> delegate; 60 scoped_ptr<BookmarkBubbleDelegate> delegate;
54 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 61 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
55 62
56 delegate->OnSignInLinkClicked(); 63 delegate->OnSignInLinkClicked();
57 64
58 // A new tab should have been opened and the browser should be visible. 65 if (kHasProfileChooser) {
59 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); 66 EXPECT_TRUE(ProfileChooserView::IsShowing());
67 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
68 } else {
69 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count());
70 }
60 } 71 }
61 72
62 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, 73 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
63 OnSignInLinkClickedReusesBlank) { 74 OnSignInLinkClickedReusesBlank) {
64 int starting_tab_count = browser()->tab_strip_model()->count(); 75 int starting_tab_count = browser()->tab_strip_model()->count();
65 76
66 scoped_ptr<BookmarkBubbleDelegate> delegate; 77 scoped_ptr<BookmarkBubbleDelegate> delegate;
67 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 78 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
68 79
69 delegate->OnSignInLinkClicked(); 80 delegate->OnSignInLinkClicked();
70 81
71 // A new tab should have been opened and the browser should be visible. 82 if (kHasProfileChooser) {
72 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 83 EXPECT_TRUE(ProfileChooserView::IsShowing());
84 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
85 } else {
86 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
87 }
73 } 88 }
74 89
75 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, 90 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
76 OnSignInLinkClickedIncognito) { 91 OnSignInLinkClickedIncognito) {
77 ReplaceBlank(browser()); 92 ReplaceBlank(browser());
78 Browser* incognito_browser = CreateIncognitoBrowser(); 93 Browser* incognito_browser = CreateIncognitoBrowser();
79 94
80 int starting_tab_count_normal = browser()->tab_strip_model()->count(); 95 int starting_tab_count_normal = browser()->tab_strip_model()->count();
81 int starting_tab_count_incognito = 96 int starting_tab_count_incognito =
82 incognito_browser->tab_strip_model()->count(); 97 incognito_browser->tab_strip_model()->count();
83 98
84 scoped_ptr<BookmarkBubbleDelegate> delegate; 99 scoped_ptr<BookmarkBubbleDelegate> delegate;
85 delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser)); 100 delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser));
86 101
87 delegate->OnSignInLinkClicked(); 102 delegate->OnSignInLinkClicked();
88 103
89 // A new tab should have been opened in the normal browser, which should be 104 if (kHasProfileChooser) {
90 // visible. 105 // ProfileChooser doesn't show in an incognito window.
91 int tab_count_normal = browser()->tab_strip_model()->count(); 106 EXPECT_FALSE(ProfileChooserView::IsShowing());
92 EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal); 107 } else {
93 108 // A new tab should have been opened in the normal browser, which should be
109 // visible.
110 int tab_count_normal = browser()->tab_strip_model()->count();
111 EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal);
112 }
94 // No effect is expected on the incognito browser. 113 // No effect is expected on the incognito browser.
95 int tab_count_incognito = incognito_browser->tab_strip_model()->count(); 114 int tab_count_incognito = incognito_browser->tab_strip_model()->count();
96 EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito); 115 EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito);
97 } 116 }
98 117
99 // Verifies that the sign in page can be loaded in a different browser 118 // Verifies that the sign in page can be loaded in a different browser
100 // if the provided browser is invalidated. 119 // if the provided browser is invalidated.
101 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) { 120 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) {
102 // Create an extra browser. 121 // Create an extra browser.
103 Browser* extra_browser = CreateBrowser(profile()); 122 Browser* extra_browser = CreateBrowser(profile());
104 ReplaceBlank(extra_browser); 123 ReplaceBlank(extra_browser);
105 124
106 int starting_tab_count = extra_browser->tab_strip_model()->count(); 125 int starting_tab_count = extra_browser->tab_strip_model()->count();
107 126
108 scoped_ptr<BookmarkBubbleDelegate> delegate; 127 scoped_ptr<BookmarkBubbleDelegate> delegate;
109 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 128 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
110 129
111 BrowserList::SetLastActive(extra_browser); 130 BrowserList::SetLastActive(extra_browser);
112 131
113 // Close all tabs in the original browser. Run all pending messages 132 // Close all tabs in the original browser. Run all pending messages
114 // to make sure the browser window closes before continuing. 133 // to make sure the browser window closes before continuing.
115 browser()->tab_strip_model()->CloseAllTabs(); 134 browser()->tab_strip_model()->CloseAllTabs();
116 content::RunAllPendingInMessageLoop(); 135 content::RunAllPendingInMessageLoop();
117 136
118 delegate->OnSignInLinkClicked(); 137 delegate->OnSignInLinkClicked();
119 138
120 // A new tab should have been opened in the extra browser, which should be 139 if (kHasProfileChooser) {
121 // visible. 140 EXPECT_TRUE(ProfileChooserView::IsShowing());
122 int tab_count = extra_browser->tab_strip_model()->count(); 141 } else {
123 EXPECT_EQ(starting_tab_count + 1, tab_count); 142 // A new tab should have been opened in the extra browser, which should be
143 // visible.
144 int tab_count = extra_browser->tab_strip_model()->count();
145 EXPECT_EQ(starting_tab_count + 1, tab_count);
146 }
124 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698