OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/test/browser_test_base.h" | 5 #include "content/test/browser_test_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
10 #include "content/public/common/main_function_params.h" | 10 #include "content/public/common/main_function_params.h" |
11 #include "sandbox/win/src/dep.h" | 11 #include "sandbox/win/src/dep.h" |
12 | 12 |
13 #if defined(OS_MACOSX) | 13 #if defined(OS_MACOSX) |
14 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
15 #include "base/system_monitor/system_monitor.h" | 15 #include "base/system_monitor/system_monitor.h" |
16 #endif | 16 #endif |
17 | 17 |
| 18 #if defined(USE_AURA) |
| 19 #include "ui/aura/test/aura_test_helper.h" |
| 20 #endif |
| 21 |
18 extern int BrowserMain(const content::MainFunctionParams&); | 22 extern int BrowserMain(const content::MainFunctionParams&); |
19 | 23 |
20 BrowserTestBase::BrowserTestBase() { | 24 BrowserTestBase::BrowserTestBase() { |
21 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
22 base::mac::SetOverrideAmIBundled(true); | 26 base::mac::SetOverrideAmIBundled(true); |
23 base::SystemMonitor::AllocateSystemIOPorts(); | 27 base::SystemMonitor::AllocateSystemIOPorts(); |
24 #endif | 28 #endif |
25 } | 29 } |
26 | 30 |
27 BrowserTestBase::~BrowserTestBase() { | 31 BrowserTestBase::~BrowserTestBase() { |
28 } | 32 } |
29 | 33 |
30 void BrowserTestBase::SetUp() { | 34 void BrowserTestBase::SetUp() { |
31 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 35 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
32 | 36 |
33 // The tests assume that file:// URIs can freely access other file:// URIs. | 37 // The tests assume that file:// URIs can freely access other file:// URIs. |
34 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); | 38 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
35 | 39 |
36 command_line->AppendSwitch(switches::kDomAutomationController); | 40 command_line->AppendSwitch(switches::kDomAutomationController); |
37 | 41 |
38 content::MainFunctionParams params(*command_line); | 42 content::MainFunctionParams params(*command_line); |
39 params.ui_task = | 43 params.ui_task = |
40 new base::Closure( | 44 new base::Closure( |
41 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); | 45 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); |
42 | 46 |
43 SetUpInProcessBrowserTestFixture(); | 47 SetUpInProcessBrowserTestFixture(); |
| 48 #if defined(USE_AURA) |
| 49 aura_test_helper_.reset(new aura::test::AuraTestHelper(&ui_loop_)); |
| 50 aura_test_helper_->SetUp(); |
| 51 #endif // USE_AURA |
44 BrowserMain(params); | 52 BrowserMain(params); |
45 TearDownInProcessBrowserTestFixture(); | 53 TearDownInProcessBrowserTestFixture(); |
46 } | 54 } |
47 | 55 |
48 void BrowserTestBase::TearDown() { | 56 void BrowserTestBase::TearDown() { |
| 57 #if defined(USE_AURA) |
| 58 aura_test_helper_->TearDown(); |
| 59 #endif |
49 } | 60 } |
50 | 61 |
51 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { | 62 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { |
52 RunTestOnMainThreadLoop(); | 63 RunTestOnMainThreadLoop(); |
53 } | 64 } |
54 | 65 |
55 void BrowserTestBase::CreateTestServer(const char* test_server_base) { | 66 void BrowserTestBase::CreateTestServer(const char* test_server_base) { |
56 CHECK(!test_server_.get()); | 67 CHECK(!test_server_.get()); |
57 test_server_.reset(new net::TestServer( | 68 test_server_.reset(new net::TestServer( |
58 net::TestServer::TYPE_HTTP, | 69 net::TestServer::TYPE_HTTP, |
59 net::TestServer::kLocalhost, | 70 net::TestServer::kLocalhost, |
60 FilePath().AppendASCII(test_server_base))); | 71 FilePath().AppendASCII(test_server_base))); |
61 } | 72 } |
OLD | NEW |