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

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

Issue 120313002: Use stub GL draw/clear calls for browser tests that do not need pixels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stubgl: use_osmesa Created 6 years, 11 months 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),
124 use_software_compositing_(false) { 123 use_software_compositing_(false) {
125 #if defined(OS_MACOSX) 124 #if defined(OS_MACOSX)
126 base::mac::SetOverrideAmIBundled(true); 125 base::mac::SetOverrideAmIBundled(true);
127 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); 126 base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
128 #endif 127 #endif
129 128
130 #if defined(OS_POSIX) 129 #if defined(OS_POSIX)
131 handle_sigterm_ = true; 130 handle_sigterm_ = true;
132 #endif 131 #endif
133 132
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (base::SysInfo::IsRunningOnChromeOS()) 168 if (base::SysInfo::IsRunningOnChromeOS())
170 allow_test_contexts_ = false; 169 allow_test_contexts_ = false;
171 #endif 170 #endif
172 171
173 #if defined(USE_AURA) 172 #if defined(USE_AURA)
174 if (command_line->HasSwitch(switches::kDisableTestCompositor)) 173 if (command_line->HasSwitch(switches::kDisableTestCompositor))
175 allow_test_contexts_ = false; 174 allow_test_contexts_ = false;
176 175
177 // Use test contexts for browser tests unless they override and force us to 176 // Use test contexts for browser tests unless they override and force us to
178 // use a real context. 177 // use a real context.
179 if (allow_test_contexts_ && !use_software_compositing_) { 178 if (allow_test_contexts_ && !use_software_compositing_)
180 content::ImageTransportFactory::InitializeForUnitTests( 179 command_line->AppendSwitch(switches::kDisableGLDrawingForTests);
181 scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory));
182 }
183 #endif 180 #endif
184 181
185 // When using real GL contexts, we usually use OSMesa as this works on all 182 bool use_osmesa = true;
186 // bots. The command line can override this behaviour to use a real GPU. 183
184 // We usually use OSMesa as this works on all bots. The command line can
185 // override this behaviour to use hardware GL.
187 if (command_line->HasSwitch(switches::kUseGpuInTests)) 186 if (command_line->HasSwitch(switches::kUseGpuInTests))
188 allow_osmesa_ = false; 187 use_osmesa = false;
189 188
190 // Some bots pass this flag when they want to use a real GPU. 189 // Some bots pass this flag when they want to use hardware GL.
191 if (command_line->HasSwitch("enable-gpu")) 190 if (command_line->HasSwitch("enable-gpu"))
192 allow_osmesa_ = false; 191 use_osmesa = false;
193 192
194 #if defined(OS_MACOSX) 193 #if defined(OS_MACOSX)
195 // On Mac we always use a real GPU. 194 // On Mac we always use hardware GL.
196 allow_osmesa_ = false; 195 use_osmesa = false;
197 #endif 196 #endif
198 197
199 #if defined(OS_ANDROID) 198 #if defined(OS_ANDROID)
200 // On Android we always use a real GPU. 199 // On Android we always use hardware GL.
201 allow_osmesa_ = false; 200 use_osmesa = false;
202 #endif 201 #endif
203 202
204 #if defined(OS_CHROMEOS) 203 #if defined(OS_CHROMEOS)
205 // If the test is running on the chromeos envrionment (such as 204 // If the test is running on the chromeos envrionment (such as
206 // device or vm bots), the compositor will use real GL contexts, and 205 // device or vm bots), we use hardware GL.
207 // we should use real GL bindings with it.
208 if (base::SysInfo::IsRunningOnChromeOS()) 206 if (base::SysInfo::IsRunningOnChromeOS())
209 allow_osmesa_ = false; 207 use_osmesa = false;
210 #endif 208 #endif
211 209
212 if (command_line->HasSwitch(switches::kUseGL)) { 210 if (command_line->HasSwitch(switches::kUseGL)) {
213 NOTREACHED() << 211 NOTREACHED() <<
214 "kUseGL should not be used with tests. Try kUseGpuInTests instead."; 212 "kUseGL should not be used with tests. Try kUseGpuInTests instead.";
215 } 213 }
216 214
217 if (allow_osmesa_ && !use_software_compositing_) { 215 if (use_osmesa && !use_software_compositing_) {
218 command_line->AppendSwitchASCII( 216 command_line->AppendSwitchASCII(
219 switches::kUseGL, gfx::kGLImplementationOSMesaName); 217 switches::kUseGL, gfx::kGLImplementationOSMesaName);
220 } 218 }
221 219
222 scoped_refptr<net::HostResolverProc> local_resolver = 220 scoped_refptr<net::HostResolverProc> local_resolver =
223 new LocalHostResolverProc(); 221 new LocalHostResolverProc();
224 rule_based_resolver_ = 222 rule_based_resolver_ =
225 new net::RuleBasedHostResolverProc(local_resolver.get()); 223 new net::RuleBasedHostResolverProc(local_resolver.get());
226 rule_based_resolver_->AddSimulatedFailure("wpad"); 224 rule_based_resolver_->AddSimulatedFailure("wpad");
227 net::ScopedDefaultHostResolverProc scoped_local_host_resolver_proc( 225 net::ScopedDefaultHostResolverProc scoped_local_host_resolver_proc(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 CHECK(renderer_loop); 277 CHECK(renderer_loop);
280 278
281 renderer_loop->PostTask( 279 renderer_loop->PostTask(
282 FROM_HERE, 280 FROM_HERE,
283 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); 281 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure()));
284 runner->Run(); 282 runner->Run();
285 } 283 }
286 284
287 void BrowserTestBase::UseRealGLContexts() { allow_test_contexts_ = false; } 285 void BrowserTestBase::UseRealGLContexts() { allow_test_contexts_ = false; }
288 286
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() { 287 void BrowserTestBase::UseSoftwareCompositing() {
296 #if !defined(USE_AURA) && !defined(OS_MACOSX) 288 #if !defined(USE_AURA) && !defined(OS_MACOSX)
297 // TODO(danakj): Remove when GTK linux is no more. 289 // TODO(danakj): Remove when GTK linux is no more.
298 NOTREACHED(); 290 NOTREACHED();
299 #endif 291 #endif
300
301 DCHECK(allow_osmesa_) << "Can't use GL with software compositing";
302 use_software_compositing_ = true; 292 use_software_compositing_ = true;
303 } 293 }
304 294
305 bool BrowserTestBase::UsingOSMesa() const { 295 bool BrowserTestBase::UsingOSMesa() const {
306 CommandLine* cmd = CommandLine::ForCurrentProcess(); 296 CommandLine* cmd = CommandLine::ForCurrentProcess();
307 return cmd->GetSwitchValueASCII(switches::kUseGL) == 297 return cmd->GetSwitchValueASCII(switches::kUseGL) ==
308 gfx::kGLImplementationOSMesaName; 298 gfx::kGLImplementationOSMesaName;
309 } 299 }
310 300
311 } // namespace content 301 } // 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