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