| 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" |
| 11 #include "base/sys_info.h" |
| 11 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/common/main_function_params.h" | 15 #include "content/public/common/main_function_params.h" |
| 15 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
| 18 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 19 #include "ui/compositor/compositor_switches.h" | 20 #include "ui/compositor/compositor_switches.h" |
| 20 #include "ui/gl/gl_implementation.h" | 21 #include "ui/gl/gl_implementation.h" |
| 21 #include "ui/gl/gl_switches.h" | 22 #include "ui/gl/gl_switches.h" |
| 22 | 23 |
| 23 #if defined(OS_POSIX) | 24 #if defined(OS_POSIX) |
| 24 #include "base/process/process_handle.h" | 25 #include "base/process/process_handle.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
| 28 #include "base/mac/mac_util.h" | 29 #include "base/mac/mac_util.h" |
| 29 #include "base/power_monitor/power_monitor_device_source.h" | 30 #include "base/power_monitor/power_monitor_device_source.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 33 #include "base/threading/thread_restrictions.h" | 34 #include "base/threading/thread_restrictions.h" |
| 34 #include "content/public/browser/browser_main_runner.h" | 35 #include "content/public/browser/browser_main_runner.h" |
| 35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 #if defined(OS_CHROMEOS) | |
| 39 #include "base/chromeos/chromeos_version.h" | |
| 40 #endif | |
| 41 | |
| 42 namespace content { | 39 namespace content { |
| 43 namespace { | 40 namespace { |
| 44 | 41 |
| 45 #if defined(OS_POSIX) | 42 #if defined(OS_POSIX) |
| 46 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 43 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
| 47 // debugging easier) and also exit with a known error code (so that the test | 44 // debugging easier) and also exit with a known error code (so that the test |
| 48 // framework considers this a failure -- http://crbug.com/57578). | 45 // framework considers this a failure -- http://crbug.com/57578). |
| 49 // Note: We only want to do this in the browser process, and not forked | 46 // Note: We only want to do this in the browser process, and not forked |
| 50 // processes. That might lead to hangs because of locks inside tcmalloc or the | 47 // processes. That might lead to hangs because of locks inside tcmalloc or the |
| 51 // OS. See http://crbug.com/141302. | 48 // OS. See http://crbug.com/141302. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 178 |
| 182 #if defined(OS_ANDROID) | 179 #if defined(OS_ANDROID) |
| 183 // On Android we always use a real GPU. | 180 // On Android we always use a real GPU. |
| 184 allow_osmesa_ = false; | 181 allow_osmesa_ = false; |
| 185 #endif | 182 #endif |
| 186 | 183 |
| 187 #if defined(OS_CHROMEOS) | 184 #if defined(OS_CHROMEOS) |
| 188 // If the test is running on the chromeos envrionment (such as | 185 // If the test is running on the chromeos envrionment (such as |
| 189 // device or vm bots), the compositor will use real GL contexts, and | 186 // device or vm bots), the compositor will use real GL contexts, and |
| 190 // we should use real GL bindings with it. | 187 // we should use real GL bindings with it. |
| 191 if (base::chromeos::IsRunningOnChromeOS()) | 188 if (base::SysInfo::IsRunningOnChromeOS()) |
| 192 allow_osmesa_ = false; | 189 allow_osmesa_ = false; |
| 193 #endif | 190 #endif |
| 194 | 191 |
| 195 if (command_line->HasSwitch(switches::kUseGL)) { | 192 if (command_line->HasSwitch(switches::kUseGL)) { |
| 196 NOTREACHED() << | 193 NOTREACHED() << |
| 197 "kUseGL should not be used with tests. Try kUseGpuInTests instead."; | 194 "kUseGL should not be used with tests. Try kUseGpuInTests instead."; |
| 198 } | 195 } |
| 199 | 196 |
| 200 if (allow_osmesa_) { | 197 if (allow_osmesa_) { |
| 201 command_line->AppendSwitchASCII( | 198 command_line->AppendSwitchASCII( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); | 260 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
| 264 CHECK(renderer_loop); | 261 CHECK(renderer_loop); |
| 265 | 262 |
| 266 renderer_loop->PostTask( | 263 renderer_loop->PostTask( |
| 267 FROM_HERE, | 264 FROM_HERE, |
| 268 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); | 265 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
| 269 runner->Run(); | 266 runner->Run(); |
| 270 } | 267 } |
| 271 | 268 |
| 272 } // namespace content | 269 } // namespace content |
| OLD | NEW |