Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: content/public/test/browser_test_base.cc

Issue 116893004: Parameterize the composited RenderWidgetHostViewBrowserTests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests: only gl on GTK, not only software on GTK. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/public/test/browser_test_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 private: 113 private:
114 virtual ~LocalHostResolverProc() {} 114 virtual ~LocalHostResolverProc() {}
115 }; 115 };
116 116
117 } // namespace 117 } // namespace
118 118
119 extern int BrowserMain(const MainFunctionParams&); 119 extern int BrowserMain(const MainFunctionParams&);
120 120
121 BrowserTestBase::BrowserTestBase() 121 BrowserTestBase::BrowserTestBase()
122 : allow_test_contexts_(true), 122 : allow_test_contexts_(true),
123 allow_osmesa_(true) { 123 allow_osmesa_(true),
124 use_software_compositing_(false) {
124 #if defined(OS_MACOSX) 125 #if defined(OS_MACOSX)
125 base::mac::SetOverrideAmIBundled(true); 126 base::mac::SetOverrideAmIBundled(true);
126 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); 127 base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
127 #endif 128 #endif
128 129
129 #if defined(OS_POSIX) 130 #if defined(OS_POSIX)
130 handle_sigterm_ = true; 131 handle_sigterm_ = true;
131 #endif 132 #endif
132 133
133 embedded_test_server_.reset(new net::test_server::EmbeddedTestServer); 134 embedded_test_server_.reset(new net::test_server::EmbeddedTestServer);
(...skipping 12 matching lines...) Expand all
146 147
147 // The tests assume that file:// URIs can freely access other file:// URIs. 148 // The tests assume that file:// URIs can freely access other file:// URIs.
148 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); 149 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
149 150
150 command_line->AppendSwitch(switches::kDomAutomationController); 151 command_line->AppendSwitch(switches::kDomAutomationController);
151 152
152 // It is sometimes useful when looking at browser test failures to know which 153 // It is sometimes useful when looking at browser test failures to know which
153 // GPU blacklisting decisions were made. 154 // GPU blacklisting decisions were made.
154 command_line->AppendSwitch(switches::kLogGpuControlListDecisions); 155 command_line->AppendSwitch(switches::kLogGpuControlListDecisions);
155 156
157 if (use_software_compositing_) {
158 command_line->AppendSwitch(switches::kDisableGpu);
159 command_line->AppendSwitch(switches::kEnableSoftwareCompositing);
160 #if defined(USE_AURA)
161 command_line->AppendSwitch(switches::kUIEnableSoftwareCompositing);
162 command_line->AppendSwitch(switches::kUIDisableThreadedCompositing);
163 #endif
164 }
165
156 #if defined(OS_CHROMEOS) 166 #if defined(OS_CHROMEOS)
157 // If the test is running on the chromeos envrionment (such as 167 // If the test is running on the chromeos envrionment (such as
158 // device or vm bots), always use real contexts. 168 // device or vm bots), always use real contexts.
159 if (base::SysInfo::IsRunningOnChromeOS()) 169 if (base::SysInfo::IsRunningOnChromeOS())
160 allow_test_contexts_ = false; 170 allow_test_contexts_ = false;
161 #endif 171 #endif
162 172
163 #if defined(USE_AURA) 173 #if defined(USE_AURA)
164 if (command_line->HasSwitch(switches::kDisableTestCompositor)) 174 if (command_line->HasSwitch(switches::kDisableTestCompositor))
165 allow_test_contexts_ = false; 175 allow_test_contexts_ = false;
166 176
167 // Use test contexts for browser tests unless they override and force us to 177 // Use test contexts for browser tests unless they override and force us to
168 // use a real context. 178 // use a real context.
169 if (allow_test_contexts_) { 179 if (allow_test_contexts_ && !use_software_compositing_) {
170 content::ImageTransportFactory::InitializeForUnitTests( 180 content::ImageTransportFactory::InitializeForUnitTests(
171 scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory)); 181 scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory));
172 } 182 }
173 #endif 183 #endif
174 184
175 // When using real GL contexts, we usually use OSMesa as this works on all 185 // When using real GL contexts, we usually use OSMesa as this works on all
176 // bots. The command line can override this behaviour to use a real GPU. 186 // bots. The command line can override this behaviour to use a real GPU.
177 if (command_line->HasSwitch(switches::kUseGpuInTests)) 187 if (command_line->HasSwitch(switches::kUseGpuInTests))
178 allow_osmesa_ = false; 188 allow_osmesa_ = false;
179 189
(...skipping 17 matching lines...) Expand all
197 // we should use real GL bindings with it. 207 // we should use real GL bindings with it.
198 if (base::SysInfo::IsRunningOnChromeOS()) 208 if (base::SysInfo::IsRunningOnChromeOS())
199 allow_osmesa_ = false; 209 allow_osmesa_ = false;
200 #endif 210 #endif
201 211
202 if (command_line->HasSwitch(switches::kUseGL)) { 212 if (command_line->HasSwitch(switches::kUseGL)) {
203 NOTREACHED() << 213 NOTREACHED() <<
204 "kUseGL should not be used with tests. Try kUseGpuInTests instead."; 214 "kUseGL should not be used with tests. Try kUseGpuInTests instead.";
205 } 215 }
206 216
207 if (allow_osmesa_) { 217 if (allow_osmesa_ && !use_software_compositing_) {
208 command_line->AppendSwitchASCII( 218 command_line->AppendSwitchASCII(
209 switches::kUseGL, gfx::kGLImplementationOSMesaName); 219 switches::kUseGL, gfx::kGLImplementationOSMesaName);
210 } 220 }
211 221
212 scoped_refptr<net::HostResolverProc> local_resolver = 222 scoped_refptr<net::HostResolverProc> local_resolver =
213 new LocalHostResolverProc(); 223 new LocalHostResolverProc();
214 rule_based_resolver_ = 224 rule_based_resolver_ =
215 new net::RuleBasedHostResolverProc(local_resolver.get()); 225 new net::RuleBasedHostResolverProc(local_resolver.get());
216 rule_based_resolver_->AddSimulatedFailure("wpad"); 226 rule_based_resolver_->AddSimulatedFailure("wpad");
217 net::ScopedDefaultHostResolverProc scoped_local_host_resolver_proc( 227 net::ScopedDefaultHostResolverProc scoped_local_host_resolver_proc(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 base::MessageLoop* renderer_loop = 277 base::MessageLoop* renderer_loop =
268 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); 278 RenderProcessHostImpl::GetInProcessRendererThreadForTesting();
269 CHECK(renderer_loop); 279 CHECK(renderer_loop);
270 280
271 renderer_loop->PostTask( 281 renderer_loop->PostTask(
272 FROM_HERE, 282 FROM_HERE,
273 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); 283 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure()));
274 runner->Run(); 284 runner->Run();
275 } 285 }
276 286
287 void BrowserTestBase::UseRealGLContexts() { allow_test_contexts_ = false; }
288
289 void BrowserTestBase::UseRealGLBindings() {
290 DCHECK(!use_software_compositing_)
291 << "Can't use GL with software compositing";
292 allow_osmesa_ = false;
293 }
294
295 void BrowserTestBase::UseSoftwareCompositing() {
296 #if !defined(USE_AURA) && !defined(OS_MACOSX)
297 // TODO(danakj): Remove when GTK linux is no more.
298 NOTREACHED();
299 #endif
300
301 DCHECK(allow_osmesa_) << "Can't use GL with software compositing";
302 use_software_compositing_ = true;
303 }
304
277 } // namespace content 305 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698