Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/public/test/browser_test_base.h" |
| 6 | |
| 7 | #include "base/bind.h" |
| 8 | #include "base/command_line.h" |
| 9 | #include "base/debug/stack_trace.h" |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 10 | #include "base/i18n/icu_util.h" |
Torne (Richard Coles) | 58537e2 | 2013-09-12 12:10:22 +0100 | [diff] [blame] | 11 | #include "base/message_loop/message_loop.h" |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 12 | #include "base/strings/string_number_conversions.h" |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame] | 13 | #include "base/sys_info.h" |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 14 | #include "base/test/test_timeouts.h" |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 15 | #include "content/public/app/content_main.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 16 | #include "content/browser/renderer_host/render_process_host_impl.h" |
| 17 | #include "content/public/browser/browser_thread.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 18 | #include "content/public/common/content_switches.h" |
| 19 | #include "content/public/common/main_function_params.h" |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 20 | #include "content/public/test/test_launcher.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 21 | #include "content/public/test/test_utils.h" |
Torne (Richard Coles) | 68043e1 | 2013-09-26 13:24:57 +0100 | [diff] [blame] | 22 | #include "net/base/net_errors.h" |
| 23 | #include "net/dns/mock_host_resolver.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 24 | #include "net/test/embedded_test_server/embedded_test_server.h" |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 25 | #include "ui/compositor/compositor_switches.h" |
| 26 | #include "ui/gl/gl_implementation.h" |
| 27 | #include "ui/gl/gl_switches.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 28 | |
Ben Murdoch | 58e6fbe | 2013-07-26 10:20:38 +0100 | [diff] [blame] | 29 | #if defined(OS_POSIX) |
| 30 | #include "base/process/process_handle.h" |
| 31 | #endif |
| 32 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 33 | #if defined(OS_MACOSX) |
| 34 | #include "base/mac/mac_util.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 35 | #endif |
| 36 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 37 | #if defined(OS_ANDROID) |
| 38 | #include "base/threading/thread_restrictions.h" |
| 39 | #include "content/public/browser/browser_main_runner.h" |
| 40 | #include "content/public/browser/browser_thread.h" |
| 41 | #endif |
| 42 | |
Torne (Richard Coles) | 1e9bf3e | 2013-10-31 11:16:26 +0000 | [diff] [blame] | 43 | #if defined(USE_AURA) |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 44 | #include "content/browser/compositor/image_transport_factory.h" |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame^] | 45 | #include "ui/aura/test/event_generator_delegate_aura.h" |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 46 | #if defined(USE_X11) |
| 47 | #include "ui/aura/window_tree_host_x11.h" |
| 48 | #endif |
Torne (Richard Coles) | 1e9bf3e | 2013-10-31 11:16:26 +0000 | [diff] [blame] | 49 | #endif |
| 50 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 51 | namespace content { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 52 | namespace { |
| 53 | |
| 54 | #if defined(OS_POSIX) |
| 55 | // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
| 56 | // debugging easier) and also exit with a known error code (so that the test |
| 57 | // framework considers this a failure -- http://crbug.com/57578). |
| 58 | // Note: We only want to do this in the browser process, and not forked |
| 59 | // processes. That might lead to hangs because of locks inside tcmalloc or the |
| 60 | // OS. See http://crbug.com/141302. |
| 61 | static int g_browser_process_pid; |
| 62 | static void DumpStackTraceSignalHandler(int signal) { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 63 | if (g_browser_process_pid == base::GetCurrentProcId()) { |
| 64 | logging::RawLog(logging::LOG_ERROR, |
| 65 | "BrowserTestBase signal handler received SIGTERM. " |
| 66 | "Backtrace:\n"); |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 67 | base::debug::StackTrace().Print(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 68 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 69 | _exit(128 + signal); |
| 70 | } |
| 71 | #endif // defined(OS_POSIX) |
| 72 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 73 | void RunTaskOnRendererThread(const base::Closure& task, |
| 74 | const base::Closure& quit_task) { |
| 75 | task.Run(); |
| 76 | BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
| 77 | } |
| 78 | |
Torne (Richard Coles) | 68043e1 | 2013-09-26 13:24:57 +0100 | [diff] [blame] | 79 | // In many cases it may be not obvious that a test makes a real DNS lookup. |
| 80 | // We generally don't want to rely on external DNS servers for our tests, |
| 81 | // so this host resolver procedure catches external queries and returns a failed |
| 82 | // lookup result. |
| 83 | class LocalHostResolverProc : public net::HostResolverProc { |
| 84 | public: |
| 85 | LocalHostResolverProc() : HostResolverProc(NULL) {} |
| 86 | |
| 87 | virtual int Resolve(const std::string& host, |
| 88 | net::AddressFamily address_family, |
| 89 | net::HostResolverFlags host_resolver_flags, |
| 90 | net::AddressList* addrlist, |
| 91 | int* os_error) OVERRIDE { |
| 92 | const char* kLocalHostNames[] = {"localhost", "127.0.0.1", "::1"}; |
| 93 | bool local = false; |
| 94 | |
| 95 | if (host == net::GetHostName()) { |
| 96 | local = true; |
| 97 | } else { |
| 98 | for (size_t i = 0; i < arraysize(kLocalHostNames); i++) |
| 99 | if (host == kLocalHostNames[i]) { |
| 100 | local = true; |
| 101 | break; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // To avoid depending on external resources and to reduce (if not preclude) |
| 106 | // network interactions from tests, we simulate failure for non-local DNS |
| 107 | // queries, rather than perform them. |
| 108 | // If you really need to make an external DNS query, use |
| 109 | // net::RuleBasedHostResolverProc and its AllowDirectLookup method. |
| 110 | if (!local) { |
| 111 | DVLOG(1) << "To avoid external dependencies, simulating failure for " |
| 112 | "external DNS lookup of " << host; |
| 113 | return net::ERR_NOT_IMPLEMENTED; |
| 114 | } |
| 115 | |
| 116 | return ResolveUsingPrevious(host, address_family, host_resolver_flags, |
| 117 | addrlist, os_error); |
| 118 | } |
| 119 | |
| 120 | private: |
| 121 | virtual ~LocalHostResolverProc() {} |
| 122 | }; |
| 123 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 124 | } // namespace |
| 125 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 126 | extern int BrowserMain(const MainFunctionParams&); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 127 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 128 | BrowserTestBase::BrowserTestBase() |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 129 | : expected_exit_code_(0), |
| 130 | enable_pixel_output_(false), |
| 131 | use_software_compositing_(false) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 132 | #if defined(OS_MACOSX) |
| 133 | base::mac::SetOverrideAmIBundled(true); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 134 | #endif |
| 135 | |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame^] | 136 | #if defined(USE_AURA) |
| 137 | #if defined(USE_X11) |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 138 | aura::test::SetUseOverrideRedirectWindowByDefault(true); |
| 139 | #endif |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame^] | 140 | aura::test::InitializeAuraEventGeneratorDelegate(); |
| 141 | #endif |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 142 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 143 | #if defined(OS_POSIX) |
| 144 | handle_sigterm_ = true; |
| 145 | #endif |
Torne (Richard Coles) | 58537e2 | 2013-09-12 12:10:22 +0100 | [diff] [blame] | 146 | |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 147 | // This is called through base::TestSuite initially. It'll also be called |
| 148 | // inside BrowserMain, so tell the code to ignore the check that it's being |
| 149 | // called more than once |
| 150 | base::i18n::AllowMultipleInitializeCallsForTesting(); |
| 151 | |
Torne (Richard Coles) | 1e9bf3e | 2013-10-31 11:16:26 +0000 | [diff] [blame] | 152 | embedded_test_server_.reset(new net::test_server::EmbeddedTestServer); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | BrowserTestBase::~BrowserTestBase() { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 156 | #if defined(OS_ANDROID) |
| 157 | // RemoteTestServer can cause wait on the UI thread. |
| 158 | base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 159 | test_server_.reset(NULL); |
| 160 | #endif |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | void BrowserTestBase::SetUp() { |
| 164 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 165 | |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 166 | // Override the child process connection timeout since tests can exceed that |
| 167 | // when sharded. |
| 168 | command_line->AppendSwitchASCII( |
| 169 | switches::kIPCConnectionTimeout, |
| 170 | base::IntToString(TestTimeouts::action_max_timeout().InSeconds())); |
| 171 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 172 | // The tests assume that file:// URIs can freely access other file:// URIs. |
| 173 | command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
| 174 | |
| 175 | command_line->AppendSwitch(switches::kDomAutomationController); |
| 176 | |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame] | 177 | // It is sometimes useful when looking at browser test failures to know which |
| 178 | // GPU blacklisting decisions were made. |
| 179 | command_line->AppendSwitch(switches::kLogGpuControlListDecisions); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 180 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 181 | if (use_software_compositing_) { |
| 182 | command_line->AppendSwitch(switches::kDisableGpu); |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 183 | #if defined(USE_AURA) |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 184 | command_line->AppendSwitch(switches::kUIDisableThreadedCompositing); |
Torne (Richard Coles) | 1e9bf3e | 2013-10-31 11:16:26 +0000 | [diff] [blame] | 185 | #endif |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 186 | } |
Torne (Richard Coles) | 1e9bf3e | 2013-10-31 11:16:26 +0000 | [diff] [blame] | 187 | |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 188 | #if defined(USE_AURA) |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 189 | // Most tests do not need pixel output, so we don't produce any. The command |
| 190 | // line can override this behaviour to allow for visual debugging. |
| 191 | if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) |
| 192 | enable_pixel_output_ = true; |
Torne (Richard Coles) | 1e9bf3e | 2013-10-31 11:16:26 +0000 | [diff] [blame] | 193 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 194 | if (command_line->HasSwitch(switches::kDisableGLDrawingForTests)) { |
| 195 | NOTREACHED() << "kDisableGLDrawingForTests should not be used as it" |
| 196 | "is chosen by tests. Use kEnablePixelOutputInTests " |
| 197 | "to enable pixel output."; |
Torne (Richard Coles) | 1e9bf3e | 2013-10-31 11:16:26 +0000 | [diff] [blame] | 198 | } |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 199 | |
| 200 | // Don't enable pixel output for browser tests unless they override and force |
| 201 | // us to, or it's requested on the command line. |
| 202 | if (!enable_pixel_output_ && !use_software_compositing_) |
| 203 | command_line->AppendSwitch(switches::kDisableGLDrawingForTests); |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 204 | #endif |
| 205 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 206 | bool use_osmesa = true; |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 207 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 208 | // We usually use OSMesa as this works on all bots. The command line can |
| 209 | // override this behaviour to use hardware GL. |
| 210 | if (command_line->HasSwitch(switches::kUseGpuInTests)) |
| 211 | use_osmesa = false; |
| 212 | |
| 213 | // Some bots pass this flag when they want to use hardware GL. |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 214 | if (command_line->HasSwitch("enable-gpu")) |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 215 | use_osmesa = false; |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 216 | |
| 217 | #if defined(OS_MACOSX) |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 218 | // On Mac we always use hardware GL. |
| 219 | use_osmesa = false; |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 220 | #endif |
| 221 | |
| 222 | #if defined(OS_ANDROID) |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 223 | // On Android we always use hardware GL. |
| 224 | use_osmesa = false; |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 225 | #endif |
| 226 | |
| 227 | #if defined(OS_CHROMEOS) |
| 228 | // If the test is running on the chromeos envrionment (such as |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 229 | // device or vm bots), we use hardware GL. |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame] | 230 | if (base::SysInfo::IsRunningOnChromeOS()) |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 231 | use_osmesa = false; |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 232 | #endif |
| 233 | |
Torne (Richard Coles) | 010d83a | 2014-05-14 12:12:37 +0100 | [diff] [blame] | 234 | if (use_osmesa && !use_software_compositing_) |
| 235 | command_line->AppendSwitch(switches::kOverrideUseGLWithOSMesaForTests); |
Ben Murdoch | c2db58b | 2013-08-14 11:51:42 +0100 | [diff] [blame] | 236 | |
Torne (Richard Coles) | 68043e1 | 2013-09-26 13:24:57 +0100 | [diff] [blame] | 237 | scoped_refptr<net::HostResolverProc> local_resolver = |
| 238 | new LocalHostResolverProc(); |
| 239 | rule_based_resolver_ = |
| 240 | new net::RuleBasedHostResolverProc(local_resolver.get()); |
| 241 | rule_based_resolver_->AddSimulatedFailure("wpad"); |
| 242 | net::ScopedDefaultHostResolverProc scoped_local_host_resolver_proc( |
| 243 | rule_based_resolver_.get()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 244 | SetUpInProcessBrowserTestFixture(); |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 245 | |
| 246 | base::Closure* ui_task = |
Torne (Richard Coles) | 3551c9c | 2013-08-23 16:39:15 +0100 | [diff] [blame] | 247 | new base::Closure( |
| 248 | base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); |
| 249 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 250 | #if defined(OS_ANDROID) |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 251 | MainFunctionParams params(*command_line); |
| 252 | params.ui_task = ui_task; |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 253 | // TODO(phajdan.jr): Check return code, http://crbug.com/374738 . |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 254 | BrowserMain(params); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 255 | #else |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 256 | GetContentMainParams()->ui_task = ui_task; |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 257 | EXPECT_EQ(expected_exit_code_, ContentMain(*GetContentMainParams())); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 258 | #endif |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 259 | TearDownInProcessBrowserTestFixture(); |
| 260 | } |
| 261 | |
| 262 | void BrowserTestBase::TearDown() { |
| 263 | } |
| 264 | |
| 265 | void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { |
| 266 | #if defined(OS_POSIX) |
| 267 | if (handle_sigterm_) { |
| 268 | g_browser_process_pid = base::GetCurrentProcId(); |
| 269 | signal(SIGTERM, DumpStackTraceSignalHandler); |
| 270 | } |
| 271 | #endif // defined(OS_POSIX) |
| 272 | RunTestOnMainThreadLoop(); |
| 273 | } |
| 274 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 275 | void BrowserTestBase::CreateTestServer(const base::FilePath& test_server_base) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 276 | CHECK(!test_server_.get()); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 277 | test_server_.reset(new net::SpawnedTestServer( |
| 278 | net::SpawnedTestServer::TYPE_HTTP, |
| 279 | net::SpawnedTestServer::kLocalhost, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 280 | test_server_base)); |
| 281 | } |
| 282 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 283 | void BrowserTestBase::PostTaskToInProcessRendererAndWait( |
| 284 | const base::Closure& task) { |
| 285 | CHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); |
| 286 | |
| 287 | scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; |
| 288 | |
| 289 | base::MessageLoop* renderer_loop = |
| 290 | RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
| 291 | CHECK(renderer_loop); |
| 292 | |
| 293 | renderer_loop->PostTask( |
| 294 | FROM_HERE, |
| 295 | base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
| 296 | runner->Run(); |
| 297 | } |
| 298 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 299 | void BrowserTestBase::EnablePixelOutput() { enable_pixel_output_ = true; } |
| 300 | |
| 301 | void BrowserTestBase::UseSoftwareCompositing() { |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 302 | use_software_compositing_ = true; |
| 303 | } |
| 304 | |
| 305 | bool BrowserTestBase::UsingOSMesa() const { |
| 306 | CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 307 | return cmd->GetSwitchValueASCII(switches::kUseGL) == |
| 308 | gfx::kGLImplementationOSMesaName; |
| 309 | } |
| 310 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 311 | } // namespace content |