| 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/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 #include "ui/compositor/compositor_switches.h" | 18 #include "ui/compositor/compositor_switches.h" |
| 18 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
| 19 #include "ui/gl/gl_switches.h" | 20 #include "ui/gl/gl_switches.h" |
| 20 | 21 |
| 21 #if defined(OS_POSIX) | 22 #if defined(OS_POSIX) |
| 22 #include "base/process/process_handle.h" | 23 #include "base/process/process_handle.h" |
| 23 #endif | 24 #endif |
| 24 | 25 |
| 25 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
| 26 #include "base/mac/mac_util.h" | 27 #include "base/mac/mac_util.h" |
| 27 #include "base/power_monitor/power_monitor_device_source.h" | 28 #include "base/power_monitor/power_monitor_device_source.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
| 31 #include "base/threading/thread_restrictions.h" | 32 #include "base/threading/thread_restrictions.h" |
| 32 #include "content/public/browser/browser_main_runner.h" | 33 #include "content/public/browser/browser_main_runner.h" |
| 33 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 #if defined(OS_CHROMEOS) | |
| 37 #include "base/chromeos/chromeos_version.h" | |
| 38 #endif | |
| 39 | |
| 40 namespace content { | 37 namespace content { |
| 41 namespace { | 38 namespace { |
| 42 | 39 |
| 43 #if defined(OS_POSIX) | 40 #if defined(OS_POSIX) |
| 44 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 41 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
| 45 // debugging easier) and also exit with a known error code (so that the test | 42 // debugging easier) and also exit with a known error code (so that the test |
| 46 // framework considers this a failure -- http://crbug.com/57578). | 43 // framework considers this a failure -- http://crbug.com/57578). |
| 47 // Note: We only want to do this in the browser process, and not forked | 44 // Note: We only want to do this in the browser process, and not forked |
| 48 // processes. That might lead to hangs because of locks inside tcmalloc or the | 45 // processes. That might lead to hangs because of locks inside tcmalloc or the |
| 49 // OS. See http://crbug.com/141302. | 46 // OS. See http://crbug.com/141302. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 131 |
| 135 #if defined(OS_ANDROID) | 132 #if defined(OS_ANDROID) |
| 136 // On Android we always use a real GPU. | 133 // On Android we always use a real GPU. |
| 137 allow_osmesa_ = false; | 134 allow_osmesa_ = false; |
| 138 #endif | 135 #endif |
| 139 | 136 |
| 140 #if defined(OS_CHROMEOS) | 137 #if defined(OS_CHROMEOS) |
| 141 // If the test is running on the chromeos envrionment (such as | 138 // If the test is running on the chromeos envrionment (such as |
| 142 // device or vm bots), the compositor will use real GL contexts, and | 139 // device or vm bots), the compositor will use real GL contexts, and |
| 143 // we should use real GL bindings with it. | 140 // we should use real GL bindings with it. |
| 144 if (base::chromeos::IsRunningOnChromeOS()) | 141 if (base::SysInfo::IsRunningOnChromeOS()) |
| 145 allow_osmesa_ = false; | 142 allow_osmesa_ = false; |
| 146 #endif | 143 #endif |
| 147 | 144 |
| 148 if (command_line->HasSwitch(switches::kUseGL)) { | 145 if (command_line->HasSwitch(switches::kUseGL)) { |
| 149 NOTREACHED() << | 146 NOTREACHED() << |
| 150 "kUseGL should not be used with tests. Try kUseGpuInTests instead."; | 147 "kUseGL should not be used with tests. Try kUseGpuInTests instead."; |
| 151 } | 148 } |
| 152 | 149 |
| 153 if (allow_osmesa_) { | 150 if (allow_osmesa_) { |
| 154 command_line->AppendSwitchASCII( | 151 command_line->AppendSwitchASCII( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); | 205 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
| 209 CHECK(renderer_loop); | 206 CHECK(renderer_loop); |
| 210 | 207 |
| 211 renderer_loop->PostTask( | 208 renderer_loop->PostTask( |
| 212 FROM_HERE, | 209 FROM_HERE, |
| 213 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); | 210 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
| 214 runner->Run(); | 211 runner->Run(); |
| 215 } | 212 } |
| 216 | 213 |
| 217 } // namespace content | 214 } // namespace content |
| OLD | NEW |