Commit 8a938220 authored by danakj@chromium.org's avatar danakj@chromium.org

Remove the TestContextFactory, always use NullDraw GL for unit tests.

All unit tests suites are now opted into using real NullDraw GL
contexts instead of fake "test contexts". So remove the code to
create test contexts.

Removes the --disable-test-compositor flag as this does nothing
now that no tests use test contexts.

R=sievers@chromium.org
BUG=270918

Review URL: https://codereview.chromium.org/183743014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255765 0039d316-1c4b-4281-b951-d872f2087c98
parent b3cb61a7
...@@ -104,8 +104,6 @@ ...@@ -104,8 +104,6 @@
'test/test_compositor_host_ozone.cc', 'test/test_compositor_host_ozone.cc',
'test/test_compositor_host_win.cc', 'test/test_compositor_host_win.cc',
'test/test_compositor_host_x11.cc', 'test/test_compositor_host_x11.cc',
'test/test_context_factory.cc',
'test/test_context_factory.h',
'test/test_layer_animation_delegate.cc', 'test/test_layer_animation_delegate.cc',
'test/test_layer_animation_delegate.h', 'test/test_layer_animation_delegate.h',
'test/test_layer_animation_observer.cc', 'test/test_layer_animation_observer.cc',
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
namespace switches { namespace switches {
const char kDisableTestCompositor[] = "disable-test-compositor";
// Forces tests to produce pixel output when they normally wouldn't. // Forces tests to produce pixel output when they normally wouldn't.
const char kEnablePixelOutputInTests[] = "enable-pixel-output-in-tests"; const char kEnablePixelOutputInTests[] = "enable-pixel-output-in-tests";
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
namespace switches { namespace switches {
COMPOSITOR_EXPORT extern const char kDisableTestCompositor[];
COMPOSITOR_EXPORT extern const char kEnablePixelOutputInTests[]; COMPOSITOR_EXPORT extern const char kEnablePixelOutputInTests[];
COMPOSITOR_EXPORT extern const char kUIDisableThreadedCompositing[]; COMPOSITOR_EXPORT extern const char kUIDisableThreadedCompositing[];
COMPOSITOR_EXPORT extern const char kUIShowPaintRects[]; COMPOSITOR_EXPORT extern const char kUIShowPaintRects[];
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_switches.h" #include "ui/compositor/compositor_switches.h"
#include "ui/compositor/test/in_process_context_factory.h" #include "ui/compositor/test/in_process_context_factory.h"
#include "ui/compositor/test/test_context_factory.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
namespace { namespace {
...@@ -28,35 +27,9 @@ void InitializeContextFactoryForTests(bool enable_pixel_output) { ...@@ -28,35 +27,9 @@ void InitializeContextFactoryForTests(bool enable_pixel_output) {
CommandLine* command_line = CommandLine::ForCurrentProcess(); CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) if (command_line->HasSwitch(switches::kEnablePixelOutputInTests))
enable_pixel_output = true; enable_pixel_output = true;
bool use_test_contexts = true;
if (gfx::HasInitializedNullDrawGLBindings())
use_test_contexts = false;
// Always use test contexts unless the disable command line flag is used.
if (command_line->HasSwitch(switches::kDisableTestCompositor))
use_test_contexts = false;
#if defined(OS_CHROMEOS)
// If the test is running on the chromeos envrionment (such as
// device or vm bots), always use real contexts.
if (base::SysInfo::IsRunningOnChromeOS())
use_test_contexts = false;
#endif
if (enable_pixel_output) if (enable_pixel_output)
use_test_contexts = false; g_disable_null_draw = new gfx::DisableNullDrawGLBindings;
g_implicit_factory = new InProcessContextFactory();
if (use_test_contexts) {
g_implicit_factory = new ui::TestContextFactory;
} else {
DCHECK_NE(gfx::kGLImplementationNone, gfx::GetGLImplementation());
DVLOG(1) << "Using InProcessContextFactory";
if (enable_pixel_output && gfx::HasInitializedNullDrawGLBindings())
g_disable_null_draw = new gfx::DisableNullDrawGLBindings;
g_implicit_factory = new ui::InProcessContextFactory();
}
ContextFactory::SetInstance(g_implicit_factory); ContextFactory::SetInstance(g_implicit_factory);
} }
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/compositor/test/test_context_factory.h"
#include "cc/output/output_surface.h"
#include "cc/test/test_context_provider.h"
#include "ui/compositor/reflector.h"
namespace ui {
TestContextFactory::TestContextFactory() {}
TestContextFactory::~TestContextFactory() {}
scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface(
Compositor* compositor, bool software_fallback) {
DCHECK(!software_fallback);
return make_scoped_ptr(
new cc::OutputSurface(cc::TestContextProvider::Create()));
}
scoped_refptr<Reflector> TestContextFactory::CreateReflector(
Compositor* mirrored_compositor,
Layer* mirroring_layer) {
return new Reflector();
}
void TestContextFactory::RemoveReflector(scoped_refptr<Reflector> reflector) {
}
scoped_refptr<cc::ContextProvider>
TestContextFactory::OffscreenCompositorContextProvider() {
if (!offscreen_compositor_contexts_.get() ||
offscreen_compositor_contexts_->DestroyedOnMainThread())
offscreen_compositor_contexts_ = cc::TestContextProvider::Create();
return offscreen_compositor_contexts_;
}
scoped_refptr<cc::ContextProvider>
TestContextFactory::SharedMainThreadContextProvider() {
if (shared_main_thread_contexts_ &&
!shared_main_thread_contexts_->DestroyedOnMainThread())
return shared_main_thread_contexts_;
if (ui::Compositor::WasInitializedWithThread()) {
shared_main_thread_contexts_ = cc::TestContextProvider::Create();
} else {
shared_main_thread_contexts_ =
static_cast<cc::TestContextProvider*>(
OffscreenCompositorContextProvider().get());
}
if (shared_main_thread_contexts_ &&
!shared_main_thread_contexts_->BindToCurrentThread())
shared_main_thread_contexts_ = NULL;
return shared_main_thread_contexts_;
}
void TestContextFactory::RemoveCompositor(Compositor* compositor) {
}
bool TestContextFactory::DoesCreateTestContexts() { return true; }
} // namespace ui
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORY_H_
#define UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORY_H_
#include "ui/compositor/compositor.h"
namespace cc { class TestContextProvider; }
namespace ui {
// The factory that creates test contexts.
class TestContextFactory : public ContextFactory {
public:
TestContextFactory();
virtual ~TestContextFactory();
// ContextFactory implementation
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
Compositor* compositor, bool software_fallback) OVERRIDE;
virtual scoped_refptr<Reflector> CreateReflector(
Compositor* mirrored_compositor,
Layer* mirroring_layer) OVERRIDE;
virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE;
virtual scoped_refptr<cc::ContextProvider>
OffscreenCompositorContextProvider() OVERRIDE;
virtual scoped_refptr<cc::ContextProvider>
SharedMainThreadContextProvider() OVERRIDE;
virtual void RemoveCompositor(Compositor* compositor) OVERRIDE;
virtual bool DoesCreateTestContexts() OVERRIDE;
private:
scoped_refptr<cc::TestContextProvider> offscreen_compositor_contexts_;
scoped_refptr<cc::TestContextProvider> shared_main_thread_contexts_;
DISALLOW_COPY_AND_ASSIGN(TestContextFactory);
};
} // namespace ui
#endif // UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORY_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment