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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 146 |
142 // The tests assume that file:// URIs can freely access other file:// URIs. | 147 // The tests assume that file:// URIs can freely access other file:// URIs. |
143 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); | 148 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
144 | 149 |
145 command_line->AppendSwitch(switches::kDomAutomationController); | 150 command_line->AppendSwitch(switches::kDomAutomationController); |
146 | 151 |
147 // It is sometimes useful when looking at browser test failures to know which | 152 // It is sometimes useful when looking at browser test failures to know which |
148 // GPU blacklisting decisions were made. | 153 // GPU blacklisting decisions were made. |
149 command_line->AppendSwitch(switches::kLogGpuControlListDecisions); | 154 command_line->AppendSwitch(switches::kLogGpuControlListDecisions); |
150 | 155 |
| 156 #if defined(OS_CHROMEOS) |
| 157 // If the test is running on the chromeos envrionment (such as |
| 158 // device or vm bots), always use real contexts. |
| 159 if (base::SysInfo::IsRunningOnChromeOS()) |
| 160 allow_test_contexts_ = false; |
| 161 #endif |
| 162 |
151 #if defined(USE_AURA) | 163 #if defined(USE_AURA) |
| 164 if (command_line->HasSwitch(switches::kDisableTestCompositor)) |
| 165 allow_test_contexts_ = false; |
| 166 |
152 // Use test contexts for browser tests unless they override and force us to | 167 // Use test contexts for browser tests unless they override and force us to |
153 // use a real context. | 168 // use a real context. |
154 if (allow_test_contexts_) | 169 if (allow_test_contexts_) { |
155 command_line->AppendSwitch(switches::kTestCompositor); | 170 content::ImageTransportFactory::InitializeForUnitTests( |
| 171 scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory)); |
| 172 } |
156 #endif | 173 #endif |
157 | 174 |
158 // When using real GL contexts, we usually use OSMesa as this works on all | 175 // When using real GL contexts, we usually use OSMesa as this works on all |
159 // bots. The command line can override this behaviour to use a real GPU. | 176 // bots. The command line can override this behaviour to use a real GPU. |
160 if (command_line->HasSwitch(switches::kUseGpuInTests)) | 177 if (command_line->HasSwitch(switches::kUseGpuInTests)) |
161 allow_osmesa_ = false; | 178 allow_osmesa_ = false; |
162 | 179 |
163 // Some bots pass this flag when they want to use a real GPU. | 180 // Some bots pass this flag when they want to use a real GPU. |
164 if (command_line->HasSwitch("enable-gpu")) | 181 if (command_line->HasSwitch("enable-gpu")) |
165 allow_osmesa_ = false; | 182 allow_osmesa_ = false; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); | 270 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
254 CHECK(renderer_loop); | 271 CHECK(renderer_loop); |
255 | 272 |
256 renderer_loop->PostTask( | 273 renderer_loop->PostTask( |
257 FROM_HERE, | 274 FROM_HERE, |
258 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); | 275 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
259 runner->Run(); | 276 runner->Run(); |
260 } | 277 } |
261 | 278 |
262 } // namespace content | 279 } // namespace content |
OLD | NEW |