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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/process/launch.h" | 6 #include "base/process/launch.h" |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #if defined(OS_WIN) && defined(USE_ASH) | 39 #if defined(OS_WIN) && defined(USE_ASH) |
40 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 40 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
41 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 41 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
42 switches::kAshBrowserTests)) | 42 switches::kAshBrowserTests)) |
43 return; | 43 return; |
44 #endif | 44 #endif |
45 | 45 |
46 ui_test_utils::BrowserAddedObserver observer; | 46 ui_test_utils::BrowserAddedObserver observer; |
47 Relaunch(GetCommandLineForRelaunch()); | 47 Relaunch(GetCommandLineForRelaunch()); |
48 observer.WaitForSingleNewBrowser(); | 48 observer.WaitForSingleNewBrowser(); |
49 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 49 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
50 browser()->host_desktop_type())); | |
51 } | 50 } |
52 | 51 |
53 IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { | 52 IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { |
54 #if defined(OS_WIN) && defined(USE_ASH) | 53 #if defined(OS_WIN) && defined(USE_ASH) |
55 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 54 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
56 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 55 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
57 switches::kAshBrowserTests)) | 56 switches::kAshBrowserTests)) |
58 return; | 57 return; |
59 #endif | 58 #endif |
60 | 59 |
(...skipping 16 matching lines...) Expand all Loading... |
77 // ChromeMainTest.SecondLaunchWithIncognitoUrl is flaky on Win and Linux. | 76 // ChromeMainTest.SecondLaunchWithIncognitoUrl is flaky on Win and Linux. |
78 // http://crbug.com/130395 | 77 // http://crbug.com/130395 |
79 #if defined(OS_WIN) || defined(OS_LINUX) | 78 #if defined(OS_WIN) || defined(OS_LINUX) |
80 #define MAYBE_SecondLaunchWithIncognitoUrl DISABLED_SecondLaunchWithIncognitoUrl | 79 #define MAYBE_SecondLaunchWithIncognitoUrl DISABLED_SecondLaunchWithIncognitoUrl |
81 #else | 80 #else |
82 #define MAYBE_SecondLaunchWithIncognitoUrl SecondLaunchWithIncognitoUrl | 81 #define MAYBE_SecondLaunchWithIncognitoUrl SecondLaunchWithIncognitoUrl |
83 #endif | 82 #endif |
84 | 83 |
85 IN_PROC_BROWSER_TEST_F(ChromeMainTest, MAYBE_SecondLaunchWithIncognitoUrl) { | 84 IN_PROC_BROWSER_TEST_F(ChromeMainTest, MAYBE_SecondLaunchWithIncognitoUrl) { |
86 // We should start with one normal window. | 85 // We should start with one normal window. |
87 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), | 86 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); |
88 browser()->host_desktop_type())); | |
89 | 87 |
90 // Run with --incognito switch and an URL specified. | 88 // Run with --incognito switch and an URL specified. |
91 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( | 89 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( |
92 base::FilePath(), base::FilePath().AppendASCII("empty.html")); | 90 base::FilePath(), base::FilePath().AppendASCII("empty.html")); |
93 base::CommandLine new_command_line(GetCommandLineForRelaunch()); | 91 base::CommandLine new_command_line(GetCommandLineForRelaunch()); |
94 new_command_line.AppendSwitch(switches::kIncognito); | 92 new_command_line.AppendSwitch(switches::kIncognito); |
95 new_command_line.AppendArgPath(test_file_path); | 93 new_command_line.AppendArgPath(test_file_path); |
96 | 94 |
97 Relaunch(new_command_line); | 95 Relaunch(new_command_line); |
98 | 96 |
99 // There should be one normal and one incognito window now. | 97 // There should be one normal and one incognito window now. |
100 ui_test_utils::BrowserAddedObserver observer; | 98 ui_test_utils::BrowserAddedObserver observer; |
101 Relaunch(new_command_line); | 99 Relaunch(new_command_line); |
102 observer.WaitForSingleNewBrowser(); | 100 observer.WaitForSingleNewBrowser(); |
103 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); | 101 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); |
104 | 102 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); |
105 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), | |
106 browser()->host_desktop_type())); | |
107 } | 103 } |
108 | 104 |
109 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { | 105 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { |
110 #if defined(OS_WIN) && defined(USE_ASH) | 106 #if defined(OS_WIN) && defined(USE_ASH) |
111 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 107 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
112 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 108 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
113 switches::kAshBrowserTests)) | 109 switches::kAshBrowserTests)) |
114 return; | 110 return; |
115 #endif | 111 #endif |
116 | 112 |
117 // We should start with one normal window. | 113 // We should start with one normal window. |
118 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), | 114 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); |
119 browser()->host_desktop_type())); | |
120 | 115 |
121 // Create an incognito window. | 116 // Create an incognito window. |
122 chrome::NewIncognitoWindow(browser()); | 117 chrome::NewIncognitoWindow(browser()); |
123 | 118 |
124 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); | 119 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); |
125 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), | 120 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); |
126 browser()->host_desktop_type())); | |
127 | 121 |
128 // Close the first window. | 122 // Close the first window. |
129 Profile* profile = browser()->profile(); | 123 Profile* profile = browser()->profile(); |
130 chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type(); | |
131 content::WindowedNotificationObserver observer( | 124 content::WindowedNotificationObserver observer( |
132 chrome::NOTIFICATION_BROWSER_CLOSED, | 125 chrome::NOTIFICATION_BROWSER_CLOSED, |
133 content::NotificationService::AllSources()); | 126 content::NotificationService::AllSources()); |
134 chrome::CloseWindow(browser()); | 127 chrome::CloseWindow(browser()); |
135 observer.Wait(); | 128 observer.Wait(); |
136 | 129 |
137 // There should only be the incognito window open now. | 130 // There should only be the incognito window open now. |
138 ASSERT_EQ(1u, chrome::GetTotalBrowserCount()); | 131 ASSERT_EQ(1u, chrome::GetTotalBrowserCount()); |
139 ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile, host_desktop_type)); | 132 ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile)); |
140 | 133 |
141 // Run with just an URL specified, no --incognito switch. | 134 // Run with just an URL specified, no --incognito switch. |
142 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( | 135 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( |
143 base::FilePath(), base::FilePath().AppendASCII("empty.html")); | 136 base::FilePath(), base::FilePath().AppendASCII("empty.html")); |
144 base::CommandLine new_command_line(GetCommandLineForRelaunch()); | 137 base::CommandLine new_command_line(GetCommandLineForRelaunch()); |
145 new_command_line.AppendArgPath(test_file_path); | 138 new_command_line.AppendArgPath(test_file_path); |
146 content::WindowedNotificationObserver tab_observer( | 139 content::WindowedNotificationObserver tab_observer( |
147 chrome::NOTIFICATION_TAB_ADDED, | 140 chrome::NOTIFICATION_TAB_ADDED, |
148 content::NotificationService::AllSources()); | 141 content::NotificationService::AllSources()); |
149 Relaunch(new_command_line); | 142 Relaunch(new_command_line); |
150 tab_observer.Wait(); | 143 tab_observer.Wait(); |
151 | 144 |
152 // There should be one normal and one incognito window now. | 145 // There should be one normal and one incognito window now. |
153 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); | 146 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); |
154 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile, host_desktop_type)); | 147 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile)); |
155 } | 148 } |
156 | 149 |
157 #endif // !OS_MACOSX | 150 #endif // !OS_MACOSX |
OLD | NEW |