| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "chrome/test/base/ui_test_utils.h" | 44 #include "chrome/test/base/ui_test_utils.h" |
| 45 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/browser/notification_types.h" | 46 #include "content/public/browser/notification_types.h" |
| 47 #include "content/public/test/browser_test_utils.h" | 47 #include "content/public/test/browser_test_utils.h" |
| 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/dns/mock_host_resolver.h" | 51 #include "net/dns/mock_host_resolver.h" |
| 52 #include "net/test/embedded_test_server/embedded_test_server.h" | 52 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 53 #include "net/test/spawned_test_server/spawned_test_server.h" | 53 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 54 #include "ui/compositor/compositor_switches.h" |
| 54 | 55 |
| 55 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
| 56 #include "base/mac/scoped_nsautorelease_pool.h" | 57 #include "base/mac/scoped_nsautorelease_pool.h" |
| 57 #endif | 58 #endif |
| 58 | 59 |
| 59 #if defined(OS_WIN) && defined(USE_AURA) | 60 #if defined(OS_WIN) && defined(USE_AURA) |
| 60 #include "base/win/scoped_com_initializer.h" | 61 #include "base/win/scoped_com_initializer.h" |
| 61 #include "base/win/windows_version.h" | 62 #include "base/win/windows_version.h" |
| 62 #include "ui/base/win/atl_module.h" | 63 #include "ui/base/win/atl_module.h" |
| 64 #include "ui/compositor/compositor_setup.h" |
| 63 #include "win8/test/metro_registration_helper.h" | 65 #include "win8/test/metro_registration_helper.h" |
| 64 #include "win8/test/test_registrar_constants.h" | 66 #include "win8/test/test_registrar_constants.h" |
| 65 #endif | 67 #endif |
| 66 | 68 |
| 67 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 69 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 68 #include "chrome/browser/captive_portal/captive_portal_service.h" | 70 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 69 #endif | 71 #endif |
| 70 | 72 |
| 71 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 73 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 72 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 74 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); | 213 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); |
| 212 | 214 |
| 213 google_util::SetMockLinkDoctorBaseURLForTesting(); | 215 google_util::SetMockLinkDoctorBaseURLForTesting(); |
| 214 | 216 |
| 215 #if defined(OS_WIN) && defined(USE_AURA) | 217 #if defined(OS_WIN) && defined(USE_AURA) |
| 216 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 218 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
| 217 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { | 219 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { |
| 218 com_initializer_.reset(new base::win::ScopedCOMInitializer()); | 220 com_initializer_.reset(new base::win::ScopedCOMInitializer()); |
| 219 ui::win::CreateATLModuleIfNeeded(); | 221 ui::win::CreateATLModuleIfNeeded(); |
| 220 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); | 222 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); |
| 223 |
| 224 // Ash browser tests need the real compositor. |
| 225 ui::DisableTestCompositor(); |
| 221 } | 226 } |
| 222 #endif | 227 #endif |
| 223 | 228 |
| 224 BrowserTestBase::SetUp(); | 229 BrowserTestBase::SetUp(); |
| 225 } | 230 } |
| 226 | 231 |
| 227 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { | 232 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { |
| 228 // Propagate commandline settings from test_launcher_utils. | 233 // Propagate commandline settings from test_launcher_utils. |
| 229 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); | 234 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); |
| 230 | 235 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 #if !defined(OS_MACOSX) | 371 #if !defined(OS_MACOSX) |
| 367 CommandLine InProcessBrowserTest::GetCommandLineForRelaunch() { | 372 CommandLine InProcessBrowserTest::GetCommandLineForRelaunch() { |
| 368 CommandLine new_command_line(CommandLine::ForCurrentProcess()->GetProgram()); | 373 CommandLine new_command_line(CommandLine::ForCurrentProcess()->GetProgram()); |
| 369 CommandLine::SwitchMap switches = | 374 CommandLine::SwitchMap switches = |
| 370 CommandLine::ForCurrentProcess()->GetSwitches(); | 375 CommandLine::ForCurrentProcess()->GetSwitches(); |
| 371 switches.erase(switches::kUserDataDir); | 376 switches.erase(switches::kUserDataDir); |
| 372 switches.erase(content::kSingleProcessTestsFlag); | 377 switches.erase(content::kSingleProcessTestsFlag); |
| 373 switches.erase(switches::kSingleProcess); | 378 switches.erase(switches::kSingleProcess); |
| 374 new_command_line.AppendSwitch(content::kLaunchAsBrowser); | 379 new_command_line.AppendSwitch(content::kLaunchAsBrowser); |
| 375 | 380 |
| 381 #if defined(USE_AURA) |
| 382 // Copy what UITestBase::SetLaunchSwitches() does, and also what |
| 383 // ChromeTestSuite does if the process had went into the test path. Otherwise |
| 384 // tests will fail on bots. |
| 385 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 386 switches::kDisableTestCompositor)) { |
| 387 new_command_line.AppendSwitch(switches::kTestCompositor); |
| 388 } |
| 389 #endif |
| 390 |
| 376 base::FilePath user_data_dir; | 391 base::FilePath user_data_dir; |
| 377 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 392 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 378 new_command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 393 new_command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 379 | 394 |
| 380 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 395 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
| 381 iter != switches.end(); ++iter) { | 396 iter != switches.end(); ++iter) { |
| 382 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); | 397 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); |
| 383 } | 398 } |
| 384 return new_command_line; | 399 return new_command_line; |
| 385 } | 400 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 // On the Mac, this eventually reaches | 491 // On the Mac, this eventually reaches |
| 477 // -[BrowserWindowController windowWillClose:], which will post a deferred | 492 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 478 // -autorelease on itself to ultimately destroy the Browser object. The line | 493 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 479 // below is necessary to pump these pending messages to ensure all Browsers | 494 // below is necessary to pump these pending messages to ensure all Browsers |
| 480 // get deleted. | 495 // get deleted. |
| 481 content::RunAllPendingInMessageLoop(); | 496 content::RunAllPendingInMessageLoop(); |
| 482 delete autorelease_pool_; | 497 delete autorelease_pool_; |
| 483 autorelease_pool_ = NULL; | 498 autorelease_pool_ = NULL; |
| 484 #endif | 499 #endif |
| 485 } | 500 } |
| OLD | NEW |