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 "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 10 #include "chrome/browser/prefs/incognito_mode_prefs.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_finder.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_tabstrip.h" |
16 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
17 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 | 103 |
104 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { | 104 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { |
105 GURL old_url = browser()->tab_strip_model()->GetActiveWebContents()->GetURL(); | 105 GURL old_url = browser()->tab_strip_model()->GetActiveWebContents()->GetURL(); |
106 chrome::NavigateParams p(MakeNavigateParams()); | 106 chrome::NavigateParams p(MakeNavigateParams()); |
107 p.disposition = disposition; | 107 p.disposition = disposition; |
108 chrome::Navigate(&p); | 108 chrome::Navigate(&p); |
109 | 109 |
110 // Nothing should have happened as a result of Navigate(); | 110 // Nothing should have happened as a result of Navigate(); |
111 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 111 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
112 EXPECT_EQ(1u, BrowserList::size()); | 112 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
113 EXPECT_EQ(old_url, | 113 EXPECT_EQ(old_url, |
114 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 114 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
115 } | 115 } |
116 | 116 |
117 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { | 117 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { |
118 Browser* incognito_browser = CreateIncognitoBrowser(); | 118 Browser* incognito_browser = CreateIncognitoBrowser(); |
119 | 119 |
120 EXPECT_EQ(2u, BrowserList::size()); | 120 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
121 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 121 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
122 EXPECT_EQ(1, incognito_browser->tab_strip_model()->count()); | 122 EXPECT_EQ(1, incognito_browser->tab_strip_model()->count()); |
123 | 123 |
124 // Navigate to the page. | 124 // Navigate to the page. |
125 chrome::NavigateParams p(MakeNavigateParams(incognito_browser)); | 125 chrome::NavigateParams p(MakeNavigateParams(incognito_browser)); |
126 p.disposition = SINGLETON_TAB; | 126 p.disposition = SINGLETON_TAB; |
127 p.url = url; | 127 p.url = url; |
128 p.window_action = chrome::NavigateParams::SHOW_WINDOW; | 128 p.window_action = chrome::NavigateParams::SHOW_WINDOW; |
129 chrome::Navigate(&p); | 129 chrome::Navigate(&p); |
130 | 130 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 namespace { | 180 namespace { |
181 | 181 |
182 // This test verifies that when a navigation occurs within a tab, the tab count | 182 // This test verifies that when a navigation occurs within a tab, the tab count |
183 // of the Browser remains the same and the current tab bears the loaded URL. | 183 // of the Browser remains the same and the current tab bears the loaded URL. |
184 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { | 184 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { |
185 ui_test_utils::NavigateToURL(browser(), GetGoogleURL()); | 185 ui_test_utils::NavigateToURL(browser(), GetGoogleURL()); |
186 EXPECT_EQ(GetGoogleURL(), | 186 EXPECT_EQ(GetGoogleURL(), |
187 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 187 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
188 // We should have one window with one tab. | 188 // We should have one window with one tab. |
189 EXPECT_EQ(1u, BrowserList::size()); | 189 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
190 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 190 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
191 } | 191 } |
192 | 192 |
193 // This test verifies that a singleton tab is refocused if one is already opened | 193 // This test verifies that a singleton tab is refocused if one is already opened |
194 // in another or an existing window, or added if it is not. | 194 // in another or an existing window, or added if it is not. |
195 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { | 195 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { |
196 GURL singleton_url1("http://maps.google.com/"); | 196 GURL singleton_url1("http://maps.google.com/"); |
197 | 197 |
198 // Register for a notification if an additional WebContents was instantiated. | 198 // Register for a notification if an additional WebContents was instantiated. |
199 // Opening a Singleton tab that is already opened should not be opening a new | 199 // Opening a Singleton tab that is already opened should not be opening a new |
200 // tab nor be creating a new WebContents object. | 200 // tab nor be creating a new WebContents object. |
201 content::NotificationRegistrar registrar; | 201 content::NotificationRegistrar registrar; |
202 | 202 |
203 // As the registrar object goes out of scope, this will get unregistered | 203 // As the registrar object goes out of scope, this will get unregistered |
204 registrar.Add(this, | 204 registrar.Add(this, |
205 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 205 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
206 content::NotificationService::AllSources()); | 206 content::NotificationService::AllSources()); |
207 | 207 |
208 chrome::AddSelectedTabWithURL(browser(), singleton_url1, | 208 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
209 content::PAGE_TRANSITION_LINK); | 209 content::PAGE_TRANSITION_LINK); |
210 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 210 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
211 content::PAGE_TRANSITION_LINK); | 211 content::PAGE_TRANSITION_LINK); |
212 | 212 |
213 // We should have one browser with 3 tabs, the 3rd selected. | 213 // We should have one browser with 3 tabs, the 3rd selected. |
214 EXPECT_EQ(1u, BrowserList::size()); | 214 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
215 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 215 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
216 | 216 |
217 unsigned int previous_tab_contents_count = | 217 unsigned int previous_tab_contents_count = |
218 created_tab_contents_count_ = 0; | 218 created_tab_contents_count_ = 0; |
219 | 219 |
220 // Navigate to singleton_url1. | 220 // Navigate to singleton_url1. |
221 chrome::NavigateParams p(MakeNavigateParams()); | 221 chrome::NavigateParams p(MakeNavigateParams()); |
222 p.disposition = SINGLETON_TAB; | 222 p.disposition = SINGLETON_TAB; |
223 p.url = singleton_url1; | 223 p.url = singleton_url1; |
224 chrome::Navigate(&p); | 224 chrome::Navigate(&p); |
(...skipping 10 matching lines...) Expand all Loading... |
235 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 235 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
236 Disposition_SingletonTabRespectingRef) { | 236 Disposition_SingletonTabRespectingRef) { |
237 GURL singleton_ref_url1("http://maps.google.com/#a"); | 237 GURL singleton_ref_url1("http://maps.google.com/#a"); |
238 GURL singleton_ref_url2("http://maps.google.com/#b"); | 238 GURL singleton_ref_url2("http://maps.google.com/#b"); |
239 GURL singleton_ref_url3("http://maps.google.com/"); | 239 GURL singleton_ref_url3("http://maps.google.com/"); |
240 | 240 |
241 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, | 241 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, |
242 content::PAGE_TRANSITION_LINK); | 242 content::PAGE_TRANSITION_LINK); |
243 | 243 |
244 // We should have one browser with 2 tabs, 2nd selected. | 244 // We should have one browser with 2 tabs, 2nd selected. |
245 EXPECT_EQ(1u, BrowserList::size()); | 245 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
246 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 246 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
247 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 247 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
248 | 248 |
249 // Navigate to singleton_url2. | 249 // Navigate to singleton_url2. |
250 chrome::NavigateParams p(MakeNavigateParams()); | 250 chrome::NavigateParams p(MakeNavigateParams()); |
251 p.disposition = SINGLETON_TAB; | 251 p.disposition = SINGLETON_TAB; |
252 p.url = singleton_ref_url2; | 252 p.url = singleton_ref_url2; |
253 chrome::Navigate(&p); | 253 chrome::Navigate(&p); |
254 | 254 |
255 // We should now have 2 tabs, the 2nd one selected. | 255 // We should now have 2 tabs, the 2nd one selected. |
(...skipping 24 matching lines...) Expand all Loading... |
280 EXPECT_EQ(browser(), p.browser); | 280 EXPECT_EQ(browser(), p.browser); |
281 EXPECT_EQ(4, browser()->tab_strip_model()->count()); | 281 EXPECT_EQ(4, browser()->tab_strip_model()->count()); |
282 EXPECT_EQ(3, browser()->tab_strip_model()->active_index()); | 282 EXPECT_EQ(3, browser()->tab_strip_model()->active_index()); |
283 } | 283 } |
284 | 284 |
285 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 285 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
286 Disposition_SingletonTabNoneExisting) { | 286 Disposition_SingletonTabNoneExisting) { |
287 GURL singleton_url1("http://maps.google.com/"); | 287 GURL singleton_url1("http://maps.google.com/"); |
288 | 288 |
289 // We should have one browser with 1 tab. | 289 // We should have one browser with 1 tab. |
290 EXPECT_EQ(1u, BrowserList::size()); | 290 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
291 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 291 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
292 | 292 |
293 // Navigate to singleton_url1. | 293 // Navigate to singleton_url1. |
294 chrome::NavigateParams p(MakeNavigateParams()); | 294 chrome::NavigateParams p(MakeNavigateParams()); |
295 p.disposition = SINGLETON_TAB; | 295 p.disposition = SINGLETON_TAB; |
296 p.url = singleton_url1; | 296 p.url = singleton_url1; |
297 chrome::Navigate(&p); | 297 chrome::Navigate(&p); |
298 | 298 |
299 // We should now have 2 tabs, the 2nd one selected. | 299 // We should now have 2 tabs, the 2nd one selected. |
300 EXPECT_EQ(browser(), p.browser); | 300 EXPECT_EQ(browser(), p.browser); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // Navigate() should have opened the tab in a different browser since the | 350 // Navigate() should have opened the tab in a different browser since the |
351 // one we supplied didn't support additional tabs. | 351 // one we supplied didn't support additional tabs. |
352 EXPECT_NE(popup, p.browser); | 352 EXPECT_NE(popup, p.browser); |
353 | 353 |
354 // Since browser() is an existing compatible tabbed browser, it should have | 354 // Since browser() is an existing compatible tabbed browser, it should have |
355 // opened the tab there. | 355 // opened the tab there. |
356 EXPECT_EQ(browser(), p.browser); | 356 EXPECT_EQ(browser(), p.browser); |
357 | 357 |
358 // We should be left with 2 windows, the popup with one tab and the browser() | 358 // We should be left with 2 windows, the popup with one tab and the browser() |
359 // provided by the framework with two. | 359 // provided by the framework with two. |
360 EXPECT_EQ(2u, BrowserList::size()); | 360 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
361 EXPECT_EQ(1, popup->tab_strip_model()->count()); | 361 EXPECT_EQ(1, popup->tab_strip_model()->count()); |
362 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 362 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
363 } | 363 } |
364 | 364 |
365 // This test verifies that when a navigation requiring a new foreground tab | 365 // This test verifies that when a navigation requiring a new foreground tab |
366 // occurs in a Browser that cannot host multiple tabs and no compatible Browser | 366 // occurs in a Browser that cannot host multiple tabs and no compatible Browser |
367 // that can is open, a compatible Browser is created. | 367 // that can is open, a compatible Browser is created. |
368 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 368 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
369 Disposition_IncompatibleWindow_NoExisting) { | 369 Disposition_IncompatibleWindow_NoExisting) { |
370 // We want to simulate not being able to find an existing window compatible | 370 // We want to simulate not being able to find an existing window compatible |
(...skipping 14 matching lines...) Expand all Loading... |
385 EXPECT_NE(popup, p.browser); | 385 EXPECT_NE(popup, p.browser); |
386 | 386 |
387 // This time, browser() is _not_ compatible with popup since it is not an | 387 // This time, browser() is _not_ compatible with popup since it is not an |
388 // incognito window. | 388 // incognito window. |
389 EXPECT_NE(browser(), p.browser); | 389 EXPECT_NE(browser(), p.browser); |
390 | 390 |
391 // We should have three windows, each with one tab: | 391 // We should have three windows, each with one tab: |
392 // 1. the browser() provided by the framework (unchanged in this test) | 392 // 1. the browser() provided by the framework (unchanged in this test) |
393 // 2. the incognito popup we created originally | 393 // 2. the incognito popup we created originally |
394 // 3. the new incognito tabbed browser that was created by Navigate(). | 394 // 3. the new incognito tabbed browser that was created by Navigate(). |
395 EXPECT_EQ(3u, BrowserList::size()); | 395 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); |
396 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 396 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
397 EXPECT_EQ(1, popup->tab_strip_model()->count()); | 397 EXPECT_EQ(1, popup->tab_strip_model()->count()); |
398 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); | 398 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); |
399 EXPECT_TRUE(p.browser->is_type_tabbed()); | 399 EXPECT_TRUE(p.browser->is_type_tabbed()); |
400 } | 400 } |
401 | 401 |
402 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 402 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
403 // from a normal Browser results in a new Browser with TYPE_POPUP. | 403 // from a normal Browser results in a new Browser with TYPE_POPUP. |
404 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { | 404 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { |
405 chrome::NavigateParams p(MakeNavigateParams()); | 405 chrome::NavigateParams p(MakeNavigateParams()); |
406 p.disposition = NEW_POPUP; | 406 p.disposition = NEW_POPUP; |
407 p.window_bounds = gfx::Rect(0, 0, 200, 200); | 407 p.window_bounds = gfx::Rect(0, 0, 200, 200); |
408 // Wait for new popup to to load and gain focus. | 408 // Wait for new popup to to load and gain focus. |
409 ui_test_utils::NavigateToURL(&p); | 409 ui_test_utils::NavigateToURL(&p); |
410 | 410 |
411 // Navigate() should have opened a new, focused popup window. | 411 // Navigate() should have opened a new, focused popup window. |
412 EXPECT_NE(browser(), p.browser); | 412 EXPECT_NE(browser(), p.browser); |
413 #if 0 | 413 #if 0 |
414 // TODO(stevenjb): Enable this test. See: crbug.com/79493 | 414 // TODO(stevenjb): Enable this test. See: crbug.com/79493 |
415 EXPECT_TRUE(p.browser->window()->IsActive()); | 415 EXPECT_TRUE(p.browser->window()->IsActive()); |
416 #endif | 416 #endif |
417 EXPECT_TRUE(p.browser->is_type_popup()); | 417 EXPECT_TRUE(p.browser->is_type_popup()); |
418 EXPECT_FALSE(p.browser->is_app()); | 418 EXPECT_FALSE(p.browser->is_app()); |
419 | 419 |
420 // We should have two windows, the browser() provided by the framework and the | 420 // We should have two windows, the browser() provided by the framework and the |
421 // new popup window. | 421 // new popup window. |
422 EXPECT_EQ(2u, BrowserList::size()); | 422 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
423 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 423 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
424 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); | 424 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); |
425 } | 425 } |
426 | 426 |
427 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 427 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
428 // from a normal Browser results in a new Browser with is_app() true. | 428 // from a normal Browser results in a new Browser with is_app() true. |
429 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { | 429 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { |
430 chrome::NavigateParams p(MakeNavigateParams()); | 430 chrome::NavigateParams p(MakeNavigateParams()); |
431 p.disposition = NEW_POPUP; | 431 p.disposition = NEW_POPUP; |
432 p.extension_app_id = "extensionappid"; | 432 p.extension_app_id = "extensionappid"; |
433 p.window_bounds = gfx::Rect(0, 0, 200, 200); | 433 p.window_bounds = gfx::Rect(0, 0, 200, 200); |
434 // Wait for new popup to to load and gain focus. | 434 // Wait for new popup to to load and gain focus. |
435 ui_test_utils::NavigateToURL(&p); | 435 ui_test_utils::NavigateToURL(&p); |
436 | 436 |
437 // Navigate() should have opened a new, focused popup window. | 437 // Navigate() should have opened a new, focused popup window. |
438 EXPECT_NE(browser(), p.browser); | 438 EXPECT_NE(browser(), p.browser); |
439 EXPECT_TRUE(p.browser->is_type_popup()); | 439 EXPECT_TRUE(p.browser->is_type_popup()); |
440 EXPECT_TRUE(p.browser->is_app()); | 440 EXPECT_TRUE(p.browser->is_app()); |
441 | 441 |
442 // We should have two windows, the browser() provided by the framework and the | 442 // We should have two windows, the browser() provided by the framework and the |
443 // new popup window. | 443 // new popup window. |
444 EXPECT_EQ(2u, BrowserList::size()); | 444 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
445 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 445 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
446 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); | 446 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); |
447 } | 447 } |
448 | 448 |
449 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 449 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
450 // from a normal popup results in a new Browser with TYPE_POPUP. | 450 // from a normal popup results in a new Browser with TYPE_POPUP. |
451 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { | 451 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { |
452 // Open a popup. | 452 // Open a popup. |
453 chrome::NavigateParams p1(MakeNavigateParams()); | 453 chrome::NavigateParams p1(MakeNavigateParams()); |
454 p1.disposition = NEW_POPUP; | 454 p1.disposition = NEW_POPUP; |
455 p1.window_bounds = gfx::Rect(0, 0, 200, 200); | 455 p1.window_bounds = gfx::Rect(0, 0, 200, 200); |
456 chrome::Navigate(&p1); | 456 chrome::Navigate(&p1); |
457 // Open another popup. | 457 // Open another popup. |
458 chrome::NavigateParams p2(MakeNavigateParams(p1.browser)); | 458 chrome::NavigateParams p2(MakeNavigateParams(p1.browser)); |
459 p2.disposition = NEW_POPUP; | 459 p2.disposition = NEW_POPUP; |
460 p2.window_bounds = gfx::Rect(0, 0, 200, 200); | 460 p2.window_bounds = gfx::Rect(0, 0, 200, 200); |
461 chrome::Navigate(&p2); | 461 chrome::Navigate(&p2); |
462 | 462 |
463 // Navigate() should have opened a new normal popup window. | 463 // Navigate() should have opened a new normal popup window. |
464 EXPECT_NE(p1.browser, p2.browser); | 464 EXPECT_NE(p1.browser, p2.browser); |
465 EXPECT_TRUE(p2.browser->is_type_popup()); | 465 EXPECT_TRUE(p2.browser->is_type_popup()); |
466 EXPECT_FALSE(p2.browser->is_app()); | 466 EXPECT_FALSE(p2.browser->is_app()); |
467 | 467 |
468 // We should have three windows, the browser() provided by the framework, | 468 // We should have three windows, the browser() provided by the framework, |
469 // the first popup window, and the second popup window. | 469 // the first popup window, and the second popup window. |
470 EXPECT_EQ(3u, BrowserList::size()); | 470 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); |
471 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 471 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
472 EXPECT_EQ(1, p1.browser->tab_strip_model()->count()); | 472 EXPECT_EQ(1, p1.browser->tab_strip_model()->count()); |
473 EXPECT_EQ(1, p2.browser->tab_strip_model()->count()); | 473 EXPECT_EQ(1, p2.browser->tab_strip_model()->count()); |
474 } | 474 } |
475 | 475 |
476 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 476 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
477 // from an app frame results in a new Browser with TYPE_APP_POPUP. | 477 // from an app frame results in a new Browser with TYPE_APP_POPUP. |
478 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 478 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
479 Disposition_NewPopupFromAppWindow) { | 479 Disposition_NewPopupFromAppWindow) { |
480 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, | 480 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, |
481 browser()->profile()); | 481 browser()->profile()); |
482 chrome::NavigateParams p(MakeNavigateParams(app_browser)); | 482 chrome::NavigateParams p(MakeNavigateParams(app_browser)); |
483 p.disposition = NEW_POPUP; | 483 p.disposition = NEW_POPUP; |
484 p.window_bounds = gfx::Rect(0, 0, 200, 200); | 484 p.window_bounds = gfx::Rect(0, 0, 200, 200); |
485 chrome::Navigate(&p); | 485 chrome::Navigate(&p); |
486 | 486 |
487 // Navigate() should have opened a new popup app window. | 487 // Navigate() should have opened a new popup app window. |
488 EXPECT_NE(app_browser, p.browser); | 488 EXPECT_NE(app_browser, p.browser); |
489 EXPECT_NE(browser(), p.browser); | 489 EXPECT_NE(browser(), p.browser); |
490 EXPECT_TRUE(p.browser->is_type_popup()); | 490 EXPECT_TRUE(p.browser->is_type_popup()); |
491 EXPECT_TRUE(p.browser->is_app()); | 491 EXPECT_TRUE(p.browser->is_app()); |
492 | 492 |
493 // We should now have three windows, the app window, the app popup it created, | 493 // We should now have three windows, the app window, the app popup it created, |
494 // and the original browser() provided by the framework. | 494 // and the original browser() provided by the framework. |
495 EXPECT_EQ(3u, BrowserList::size()); | 495 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); |
496 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 496 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
497 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); | 497 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); |
498 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); | 498 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); |
499 } | 499 } |
500 | 500 |
501 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 501 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
502 // from an app popup results in a new Browser also of TYPE_APP_POPUP. | 502 // from an app popup results in a new Browser also of TYPE_APP_POPUP. |
503 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 503 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
504 Disposition_NewPopupFromAppPopup) { | 504 Disposition_NewPopupFromAppPopup) { |
505 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, | 505 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, |
(...skipping 10 matching lines...) Expand all Loading... |
516 chrome::Navigate(&p2); | 516 chrome::Navigate(&p2); |
517 | 517 |
518 // Navigate() should have opened a new popup app window. | 518 // Navigate() should have opened a new popup app window. |
519 EXPECT_NE(browser(), p1.browser); | 519 EXPECT_NE(browser(), p1.browser); |
520 EXPECT_NE(p1.browser, p2.browser); | 520 EXPECT_NE(p1.browser, p2.browser); |
521 EXPECT_TRUE(p2.browser->is_type_popup()); | 521 EXPECT_TRUE(p2.browser->is_type_popup()); |
522 EXPECT_TRUE(p2.browser->is_app()); | 522 EXPECT_TRUE(p2.browser->is_app()); |
523 | 523 |
524 // We should now have four windows, the app window, the first app popup, | 524 // We should now have four windows, the app window, the first app popup, |
525 // the second app popup, and the original browser() provided by the framework. | 525 // the second app popup, and the original browser() provided by the framework. |
526 EXPECT_EQ(4u, BrowserList::size()); | 526 EXPECT_EQ(4u, chrome::GetTotalBrowserCount()); |
527 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 527 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
528 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); | 528 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); |
529 EXPECT_EQ(1, p1.browser->tab_strip_model()->count()); | 529 EXPECT_EQ(1, p1.browser->tab_strip_model()->count()); |
530 EXPECT_EQ(1, p2.browser->tab_strip_model()->count()); | 530 EXPECT_EQ(1, p2.browser->tab_strip_model()->count()); |
531 } | 531 } |
532 | 532 |
533 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 533 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
534 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. | 534 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. |
535 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 535 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
536 Disposition_NewPopupFromExtensionApp) { | 536 Disposition_NewPopupFromExtensionApp) { |
(...skipping 25 matching lines...) Expand all Loading... |
562 chrome::NavigateParams p(MakeNavigateParams()); | 562 chrome::NavigateParams p(MakeNavigateParams()); |
563 p.disposition = NEW_WINDOW; | 563 p.disposition = NEW_WINDOW; |
564 chrome::Navigate(&p); | 564 chrome::Navigate(&p); |
565 | 565 |
566 // Navigate() should have opened a new toplevel window. | 566 // Navigate() should have opened a new toplevel window. |
567 EXPECT_NE(browser(), p.browser); | 567 EXPECT_NE(browser(), p.browser); |
568 EXPECT_TRUE(p.browser->is_type_tabbed()); | 568 EXPECT_TRUE(p.browser->is_type_tabbed()); |
569 | 569 |
570 // We should now have two windows, the browser() provided by the framework and | 570 // We should now have two windows, the browser() provided by the framework and |
571 // the new normal window. | 571 // the new normal window. |
572 EXPECT_EQ(2u, BrowserList::size()); | 572 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
573 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 573 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
574 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); | 574 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); |
575 } | 575 } |
576 | 576 |
577 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO | 577 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
578 // opens a new incognito window if no existing incognito window is present. | 578 // opens a new incognito window if no existing incognito window is present. |
579 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { | 579 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { |
580 chrome::NavigateParams p(MakeNavigateParams()); | 580 chrome::NavigateParams p(MakeNavigateParams()); |
581 p.disposition = OFF_THE_RECORD; | 581 p.disposition = OFF_THE_RECORD; |
582 chrome::Navigate(&p); | 582 chrome::Navigate(&p); |
583 | 583 |
584 // Navigate() should have opened a new toplevel incognito window. | 584 // Navigate() should have opened a new toplevel incognito window. |
585 EXPECT_NE(browser(), p.browser); | 585 EXPECT_NE(browser(), p.browser); |
586 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), | 586 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), |
587 p.browser->profile()); | 587 p.browser->profile()); |
588 | 588 |
589 // |source_contents| should be set to NULL because the profile for the new | 589 // |source_contents| should be set to NULL because the profile for the new |
590 // page is different from the originating page. | 590 // page is different from the originating page. |
591 EXPECT_EQ(NULL, p.source_contents); | 591 EXPECT_EQ(NULL, p.source_contents); |
592 | 592 |
593 // We should now have two windows, the browser() provided by the framework and | 593 // We should now have two windows, the browser() provided by the framework and |
594 // the new incognito window. | 594 // the new incognito window. |
595 EXPECT_EQ(2u, BrowserList::size()); | 595 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
596 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 596 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
597 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); | 597 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); |
598 } | 598 } |
599 | 599 |
600 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO | 600 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
601 // reuses an existing incognito window when possible. | 601 // reuses an existing incognito window when possible. |
602 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { | 602 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { |
603 Browser* incognito_browser = | 603 Browser* incognito_browser = |
604 CreateEmptyBrowserForType(Browser::TYPE_TABBED, | 604 CreateEmptyBrowserForType(Browser::TYPE_TABBED, |
605 browser()->profile()->GetOffTheRecordProfile()); | 605 browser()->profile()->GetOffTheRecordProfile()); |
606 chrome::NavigateParams p(MakeNavigateParams()); | 606 chrome::NavigateParams p(MakeNavigateParams()); |
607 p.disposition = OFF_THE_RECORD; | 607 p.disposition = OFF_THE_RECORD; |
608 chrome::Navigate(&p); | 608 chrome::Navigate(&p); |
609 | 609 |
610 // Navigate() should have opened a new tab in the existing incognito window. | 610 // Navigate() should have opened a new tab in the existing incognito window. |
611 EXPECT_NE(browser(), p.browser); | 611 EXPECT_NE(browser(), p.browser); |
612 EXPECT_EQ(p.browser, incognito_browser); | 612 EXPECT_EQ(p.browser, incognito_browser); |
613 | 613 |
614 // We should now have two windows, the browser() provided by the framework and | 614 // We should now have two windows, the browser() provided by the framework and |
615 // the incognito window we opened earlier. | 615 // the incognito window we opened earlier. |
616 EXPECT_EQ(2u, BrowserList::size()); | 616 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
617 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 617 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
618 EXPECT_EQ(2, incognito_browser->tab_strip_model()->count()); | 618 EXPECT_EQ(2, incognito_browser->tab_strip_model()->count()); |
619 } | 619 } |
620 | 620 |
621 // This test verifies that no navigation action occurs when | 621 // This test verifies that no navigation action occurs when |
622 // WindowOpenDisposition = SUPPRESS_OPEN. | 622 // WindowOpenDisposition = SUPPRESS_OPEN. |
623 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SuppressOpen) { | 623 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SuppressOpen) { |
624 RunSuppressTest(SUPPRESS_OPEN); | 624 RunSuppressTest(SUPPRESS_OPEN); |
625 } | 625 } |
626 | 626 |
(...skipping 16 matching lines...) Expand all Loading... |
643 p.target_contents = CreateWebContents(); | 643 p.target_contents = CreateWebContents(); |
644 chrome::Navigate(&p); | 644 chrome::Navigate(&p); |
645 | 645 |
646 // Navigate() should have opened the contents in a new foreground in the | 646 // Navigate() should have opened the contents in a new foreground in the |
647 // current Browser. | 647 // current Browser. |
648 EXPECT_EQ(browser(), p.browser); | 648 EXPECT_EQ(browser(), p.browser); |
649 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), | 649 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), |
650 p.target_contents); | 650 p.target_contents); |
651 | 651 |
652 // We should have one window, with two tabs. | 652 // We should have one window, with two tabs. |
653 EXPECT_EQ(1u, BrowserList::size()); | 653 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
654 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 654 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
655 } | 655 } |
656 | 656 |
657 #if defined(OS_WIN) | 657 #if defined(OS_WIN) |
658 // This tests adding a popup with a predefined WebContents. | 658 // This tests adding a popup with a predefined WebContents. |
659 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { | 659 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { |
660 chrome::NavigateParams p(MakeNavigateParams()); | 660 chrome::NavigateParams p(MakeNavigateParams()); |
661 p.disposition = NEW_POPUP; | 661 p.disposition = NEW_POPUP; |
662 p.target_contents = CreateWebContents(); | 662 p.target_contents = CreateWebContents(); |
663 p.window_bounds = gfx::Rect(10, 10, 500, 500); | 663 p.window_bounds = gfx::Rect(10, 10, 500, 500); |
(...skipping 16 matching lines...) Expand all Loading... |
680 // at 0,0. | 680 // at 0,0. |
681 EXPECT_EQ(p.window_bounds.origin(), | 681 EXPECT_EQ(p.window_bounds.origin(), |
682 p.browser->window()->GetRestoredBounds().origin()); | 682 p.browser->window()->GetRestoredBounds().origin()); |
683 // All platforms should respect size however provided width > 400 (Mac has a | 683 // All platforms should respect size however provided width > 400 (Mac has a |
684 // minimum window width of 400). | 684 // minimum window width of 400). |
685 EXPECT_EQ(p.window_bounds.size(), | 685 EXPECT_EQ(p.window_bounds.size(), |
686 p.target_contents->GetView()->GetContainerSize()); | 686 p.target_contents->GetView()->GetContainerSize()); |
687 | 687 |
688 // We should have two windows, the new popup and the browser() provided by the | 688 // We should have two windows, the new popup and the browser() provided by the |
689 // framework. | 689 // framework. |
690 EXPECT_EQ(2u, BrowserList::size()); | 690 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
691 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 691 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
692 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); | 692 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); |
693 } | 693 } |
694 #endif | 694 #endif |
695 | 695 |
696 // This tests adding a tab at a specific index. | 696 // This tests adding a tab at a specific index. |
697 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { | 697 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { |
698 // This is not meant to be a comprehensive test of whether or not the tab | 698 // This is not meant to be a comprehensive test of whether or not the tab |
699 // implementation of the browser observes the insertion index. That is | 699 // implementation of the browser observes the insertion index. That is |
700 // covered by the unit tests for TabStripModel. This merely verifies that | 700 // covered by the unit tests for TabStripModel. This merely verifies that |
701 // insertion index preference is reflected in common cases. | 701 // insertion index preference is reflected in common cases. |
702 chrome::NavigateParams p(MakeNavigateParams()); | 702 chrome::NavigateParams p(MakeNavigateParams()); |
703 p.disposition = NEW_FOREGROUND_TAB; | 703 p.disposition = NEW_FOREGROUND_TAB; |
704 p.tabstrip_index = 0; | 704 p.tabstrip_index = 0; |
705 p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; | 705 p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; |
706 chrome::Navigate(&p); | 706 chrome::Navigate(&p); |
707 | 707 |
708 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. | 708 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. |
709 EXPECT_EQ(browser(), p.browser); | 709 EXPECT_EQ(browser(), p.browser); |
710 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents( | 710 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents( |
711 static_cast<const WebContents*>(p.target_contents))); | 711 static_cast<const WebContents*>(p.target_contents))); |
712 | 712 |
713 // We should have one window - the browser() provided by the framework. | 713 // We should have one window - the browser() provided by the framework. |
714 EXPECT_EQ(1u, BrowserList::size()); | 714 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
715 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 715 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
716 } | 716 } |
717 | 717 |
718 // This test verifies that constructing params with disposition = SINGLETON_TAB | 718 // This test verifies that constructing params with disposition = SINGLETON_TAB |
719 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if | 719 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if |
720 // no previous tab with that URL (minus the path) exists. | 720 // no previous tab with that URL (minus the path) exists. |
721 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 721 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
722 Disposition_SingletonTabNew_IgnorePath) { | 722 Disposition_SingletonTabNew_IgnorePath) { |
723 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 723 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
724 content::PAGE_TRANSITION_LINK); | 724 content::PAGE_TRANSITION_LINK); |
725 | 725 |
726 // We should have one browser with 2 tabs, the 2nd selected. | 726 // We should have one browser with 2 tabs, the 2nd selected. |
727 EXPECT_EQ(1u, BrowserList::size()); | 727 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
728 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 728 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
729 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 729 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
730 | 730 |
731 // Navigate to a new singleton tab with a sub-page. | 731 // Navigate to a new singleton tab with a sub-page. |
732 chrome::NavigateParams p(MakeNavigateParams()); | 732 chrome::NavigateParams p(MakeNavigateParams()); |
733 p.disposition = SINGLETON_TAB; | 733 p.disposition = SINGLETON_TAB; |
734 p.url = GetContentSettingsURL(); | 734 p.url = GetContentSettingsURL(); |
735 p.window_action = chrome::NavigateParams::SHOW_WINDOW; | 735 p.window_action = chrome::NavigateParams::SHOW_WINDOW; |
736 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 736 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
737 chrome::Navigate(&p); | 737 chrome::Navigate(&p); |
(...skipping 13 matching lines...) Expand all Loading... |
751 // the path) which is navigated to the specified URL. | 751 // the path) which is navigated to the specified URL. |
752 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 752 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
753 Disposition_SingletonTabExisting_IgnorePath) { | 753 Disposition_SingletonTabExisting_IgnorePath) { |
754 GURL singleton_url1(GetSettingsURL()); | 754 GURL singleton_url1(GetSettingsURL()); |
755 chrome::AddSelectedTabWithURL(browser(), singleton_url1, | 755 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
756 content::PAGE_TRANSITION_LINK); | 756 content::PAGE_TRANSITION_LINK); |
757 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 757 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
758 content::PAGE_TRANSITION_LINK); | 758 content::PAGE_TRANSITION_LINK); |
759 | 759 |
760 // We should have one browser with 3 tabs, the 3rd selected. | 760 // We should have one browser with 3 tabs, the 3rd selected. |
761 EXPECT_EQ(1u, BrowserList::size()); | 761 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
762 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 762 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
763 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 763 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
764 | 764 |
765 // Navigate to singleton_url1. | 765 // Navigate to singleton_url1. |
766 chrome::NavigateParams p(MakeNavigateParams()); | 766 chrome::NavigateParams p(MakeNavigateParams()); |
767 p.disposition = SINGLETON_TAB; | 767 p.disposition = SINGLETON_TAB; |
768 p.url = GetContentSettingsURL(); | 768 p.url = GetContentSettingsURL(); |
769 p.window_action = chrome::NavigateParams::SHOW_WINDOW; | 769 p.window_action = chrome::NavigateParams::SHOW_WINDOW; |
770 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 770 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
771 chrome::Navigate(&p); | 771 chrome::Navigate(&p); |
(...skipping 13 matching lines...) Expand all Loading... |
785 // the path) which is navigated to the specified URL. | 785 // the path) which is navigated to the specified URL. |
786 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 786 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
787 Disposition_SingletonTabExistingSubPath_IgnorePath) { | 787 Disposition_SingletonTabExistingSubPath_IgnorePath) { |
788 GURL singleton_url1(GetContentSettingsURL()); | 788 GURL singleton_url1(GetContentSettingsURL()); |
789 chrome::AddSelectedTabWithURL(browser(), singleton_url1, | 789 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
790 content::PAGE_TRANSITION_LINK); | 790 content::PAGE_TRANSITION_LINK); |
791 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 791 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
792 content::PAGE_TRANSITION_LINK); | 792 content::PAGE_TRANSITION_LINK); |
793 | 793 |
794 // We should have one browser with 3 tabs, the 3rd selected. | 794 // We should have one browser with 3 tabs, the 3rd selected. |
795 EXPECT_EQ(1u, BrowserList::size()); | 795 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
796 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 796 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
797 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 797 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
798 | 798 |
799 // Navigate to singleton_url1. | 799 // Navigate to singleton_url1. |
800 chrome::NavigateParams p(MakeNavigateParams()); | 800 chrome::NavigateParams p(MakeNavigateParams()); |
801 p.disposition = SINGLETON_TAB; | 801 p.disposition = SINGLETON_TAB; |
802 p.url = GetClearBrowsingDataURL(); | 802 p.url = GetClearBrowsingDataURL(); |
803 p.window_action = chrome::NavigateParams::SHOW_WINDOW; | 803 p.window_action = chrome::NavigateParams::SHOW_WINDOW; |
804 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 804 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
805 chrome::Navigate(&p); | 805 chrome::Navigate(&p); |
(...skipping 13 matching lines...) Expand all Loading... |
819 // the path). | 819 // the path). |
820 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 820 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
821 Disposition_SingletonTabExistingSubPath_IgnorePath2) { | 821 Disposition_SingletonTabExistingSubPath_IgnorePath2) { |
822 GURL singleton_url1(GetContentSettingsURL()); | 822 GURL singleton_url1(GetContentSettingsURL()); |
823 chrome::AddSelectedTabWithURL(browser(), singleton_url1, | 823 chrome::AddSelectedTabWithURL(browser(), singleton_url1, |
824 content::PAGE_TRANSITION_LINK); | 824 content::PAGE_TRANSITION_LINK); |
825 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 825 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
826 content::PAGE_TRANSITION_LINK); | 826 content::PAGE_TRANSITION_LINK); |
827 | 827 |
828 // We should have one browser with 3 tabs, the 3rd selected. | 828 // We should have one browser with 3 tabs, the 3rd selected. |
829 EXPECT_EQ(1u, BrowserList::size()); | 829 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
830 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 830 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
831 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 831 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
832 | 832 |
833 // Navigate to singleton_url1. | 833 // Navigate to singleton_url1. |
834 chrome::NavigateParams p(MakeNavigateParams()); | 834 chrome::NavigateParams p(MakeNavigateParams()); |
835 p.disposition = SINGLETON_TAB; | 835 p.disposition = SINGLETON_TAB; |
836 p.url = GetClearBrowsingDataURL(); | 836 p.url = GetClearBrowsingDataURL(); |
837 p.window_action = chrome::NavigateParams::SHOW_WINDOW; | 837 p.window_action = chrome::NavigateParams::SHOW_WINDOW; |
838 p.path_behavior = chrome::NavigateParams::IGNORE_AND_STAY_PUT; | 838 p.path_behavior = chrome::NavigateParams::IGNORE_AND_STAY_PUT; |
839 chrome::Navigate(&p); | 839 chrome::Navigate(&p); |
(...skipping 10 matching lines...) Expand all Loading... |
850 // This test verifies that constructing params with disposition = SINGLETON_TAB | 850 // This test verifies that constructing params with disposition = SINGLETON_TAB |
851 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently | 851 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently |
852 // selected tab is a match but has a different path. | 852 // selected tab is a match but has a different path. |
853 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 853 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
854 Disposition_SingletonTabFocused_IgnorePath) { | 854 Disposition_SingletonTabFocused_IgnorePath) { |
855 GURL singleton_url_current(GetContentSettingsURL()); | 855 GURL singleton_url_current(GetContentSettingsURL()); |
856 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, | 856 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, |
857 content::PAGE_TRANSITION_LINK); | 857 content::PAGE_TRANSITION_LINK); |
858 | 858 |
859 // We should have one browser with 2 tabs, the 2nd selected. | 859 // We should have one browser with 2 tabs, the 2nd selected. |
860 EXPECT_EQ(1u, BrowserList::size()); | 860 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
861 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 861 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
862 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 862 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
863 | 863 |
864 // Navigate to a different settings path. | 864 // Navigate to a different settings path. |
865 GURL singleton_url_target(GetClearBrowsingDataURL()); | 865 GURL singleton_url_target(GetClearBrowsingDataURL()); |
866 chrome::NavigateParams p(MakeNavigateParams()); | 866 chrome::NavigateParams p(MakeNavigateParams()); |
867 p.disposition = SINGLETON_TAB; | 867 p.disposition = SINGLETON_TAB; |
868 p.url = singleton_url_target; | 868 p.url = singleton_url_target; |
869 p.window_action = chrome::NavigateParams::SHOW_WINDOW; | 869 p.window_action = chrome::NavigateParams::SHOW_WINDOW; |
870 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 870 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 926 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
927 params.disposition = OFF_THE_RECORD; | 927 params.disposition = OFF_THE_RECORD; |
928 { | 928 { |
929 content::WindowedNotificationObserver observer( | 929 content::WindowedNotificationObserver observer( |
930 content::NOTIFICATION_LOAD_STOP, | 930 content::NOTIFICATION_LOAD_STOP, |
931 content::NotificationService::AllSources()); | 931 content::NotificationService::AllSources()); |
932 chrome::Navigate(¶ms); | 932 chrome::Navigate(¶ms); |
933 observer.Wait(); | 933 observer.Wait(); |
934 } | 934 } |
935 | 935 |
936 EXPECT_EQ(1u, BrowserList::size()); | 936 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
937 EXPECT_EQ(GetSettingsURL(), | 937 EXPECT_EQ(GetSettingsURL(), |
938 ShortenUberURL(browser()->tab_strip_model()-> | 938 ShortenUberURL(browser()->tab_strip_model()-> |
939 GetActiveWebContents()->GetURL())); | 939 GetActiveWebContents()->GetURL())); |
940 } | 940 } |
941 | 941 |
942 // Settings page is expected to always open in normal mode regardless | 942 // Settings page is expected to always open in normal mode regardless |
943 // of whether the user is trying to open it in incognito mode or not. | 943 // of whether the user is trying to open it in incognito mode or not. |
944 // This test verifies that if incognito mode is forced (by policy), settings | 944 // This test verifies that if incognito mode is forced (by policy), settings |
945 // page doesn't open at all. | 945 // page doesn't open at all. |
946 // Disabled until fixed for uber settings: http://crbug.com/111243 | 946 // Disabled until fixed for uber settings: http://crbug.com/111243 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 982 } |
983 | 983 |
984 // This test makes sure a crashed singleton tab reloads from a new navigation. | 984 // This test makes sure a crashed singleton tab reloads from a new navigation. |
985 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 985 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
986 NavigateToCrashedSingletonTab) { | 986 NavigateToCrashedSingletonTab) { |
987 GURL singleton_url(GetContentSettingsURL()); | 987 GURL singleton_url(GetContentSettingsURL()); |
988 WebContents* web_contents = chrome::AddSelectedTabWithURL( | 988 WebContents* web_contents = chrome::AddSelectedTabWithURL( |
989 browser(), singleton_url, content::PAGE_TRANSITION_LINK); | 989 browser(), singleton_url, content::PAGE_TRANSITION_LINK); |
990 | 990 |
991 // We should have one browser with 2 tabs, the 2nd selected. | 991 // We should have one browser with 2 tabs, the 2nd selected. |
992 EXPECT_EQ(1u, BrowserList::size()); | 992 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
993 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 993 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
994 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 994 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
995 | 995 |
996 // Kill the singleton tab. | 996 // Kill the singleton tab. |
997 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 997 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
998 EXPECT_TRUE(web_contents->IsCrashed()); | 998 EXPECT_TRUE(web_contents->IsCrashed()); |
999 | 999 |
1000 chrome::NavigateParams p(MakeNavigateParams()); | 1000 chrome::NavigateParams p(MakeNavigateParams()); |
1001 p.disposition = SINGLETON_TAB; | 1001 p.disposition = SINGLETON_TAB; |
1002 p.url = singleton_url; | 1002 p.url = singleton_url; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 ShortenUberURL(browser()->tab_strip_model()-> | 1063 ShortenUberURL(browser()->tab_strip_model()-> |
1064 GetActiveWebContents()->GetURL())); | 1064 GetActiveWebContents()->GetURL())); |
1065 } | 1065 } |
1066 | 1066 |
1067 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1067 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1068 NavigateFromPageToOptionsInNewTab) { | 1068 NavigateFromPageToOptionsInNewTab) { |
1069 chrome::NavigateParams p(MakeNavigateParams()); | 1069 chrome::NavigateParams p(MakeNavigateParams()); |
1070 ui_test_utils::NavigateToURL(&p); | 1070 ui_test_utils::NavigateToURL(&p); |
1071 EXPECT_EQ(GetGoogleURL(), | 1071 EXPECT_EQ(GetGoogleURL(), |
1072 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 1072 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
1073 EXPECT_EQ(1u, BrowserList::size()); | 1073 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1074 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 1074 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
1075 | 1075 |
1076 { | 1076 { |
1077 content::WindowedNotificationObserver observer( | 1077 content::WindowedNotificationObserver observer( |
1078 content::NOTIFICATION_LOAD_STOP, | 1078 content::NOTIFICATION_LOAD_STOP, |
1079 content::NotificationService::AllSources()); | 1079 content::NotificationService::AllSources()); |
1080 chrome::ShowSettings(browser()); | 1080 chrome::ShowSettings(browser()); |
1081 observer.Wait(); | 1081 observer.Wait(); |
1082 } | 1082 } |
1083 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 1083 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 1224 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
1225 } | 1225 } |
1226 | 1226 |
1227 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1227 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1228 NavigateWithoutBrowser) { | 1228 NavigateWithoutBrowser) { |
1229 // First navigate using the profile of the existing browser window, and | 1229 // First navigate using the profile of the existing browser window, and |
1230 // check that the window is reused. | 1230 // check that the window is reused. |
1231 chrome::NavigateParams params(browser()->profile(), GetGoogleURL(), | 1231 chrome::NavigateParams params(browser()->profile(), GetGoogleURL(), |
1232 content::PAGE_TRANSITION_LINK); | 1232 content::PAGE_TRANSITION_LINK); |
1233 ui_test_utils::NavigateToURL(¶ms); | 1233 ui_test_utils::NavigateToURL(¶ms); |
1234 EXPECT_EQ(1u, BrowserList::size()); | 1234 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1235 | 1235 |
1236 // Now navigate using the incognito profile and check that a new window | 1236 // Now navigate using the incognito profile and check that a new window |
1237 // is created. | 1237 // is created. |
1238 chrome::NavigateParams params_incognito( | 1238 chrome::NavigateParams params_incognito( |
1239 browser()->profile()->GetOffTheRecordProfile(), | 1239 browser()->profile()->GetOffTheRecordProfile(), |
1240 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 1240 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
1241 ui_test_utils::NavigateToURL(¶ms_incognito); | 1241 ui_test_utils::NavigateToURL(¶ms_incognito); |
1242 EXPECT_EQ(2u, BrowserList::size()); | 1242 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
1243 } | 1243 } |
1244 | 1244 |
1245 } // namespace | 1245 } // namespace |
OLD | NEW |