OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_navigator_browsertest.h" | 5 #include "chrome/browser/ui/browser_navigator_browsertest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 9 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/browser_navigator.h" | 14 #include "chrome/browser/ui/browser_navigator.h" |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" |
15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
17 #include "chrome/browser/ui/omnibox/location_bar.h" | 18 #include "chrome/browser/ui/omnibox/location_bar.h" |
18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 19 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
19 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 20 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
20 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 21 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
21 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, | 77 Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, |
77 Profile* profile) { | 78 Profile* profile) { |
78 Browser* browser = Browser::CreateWithParams( | 79 Browser* browser = Browser::CreateWithParams( |
79 Browser::CreateParams::CreateForApp( | 80 Browser::CreateParams::CreateForApp( |
80 Browser::TYPE_POPUP, "Test", gfx::Rect(), profile)); | 81 Browser::TYPE_POPUP, "Test", gfx::Rect(), profile)); |
81 browser->AddBlankTab(true); | 82 browser->AddBlankTab(true); |
82 return browser; | 83 return browser; |
83 } | 84 } |
84 | 85 |
85 TabContents* BrowserNavigatorTest::CreateTabContents() { | 86 TabContents* BrowserNavigatorTest::CreateTabContents() { |
86 return Browser::TabContentsFactory( | 87 return chrome::TabContentsFactory( |
87 browser()->profile(), | 88 browser()->profile(), |
88 NULL, | 89 NULL, |
89 MSG_ROUTING_NONE, | 90 MSG_ROUTING_NONE, |
90 browser()->GetActiveWebContents(), | 91 chrome::GetActiveWebContents(browser()), |
91 NULL); | 92 NULL); |
92 } | 93 } |
93 | 94 |
94 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { | 95 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { |
95 GURL old_url = browser()->GetActiveWebContents()->GetURL(); | 96 GURL old_url = chrome::GetActiveWebContents(browser())->GetURL(); |
96 browser::NavigateParams p(MakeNavigateParams()); | 97 browser::NavigateParams p(MakeNavigateParams()); |
97 p.disposition = disposition; | 98 p.disposition = disposition; |
98 browser::Navigate(&p); | 99 browser::Navigate(&p); |
99 | 100 |
100 // Nothing should have happened as a result of Navigate(); | 101 // Nothing should have happened as a result of Navigate(); |
101 EXPECT_EQ(1, browser()->tab_count()); | 102 EXPECT_EQ(1, browser()->tab_count()); |
102 EXPECT_EQ(1u, BrowserList::size()); | 103 EXPECT_EQ(1u, BrowserList::size()); |
103 EXPECT_EQ(old_url, browser()->GetActiveWebContents()->GetURL()); | 104 EXPECT_EQ(old_url, chrome::GetActiveWebContents(browser())->GetURL()); |
104 } | 105 } |
105 | 106 |
106 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { | 107 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { |
107 Browser* incognito_browser = CreateIncognitoBrowser(); | 108 Browser* incognito_browser = CreateIncognitoBrowser(); |
108 | 109 |
109 EXPECT_EQ(2u, BrowserList::size()); | 110 EXPECT_EQ(2u, BrowserList::size()); |
110 EXPECT_EQ(1, browser()->tab_count()); | 111 EXPECT_EQ(1, browser()->tab_count()); |
111 EXPECT_EQ(1, incognito_browser->tab_count()); | 112 EXPECT_EQ(1, incognito_browser->tab_count()); |
112 | 113 |
113 // Navigate to the page. | 114 // Navigate to the page. |
114 browser::NavigateParams p(MakeNavigateParams(incognito_browser)); | 115 browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
115 p.disposition = SINGLETON_TAB; | 116 p.disposition = SINGLETON_TAB; |
116 p.url = url; | 117 p.url = url; |
117 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 118 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
118 browser::Navigate(&p); | 119 browser::Navigate(&p); |
119 | 120 |
120 // This page should be opened in browser() window. | 121 // This page should be opened in browser() window. |
121 EXPECT_NE(incognito_browser, p.browser); | 122 EXPECT_NE(incognito_browser, p.browser); |
122 EXPECT_EQ(browser(), p.browser); | 123 EXPECT_EQ(browser(), p.browser); |
123 EXPECT_EQ(2, browser()->tab_count()); | 124 EXPECT_EQ(2, browser()->tab_count()); |
124 EXPECT_EQ(url, browser()->GetActiveWebContents()->GetURL()); | 125 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
125 } | 126 } |
126 | 127 |
127 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest( | 128 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest( |
128 const GURL& url) { | 129 const GURL& url) { |
129 Browser* browser = CreateIncognitoBrowser(); | 130 Browser* browser = CreateIncognitoBrowser(); |
130 | 131 |
131 // Set kIncognitoModeAvailability to FORCED. | 132 // Set kIncognitoModeAvailability to FORCED. |
132 PrefService* prefs1 = browser->profile()->GetPrefs(); | 133 PrefService* prefs1 = browser->profile()->GetPrefs(); |
133 prefs1->SetInteger(prefs::kIncognitoModeAvailability, | 134 prefs1->SetInteger(prefs::kIncognitoModeAvailability, |
134 IncognitoModePrefs::FORCED); | 135 IncognitoModePrefs::FORCED); |
135 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); | 136 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); |
136 prefs2->SetInteger(prefs::kIncognitoModeAvailability, | 137 prefs2->SetInteger(prefs::kIncognitoModeAvailability, |
137 IncognitoModePrefs::FORCED); | 138 IncognitoModePrefs::FORCED); |
138 | 139 |
139 // Navigate to the page. | 140 // Navigate to the page. |
140 browser::NavigateParams p(MakeNavigateParams(browser)); | 141 browser::NavigateParams p(MakeNavigateParams(browser)); |
141 p.disposition = OFF_THE_RECORD; | 142 p.disposition = OFF_THE_RECORD; |
142 p.url = url; | 143 p.url = url; |
143 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 144 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
144 browser::Navigate(&p); | 145 browser::Navigate(&p); |
145 | 146 |
146 // The page should not be opened. | 147 // The page should not be opened. |
147 EXPECT_EQ(browser, p.browser); | 148 EXPECT_EQ(browser, p.browser); |
148 EXPECT_EQ(1, browser->tab_count()); | 149 EXPECT_EQ(1, browser->tab_count()); |
149 EXPECT_EQ(GURL(chrome::kAboutBlankURL), | 150 EXPECT_EQ(GURL(chrome::kAboutBlankURL), |
150 browser->GetActiveWebContents()->GetURL()); | 151 chrome::GetActiveWebContents(browser)->GetURL()); |
151 } | 152 } |
152 | 153 |
153 void BrowserNavigatorTest::Observe( | 154 void BrowserNavigatorTest::Observe( |
154 int type, | 155 int type, |
155 const content::NotificationSource& source, | 156 const content::NotificationSource& source, |
156 const content::NotificationDetails& details) { | 157 const content::NotificationDetails& details) { |
157 switch (type) { | 158 switch (type) { |
158 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { | 159 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { |
159 ++this->created_tab_contents_count_; | 160 ++this->created_tab_contents_count_; |
160 break; | 161 break; |
161 } | 162 } |
162 default: | 163 default: |
163 break; | 164 break; |
164 } | 165 } |
165 } | 166 } |
166 | 167 |
167 | 168 |
168 namespace { | 169 namespace { |
169 | 170 |
170 // This test verifies that when a navigation occurs within a tab, the tab count | 171 // This test verifies that when a navigation occurs within a tab, the tab count |
171 // of the Browser remains the same and the current tab bears the loaded URL. | 172 // of the Browser remains the same and the current tab bears the loaded URL. |
172 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { | 173 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { |
173 ui_test_utils::NavigateToURL(browser(), GetGoogleURL()); | 174 ui_test_utils::NavigateToURL(browser(), GetGoogleURL()); |
174 EXPECT_EQ(GetGoogleURL(), browser()->GetActiveWebContents()->GetURL()); | 175 EXPECT_EQ(GetGoogleURL(), chrome::GetActiveWebContents(browser())->GetURL()); |
175 // We should have one window with one tab. | 176 // We should have one window with one tab. |
176 EXPECT_EQ(1u, BrowserList::size()); | 177 EXPECT_EQ(1u, BrowserList::size()); |
177 EXPECT_EQ(1, browser()->tab_count()); | 178 EXPECT_EQ(1, browser()->tab_count()); |
178 } | 179 } |
179 | 180 |
180 // This test verifies that a singleton tab is refocused if one is already opened | 181 // This test verifies that a singleton tab is refocused if one is already opened |
181 // in another or an existing window, or added if it is not. | 182 // in another or an existing window, or added if it is not. |
182 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { | 183 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { |
183 GURL singleton_url1("http://maps.google.com/"); | 184 GURL singleton_url1("http://maps.google.com/"); |
184 | 185 |
185 // Register for a notification if an additional tab_contents was instantiated. | 186 // Register for a notification if an additional tab_contents was instantiated. |
186 // Opening a Singleton tab that is already opened should not be opening a new | 187 // Opening a Singleton tab that is already opened should not be opening a new |
187 // tab nor be creating a new TabContents object. | 188 // tab nor be creating a new TabContents object. |
188 content::NotificationRegistrar registrar; | 189 content::NotificationRegistrar registrar; |
189 | 190 |
190 // As the registrar object goes out of scope, this will get unregistered | 191 // As the registrar object goes out of scope, this will get unregistered |
191 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, | 192 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
192 content::NotificationService::AllSources()); | 193 content::NotificationService::AllSources()); |
193 | 194 |
194 browser()->AddSelectedTabWithURL( | 195 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
195 singleton_url1, content::PAGE_TRANSITION_LINK); | 196 content::PAGE_TRANSITION_LINK); |
196 browser()->AddSelectedTabWithURL( | 197 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
197 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 198 content::PAGE_TRANSITION_LINK); |
198 | 199 |
199 // We should have one browser with 3 tabs, the 3rd selected. | 200 // We should have one browser with 3 tabs, the 3rd selected. |
200 EXPECT_EQ(1u, BrowserList::size()); | 201 EXPECT_EQ(1u, BrowserList::size()); |
201 EXPECT_EQ(2, browser()->active_index()); | 202 EXPECT_EQ(2, browser()->active_index()); |
202 | 203 |
203 unsigned int previous_tab_contents_count = | 204 unsigned int previous_tab_contents_count = |
204 created_tab_contents_count_ = 0; | 205 created_tab_contents_count_ = 0; |
205 | 206 |
206 // Navigate to singleton_url1. | 207 // Navigate to singleton_url1. |
207 browser::NavigateParams p(MakeNavigateParams()); | 208 browser::NavigateParams p(MakeNavigateParams()); |
208 p.disposition = SINGLETON_TAB; | 209 p.disposition = SINGLETON_TAB; |
209 p.url = singleton_url1; | 210 p.url = singleton_url1; |
210 browser::Navigate(&p); | 211 browser::Navigate(&p); |
211 | 212 |
212 // The middle tab should now be selected. | 213 // The middle tab should now be selected. |
213 EXPECT_EQ(browser(), p.browser); | 214 EXPECT_EQ(browser(), p.browser); |
214 EXPECT_EQ(1, browser()->active_index()); | 215 EXPECT_EQ(1, browser()->active_index()); |
215 | 216 |
216 // No tab contents should have been created | 217 // No tab contents should have been created |
217 EXPECT_EQ(previous_tab_contents_count, | 218 EXPECT_EQ(previous_tab_contents_count, |
218 created_tab_contents_count_); | 219 created_tab_contents_count_); |
219 } | 220 } |
220 | 221 |
221 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 222 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
222 Disposition_SingletonTabRespectingRef) { | 223 Disposition_SingletonTabRespectingRef) { |
223 GURL singleton_ref_url1("http://maps.google.com/#a"); | 224 GURL singleton_ref_url1("http://maps.google.com/#a"); |
224 GURL singleton_ref_url2("http://maps.google.com/#b"); | 225 GURL singleton_ref_url2("http://maps.google.com/#b"); |
225 GURL singleton_ref_url3("http://maps.google.com/"); | 226 GURL singleton_ref_url3("http://maps.google.com/"); |
226 | 227 |
227 browser()->AddSelectedTabWithURL( | 228 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, |
228 singleton_ref_url1, content::PAGE_TRANSITION_LINK); | 229 content::PAGE_TRANSITION_LINK); |
229 | 230 |
230 // We should have one browser with 2 tabs, 2nd selected. | 231 // We should have one browser with 2 tabs, 2nd selected. |
231 EXPECT_EQ(1u, BrowserList::size()); | 232 EXPECT_EQ(1u, BrowserList::size()); |
232 EXPECT_EQ(2, browser()->tab_count()); | 233 EXPECT_EQ(2, browser()->tab_count()); |
233 EXPECT_EQ(1, browser()->active_index()); | 234 EXPECT_EQ(1, browser()->active_index()); |
234 | 235 |
235 // Navigate to singleton_url2. | 236 // Navigate to singleton_url2. |
236 browser::NavigateParams p(MakeNavigateParams()); | 237 browser::NavigateParams p(MakeNavigateParams()); |
237 p.disposition = SINGLETON_TAB; | 238 p.disposition = SINGLETON_TAB; |
238 p.url = singleton_ref_url2; | 239 p.url = singleton_ref_url2; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // We should now have 2 tabs, the 2nd one selected. | 286 // We should now have 2 tabs, the 2nd one selected. |
286 EXPECT_EQ(browser(), p.browser); | 287 EXPECT_EQ(browser(), p.browser); |
287 EXPECT_EQ(2, browser()->tab_count()); | 288 EXPECT_EQ(2, browser()->tab_count()); |
288 EXPECT_EQ(1, browser()->active_index()); | 289 EXPECT_EQ(1, browser()->active_index()); |
289 } | 290 } |
290 | 291 |
291 // This test verifies that when a navigation results in a foreground tab, the | 292 // This test verifies that when a navigation results in a foreground tab, the |
292 // tab count of the Browser increases and the selected tab shifts to the new | 293 // tab count of the Browser increases and the selected tab shifts to the new |
293 // foreground tab. | 294 // foreground tab. |
294 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { | 295 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { |
295 WebContents* old_contents = browser()->GetActiveWebContents(); | 296 WebContents* old_contents = chrome::GetActiveWebContents(browser()); |
296 browser::NavigateParams p(MakeNavigateParams()); | 297 browser::NavigateParams p(MakeNavigateParams()); |
297 p.disposition = NEW_FOREGROUND_TAB; | 298 p.disposition = NEW_FOREGROUND_TAB; |
298 browser::Navigate(&p); | 299 browser::Navigate(&p); |
299 EXPECT_NE(old_contents, browser()->GetActiveWebContents()); | 300 EXPECT_NE(old_contents, chrome::GetActiveWebContents(browser())); |
300 EXPECT_EQ(browser()->GetActiveTabContents(), p.target_contents); | 301 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents); |
301 EXPECT_EQ(2, browser()->tab_count()); | 302 EXPECT_EQ(2, browser()->tab_count()); |
302 } | 303 } |
303 | 304 |
304 // This test verifies that when a navigation results in a background tab, the | 305 // This test verifies that when a navigation results in a background tab, the |
305 // tab count of the Browser increases but the selected tab remains the same. | 306 // tab count of the Browser increases but the selected tab remains the same. |
306 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { | 307 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { |
307 WebContents* old_contents = browser()->GetActiveWebContents(); | 308 WebContents* old_contents = chrome::GetActiveWebContents(browser()); |
308 browser::NavigateParams p(MakeNavigateParams()); | 309 browser::NavigateParams p(MakeNavigateParams()); |
309 p.disposition = NEW_BACKGROUND_TAB; | 310 p.disposition = NEW_BACKGROUND_TAB; |
310 browser::Navigate(&p); | 311 browser::Navigate(&p); |
311 WebContents* new_contents = browser()->GetActiveWebContents(); | 312 WebContents* new_contents = chrome::GetActiveWebContents(browser()); |
312 // The selected tab should have remained unchanged, since the new tab was | 313 // The selected tab should have remained unchanged, since the new tab was |
313 // opened in the background. | 314 // opened in the background. |
314 EXPECT_EQ(old_contents, new_contents); | 315 EXPECT_EQ(old_contents, new_contents); |
315 EXPECT_EQ(2, browser()->tab_count()); | 316 EXPECT_EQ(2, browser()->tab_count()); |
316 } | 317 } |
317 | 318 |
318 // This test verifies that when a navigation requiring a new foreground tab | 319 // This test verifies that when a navigation requiring a new foreground tab |
319 // occurs in a Browser that cannot host multiple tabs, the new foreground tab | 320 // occurs in a Browser that cannot host multiple tabs, the new foreground tab |
320 // is created in an existing compatible Browser. | 321 // is created in an existing compatible Browser. |
321 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 322 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 // This tests adding a foreground tab with a predefined TabContents. | 621 // This tests adding a foreground tab with a predefined TabContents. |
621 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { | 622 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { |
622 browser::NavigateParams p(MakeNavigateParams()); | 623 browser::NavigateParams p(MakeNavigateParams()); |
623 p.disposition = NEW_FOREGROUND_TAB; | 624 p.disposition = NEW_FOREGROUND_TAB; |
624 p.target_contents = CreateTabContents(); | 625 p.target_contents = CreateTabContents(); |
625 browser::Navigate(&p); | 626 browser::Navigate(&p); |
626 | 627 |
627 // Navigate() should have opened the contents in a new foreground in the | 628 // Navigate() should have opened the contents in a new foreground in the |
628 // current Browser. | 629 // current Browser. |
629 EXPECT_EQ(browser(), p.browser); | 630 EXPECT_EQ(browser(), p.browser); |
630 EXPECT_EQ(browser()->GetActiveTabContents(), p.target_contents); | 631 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents); |
631 | 632 |
632 // We should have one window, with two tabs. | 633 // We should have one window, with two tabs. |
633 EXPECT_EQ(1u, BrowserList::size()); | 634 EXPECT_EQ(1u, BrowserList::size()); |
634 EXPECT_EQ(2, browser()->tab_count()); | 635 EXPECT_EQ(2, browser()->tab_count()); |
635 } | 636 } |
636 | 637 |
637 #if defined(OS_WIN) | 638 #if defined(OS_WIN) |
638 // This tests adding a popup with a predefined TabContents. | 639 // This tests adding a popup with a predefined TabContents. |
639 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { | 640 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { |
640 browser::NavigateParams p(MakeNavigateParams()); | 641 browser::NavigateParams p(MakeNavigateParams()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 693 |
693 // We should have one window - the browser() provided by the framework. | 694 // We should have one window - the browser() provided by the framework. |
694 EXPECT_EQ(1u, BrowserList::size()); | 695 EXPECT_EQ(1u, BrowserList::size()); |
695 EXPECT_EQ(2, browser()->tab_count()); | 696 EXPECT_EQ(2, browser()->tab_count()); |
696 } | 697 } |
697 | 698 |
698 // This test verifies that constructing params with a NULL browser has | 699 // This test verifies that constructing params with a NULL browser has |
699 // the same result as navigating to a new foreground tab in the (only) | 700 // the same result as navigating to a new foreground tab in the (only) |
700 // active browser. Tests are the same as for Disposition_NewForegroundTab. | 701 // active browser. Tests are the same as for Disposition_NewForegroundTab. |
701 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) { | 702 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) { |
702 WebContents* old_contents = browser()->GetActiveWebContents(); | 703 WebContents* old_contents = chrome::GetActiveWebContents(browser()); |
703 // Navigate with a NULL browser. | 704 // Navigate with a NULL browser. |
704 browser::NavigateParams p(MakeNavigateParams(NULL)); | 705 browser::NavigateParams p(MakeNavigateParams(NULL)); |
705 p.disposition = NEW_FOREGROUND_TAB; | 706 p.disposition = NEW_FOREGROUND_TAB; |
706 p.profile = browser()->profile(); | 707 p.profile = browser()->profile(); |
707 browser::Navigate(&p); | 708 browser::Navigate(&p); |
708 | 709 |
709 // Navigate() should have found browser() and create a new tab. | 710 // Navigate() should have found browser() and create a new tab. |
710 EXPECT_EQ(browser(), p.browser); | 711 EXPECT_EQ(browser(), p.browser); |
711 EXPECT_NE(old_contents, browser()->GetActiveWebContents()); | 712 EXPECT_NE(old_contents, chrome::GetActiveWebContents(browser())); |
712 EXPECT_EQ(browser()->GetActiveTabContents(), p.target_contents); | 713 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents); |
713 EXPECT_EQ(2, browser()->tab_count()); | 714 EXPECT_EQ(2, browser()->tab_count()); |
714 } | 715 } |
715 | 716 |
716 // This test verifies that constructing params with a NULL browser and | 717 // This test verifies that constructing params with a NULL browser and |
717 // a specific profile matches the specified profile. | 718 // a specific profile matches the specified profile. |
718 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) { | 719 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) { |
719 // Create a new browser with using the incognito profile. | 720 // Create a new browser with using the incognito profile. |
720 Browser* incognito = | 721 Browser* incognito = |
721 Browser::Create(browser()->profile()->GetOffTheRecordProfile()); | 722 Browser::Create(browser()->profile()->GetOffTheRecordProfile()); |
722 | 723 |
723 // Navigate with a NULL browser and the incognito profile. | 724 // Navigate with a NULL browser and the incognito profile. |
724 browser::NavigateParams p(MakeNavigateParams(NULL)); | 725 browser::NavigateParams p(MakeNavigateParams(NULL)); |
725 p.disposition = NEW_FOREGROUND_TAB; | 726 p.disposition = NEW_FOREGROUND_TAB; |
726 p.profile = incognito->profile(); | 727 p.profile = incognito->profile(); |
727 browser::Navigate(&p); | 728 browser::Navigate(&p); |
728 | 729 |
729 // Navigate() should have found incognito, not browser(). | 730 // Navigate() should have found incognito, not browser(). |
730 EXPECT_EQ(incognito, p.browser); | 731 EXPECT_EQ(incognito, p.browser); |
731 EXPECT_EQ(incognito->GetActiveTabContents(), p.target_contents); | 732 EXPECT_EQ(chrome::GetActiveTabContents(incognito), p.target_contents); |
732 EXPECT_EQ(1, incognito->tab_count()); | 733 EXPECT_EQ(1, incognito->tab_count()); |
733 } | 734 } |
734 | 735 |
735 // This test verifies that constructing params with a NULL browser and | 736 // This test verifies that constructing params with a NULL browser and |
736 // disposition = NEW_WINDOW always opens exactly one new window. | 737 // disposition = NEW_WINDOW always opens exactly one new window. |
737 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { | 738 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { |
738 browser::NavigateParams p(MakeNavigateParams(NULL)); | 739 browser::NavigateParams p(MakeNavigateParams(NULL)); |
739 p.disposition = NEW_WINDOW; | 740 p.disposition = NEW_WINDOW; |
740 p.profile = browser()->profile(); | 741 p.profile = browser()->profile(); |
741 browser::Navigate(&p); | 742 browser::Navigate(&p); |
742 | 743 |
743 // Navigate() should have created a new browser. | 744 // Navigate() should have created a new browser. |
744 EXPECT_NE(browser(), p.browser); | 745 EXPECT_NE(browser(), p.browser); |
745 EXPECT_TRUE( p.browser->is_type_tabbed()); | 746 EXPECT_TRUE( p.browser->is_type_tabbed()); |
746 | 747 |
747 // We should now have two windows, the browser() provided by the framework and | 748 // We should now have two windows, the browser() provided by the framework and |
748 // the new normal window. | 749 // the new normal window. |
749 EXPECT_EQ(2u, BrowserList::size()); | 750 EXPECT_EQ(2u, BrowserList::size()); |
750 EXPECT_EQ(1, browser()->tab_count()); | 751 EXPECT_EQ(1, browser()->tab_count()); |
751 EXPECT_EQ(1, p.browser->tab_count()); | 752 EXPECT_EQ(1, p.browser->tab_count()); |
752 } | 753 } |
753 | 754 |
754 // This test verifies that constructing params with disposition = SINGLETON_TAB | 755 // This test verifies that constructing params with disposition = SINGLETON_TAB |
755 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if | 756 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if |
756 // no previous tab with that URL (minus the path) exists. | 757 // no previous tab with that URL (minus the path) exists. |
757 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 758 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
758 Disposition_SingletonTabNew_IgnorePath) { | 759 Disposition_SingletonTabNew_IgnorePath) { |
759 browser()->AddSelectedTabWithURL( | 760 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
760 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 761 content::PAGE_TRANSITION_LINK); |
761 | 762 |
762 // We should have one browser with 2 tabs, the 2nd selected. | 763 // We should have one browser with 2 tabs, the 2nd selected. |
763 EXPECT_EQ(1u, BrowserList::size()); | 764 EXPECT_EQ(1u, BrowserList::size()); |
764 EXPECT_EQ(2, browser()->tab_count()); | 765 EXPECT_EQ(2, browser()->tab_count()); |
765 EXPECT_EQ(1, browser()->active_index()); | 766 EXPECT_EQ(1, browser()->active_index()); |
766 | 767 |
767 // Navigate to a new singleton tab with a sub-page. | 768 // Navigate to a new singleton tab with a sub-page. |
768 browser::NavigateParams p(MakeNavigateParams()); | 769 browser::NavigateParams p(MakeNavigateParams()); |
769 p.disposition = SINGLETON_TAB; | 770 p.disposition = SINGLETON_TAB; |
770 p.url = GetContentSettingsURL(); | 771 p.url = GetContentSettingsURL(); |
771 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 772 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
772 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 773 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
773 browser::Navigate(&p); | 774 browser::Navigate(&p); |
774 | 775 |
775 // The last tab should now be selected and navigated to the sub-page of the | 776 // The last tab should now be selected and navigated to the sub-page of the |
776 // URL. | 777 // URL. |
777 EXPECT_EQ(browser(), p.browser); | 778 EXPECT_EQ(browser(), p.browser); |
778 EXPECT_EQ(3, browser()->tab_count()); | 779 EXPECT_EQ(3, browser()->tab_count()); |
779 EXPECT_EQ(2, browser()->active_index()); | 780 EXPECT_EQ(2, browser()->active_index()); |
780 EXPECT_EQ(GetContentSettingsURL(), | 781 EXPECT_EQ(GetContentSettingsURL(), |
781 browser()->GetActiveWebContents()->GetURL()); | 782 chrome::GetActiveWebContents(browser())->GetURL()); |
782 } | 783 } |
783 | 784 |
784 // This test verifies that constructing params with disposition = SINGLETON_TAB | 785 // This test verifies that constructing params with disposition = SINGLETON_TAB |
785 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus | 786 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
786 // the path) which is navigated to the specified URL. | 787 // the path) which is navigated to the specified URL. |
787 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 788 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
788 Disposition_SingletonTabExisting_IgnorePath) { | 789 Disposition_SingletonTabExisting_IgnorePath) { |
789 GURL singleton_url1(GetSettingsURL()); | 790 GURL singleton_url1(GetSettingsURL()); |
790 browser()->AddSelectedTabWithURL( | 791 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
791 singleton_url1, content::PAGE_TRANSITION_LINK); | 792 content::PAGE_TRANSITION_LINK); |
792 browser()->AddSelectedTabWithURL( | 793 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
793 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 794 content::PAGE_TRANSITION_LINK); |
794 | 795 |
795 // We should have one browser with 3 tabs, the 3rd selected. | 796 // We should have one browser with 3 tabs, the 3rd selected. |
796 EXPECT_EQ(1u, BrowserList::size()); | 797 EXPECT_EQ(1u, BrowserList::size()); |
797 EXPECT_EQ(3, browser()->tab_count()); | 798 EXPECT_EQ(3, browser()->tab_count()); |
798 EXPECT_EQ(2, browser()->active_index()); | 799 EXPECT_EQ(2, browser()->active_index()); |
799 | 800 |
800 // Navigate to singleton_url1. | 801 // Navigate to singleton_url1. |
801 browser::NavigateParams p(MakeNavigateParams()); | 802 browser::NavigateParams p(MakeNavigateParams()); |
802 p.disposition = SINGLETON_TAB; | 803 p.disposition = SINGLETON_TAB; |
803 p.url = GetContentSettingsURL(); | 804 p.url = GetContentSettingsURL(); |
804 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 805 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
805 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 806 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
806 browser::Navigate(&p); | 807 browser::Navigate(&p); |
807 | 808 |
808 // The middle tab should now be selected and navigated to the sub-page of the | 809 // The middle tab should now be selected and navigated to the sub-page of the |
809 // URL. | 810 // URL. |
810 EXPECT_EQ(browser(), p.browser); | 811 EXPECT_EQ(browser(), p.browser); |
811 EXPECT_EQ(3, browser()->tab_count()); | 812 EXPECT_EQ(3, browser()->tab_count()); |
812 EXPECT_EQ(1, browser()->active_index()); | 813 EXPECT_EQ(1, browser()->active_index()); |
813 EXPECT_EQ(GetContentSettingsURL(), | 814 EXPECT_EQ(GetContentSettingsURL(), |
814 browser()->GetActiveWebContents()->GetURL()); | 815 chrome::GetActiveWebContents(browser())->GetURL()); |
815 } | 816 } |
816 | 817 |
817 // This test verifies that constructing params with disposition = SINGLETON_TAB | 818 // This test verifies that constructing params with disposition = SINGLETON_TAB |
818 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus | 819 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
819 // the path) which is navigated to the specified URL. | 820 // the path) which is navigated to the specified URL. |
820 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 821 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
821 Disposition_SingletonTabExistingSubPath_IgnorePath) { | 822 Disposition_SingletonTabExistingSubPath_IgnorePath) { |
822 GURL singleton_url1(GetContentSettingsURL()); | 823 GURL singleton_url1(GetContentSettingsURL()); |
823 browser()->AddSelectedTabWithURL( | 824 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
824 singleton_url1, content::PAGE_TRANSITION_LINK); | 825 content::PAGE_TRANSITION_LINK); |
825 browser()->AddSelectedTabWithURL( | 826 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
826 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 827 content::PAGE_TRANSITION_LINK); |
827 | 828 |
828 // We should have one browser with 3 tabs, the 3rd selected. | 829 // We should have one browser with 3 tabs, the 3rd selected. |
829 EXPECT_EQ(1u, BrowserList::size()); | 830 EXPECT_EQ(1u, BrowserList::size()); |
830 EXPECT_EQ(3, browser()->tab_count()); | 831 EXPECT_EQ(3, browser()->tab_count()); |
831 EXPECT_EQ(2, browser()->active_index()); | 832 EXPECT_EQ(2, browser()->active_index()); |
832 | 833 |
833 // Navigate to singleton_url1. | 834 // Navigate to singleton_url1. |
834 browser::NavigateParams p(MakeNavigateParams()); | 835 browser::NavigateParams p(MakeNavigateParams()); |
835 p.disposition = SINGLETON_TAB; | 836 p.disposition = SINGLETON_TAB; |
836 p.url = GetClearBrowsingDataURL(); | 837 p.url = GetClearBrowsingDataURL(); |
837 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 838 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
838 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 839 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
839 browser::Navigate(&p); | 840 browser::Navigate(&p); |
840 | 841 |
841 // The middle tab should now be selected and navigated to the sub-page of the | 842 // The middle tab should now be selected and navigated to the sub-page of the |
842 // URL. | 843 // URL. |
843 EXPECT_EQ(browser(), p.browser); | 844 EXPECT_EQ(browser(), p.browser); |
844 EXPECT_EQ(3, browser()->tab_count()); | 845 EXPECT_EQ(3, browser()->tab_count()); |
845 EXPECT_EQ(1, browser()->active_index()); | 846 EXPECT_EQ(1, browser()->active_index()); |
846 EXPECT_EQ(GetClearBrowsingDataURL(), | 847 EXPECT_EQ(GetClearBrowsingDataURL(), |
847 browser()->GetActiveWebContents()->GetURL()); | 848 chrome::GetActiveWebContents(browser())->GetURL()); |
848 } | 849 } |
849 | 850 |
850 // This test verifies that constructing params with disposition = SINGLETON_TAB | 851 // This test verifies that constructing params with disposition = SINGLETON_TAB |
851 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus | 852 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus |
852 // the path). | 853 // the path). |
853 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 854 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
854 Disposition_SingletonTabExistingSubPath_IgnorePath2) { | 855 Disposition_SingletonTabExistingSubPath_IgnorePath2) { |
855 GURL singleton_url1(GetContentSettingsURL()); | 856 GURL singleton_url1(GetContentSettingsURL()); |
856 browser()->AddSelectedTabWithURL( | 857 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
857 singleton_url1, content::PAGE_TRANSITION_LINK); | 858 content::PAGE_TRANSITION_LINK); |
858 browser()->AddSelectedTabWithURL( | 859 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
859 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 860 content::PAGE_TRANSITION_LINK); |
860 | 861 |
861 // We should have one browser with 3 tabs, the 3rd selected. | 862 // We should have one browser with 3 tabs, the 3rd selected. |
862 EXPECT_EQ(1u, BrowserList::size()); | 863 EXPECT_EQ(1u, BrowserList::size()); |
863 EXPECT_EQ(3, browser()->tab_count()); | 864 EXPECT_EQ(3, browser()->tab_count()); |
864 EXPECT_EQ(2, browser()->active_index()); | 865 EXPECT_EQ(2, browser()->active_index()); |
865 | 866 |
866 // Navigate to singleton_url1. | 867 // Navigate to singleton_url1. |
867 browser::NavigateParams p(MakeNavigateParams()); | 868 browser::NavigateParams p(MakeNavigateParams()); |
868 p.disposition = SINGLETON_TAB; | 869 p.disposition = SINGLETON_TAB; |
869 p.url = GetClearBrowsingDataURL(); | 870 p.url = GetClearBrowsingDataURL(); |
870 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 871 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
871 p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; | 872 p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; |
872 browser::Navigate(&p); | 873 browser::Navigate(&p); |
873 | 874 |
874 // The middle tab should now be selected. | 875 // The middle tab should now be selected. |
875 EXPECT_EQ(browser(), p.browser); | 876 EXPECT_EQ(browser(), p.browser); |
876 EXPECT_EQ(3, browser()->tab_count()); | 877 EXPECT_EQ(3, browser()->tab_count()); |
877 EXPECT_EQ(1, browser()->active_index()); | 878 EXPECT_EQ(1, browser()->active_index()); |
878 EXPECT_EQ(singleton_url1, | 879 EXPECT_EQ(singleton_url1, |
879 browser()->GetActiveWebContents()->GetURL()); | 880 chrome::GetActiveWebContents(browser())->GetURL()); |
880 } | 881 } |
881 | 882 |
882 // This test verifies that constructing params with disposition = SINGLETON_TAB | 883 // This test verifies that constructing params with disposition = SINGLETON_TAB |
883 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently | 884 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently |
884 // selected tab is a match but has a different path. | 885 // selected tab is a match but has a different path. |
885 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 886 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
886 Disposition_SingletonTabFocused_IgnorePath) { | 887 Disposition_SingletonTabFocused_IgnorePath) { |
887 GURL singleton_url_current(GetContentSettingsURL()); | 888 GURL singleton_url_current(GetContentSettingsURL()); |
888 browser()->AddSelectedTabWithURL( | 889 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, |
889 singleton_url_current, content::PAGE_TRANSITION_LINK); | 890 content::PAGE_TRANSITION_LINK); |
890 | 891 |
891 // We should have one browser with 2 tabs, the 2nd selected. | 892 // We should have one browser with 2 tabs, the 2nd selected. |
892 EXPECT_EQ(1u, BrowserList::size()); | 893 EXPECT_EQ(1u, BrowserList::size()); |
893 EXPECT_EQ(2, browser()->tab_count()); | 894 EXPECT_EQ(2, browser()->tab_count()); |
894 EXPECT_EQ(1, browser()->active_index()); | 895 EXPECT_EQ(1, browser()->active_index()); |
895 | 896 |
896 // Navigate to a different settings path. | 897 // Navigate to a different settings path. |
897 GURL singleton_url_target(GetClearBrowsingDataURL()); | 898 GURL singleton_url_target(GetClearBrowsingDataURL()); |
898 browser::NavigateParams p(MakeNavigateParams()); | 899 browser::NavigateParams p(MakeNavigateParams()); |
899 p.disposition = SINGLETON_TAB; | 900 p.disposition = SINGLETON_TAB; |
900 p.url = singleton_url_target; | 901 p.url = singleton_url_target; |
901 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 902 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
902 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 903 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
903 browser::Navigate(&p); | 904 browser::Navigate(&p); |
904 | 905 |
905 // The second tab should still be selected, but navigated to the new path. | 906 // The second tab should still be selected, but navigated to the new path. |
906 EXPECT_EQ(browser(), p.browser); | 907 EXPECT_EQ(browser(), p.browser); |
907 EXPECT_EQ(2, browser()->tab_count()); | 908 EXPECT_EQ(2, browser()->tab_count()); |
908 EXPECT_EQ(1, browser()->active_index()); | 909 EXPECT_EQ(1, browser()->active_index()); |
909 EXPECT_EQ(singleton_url_target, | 910 EXPECT_EQ(singleton_url_target, |
910 browser()->GetActiveWebContents()->GetURL()); | 911 chrome::GetActiveWebContents(browser())->GetURL()); |
911 } | 912 } |
912 | 913 |
913 // This test verifies that constructing params with disposition = SINGLETON_TAB | 914 // This test verifies that constructing params with disposition = SINGLETON_TAB |
914 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different | 915 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different |
915 // query. | 916 // query. |
916 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 917 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
917 Disposition_SingletonTabExisting_IgnoreQuery) { | 918 Disposition_SingletonTabExisting_IgnoreQuery) { |
918 int initial_tab_count = browser()->tab_count(); | 919 int initial_tab_count = browser()->tab_count(); |
919 GURL singleton_url_current("chrome://settings/internet"); | 920 GURL singleton_url_current("chrome://settings/internet"); |
920 browser()->AddSelectedTabWithURL( | 921 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, |
921 singleton_url_current, content::PAGE_TRANSITION_LINK); | 922 content::PAGE_TRANSITION_LINK); |
922 | 923 |
923 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); | 924 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); |
924 EXPECT_EQ(initial_tab_count, browser()->active_index()); | 925 EXPECT_EQ(initial_tab_count, browser()->active_index()); |
925 | 926 |
926 // Navigate to a different settings path. | 927 // Navigate to a different settings path. |
927 GURL singleton_url_target( | 928 GURL singleton_url_target( |
928 "chrome://settings/internet?" | 929 "chrome://settings/internet?" |
929 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); | 930 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); |
930 browser::NavigateParams p(MakeNavigateParams()); | 931 browser::NavigateParams p(MakeNavigateParams()); |
931 p.disposition = SINGLETON_TAB; | 932 p.disposition = SINGLETON_TAB; |
(...skipping 26 matching lines...) Expand all Loading... |
958 params.disposition = OFF_THE_RECORD; | 959 params.disposition = OFF_THE_RECORD; |
959 { | 960 { |
960 ui_test_utils::WindowedNotificationObserver observer( | 961 ui_test_utils::WindowedNotificationObserver observer( |
961 content::NOTIFICATION_LOAD_STOP, | 962 content::NOTIFICATION_LOAD_STOP, |
962 content::NotificationService::AllSources()); | 963 content::NotificationService::AllSources()); |
963 browser::Navigate(¶ms); | 964 browser::Navigate(¶ms); |
964 observer.Wait(); | 965 observer.Wait(); |
965 } | 966 } |
966 | 967 |
967 EXPECT_EQ(1u, BrowserList::size()); | 968 EXPECT_EQ(1u, BrowserList::size()); |
968 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL()); | 969 EXPECT_EQ(GetSettingsURL(), |
| 970 chrome::GetActiveWebContents(browser())->GetURL()); |
969 } | 971 } |
970 | 972 |
971 // Settings page is expected to always open in normal mode regardless | 973 // Settings page is expected to always open in normal mode regardless |
972 // of whether the user is trying to open it in incognito mode or not. | 974 // of whether the user is trying to open it in incognito mode or not. |
973 // This test verifies that if incognito mode is forced (by policy), settings | 975 // This test verifies that if incognito mode is forced (by policy), settings |
974 // page doesn't open at all. | 976 // page doesn't open at all. |
975 // Disabled until fixed for uber settings: http://crbug.com/111243 | 977 // Disabled until fixed for uber settings: http://crbug.com/111243 |
976 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 978 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
977 DISABLED_Disposition_Settings_DoNothingIfIncognitoIsForced) { | 979 DISABLED_Disposition_Settings_DoNothingIfIncognitoIsForced) { |
978 RunDoNothingIfIncognitoIsForcedTest(GetSettingsURL()); | 980 RunDoNothingIfIncognitoIsForcedTest(GetSettingsURL()); |
(...skipping 28 matching lines...) Expand all Loading... |
1007 // doesn't open at all. | 1009 // doesn't open at all. |
1008 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1010 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1009 Disposition_SyncPromo_DoNothingIfIncognitoIsForced) { | 1011 Disposition_SyncPromo_DoNothingIfIncognitoIsForced) { |
1010 RunDoNothingIfIncognitoIsForcedTest(GURL(chrome::kChromeUISyncPromoURL)); | 1012 RunDoNothingIfIncognitoIsForcedTest(GURL(chrome::kChromeUISyncPromoURL)); |
1011 } | 1013 } |
1012 | 1014 |
1013 // This test makes sure a crashed singleton tab reloads from a new navigation. | 1015 // This test makes sure a crashed singleton tab reloads from a new navigation. |
1014 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1016 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1015 NavigateToCrashedSingletonTab) { | 1017 NavigateToCrashedSingletonTab) { |
1016 GURL singleton_url(GetContentSettingsURL()); | 1018 GURL singleton_url(GetContentSettingsURL()); |
1017 TabContents* tab_contents = browser()->AddSelectedTabWithURL( | 1019 TabContents* tab_contents = chrome::AddSelectedTabWithURL( |
1018 singleton_url, content::PAGE_TRANSITION_LINK); | 1020 browser(), singleton_url, content::PAGE_TRANSITION_LINK); |
1019 WebContents* web_contents = tab_contents->web_contents(); | 1021 WebContents* web_contents = tab_contents->web_contents(); |
1020 | 1022 |
1021 // We should have one browser with 2 tabs, the 2nd selected. | 1023 // We should have one browser with 2 tabs, the 2nd selected. |
1022 EXPECT_EQ(1u, BrowserList::size()); | 1024 EXPECT_EQ(1u, BrowserList::size()); |
1023 EXPECT_EQ(2, browser()->tab_count()); | 1025 EXPECT_EQ(2, browser()->tab_count()); |
1024 EXPECT_EQ(1, browser()->active_index()); | 1026 EXPECT_EQ(1, browser()->active_index()); |
1025 | 1027 |
1026 // Kill the singleton tab. | 1028 // Kill the singleton tab. |
1027 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 1029 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
1028 EXPECT_TRUE(web_contents->IsCrashed()); | 1030 EXPECT_TRUE(web_contents->IsCrashed()); |
(...skipping 12 matching lines...) Expand all Loading... |
1041 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1043 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1042 NavigateFromDefaultToOptionsInSameTab) { | 1044 NavigateFromDefaultToOptionsInSameTab) { |
1043 { | 1045 { |
1044 ui_test_utils::WindowedNotificationObserver observer( | 1046 ui_test_utils::WindowedNotificationObserver observer( |
1045 content::NOTIFICATION_LOAD_STOP, | 1047 content::NOTIFICATION_LOAD_STOP, |
1046 content::NotificationService::AllSources()); | 1048 content::NotificationService::AllSources()); |
1047 chrome::ShowSettings(browser()); | 1049 chrome::ShowSettings(browser()); |
1048 observer.Wait(); | 1050 observer.Wait(); |
1049 } | 1051 } |
1050 EXPECT_EQ(1, browser()->tab_count()); | 1052 EXPECT_EQ(1, browser()->tab_count()); |
1051 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL()); | 1053 EXPECT_EQ(GetSettingsURL(), |
| 1054 chrome::GetActiveWebContents(browser())->GetURL()); |
1052 } | 1055 } |
1053 | 1056 |
1054 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1057 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1055 NavigateFromBlankToOptionsInSameTab) { | 1058 NavigateFromBlankToOptionsInSameTab) { |
1056 browser::NavigateParams p(MakeNavigateParams()); | 1059 browser::NavigateParams p(MakeNavigateParams()); |
1057 p.url = GURL(chrome::kAboutBlankURL); | 1060 p.url = GURL(chrome::kAboutBlankURL); |
1058 ui_test_utils::NavigateToURL(&p); | 1061 ui_test_utils::NavigateToURL(&p); |
1059 | 1062 |
1060 { | 1063 { |
1061 ui_test_utils::WindowedNotificationObserver observer( | 1064 ui_test_utils::WindowedNotificationObserver observer( |
1062 content::NOTIFICATION_LOAD_STOP, | 1065 content::NOTIFICATION_LOAD_STOP, |
1063 content::NotificationService::AllSources()); | 1066 content::NotificationService::AllSources()); |
1064 chrome::ShowSettings(browser()); | 1067 chrome::ShowSettings(browser()); |
1065 observer.Wait(); | 1068 observer.Wait(); |
1066 } | 1069 } |
1067 EXPECT_EQ(1, browser()->tab_count()); | 1070 EXPECT_EQ(1, browser()->tab_count()); |
1068 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL()); | 1071 EXPECT_EQ(GetSettingsURL(), |
| 1072 chrome::GetActiveWebContents(browser())->GetURL()); |
1069 } | 1073 } |
1070 | 1074 |
1071 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1075 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1072 NavigateFromNTPToOptionsInSameTab) { | 1076 NavigateFromNTPToOptionsInSameTab) { |
1073 browser::NavigateParams p(MakeNavigateParams()); | 1077 browser::NavigateParams p(MakeNavigateParams()); |
1074 p.url = GURL(chrome::kChromeUINewTabURL); | 1078 p.url = GURL(chrome::kChromeUINewTabURL); |
1075 ui_test_utils::NavigateToURL(&p); | 1079 ui_test_utils::NavigateToURL(&p); |
1076 EXPECT_EQ(1, browser()->tab_count()); | 1080 EXPECT_EQ(1, browser()->tab_count()); |
1077 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 1081 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
1078 browser()->GetActiveWebContents()->GetURL()); | 1082 chrome::GetActiveWebContents(browser())->GetURL()); |
1079 | 1083 |
1080 { | 1084 { |
1081 ui_test_utils::WindowedNotificationObserver observer( | 1085 ui_test_utils::WindowedNotificationObserver observer( |
1082 content::NOTIFICATION_LOAD_STOP, | 1086 content::NOTIFICATION_LOAD_STOP, |
1083 content::NotificationService::AllSources()); | 1087 content::NotificationService::AllSources()); |
1084 chrome::ShowSettings(browser()); | 1088 chrome::ShowSettings(browser()); |
1085 observer.Wait(); | 1089 observer.Wait(); |
1086 } | 1090 } |
1087 EXPECT_EQ(1, browser()->tab_count()); | 1091 EXPECT_EQ(1, browser()->tab_count()); |
1088 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL()); | 1092 EXPECT_EQ(GetSettingsURL(), |
| 1093 chrome::GetActiveWebContents(browser())->GetURL()); |
1089 } | 1094 } |
1090 | 1095 |
1091 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1096 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1092 NavigateFromPageToOptionsInNewTab) { | 1097 NavigateFromPageToOptionsInNewTab) { |
1093 browser::NavigateParams p(MakeNavigateParams()); | 1098 browser::NavigateParams p(MakeNavigateParams()); |
1094 ui_test_utils::NavigateToURL(&p); | 1099 ui_test_utils::NavigateToURL(&p); |
1095 EXPECT_EQ(GetGoogleURL(), browser()->GetActiveWebContents()->GetURL()); | 1100 EXPECT_EQ(GetGoogleURL(), chrome::GetActiveWebContents(browser())->GetURL()); |
1096 EXPECT_EQ(1u, BrowserList::size()); | 1101 EXPECT_EQ(1u, BrowserList::size()); |
1097 EXPECT_EQ(1, browser()->tab_count()); | 1102 EXPECT_EQ(1, browser()->tab_count()); |
1098 | 1103 |
1099 { | 1104 { |
1100 ui_test_utils::WindowedNotificationObserver observer( | 1105 ui_test_utils::WindowedNotificationObserver observer( |
1101 content::NOTIFICATION_LOAD_STOP, | 1106 content::NOTIFICATION_LOAD_STOP, |
1102 content::NotificationService::AllSources()); | 1107 content::NotificationService::AllSources()); |
1103 chrome::ShowSettings(browser()); | 1108 chrome::ShowSettings(browser()); |
1104 observer.Wait(); | 1109 observer.Wait(); |
1105 } | 1110 } |
1106 EXPECT_EQ(2, browser()->tab_count()); | 1111 EXPECT_EQ(2, browser()->tab_count()); |
1107 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL()); | 1112 EXPECT_EQ(GetSettingsURL(), |
| 1113 chrome::GetActiveWebContents(browser())->GetURL()); |
1108 } | 1114 } |
1109 | 1115 |
1110 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1116 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1111 NavigateFromNTPToOptionsSingleton) { | 1117 NavigateFromNTPToOptionsSingleton) { |
1112 { | 1118 { |
1113 ui_test_utils::WindowedNotificationObserver observer( | 1119 ui_test_utils::WindowedNotificationObserver observer( |
1114 content::NOTIFICATION_LOAD_STOP, | 1120 content::NOTIFICATION_LOAD_STOP, |
1115 content::NotificationService::AllSources()); | 1121 content::NotificationService::AllSources()); |
1116 chrome::ShowSettings(browser()); | 1122 chrome::ShowSettings(browser()); |
1117 observer.Wait(); | 1123 observer.Wait(); |
1118 } | 1124 } |
1119 EXPECT_EQ(1, browser()->tab_count()); | 1125 EXPECT_EQ(1, browser()->tab_count()); |
1120 | 1126 |
1121 chrome::NewTab(browser()); | 1127 chrome::NewTab(browser()); |
1122 EXPECT_EQ(2, browser()->tab_count()); | 1128 EXPECT_EQ(2, browser()->tab_count()); |
1123 | 1129 |
1124 { | 1130 { |
1125 ui_test_utils::WindowedNotificationObserver observer( | 1131 ui_test_utils::WindowedNotificationObserver observer( |
1126 content::NOTIFICATION_LOAD_STOP, | 1132 content::NOTIFICATION_LOAD_STOP, |
1127 content::NotificationService::AllSources()); | 1133 content::NotificationService::AllSources()); |
1128 chrome::ShowSettings(browser()); | 1134 chrome::ShowSettings(browser()); |
1129 observer.Wait(); | 1135 observer.Wait(); |
1130 } | 1136 } |
1131 EXPECT_EQ(2, browser()->tab_count()); | 1137 EXPECT_EQ(2, browser()->tab_count()); |
1132 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL()); | 1138 EXPECT_EQ(GetSettingsURL(), |
| 1139 chrome::GetActiveWebContents(browser())->GetURL()); |
1133 } | 1140 } |
1134 | 1141 |
1135 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1142 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1136 NavigateFromNTPToOptionsPageInSameTab) { | 1143 NavigateFromNTPToOptionsPageInSameTab) { |
1137 { | 1144 { |
1138 ui_test_utils::WindowedNotificationObserver observer( | 1145 ui_test_utils::WindowedNotificationObserver observer( |
1139 content::NOTIFICATION_LOAD_STOP, | 1146 content::NOTIFICATION_LOAD_STOP, |
1140 content::NotificationService::AllSources()); | 1147 content::NotificationService::AllSources()); |
1141 chrome::ShowClearBrowsingDataDialog(browser()); | 1148 chrome::ShowClearBrowsingDataDialog(browser()); |
1142 observer.Wait(); | 1149 observer.Wait(); |
1143 } | 1150 } |
1144 EXPECT_EQ(1, browser()->tab_count()); | 1151 EXPECT_EQ(1, browser()->tab_count()); |
1145 EXPECT_EQ(GetClearBrowsingDataURL(), | 1152 EXPECT_EQ(GetClearBrowsingDataURL(), |
1146 browser()->GetActiveWebContents()->GetURL()); | 1153 chrome::GetActiveWebContents(browser())->GetURL()); |
1147 | 1154 |
1148 chrome::NewTab(browser()); | 1155 chrome::NewTab(browser()); |
1149 EXPECT_EQ(2, browser()->tab_count()); | 1156 EXPECT_EQ(2, browser()->tab_count()); |
1150 | 1157 |
1151 { | 1158 { |
1152 ui_test_utils::WindowedNotificationObserver observer( | 1159 ui_test_utils::WindowedNotificationObserver observer( |
1153 content::NOTIFICATION_LOAD_STOP, | 1160 content::NOTIFICATION_LOAD_STOP, |
1154 content::NotificationService::AllSources()); | 1161 content::NotificationService::AllSources()); |
1155 chrome::ShowClearBrowsingDataDialog(browser()); | 1162 chrome::ShowClearBrowsingDataDialog(browser()); |
1156 observer.Wait(); | 1163 observer.Wait(); |
1157 } | 1164 } |
1158 EXPECT_EQ(2, browser()->tab_count()); | 1165 EXPECT_EQ(2, browser()->tab_count()); |
1159 EXPECT_EQ(GetClearBrowsingDataURL(), | 1166 EXPECT_EQ(GetClearBrowsingDataURL(), |
1160 browser()->GetActiveWebContents()->GetURL()); | 1167 chrome::GetActiveWebContents(browser())->GetURL()); |
1161 } | 1168 } |
1162 | 1169 |
1163 // Times out on mac, fails on linux. | 1170 // Times out on mac, fails on linux. |
1164 // http://crbug.com/119779 | 1171 // http://crbug.com/119779 |
1165 #if defined(OS_MACOSX) || defined(OS_LINUX) | 1172 #if defined(OS_MACOSX) || defined(OS_LINUX) |
1166 #define MAYBE_NavigateFromOtherTabToSingletonOptions DISABLED_NavigateFromOtherT
abToSingletonOptions | 1173 #define MAYBE_NavigateFromOtherTabToSingletonOptions DISABLED_NavigateFromOtherT
abToSingletonOptions |
1167 #else | 1174 #else |
1168 #define MAYBE_NavigateFromOtherTabToSingletonOptions NavigatorFrameOtherTabToSin
gletonOptions | 1175 #define MAYBE_NavigateFromOtherTabToSingletonOptions NavigatorFrameOtherTabToSin
gletonOptions |
1169 #endif | 1176 #endif |
1170 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1177 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1171 MAYBE_NavigateFromOtherTabToSingletonOptions) { | 1178 MAYBE_NavigateFromOtherTabToSingletonOptions) { |
1172 { | 1179 { |
1173 ui_test_utils::WindowedNotificationObserver observer( | 1180 ui_test_utils::WindowedNotificationObserver observer( |
1174 content::NOTIFICATION_LOAD_STOP, | 1181 content::NOTIFICATION_LOAD_STOP, |
1175 content::NotificationService::AllSources()); | 1182 content::NotificationService::AllSources()); |
1176 chrome::ShowSettings(browser()); | 1183 chrome::ShowSettings(browser()); |
1177 observer.Wait(); | 1184 observer.Wait(); |
1178 } | 1185 } |
1179 { | 1186 { |
1180 ui_test_utils::WindowedNotificationObserver observer( | 1187 ui_test_utils::WindowedNotificationObserver observer( |
1181 content::NOTIFICATION_LOAD_STOP, | 1188 content::NOTIFICATION_LOAD_STOP, |
1182 content::NotificationService::AllSources()); | 1189 content::NotificationService::AllSources()); |
1183 browser()->AddSelectedTabWithURL( | 1190 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
1184 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 1191 content::PAGE_TRANSITION_LINK); |
1185 observer.Wait(); | 1192 observer.Wait(); |
1186 } | 1193 } |
1187 | 1194 |
1188 { | 1195 { |
1189 ui_test_utils::WindowedNotificationObserver observer( | 1196 ui_test_utils::WindowedNotificationObserver observer( |
1190 content::NOTIFICATION_LOAD_STOP, | 1197 content::NOTIFICATION_LOAD_STOP, |
1191 content::NotificationService::AllSources()); | 1198 content::NotificationService::AllSources()); |
1192 chrome::ShowSettings(browser()); | 1199 chrome::ShowSettings(browser()); |
1193 observer.Wait(); | 1200 observer.Wait(); |
1194 } | 1201 } |
1195 EXPECT_EQ(2, browser()->tab_count()); | 1202 EXPECT_EQ(2, browser()->tab_count()); |
1196 EXPECT_EQ(GetSettingsURL(), | 1203 EXPECT_EQ(GetSettingsURL(), |
1197 browser()->GetActiveWebContents()->GetURL()); | 1204 chrome::GetActiveWebContents(browser())->GetURL()); |
1198 } | 1205 } |
1199 | 1206 |
1200 // Tests that when a new tab is opened from the omnibox, the focus is moved from | 1207 // Tests that when a new tab is opened from the omnibox, the focus is moved from |
1201 // the omnibox for the current tab. | 1208 // the omnibox for the current tab. |
1202 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1209 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1203 NavigateFromOmniboxIntoNewTab) { | 1210 NavigateFromOmniboxIntoNewTab) { |
1204 GURL url("http://www.google.com/"); | 1211 GURL url("http://www.google.com/"); |
1205 GURL url2("http://maps.google.com/"); | 1212 GURL url2("http://maps.google.com/"); |
1206 | 1213 |
1207 // Navigate to url. | 1214 // Navigate to url. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 DISABLED_NavigateFromDefaultToHistoryInSameTab) { | 1246 DISABLED_NavigateFromDefaultToHistoryInSameTab) { |
1240 { | 1247 { |
1241 ui_test_utils::WindowedNotificationObserver observer( | 1248 ui_test_utils::WindowedNotificationObserver observer( |
1242 content::NOTIFICATION_LOAD_STOP, | 1249 content::NOTIFICATION_LOAD_STOP, |
1243 content::NotificationService::AllSources()); | 1250 content::NotificationService::AllSources()); |
1244 chrome::ShowHistory(browser()); | 1251 chrome::ShowHistory(browser()); |
1245 observer.Wait(); | 1252 observer.Wait(); |
1246 } | 1253 } |
1247 EXPECT_EQ(1, browser()->tab_count()); | 1254 EXPECT_EQ(1, browser()->tab_count()); |
1248 EXPECT_EQ(GURL(chrome::kChromeUIHistoryFrameURL), | 1255 EXPECT_EQ(GURL(chrome::kChromeUIHistoryFrameURL), |
1249 browser()->GetActiveWebContents()->GetURL()); | 1256 chrome::GetActiveWebContents(browser())->GetURL()); |
1250 } | 1257 } |
1251 | 1258 |
1252 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1259 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1253 NavigateFromDefaultToBookmarksInSameTab) { | 1260 NavigateFromDefaultToBookmarksInSameTab) { |
1254 { | 1261 { |
1255 ui_test_utils::WindowedNotificationObserver observer( | 1262 ui_test_utils::WindowedNotificationObserver observer( |
1256 content::NOTIFICATION_LOAD_STOP, | 1263 content::NOTIFICATION_LOAD_STOP, |
1257 content::NotificationService::AllSources()); | 1264 content::NotificationService::AllSources()); |
1258 chrome::ShowBookmarkManager(browser()); | 1265 chrome::ShowBookmarkManager(browser()); |
1259 observer.Wait(); | 1266 observer.Wait(); |
1260 } | 1267 } |
1261 EXPECT_EQ(1, browser()->tab_count()); | 1268 EXPECT_EQ(1, browser()->tab_count()); |
1262 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), | 1269 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), |
1263 browser()->GetActiveWebContents()->GetURL()); | 1270 chrome::GetActiveWebContents(browser())->GetURL()); |
1264 } | 1271 } |
1265 | 1272 |
1266 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1273 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1267 NavigateFromDefaultToDownloadsInSameTab) { | 1274 NavigateFromDefaultToDownloadsInSameTab) { |
1268 { | 1275 { |
1269 ui_test_utils::WindowedNotificationObserver observer( | 1276 ui_test_utils::WindowedNotificationObserver observer( |
1270 content::NOTIFICATION_LOAD_STOP, | 1277 content::NOTIFICATION_LOAD_STOP, |
1271 content::NotificationService::AllSources()); | 1278 content::NotificationService::AllSources()); |
1272 chrome::ShowDownloads(browser()); | 1279 chrome::ShowDownloads(browser()); |
1273 observer.Wait(); | 1280 observer.Wait(); |
1274 } | 1281 } |
1275 EXPECT_EQ(1, browser()->tab_count()); | 1282 EXPECT_EQ(1, browser()->tab_count()); |
1276 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), | 1283 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), |
1277 browser()->GetActiveWebContents()->GetURL()); | 1284 chrome::GetActiveWebContents(browser())->GetURL()); |
1278 } | 1285 } |
1279 | 1286 |
1280 // This test makes sure any link in a crashed panel page navigates to a tabbed | 1287 // This test makes sure any link in a crashed panel page navigates to a tabbed |
1281 // window. | 1288 // window. |
1282 class PanelBrowserNavigatorTest : public BrowserNavigatorTest { | 1289 class PanelBrowserNavigatorTest : public BrowserNavigatorTest { |
1283 protected: | 1290 protected: |
1284 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 1291 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
1285 command_line->AppendSwitch(switches::kEnablePanels); | 1292 command_line->AppendSwitch(switches::kEnablePanels); |
1286 } | 1293 } |
1287 }; | 1294 }; |
(...skipping 17 matching lines...) Expand all Loading... |
1305 // Navigate() should have navigated in the existing panel window. | 1312 // Navigate() should have navigated in the existing panel window. |
1306 EXPECT_EQ(panel_browser, p.browser); | 1313 EXPECT_EQ(panel_browser, p.browser); |
1307 | 1314 |
1308 // We should now have two windows, the browser() provided by the framework and | 1315 // We should now have two windows, the browser() provided by the framework and |
1309 // the panel window we opened earlier. The tabbed browser window has 1 tab. | 1316 // the panel window we opened earlier. The tabbed browser window has 1 tab. |
1310 EXPECT_EQ(2u, BrowserList::size()); | 1317 EXPECT_EQ(2u, BrowserList::size()); |
1311 EXPECT_EQ(1, browser()->tab_count()); | 1318 EXPECT_EQ(1, browser()->tab_count()); |
1312 EXPECT_EQ(1, panel_browser->tab_count()); | 1319 EXPECT_EQ(1, panel_browser->tab_count()); |
1313 | 1320 |
1314 // Kill the panel page. | 1321 // Kill the panel page. |
1315 WebContents* web_contents = panel_browser->GetActiveWebContents(); | 1322 WebContents* web_contents = chrome::GetActiveWebContents(panel_browser); |
1316 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 1323 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
1317 EXPECT_TRUE(web_contents->IsCrashed()); | 1324 EXPECT_TRUE(web_contents->IsCrashed()); |
1318 | 1325 |
1319 // Navigate to the page. | 1326 // Navigate to the page. |
1320 browser::NavigateParams p2(MakeNavigateParams(panel_browser)); | 1327 browser::NavigateParams p2(MakeNavigateParams(panel_browser)); |
1321 p2.source_contents = panel_browser->GetActiveTabContents(); | 1328 p2.source_contents = chrome::GetActiveTabContents(panel_browser); |
1322 p2.url = url2; | 1329 p2.url = url2; |
1323 p2.disposition = CURRENT_TAB; | 1330 p2.disposition = CURRENT_TAB; |
1324 browser::Navigate(&p2); | 1331 browser::Navigate(&p2); |
1325 | 1332 |
1326 // Navigate() should have opened a new tab in the existing tabbed window. | 1333 // Navigate() should have opened a new tab in the existing tabbed window. |
1327 EXPECT_EQ(browser(), p2.browser); | 1334 EXPECT_EQ(browser(), p2.browser); |
1328 | 1335 |
1329 // We should now have two windows, the browser() provided by the framework and | 1336 // We should now have two windows, the browser() provided by the framework and |
1330 // the panel window we opened earlier. The tabbed browser window has 2 tabs. | 1337 // the panel window we opened earlier. The tabbed browser window has 2 tabs. |
1331 EXPECT_EQ(2u, BrowserList::size()); | 1338 EXPECT_EQ(2u, BrowserList::size()); |
1332 EXPECT_EQ(2, browser()->tab_count()); | 1339 EXPECT_EQ(2, browser()->tab_count()); |
1333 EXPECT_EQ(1, panel_browser->tab_count()); | 1340 EXPECT_EQ(1, panel_browser->tab_count()); |
1334 } | 1341 } |
1335 | 1342 |
1336 } // namespace | 1343 } // namespace |
OLD | NEW |