| 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/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
| 22 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
| 23 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 CommandLine new_command_line(GetCommandLineForRelaunch()); | 79 CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 81 new_command_line.AppendSwitch(switches::kIncognito); | 80 new_command_line.AppendSwitch(switches::kIncognito); |
| 82 new_command_line.AppendArgPath(test_file_path); | 81 new_command_line.AppendArgPath(test_file_path); |
| 83 | 82 |
| 84 Relaunch(new_command_line); | 83 Relaunch(new_command_line); |
| 85 | 84 |
| 86 // There should be one normal and one incognito window now. | 85 // There should be one normal and one incognito window now. |
| 87 ui_test_utils::BrowserAddedObserver observer; | 86 ui_test_utils::BrowserAddedObserver observer; |
| 88 Relaunch(new_command_line); | 87 Relaunch(new_command_line); |
| 89 observer.WaitForSingleNewBrowser(); | 88 observer.WaitForSingleNewBrowser(); |
| 90 ASSERT_EQ(2u, BrowserList::size()); | 89 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 91 | 90 |
| 92 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); | 91 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); |
| 93 } | 92 } |
| 94 | 93 |
| 95 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { | 94 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { |
| 96 // We should start with one normal window. | 95 // We should start with one normal window. |
| 97 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); | 96 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); |
| 98 | 97 |
| 99 // Create an incognito window. | 98 // Create an incognito window. |
| 100 chrome::NewIncognitoWindow(browser()); | 99 chrome::NewIncognitoWindow(browser()); |
| 101 | 100 |
| 102 ASSERT_EQ(2u, BrowserList::size()); | 101 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 103 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); | 102 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); |
| 104 | 103 |
| 105 // Close the first window. | 104 // Close the first window. |
| 106 Profile* profile = browser()->profile(); | 105 Profile* profile = browser()->profile(); |
| 107 content::WindowedNotificationObserver observer( | 106 content::WindowedNotificationObserver observer( |
| 108 chrome::NOTIFICATION_BROWSER_CLOSED, | 107 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 109 content::NotificationService::AllSources()); | 108 content::NotificationService::AllSources()); |
| 110 chrome::CloseWindow(browser()); | 109 chrome::CloseWindow(browser()); |
| 111 observer.Wait(); | 110 observer.Wait(); |
| 112 | 111 |
| 113 // There should only be the incognito window open now. | 112 // There should only be the incognito window open now. |
| 114 ASSERT_EQ(1u, BrowserList::size()); | 113 ASSERT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 115 ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile)); | 114 ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile)); |
| 116 | 115 |
| 117 // Run with just an URL specified, no --incognito switch. | 116 // Run with just an URL specified, no --incognito switch. |
| 118 FilePath test_file_path = ui_test_utils::GetTestFilePath( | 117 FilePath test_file_path = ui_test_utils::GetTestFilePath( |
| 119 FilePath(), FilePath().AppendASCII("empty.html")); | 118 FilePath(), FilePath().AppendASCII("empty.html")); |
| 120 CommandLine new_command_line(GetCommandLineForRelaunch()); | 119 CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 121 new_command_line.AppendArgPath(test_file_path); | 120 new_command_line.AppendArgPath(test_file_path); |
| 122 content::WindowedNotificationObserver tab_observer( | 121 content::WindowedNotificationObserver tab_observer( |
| 123 chrome::NOTIFICATION_TAB_ADDED, | 122 chrome::NOTIFICATION_TAB_ADDED, |
| 124 content::NotificationService::AllSources()); | 123 content::NotificationService::AllSources()); |
| 125 Relaunch(new_command_line); | 124 Relaunch(new_command_line); |
| 126 tab_observer.Wait(); | 125 tab_observer.Wait(); |
| 127 | 126 |
| 128 // There should be one normal and one incognito window now. | 127 // There should be one normal and one incognito window now. |
| 129 ASSERT_EQ(2u, BrowserList::size()); | 128 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 130 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile)); | 129 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile)); |
| 131 } | 130 } |
| 132 | 131 |
| 133 #endif // !OS_MACOSX | 132 #endif // !OS_MACOSX |
| OLD | NEW |