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_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
57 #include "chrome/browser/chromeos/audio/audio_handler.h" | 56 #include "chrome/browser/chromeos/audio/audio_handler.h" |
58 #elif defined(OS_MACOSX) | 57 #elif defined(OS_MACOSX) |
59 #include "base/mac/scoped_nsautorelease_pool.h" | 58 #include "base/mac/scoped_nsautorelease_pool.h" |
60 #endif | 59 #endif |
61 | 60 |
62 #if defined(OS_WIN) && defined(USE_AURA) | 61 #if defined(OS_WIN) && defined(USE_AURA) |
63 #include "base/win/scoped_com_initializer.h" | 62 #include "base/win/scoped_com_initializer.h" |
64 #include "base/win/windows_version.h" | 63 #include "base/win/windows_version.h" |
65 #include "ui/base/win/atl_module.h" | 64 #include "ui/base/win/atl_module.h" |
66 #include "ui/compositor/compositor_setup.h" | |
67 #include "win8/test/metro_registration_helper.h" | 65 #include "win8/test/metro_registration_helper.h" |
68 #include "win8/test/test_registrar_constants.h" | 66 #include "win8/test/test_registrar_constants.h" |
69 #endif | 67 #endif |
70 | 68 |
71 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 69 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
72 #include "chrome/browser/captive_portal/captive_portal_service.h" | 70 #include "chrome/browser/captive_portal/captive_portal_service.h" |
73 #endif | 71 #endif |
74 | 72 |
75 namespace { | 73 namespace { |
76 | 74 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); | 209 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); |
212 | 210 |
213 google_util::SetMockLinkDoctorBaseURLForTesting(); | 211 google_util::SetMockLinkDoctorBaseURLForTesting(); |
214 | 212 |
215 #if defined(OS_WIN) && defined(USE_AURA) | 213 #if defined(OS_WIN) && defined(USE_AURA) |
216 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 214 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
217 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { | 215 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { |
218 com_initializer_.reset(new base::win::ScopedCOMInitializer()); | 216 com_initializer_.reset(new base::win::ScopedCOMInitializer()); |
219 ui::win::CreateATLModuleIfNeeded(); | 217 ui::win::CreateATLModuleIfNeeded(); |
220 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); | 218 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); |
221 | |
222 // Ash browser tests need the real compositor. | |
223 ui::DisableTestCompositor(); | |
224 } | 219 } |
225 #endif | 220 #endif |
226 | 221 |
227 BrowserTestBase::SetUp(); | 222 BrowserTestBase::SetUp(); |
228 } | 223 } |
229 | 224 |
230 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { | 225 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { |
231 // Propagate commandline settings from test_launcher_utils. | 226 // Propagate commandline settings from test_launcher_utils. |
232 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); | 227 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); |
233 | 228 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 #if !defined(OS_MACOSX) | 364 #if !defined(OS_MACOSX) |
370 CommandLine InProcessBrowserTest::GetCommandLineForRelaunch() { | 365 CommandLine InProcessBrowserTest::GetCommandLineForRelaunch() { |
371 CommandLine new_command_line(CommandLine::ForCurrentProcess()->GetProgram()); | 366 CommandLine new_command_line(CommandLine::ForCurrentProcess()->GetProgram()); |
372 CommandLine::SwitchMap switches = | 367 CommandLine::SwitchMap switches = |
373 CommandLine::ForCurrentProcess()->GetSwitches(); | 368 CommandLine::ForCurrentProcess()->GetSwitches(); |
374 switches.erase(switches::kUserDataDir); | 369 switches.erase(switches::kUserDataDir); |
375 switches.erase(content::kSingleProcessTestsFlag); | 370 switches.erase(content::kSingleProcessTestsFlag); |
376 switches.erase(switches::kSingleProcess); | 371 switches.erase(switches::kSingleProcess); |
377 new_command_line.AppendSwitch(content::kLaunchAsBrowser); | 372 new_command_line.AppendSwitch(content::kLaunchAsBrowser); |
378 | 373 |
379 #if defined(USE_AURA) | |
380 // Copy what UITestBase::SetLaunchSwitches() does, and also what | |
381 // ChromeTestSuite does if the process had went into the test path. Otherwise | |
382 // tests will fail on bots. | |
383 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
384 switches::kDisableTestCompositor)) { | |
385 new_command_line.AppendSwitch(switches::kTestCompositor); | |
386 } | |
387 #endif | |
388 | |
389 base::FilePath user_data_dir; | 374 base::FilePath user_data_dir; |
390 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 375 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
391 new_command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 376 new_command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
392 | 377 |
393 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 378 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
394 iter != switches.end(); ++iter) { | 379 iter != switches.end(); ++iter) { |
395 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); | 380 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); |
396 } | 381 } |
397 return new_command_line; | 382 return new_command_line; |
398 } | 383 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // On the Mac, this eventually reaches | 468 // On the Mac, this eventually reaches |
484 // -[BrowserWindowController windowWillClose:], which will post a deferred | 469 // -[BrowserWindowController windowWillClose:], which will post a deferred |
485 // -autorelease on itself to ultimately destroy the Browser object. The line | 470 // -autorelease on itself to ultimately destroy the Browser object. The line |
486 // below is necessary to pump these pending messages to ensure all Browsers | 471 // below is necessary to pump these pending messages to ensure all Browsers |
487 // get deleted. | 472 // get deleted. |
488 content::RunAllPendingInMessageLoop(); | 473 content::RunAllPendingInMessageLoop(); |
489 delete autorelease_pool_; | 474 delete autorelease_pool_; |
490 autorelease_pool_ = NULL; | 475 autorelease_pool_ = NULL; |
491 #endif | 476 #endif |
492 } | 477 } |
OLD | NEW |