Index: content/public/test/browser_test_base.cc |
diff --git a/content/public/test/browser_test_base.cc b/content/public/test/browser_test_base.cc |
index 25d6330103946d9ed304bf68e87c2fe9efb9219d..1ed98d0fd5ce8f81c23dd5defc31a7c081925beb 100644 |
--- a/content/public/test/browser_test_base.cc |
+++ b/content/public/test/browser_test_base.cc |
@@ -13,6 +13,9 @@ |
#include "content/public/common/main_function_params.h" |
#include "content/public/test/test_utils.h" |
#include "net/test/embedded_test_server/embedded_test_server.h" |
+#include "ui/compositor/compositor_switches.h" |
+#include "ui/gl/gl_implementation.h" |
+#include "ui/gl/gl_switches.h" |
#if defined(OS_POSIX) |
#include "base/process/process_handle.h" |
@@ -64,7 +67,10 @@ extern int BrowserMain(const MainFunctionParams&); |
BrowserTestBase::BrowserTestBase() |
: embedded_test_server_( |
new net::test_server::EmbeddedTestServer( |
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) { |
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))), |
+ allow_test_contexts_(true), |
+ allow_osmesa_(true), |
+ using_accelerated_video_decode_(false) { |
#if defined(OS_MACOSX) |
base::mac::SetOverrideAmIBundled(true); |
base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); |
@@ -98,6 +104,42 @@ void BrowserTestBase::SetUp() { |
new base::Closure( |
base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); |
+#if defined(USE_AURA) |
+ // Use test contexts for browser tests unless they override and force us to |
+ // use a real context. |
+ if (allow_test_contexts_) |
+ command_line->AppendSwitch(switches::kTestCompositor); |
+#endif |
+ |
+ // When using real GL contexts, we usually use OSMesa as this works on all |
+ // bots. The command line can override this behaviour to use a real GPU. |
+ if (command_line->HasSwitch(switches::kUseGpuInTests)) |
+ allow_osmesa_ = false; |
+ |
+#if defined(OS_MACOSX) |
+ // On Mac we always use a real GPU. |
+ allow_osmesa_ = false; |
+#endif |
+ |
+ if (command_line->HasSwitch(switches::kUseGL)) { |
+ NOTREACHED() << |
+ "kUseGL should not be used with tests. Try kUseGpuInTests instead."; |
+ } |
+ |
+ if (allow_osmesa_) { |
+ command_line->AppendSwitchASCII( |
+ switches::kUseGL, gfx::kGLImplementationOSMesaName); |
+ } |
+ |
+ // NOTE: should be kept in sync with |
+ // chrome/browser/resources/software_rendering_list.json |
+#if !defined(OS_WIN) && !defined(OS_CHROMEOS) |
+ command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); |
+ using_accelerated_video_decode_ = false; |
+#else |
+ using_accelerated_video_decode_ = true; |
+#endif |
+ |
SetUpInProcessBrowserTestFixture(); |
#if defined(OS_ANDROID) |
BrowserMainRunner::Create()->Initialize(params); |