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/public/test/browser_test_base.h" | 5 #include "content/public/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 "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
10 #include "content/browser/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "content/public/common/main_function_params.h" | 13 #include "content/public/common/main_function_params.h" |
14 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
15 #include "net/test/embedded_test_server/embedded_test_server.h" | 15 #include "net/test/embedded_test_server/embedded_test_server.h" |
16 #include "ui/compositor/compositor_switches.h" | |
17 #include "ui/gl/gl_implementation.h" | |
18 #include "ui/gl/gl_switches.h" | |
19 | 16 |
20 #if defined(OS_POSIX) | 17 #if defined(OS_POSIX) |
21 #include "base/process/process_handle.h" | 18 #include "base/process/process_handle.h" |
22 #endif | 19 #endif |
23 | 20 |
24 #if defined(OS_MACOSX) | 21 #if defined(OS_MACOSX) |
25 #include "base/mac/mac_util.h" | 22 #include "base/mac/mac_util.h" |
26 #include "base/power_monitor/power_monitor_device_source.h" | 23 #include "base/power_monitor/power_monitor_device_source.h" |
27 #endif | 24 #endif |
28 | 25 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); | 57 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
61 } | 58 } |
62 | 59 |
63 } // namespace | 60 } // namespace |
64 | 61 |
65 extern int BrowserMain(const MainFunctionParams&); | 62 extern int BrowserMain(const MainFunctionParams&); |
66 | 63 |
67 BrowserTestBase::BrowserTestBase() | 64 BrowserTestBase::BrowserTestBase() |
68 : embedded_test_server_( | 65 : embedded_test_server_( |
69 new net::test_server::EmbeddedTestServer( | 66 new net::test_server::EmbeddedTestServer( |
70 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))), | 67 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) { |
71 allow_test_contexts_(true), | |
72 allow_osmesa_(true) { | |
73 #if defined(OS_MACOSX) | 68 #if defined(OS_MACOSX) |
74 base::mac::SetOverrideAmIBundled(true); | 69 base::mac::SetOverrideAmIBundled(true); |
75 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); | 70 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); |
76 #endif | 71 #endif |
77 | 72 |
78 #if defined(OS_POSIX) | 73 #if defined(OS_POSIX) |
79 handle_sigterm_ = true; | 74 handle_sigterm_ = true; |
80 #endif | 75 #endif |
81 } | 76 } |
82 | 77 |
(...skipping 13 matching lines...) Expand all Loading... |
96 | 91 |
97 command_line->AppendSwitch(switches::kDomAutomationController); | 92 command_line->AppendSwitch(switches::kDomAutomationController); |
98 | 93 |
99 command_line->AppendSwitch(switches::kSkipGpuDataLoading); | 94 command_line->AppendSwitch(switches::kSkipGpuDataLoading); |
100 | 95 |
101 MainFunctionParams params(*command_line); | 96 MainFunctionParams params(*command_line); |
102 params.ui_task = | 97 params.ui_task = |
103 new base::Closure( | 98 new base::Closure( |
104 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); | 99 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); |
105 | 100 |
106 #if defined(USE_AURA) | |
107 // Use test contexts for browser tests unless they override and force us to | |
108 // use a real context. | |
109 if (allow_test_contexts_) | |
110 command_line->AppendSwitch(switches::kTestCompositor); | |
111 #endif | |
112 | |
113 // When using real GL contexts, we usually use OSMesa as this works on all | |
114 // bots. The command line can override this behaviour to use a real GPU. | |
115 if (command_line->HasSwitch(switches::kUseGpuInTests)) | |
116 allow_osmesa_ = false; | |
117 | |
118 #if defined(OS_MACOSX) | |
119 // On Mac we always use a real GPU. | |
120 allow_osmesa_ = false; | |
121 #endif | |
122 | |
123 if (command_line->HasSwitch(switches::kUseGL)) { | |
124 NOTREACHED() << | |
125 "kUseGL should not be used with tests. Try kUseGpuInTests instead."; | |
126 } | |
127 | |
128 if (allow_osmesa_) { | |
129 command_line->AppendSwitchASCII( | |
130 switches::kUseGL, gfx::kGLImplementationOSMesaName); | |
131 } | |
132 | |
133 SetUpInProcessBrowserTestFixture(); | 101 SetUpInProcessBrowserTestFixture(); |
134 #if defined(OS_ANDROID) | 102 #if defined(OS_ANDROID) |
135 BrowserMainRunner::Create()->Initialize(params); | 103 BrowserMainRunner::Create()->Initialize(params); |
136 // We are done running the test by now. During teardown we | 104 // We are done running the test by now. During teardown we |
137 // need to be able to perform IO. | 105 // need to be able to perform IO. |
138 base::ThreadRestrictions::SetIOAllowed(true); | 106 base::ThreadRestrictions::SetIOAllowed(true); |
139 BrowserThread::PostTask( | 107 BrowserThread::PostTask( |
140 BrowserThread::IO, FROM_HERE, | 108 BrowserThread::IO, FROM_HERE, |
141 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), | 109 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), |
142 true)); | 110 true)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); | 146 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
179 CHECK(renderer_loop); | 147 CHECK(renderer_loop); |
180 | 148 |
181 renderer_loop->PostTask( | 149 renderer_loop->PostTask( |
182 FROM_HERE, | 150 FROM_HERE, |
183 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); | 151 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
184 runner->Run(); | 152 runner->Run(); |
185 } | 153 } |
186 | 154 |
187 } // namespace content | 155 } // namespace content |
OLD | NEW |