| 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" |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. | 689 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. |
| 690 EXPECT_EQ(browser(), p.browser); | 690 EXPECT_EQ(browser(), p.browser); |
| 691 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfTabContents( | 691 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfTabContents( |
| 692 static_cast<const TabContents*>(p.target_contents))); | 692 static_cast<const TabContents*>(p.target_contents))); |
| 693 | 693 |
| 694 // We should have one window - the browser() provided by the framework. | 694 // We should have one window - the browser() provided by the framework. |
| 695 EXPECT_EQ(1u, BrowserList::size()); | 695 EXPECT_EQ(1u, BrowserList::size()); |
| 696 EXPECT_EQ(2, browser()->tab_count()); | 696 EXPECT_EQ(2, browser()->tab_count()); |
| 697 } | 697 } |
| 698 | 698 |
| 699 // This test verifies that constructing params with a NULL browser has | |
| 700 // the same result as navigating to a new foreground tab in the (only) | |
| 701 // active browser. Tests are the same as for Disposition_NewForegroundTab. | |
| 702 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) { | |
| 703 WebContents* old_contents = chrome::GetActiveWebContents(browser()); | |
| 704 // Navigate with a NULL browser. | |
| 705 chrome::NavigateParams p(MakeNavigateParams(NULL)); | |
| 706 p.disposition = NEW_FOREGROUND_TAB; | |
| 707 p.profile = browser()->profile(); | |
| 708 chrome::Navigate(&p); | |
| 709 | |
| 710 // Navigate() should have found browser() and create a new tab. | |
| 711 EXPECT_EQ(browser(), p.browser); | |
| 712 EXPECT_NE(old_contents, chrome::GetActiveWebContents(browser())); | |
| 713 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents); | |
| 714 EXPECT_EQ(2, browser()->tab_count()); | |
| 715 } | |
| 716 | |
| 717 // This test verifies that constructing params with a NULL browser and | |
| 718 // a specific profile matches the specified profile. | |
| 719 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) { | |
| 720 // Create a new browser with using the incognito profile. | |
| 721 Browser* incognito = | |
| 722 Browser::Create(browser()->profile()->GetOffTheRecordProfile()); | |
| 723 | |
| 724 // Navigate with a NULL browser and the incognito profile. | |
| 725 chrome::NavigateParams p(MakeNavigateParams(NULL)); | |
| 726 p.disposition = NEW_FOREGROUND_TAB; | |
| 727 p.profile = incognito->profile(); | |
| 728 chrome::Navigate(&p); | |
| 729 | |
| 730 // Navigate() should have found incognito, not browser(). | |
| 731 EXPECT_EQ(incognito, p.browser); | |
| 732 EXPECT_EQ(chrome::GetActiveTabContents(incognito), p.target_contents); | |
| 733 EXPECT_EQ(1, incognito->tab_count()); | |
| 734 } | |
| 735 | |
| 736 // This test verifies that constructing params with a NULL browser and | |
| 737 // disposition = NEW_WINDOW always opens exactly one new window. | |
| 738 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { | |
| 739 chrome::NavigateParams p(MakeNavigateParams(NULL)); | |
| 740 p.disposition = NEW_WINDOW; | |
| 741 p.profile = browser()->profile(); | |
| 742 chrome::Navigate(&p); | |
| 743 | |
| 744 // Navigate() should have created a new browser. | |
| 745 EXPECT_NE(browser(), p.browser); | |
| 746 EXPECT_TRUE( p.browser->is_type_tabbed()); | |
| 747 | |
| 748 // We should now have two windows, the browser() provided by the framework and | |
| 749 // the new normal window. | |
| 750 EXPECT_EQ(2u, BrowserList::size()); | |
| 751 EXPECT_EQ(1, browser()->tab_count()); | |
| 752 EXPECT_EQ(1, p.browser->tab_count()); | |
| 753 } | |
| 754 | |
| 755 // This test verifies that constructing params with disposition = SINGLETON_TAB | 699 // This test verifies that constructing params with disposition = SINGLETON_TAB |
| 756 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if | 700 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if |
| 757 // no previous tab with that URL (minus the path) exists. | 701 // no previous tab with that URL (minus the path) exists. |
| 758 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 702 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 759 Disposition_SingletonTabNew_IgnorePath) { | 703 Disposition_SingletonTabNew_IgnorePath) { |
| 760 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 704 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
| 761 content::PAGE_TRANSITION_LINK); | 705 content::PAGE_TRANSITION_LINK); |
| 762 | 706 |
| 763 // We should have one browser with 2 tabs, the 2nd selected. | 707 // We should have one browser with 2 tabs, the 2nd selected. |
| 764 EXPECT_EQ(1u, BrowserList::size()); | 708 EXPECT_EQ(1u, BrowserList::size()); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 EXPECT_EQ(browser(), p2.browser); | 1278 EXPECT_EQ(browser(), p2.browser); |
| 1335 | 1279 |
| 1336 // We should now have two windows, the browser() provided by the framework and | 1280 // We should now have two windows, the browser() provided by the framework and |
| 1337 // the panel window we opened earlier. The tabbed browser window has 2 tabs. | 1281 // the panel window we opened earlier. The tabbed browser window has 2 tabs. |
| 1338 EXPECT_EQ(2u, BrowserList::size()); | 1282 EXPECT_EQ(2u, BrowserList::size()); |
| 1339 EXPECT_EQ(2, browser()->tab_count()); | 1283 EXPECT_EQ(2, browser()->tab_count()); |
| 1340 EXPECT_EQ(1, panel_browser->tab_count()); | 1284 EXPECT_EQ(1, panel_browser->tab_count()); |
| 1341 } | 1285 } |
| 1342 | 1286 |
| 1343 } // namespace | 1287 } // namespace |
| OLD | NEW |