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 "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "base/mac/mac_util.h" | 29 #include "base/mac/mac_util.h" |
30 #include "base/power_monitor/power_monitor_device_source.h" | 30 #include "base/power_monitor/power_monitor_device_source.h" |
31 #endif | 31 #endif |
32 | 32 |
33 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
34 #include "base/threading/thread_restrictions.h" | 34 #include "base/threading/thread_restrictions.h" |
35 #include "content/public/browser/browser_main_runner.h" | 35 #include "content/public/browser/browser_main_runner.h" |
36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
37 #endif | 37 #endif |
38 | 38 |
| 39 #if defined(USE_AURA) |
| 40 #include "content/browser/aura/image_transport_factory.h" |
| 41 #include "ui/compositor/test/test_context_factory.h" |
| 42 #endif |
| 43 |
39 namespace content { | 44 namespace content { |
40 namespace { | 45 namespace { |
41 | 46 |
42 #if defined(OS_POSIX) | 47 #if defined(OS_POSIX) |
43 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 48 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
44 // debugging easier) and also exit with a known error code (so that the test | 49 // debugging easier) and also exit with a known error code (so that the test |
45 // framework considers this a failure -- http://crbug.com/57578). | 50 // framework considers this a failure -- http://crbug.com/57578). |
46 // Note: We only want to do this in the browser process, and not forked | 51 // Note: We only want to do this in the browser process, and not forked |
47 // processes. That might lead to hangs because of locks inside tcmalloc or the | 52 // processes. That might lead to hangs because of locks inside tcmalloc or the |
48 // OS. See http://crbug.com/141302. | 53 // OS. See http://crbug.com/141302. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 155 |
151 // The tests assume that file:// URIs can freely access other file:// URIs. | 156 // The tests assume that file:// URIs can freely access other file:// URIs. |
152 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); | 157 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
153 | 158 |
154 command_line->AppendSwitch(switches::kDomAutomationController); | 159 command_line->AppendSwitch(switches::kDomAutomationController); |
155 | 160 |
156 // It is sometimes useful when looking at browser test failures to know which | 161 // It is sometimes useful when looking at browser test failures to know which |
157 // GPU blacklisting decisions were made. | 162 // GPU blacklisting decisions were made. |
158 command_line->AppendSwitch(switches::kLogGpuControlListDecisions); | 163 command_line->AppendSwitch(switches::kLogGpuControlListDecisions); |
159 | 164 |
| 165 #if defined(OS_CHROMEOS) |
| 166 // If the test is running on the chromeos envrionment (such as |
| 167 // device or vm bots), always use real contexts. |
| 168 if (base::SysInfo::IsRunningOnChromeOS()) |
| 169 allow_test_contexts_ = false; |
| 170 #endif |
| 171 |
| 172 if (command_line->HasSwitch(switches::kDisableTestCompositor)) |
| 173 allow_test_contexts_ = false; |
| 174 |
160 #if defined(USE_AURA) | 175 #if defined(USE_AURA) |
161 // Use test contexts for browser tests unless they override and force us to | 176 // Use test contexts for browser tests unless they override and force us to |
162 // use a real context. | 177 // use a real context. |
163 if (allow_test_contexts_) | 178 if (allow_test_contexts_) { |
164 command_line->AppendSwitch(switches::kTestCompositor); | 179 content::ImageTransportFactory::InitializeForUnitTests( |
| 180 scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory)); |
| 181 } |
165 #endif | 182 #endif |
166 | 183 |
167 // When using real GL contexts, we usually use OSMesa as this works on all | 184 // When using real GL contexts, we usually use OSMesa as this works on all |
168 // bots. The command line can override this behaviour to use a real GPU. | 185 // bots. The command line can override this behaviour to use a real GPU. |
169 if (command_line->HasSwitch(switches::kUseGpuInTests)) | 186 if (command_line->HasSwitch(switches::kUseGpuInTests)) |
170 allow_osmesa_ = false; | 187 allow_osmesa_ = false; |
171 | 188 |
172 // Some bots pass this flag when they want to use a real GPU. | 189 // Some bots pass this flag when they want to use a real GPU. |
173 if (command_line->HasSwitch("enable-gpu")) | 190 if (command_line->HasSwitch("enable-gpu")) |
174 allow_osmesa_ = false; | 191 allow_osmesa_ = false; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); | 279 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
263 CHECK(renderer_loop); | 280 CHECK(renderer_loop); |
264 | 281 |
265 renderer_loop->PostTask( | 282 renderer_loop->PostTask( |
266 FROM_HERE, | 283 FROM_HERE, |
267 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); | 284 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
268 runner->Run(); | 285 runner->Run(); |
269 } | 286 } |
270 | 287 |
271 } // namespace content | 288 } // namespace content |
OLD | NEW |