Chromium Code Reviews| Index: chrome/browser/ui/browser_navigator_browsertest.cc |
| diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc |
| index 3fdf22f023df6185f8741c2659885d45e5763aa0..0d48551eb551e983766431822d4054b9d9a67df0 100644 |
| --- a/chrome/browser/ui/browser_navigator_browsertest.cc |
| +++ b/chrome/browser/ui/browser_navigator_browsertest.cc |
| @@ -17,6 +17,10 @@ |
| #include "chrome/test/ui_test_utils.h" |
| #include "ipc/ipc_message.h" |
| +#if defined(OS_CHROMEOS) |
| +#include "chrome/browser/chromeos/login/login_utils.h" |
| +#endif |
| + |
| namespace { |
| class BrowserNavigatorTest : public InProcessBrowserTest, |
| @@ -90,14 +94,14 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { |
| EXPECT_EQ(1, browser()->tab_count()); |
| } |
| -// This test verifies that a singleton tab is refocused if one is already open |
| +// This test verifies that a singleton tab is refocused if one is already opened |
| // in another or an existing window, or added if it is not. |
| IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { |
| GURL url("http://www.google.com/"); |
| GURL singleton_url1("http://maps.google.com/"); |
| // Register for a notification if an additional tab_contents was instantiated. |
| - // Opening a Singleton tab that is already open should not be opening a new |
| + // Opening a Singleton tab that is already opened should not be opening a new |
| // tab nor be creating a new TabContents object |
| NotificationRegistrar registrar; |
| @@ -135,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| GURL url("http://www.google.com/"); |
| GURL singleton_url1("http://maps.google.com/"); |
| - // We should have one browser with 3 tabs, the 3rd selected. |
| + // We should have one browser with 1 tab. |
| EXPECT_EQ(1u, BrowserList::size()); |
| EXPECT_EQ(0, browser()->selected_index()); |
| @@ -681,4 +685,95 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| browser()->GetSelectedTabContents()->GetURL()); |
| } |
| +// This test verifies that the settings page isn't opened in the incognito |
| +// window. |
| +IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| + Disposition_Settings_UseNonIncognitoWindow) { |
| + Browser* incognito_browser = CreateIncognitoBrowser(); |
| + |
| + EXPECT_EQ(2u, BrowserList::size()); |
| + EXPECT_EQ(1, browser()->tab_count()); |
| + EXPECT_EQ(1, incognito_browser->tab_count()); |
| + |
| + // Navigate to the settings page. |
| + browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
| + p.disposition = SINGLETON_TAB; |
| + p.url = GURL("chrome://settings"); |
| + p.show_window = true; |
| + p.ignore_path = true; |
| + browser::Navigate(&p); |
| + |
| + // The settings page should be opened in browser() window. |
| + EXPECT_NE(incognito_browser, p.browser); |
| + EXPECT_EQ(browser(), p.browser); |
| + EXPECT_EQ(2, browser()->tab_count()); |
| + EXPECT_EQ(GURL("chrome://settings"), |
| + browser()->GetSelectedTabContents()->GetURL()); |
| +} |
| + |
| +// This test verifies that the bookmarks page isn't opened in the incognito |
| +// window. |
| +IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| + Disposition_Bookmarks_UseNonIncognitoWindow) { |
| + Browser* incognito_browser = CreateIncognitoBrowser(); |
| + |
| + EXPECT_EQ(2u, BrowserList::size()); |
| + EXPECT_EQ(1, browser()->tab_count()); |
| + EXPECT_EQ(1, incognito_browser->tab_count()); |
| + |
| + // Navigate to the settings page. |
| + browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
| + p.disposition = SINGLETON_TAB; |
| + p.url = GURL("chrome://bookmarks"); |
| + p.show_window = true; |
| + p.ignore_path = true; |
| + browser::Navigate(&p); |
| + |
| + // The bookmarks page should be opened in browser() window. |
| + EXPECT_NE(incognito_browser, p.browser); |
| + EXPECT_EQ(browser(), p.browser); |
| + EXPECT_EQ(2, browser()->tab_count()); |
| + EXPECT_EQ(GURL("chrome://bookmarks"), |
| + browser()->GetSelectedTabContents()->GetURL()); |
| +} |
| + |
| +#if defined(OS_CHROMEOS) |
|
Ben Goodger (Google)
2011/02/01 17:59:09
I would rather this live in browser_navigator_brow
Evan Stade
2011/02/01 21:12:35
I actually like this here, because it is logically
|
| +// Subclass that tests navigation while in the Guest session. |
| +class BrowserGuestSessionNavigatorTest: public BrowserNavigatorTest { |
| + protected: |
| + virtual void SetUpCommandLine(CommandLine* command_line) { |
| + CommandLine command_line_copy = *command_line; |
| + chromeos::LoginUtils::Get()->GetOffTheRecordCommandLine(GetGoogleURL(), |
| + command_line_copy, |
| + command_line); |
| + } |
| +}; |
| + |
| +// This test verifies that the settings page is opened in the incognito window |
| +// in Guest Session (as well as all other windows in Guest session). |
| +IN_PROC_BROWSER_TEST_F(BrowserGuestSessionNavigatorTest, |
| + Disposition_Settings_UseIncognitoWindow) { |
| + Browser* incognito_browser = CreateIncognitoBrowser(); |
| + |
| + EXPECT_EQ(2u, BrowserList::size()); |
| + EXPECT_EQ(1, browser()->tab_count()); |
| + EXPECT_EQ(1, incognito_browser->tab_count()); |
| + |
| + // Navigate to the settings page. |
| + browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
| + p.disposition = SINGLETON_TAB; |
| + p.url = GURL("chrome://settings"); |
| + p.show_window = true; |
| + p.ignore_path = true; |
| + browser::Navigate(&p); |
| + |
| + // Settings page should be opened in incognito window. |
| + EXPECT_NE(browser(), p.browser); |
| + EXPECT_EQ(incognito_browser, p.browser); |
| + EXPECT_EQ(2, incognito_browser->tab_count()); |
| + EXPECT_EQ(GURL("chrome://settings"), |
| + incognito_browser->GetSelectedTabContents()->GetURL()); |
| +} |
| +#endif |
| + |
| } // namespace |