diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-16 18:58:00 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-16 18:58:00 +0000 |
commit | ad8b455e9d527e0b1ba006306b1ff15abe77569a (patch) | |
tree | c105f566dcf64619013465cdb8865b3ad877ab62 /chrome/app | |
parent | 482fb8c3a29285a39d7cd11a54e2a83727330692 (diff) | |
download | chromium_src-ad8b455e9d527e0b1ba006306b1ff15abe77569a.zip chromium_src-ad8b455e9d527e0b1ba006306b1ff15abe77569a.tar.gz chromium_src-ad8b455e9d527e0b1ba006306b1ff15abe77569a.tar.bz2 |
Fix "chrome --incognito <URL>" opening in non-incognito window (or vice-versa).
BUG=9636
TEST=ui_tests
Review URL: http://codereview.chromium.org/4873004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r-- | chrome/app/chrome_main_uitest.cc | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc index 6f115d6..603da88 100644 --- a/chrome/app/chrome_main_uitest.cc +++ b/chrome/app/chrome_main_uitest.cc @@ -6,6 +6,8 @@ #include "base/command_line.h" #include "base/file_util.h" +#include "chrome/app/chrome_command_ids.h" +#include "chrome/common/chrome_switches.h" #include "net/base/net_util.h" typedef UITest ChromeMainTest; @@ -35,4 +37,65 @@ TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { ASSERT_TRUE(automation()->IsURLDisplayed(net::FilePathToFileURL(test_file))); } + +TEST_F(ChromeMainTest, SecondLaunchWithIncognitoUrl) { + include_testing_id_ = false; + int num_normal_windows; + // We should start with one normal window. + ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); + ASSERT_EQ(1, num_normal_windows); + + // Run with --incognito switch and an URL specified. + FilePath test_file = test_data_directory_.AppendASCII("empty.html"); + CommandLine command_line(CommandLine::NO_PROGRAM); + command_line.AppendSwitch(switches::kIncognito); + command_line.AppendArgPath(test_file); + ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); + + // There should be one normal and one incognito window now. + ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); + ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); + ASSERT_EQ(1, num_normal_windows); +} + +TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { + include_testing_id_ = false; + int num_normal_windows; + // We should start with one normal window. + ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); + ASSERT_EQ(1, num_normal_windows); + + scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser_proxy.get()); + + // Create an off the record window. + ASSERT_TRUE(browser_proxy->RunCommand(IDC_NEW_INCOGNITO_WINDOW)); + int window_count; + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + ASSERT_EQ(2, window_count); + ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); + ASSERT_EQ(1, num_normal_windows); + + // Close the first window. + ASSERT_TRUE(browser_proxy->RunCommand(IDC_CLOSE_WINDOW)); + browser_proxy = NULL; + + // There should only be the incognito window open now. + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + ASSERT_EQ(1, window_count); + ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); + ASSERT_EQ(0, num_normal_windows); + + // Run with just an URL specified, no --incognito switch. + FilePath test_file = test_data_directory_.AppendASCII("empty.html"); + CommandLine command_line(CommandLine::NO_PROGRAM); + command_line.AppendArgPath(test_file); + ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); + + // There should be one normal and one incognito window now. + ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); + ASSERT_TRUE(automation()->GetNormalBrowserWindowCount(&num_normal_windows)); + ASSERT_EQ(1, num_normal_windows); +} + #endif // !OS_MACOSX |