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

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

Issue 1503583002: [Extensions Views] Update the extension installed bubble's sync promo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years 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"
14 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h" 14 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/browser_navigator_params.h" 15 #include "chrome/browser/ui/browser_navigator_params.h"
17 #include "chrome/browser/ui/singleton_tabs.h" 16 #include "chrome/browser/ui/singleton_tabs.h"
17 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 19 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "content/public/test/test_utils.h" 24 #include "content/public/test/test_utils.h"
25 #include "ui/events/event_constants.h" 25 #include "ui/events/event_constants.h"
26 #include "ui/gfx/range/range.h" 26 #include "ui/gfx/range/range.h"
27 27
(...skipping 23 matching lines...) Expand all
51 chrome::NavigateParams params( 51 chrome::NavigateParams params(
52 chrome::GetSingletonTabNavigateParams(browser, GURL("chrome:version"))); 52 chrome::GetSingletonTabNavigateParams(browser, GURL("chrome:version")));
53 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 53 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
54 chrome::ShowSingletonTabOverwritingNTP(browser, params); 54 chrome::ShowSingletonTabOverwritingNTP(browser, params);
55 } 55 }
56 56
57 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) { 57 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
58 ReplaceBlank(browser()); 58 ReplaceBlank(browser());
59 int starting_tab_count = browser()->tab_strip_model()->count(); 59 int starting_tab_count = browser()->tab_strip_model()->count();
60 60
61 scoped_ptr<BookmarkBubbleDelegate> delegate; 61 scoped_ptr<BubbleSyncPromoDelegate> delegate;
62 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 62 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
63 63
64 delegate->OnSignInLinkClicked(); 64 delegate->OnSignInLinkClicked();
65 65
66 if (kHasProfileChooser) { 66 if (kHasProfileChooser) {
67 EXPECT_TRUE(ProfileChooserView::IsShowing()); 67 EXPECT_TRUE(ProfileChooserView::IsShowing());
68 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 68 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
69 } else { 69 } else {
70 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); 70 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count());
71 } 71 }
72 } 72 }
73 73
74 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, 74 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
75 OnSignInLinkClickedReusesBlank) { 75 OnSignInLinkClickedReusesBlank) {
76 int starting_tab_count = browser()->tab_strip_model()->count(); 76 int starting_tab_count = browser()->tab_strip_model()->count();
77 77
78 scoped_ptr<BookmarkBubbleDelegate> delegate; 78 scoped_ptr<BubbleSyncPromoDelegate> delegate;
79 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 79 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
80 80
81 delegate->OnSignInLinkClicked(); 81 delegate->OnSignInLinkClicked();
82 82
83 if (kHasProfileChooser) { 83 if (kHasProfileChooser) {
84 EXPECT_TRUE(ProfileChooserView::IsShowing()); 84 EXPECT_TRUE(ProfileChooserView::IsShowing());
85 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 85 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
86 } else { 86 } else {
87 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 87 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
88 } 88 }
89 } 89 }
90 90
91 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, 91 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
92 OnSignInLinkClickedIncognito) { 92 OnSignInLinkClickedIncognito) {
93 ReplaceBlank(browser()); 93 ReplaceBlank(browser());
94 Browser* incognito_browser = CreateIncognitoBrowser(); 94 Browser* incognito_browser = CreateIncognitoBrowser();
95 95
96 int starting_tab_count_normal = browser()->tab_strip_model()->count(); 96 int starting_tab_count_normal = browser()->tab_strip_model()->count();
97 int starting_tab_count_incognito = 97 int starting_tab_count_incognito =
98 incognito_browser->tab_strip_model()->count(); 98 incognito_browser->tab_strip_model()->count();
99 99
100 scoped_ptr<BookmarkBubbleDelegate> delegate; 100 scoped_ptr<BubbleSyncPromoDelegate> delegate;
101 delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser)); 101 delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser));
102 102
103 delegate->OnSignInLinkClicked(); 103 delegate->OnSignInLinkClicked();
104 104
105 if (kHasProfileChooser) { 105 if (kHasProfileChooser) {
106 // ProfileChooser doesn't show in an incognito window. 106 // ProfileChooser doesn't show in an incognito window.
107 EXPECT_FALSE(ProfileChooserView::IsShowing()); 107 EXPECT_FALSE(ProfileChooserView::IsShowing());
108 } else { 108 } else {
109 // A new tab should have been opened in the normal browser, which should be 109 // A new tab should have been opened in the normal browser, which should be
110 // visible. 110 // visible.
111 int tab_count_normal = browser()->tab_strip_model()->count(); 111 int tab_count_normal = browser()->tab_strip_model()->count();
112 EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal); 112 EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal);
113 } 113 }
114 // No effect is expected on the incognito browser. 114 // No effect is expected on the incognito browser.
115 int tab_count_incognito = incognito_browser->tab_strip_model()->count(); 115 int tab_count_incognito = incognito_browser->tab_strip_model()->count();
116 EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito); 116 EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito);
117 } 117 }
118 118
119 // Verifies that the sign in page can be loaded in a different browser 119 // Verifies that the sign in page can be loaded in a different browser
120 // if the provided browser is invalidated. 120 // if the provided browser is invalidated.
121 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) { 121 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) {
122 // Create an extra browser. 122 // Create an extra browser.
123 Browser* extra_browser = CreateBrowser(profile()); 123 Browser* extra_browser = CreateBrowser(profile());
124 ReplaceBlank(extra_browser); 124 ReplaceBlank(extra_browser);
125 125
126 int starting_tab_count = extra_browser->tab_strip_model()->count(); 126 int starting_tab_count = extra_browser->tab_strip_model()->count();
127 127
128 scoped_ptr<BookmarkBubbleDelegate> delegate; 128 scoped_ptr<BubbleSyncPromoDelegate> delegate;
129 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 129 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
130 130
131 BrowserList::SetLastActive(extra_browser); 131 BrowserList::SetLastActive(extra_browser);
132 132
133 // Close all tabs in the original browser. Run all pending messages 133 // Close all tabs in the original browser. Run all pending messages
134 // to make sure the browser window closes before continuing. 134 // to make sure the browser window closes before continuing.
135 browser()->tab_strip_model()->CloseAllTabs(); 135 browser()->tab_strip_model()->CloseAllTabs();
136 content::RunAllPendingInMessageLoop(); 136 content::RunAllPendingInMessageLoop();
137 137
138 delegate->OnSignInLinkClicked(); 138 delegate->OnSignInLinkClicked();
139 139
140 if (kHasProfileChooser) { 140 if (kHasProfileChooser) {
141 EXPECT_TRUE(ProfileChooserView::IsShowing()); 141 EXPECT_TRUE(ProfileChooserView::IsShowing());
142 } else { 142 } else {
143 // A new tab should have been opened in the extra browser, which should be 143 // A new tab should have been opened in the extra browser, which should be
144 // visible. 144 // visible.
145 int tab_count = extra_browser->tab_strip_model()->count(); 145 int tab_count = extra_browser->tab_strip_model()->count();
146 EXPECT_EQ(starting_tab_count + 1, tab_count); 146 EXPECT_EQ(starting_tab_count + 1, tab_count);
147 } 147 }
148 } 148 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/bubble_sync_promo_delegate.h ('k') | chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698