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/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "content/public/test/test_browser_thread.h" | 48 #include "content/public/test/test_browser_thread.h" |
49 #include "content/public/test/test_launcher.h" | 49 #include "content/public/test/test_launcher.h" |
50 #include "content/public/test/test_navigation_observer.h" | 50 #include "content/public/test/test_navigation_observer.h" |
51 #include "net/test/embedded_test_server/embedded_test_server.h" | 51 #include "net/test/embedded_test_server/embedded_test_server.h" |
52 #include "net/test/spawned_test_server/spawned_test_server.h" | 52 #include "net/test/spawned_test_server/spawned_test_server.h" |
53 | 53 |
54 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) |
55 #include "base/mac/scoped_nsautorelease_pool.h" | 55 #include "base/mac/scoped_nsautorelease_pool.h" |
56 #endif | 56 #endif |
57 | 57 |
58 #if defined(OS_WIN) && defined(USE_AURA) | 58 #if defined(OS_WIN) |
59 #include "base/win/scoped_com_initializer.h" | 59 #include "base/win/scoped_com_initializer.h" |
60 #include "base/win/windows_version.h" | 60 #include "base/win/windows_version.h" |
61 #include "ui/base/win/atl_module.h" | 61 #include "ui/base/win/atl_module.h" |
62 #include "win8/test/metro_registration_helper.h" | 62 #include "win8/test/metro_registration_helper.h" |
63 #include "win8/test/test_registrar_constants.h" | 63 #include "win8/test/test_registrar_constants.h" |
64 #endif | 64 #endif |
65 | 65 |
66 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 66 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
67 #include "chrome/browser/captive_portal/captive_portal_service.h" | 67 #include "chrome/browser/captive_portal/captive_portal_service.h" |
68 #endif | 68 #endif |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 190 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
191 captive_portal::CaptivePortalService::set_state_for_testing( | 191 captive_portal::CaptivePortalService::set_state_for_testing( |
192 captive_portal::CaptivePortalService::DISABLED_FOR_TESTING); | 192 captive_portal::CaptivePortalService::DISABLED_FOR_TESTING); |
193 #endif | 193 #endif |
194 | 194 |
195 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( | 195 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( |
196 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); | 196 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); |
197 | 197 |
198 google_util::SetMockLinkDoctorBaseURLForTesting(); | 198 google_util::SetMockLinkDoctorBaseURLForTesting(); |
199 | 199 |
200 #if defined(OS_WIN) && defined(USE_AURA) | 200 #if defined(OS_WIN) |
201 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 201 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
202 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { | 202 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { |
203 com_initializer_.reset(new base::win::ScopedCOMInitializer()); | 203 com_initializer_.reset(new base::win::ScopedCOMInitializer()); |
204 ui::win::CreateATLModuleIfNeeded(); | 204 ui::win::CreateATLModuleIfNeeded(); |
205 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); | 205 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); |
206 } | 206 } |
207 #endif | 207 #endif |
208 | 208 |
209 BrowserTestBase::SetUp(); | 209 BrowserTestBase::SetUp(); |
210 } | 210 } |
211 | 211 |
212 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { | 212 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { |
213 // Propagate commandline settings from test_launcher_utils. | 213 // Propagate commandline settings from test_launcher_utils. |
214 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); | 214 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); |
215 | 215 |
216 // This is a Browser test. | 216 // This is a Browser test. |
217 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); | 217 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); |
218 | 218 |
219 #if defined(OS_WIN) && defined(USE_AURA) | 219 #if defined(OS_WIN) |
220 if (command_line->HasSwitch(switches::kAshBrowserTests)) { | 220 if (command_line->HasSwitch(switches::kAshBrowserTests)) { |
221 command_line->AppendSwitchNative(switches::kViewerLaunchViaAppId, | 221 command_line->AppendSwitchNative(switches::kViewerLaunchViaAppId, |
222 win8::test::kDefaultTestAppUserModelId); | 222 win8::test::kDefaultTestAppUserModelId); |
223 // Ash already launches with a single browser opened, add kSilentLaunch to | 223 // Ash already launches with a single browser opened, add kSilentLaunch to |
224 // make sure StartupBrowserCreator doesn't attempt to launch a browser on | 224 // make sure StartupBrowserCreator doesn't attempt to launch a browser on |
225 // the native desktop on startup. | 225 // the native desktop on startup. |
226 command_line->AppendSwitch(switches::kSilentLaunch); | 226 command_line->AppendSwitch(switches::kSilentLaunch); |
227 } | 227 } |
228 #endif | 228 #endif |
229 | 229 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 LOG(ERROR) << "Could not create temporary user data directory \"" | 263 LOG(ERROR) << "Could not create temporary user data directory \"" |
264 << temp_user_data_dir_.path().value() << "\"."; | 264 << temp_user_data_dir_.path().value() << "\"."; |
265 return false; | 265 return false; |
266 } | 266 } |
267 } | 267 } |
268 return test_launcher_utils::OverrideUserDataDir(user_data_dir); | 268 return test_launcher_utils::OverrideUserDataDir(user_data_dir); |
269 } | 269 } |
270 | 270 |
271 void InProcessBrowserTest::TearDown() { | 271 void InProcessBrowserTest::TearDown() { |
272 DCHECK(!g_browser_process); | 272 DCHECK(!g_browser_process); |
273 #if defined(OS_WIN) && defined(USE_AURA) | 273 #if defined(OS_WIN) |
274 com_initializer_.reset(); | 274 com_initializer_.reset(); |
275 #endif | 275 #endif |
276 BrowserTestBase::TearDown(); | 276 BrowserTestBase::TearDown(); |
277 } | 277 } |
278 | 278 |
279 void InProcessBrowserTest::AddTabAtIndexToBrowser( | 279 void InProcessBrowserTest::AddTabAtIndexToBrowser( |
280 Browser* browser, | 280 Browser* browser, |
281 int index, | 281 int index, |
282 const GURL& url, | 282 const GURL& url, |
283 content::PageTransition transition) { | 283 content::PageTransition transition) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 // On the Mac, this eventually reaches | 463 // On the Mac, this eventually reaches |
464 // -[BrowserWindowController windowWillClose:], which will post a deferred | 464 // -[BrowserWindowController windowWillClose:], which will post a deferred |
465 // -autorelease on itself to ultimately destroy the Browser object. The line | 465 // -autorelease on itself to ultimately destroy the Browser object. The line |
466 // below is necessary to pump these pending messages to ensure all Browsers | 466 // below is necessary to pump these pending messages to ensure all Browsers |
467 // get deleted. | 467 // get deleted. |
468 content::RunAllPendingInMessageLoop(); | 468 content::RunAllPendingInMessageLoop(); |
469 delete autorelease_pool_; | 469 delete autorelease_pool_; |
470 autorelease_pool_ = NULL; | 470 autorelease_pool_ = NULL; |
471 #endif | 471 #endif |
472 } | 472 } |
OLD | NEW |