summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-07 21:48:12 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-07 21:48:12 +0000
commitcbf42f2066c7fe282cea4aa307505cb73b674d9d (patch)
tree6e10789bcf773271bb98f59bb265198b56890aee /ui
parent11ea072ef514d1b8f6a2a1684f77bd4232b6e634 (diff)
downloadchromium_src-cbf42f2066c7fe282cea4aa307505cb73b674d9d.zip
chromium_src-cbf42f2066c7fe282cea4aa307505cb73b674d9d.tar.gz
chromium_src-cbf42f2066c7fe282cea4aa307505cb73b674d9d.tar.bz2
Clean up compositor initialization/destruction.
Moved from https://codereview.chromium.org/21052007/ Currently the ContextFactory is outliving the compositor thread in tests, which is bad since the contexts in there can be bound to the compositor thread. Then we end up reusing those contexts and bad things happen. This enforces ordering for initializing and destroying the compositor as follows: Initialize ContextFactory ..Compositor::Initialize ....Create Compositor instances ....Delete Compositor instances ..Compositor::Terminate The Compositor::Terminate call also destroys the ContextFactory. The ContextFactory can be initialized in one of two ways: 1. ImageTransportFactory::Initialize will set up the ContextFactory. This is used by things that invoke all of content/browser/. 2. Compositor::InitializeContextFactoryForTests() must be explicitly called by any unit tests that create a compositor. Since some tests want a real GL context and some don't, this does away with the misnomer of initializing the Compositor once for the entire test suite, and then re-initializing somewhere in the middle of the test suite. Instead, each test must Initialize/Terminate the compositor with the ContextFactory type of its choice. Incidently, this test enables 20 tests on aura or win_aura that were previously being skipped. TBR=piman@chromium.org BUG=258625 Review URL: https://codereview.chromium.org/22293003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216278 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/test/aura_test_helper.cc6
-rw-r--r--ui/aura/test/test_suite.cc3
-rw-r--r--ui/compositor/compositor.cc118
-rw-r--r--ui/compositor/compositor.gyp1
-rw-r--r--ui/compositor/compositor.h14
-rw-r--r--ui/compositor/compositor_setup.h29
-rw-r--r--ui/compositor/layer_unittest.cc132
-rw-r--r--ui/compositor/test/test_suite.cc6
-rw-r--r--ui/keyboard/keyboard_test_suite.cc3
-rw-r--r--ui/message_center/test/run_all_unittests.cc8
-rw-r--r--ui/snapshot/snapshot_aura_unittest.cc1
-rw-r--r--ui/views/run_all_unittests.cc3
-rw-r--r--ui/views/widget/desktop_aura/desktop_capture_client_unittest.cc8
13 files changed, 153 insertions, 179 deletions
diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc
index b180190..0bcc515a 100644
--- a/ui/aura/test/aura_test_helper.cc
+++ b/ui/aura/test/aura_test_helper.cc
@@ -16,6 +16,7 @@
#include "ui/aura/test/test_screen.h"
#include "ui/aura/test/test_stacking_client.h"
#include "ui/base/ime/dummy_input_method.h"
+#include "ui/compositor/compositor.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/gfx/screen.h"
@@ -59,6 +60,11 @@ AuraTestHelper::~AuraTestHelper() {
void AuraTestHelper::SetUp() {
setup_called_ = true;
+
+ // The ContextFactory must exist before any Compositors are created.
+ bool allow_test_contexts = true;
+ ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts);
+
Env::GetInstance();
test_screen_.reset(TestScreen::Create());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
diff --git a/ui/aura/test/test_suite.cc b/ui/aura/test/test_suite.cc
index 5b76a17..abd3422 100644
--- a/ui/aura/test/test_suite.cc
+++ b/ui/aura/test/test_suite.cc
@@ -9,7 +9,6 @@
#include "build/build_config.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
-#include "ui/compositor/compositor_setup.h"
#include "ui/gfx/gfx_paths.h"
#include "ui/gl/gl_implementation.h"
@@ -28,8 +27,6 @@ void AuraTestSuite::Initialize() {
// Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
-
- ui::SetupTestCompositor();
}
void AuraTestSuite::Shutdown() {
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index c976ecf..5739bbf 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -50,10 +50,9 @@ enum SwapType {
READPIXELS_SWAP,
};
+bool g_compositor_initialized = false;
base::Thread* g_compositor_thread = NULL;
-bool g_test_compositor_enabled = false;
-
ui::ContextFactory* g_implicit_factory = NULL;
ui::ContextFactory* g_context_factory = NULL;
@@ -77,39 +76,13 @@ class PendingSwap {
DISALLOW_COPY_AND_ASSIGN(PendingSwap);
};
-void SetupImplicitFactory() {
- // We leak the implicit factory so that we don't race with the tear down of
- // the gl_bindings.
- DCHECK(!g_context_factory);
- DCHECK(!g_implicit_factory);
- if (g_test_compositor_enabled) {
- g_implicit_factory = new ui::TestContextFactory;
- } else {
- DVLOG(1) << "Using DefaultContextFactory";
- scoped_ptr<ui::DefaultContextFactory> instance(
- new ui::DefaultContextFactory());
- if (instance->Initialize())
- g_implicit_factory = instance.release();
- }
- g_context_factory = g_implicit_factory;
-}
-
-void ResetImplicitFactory() {
- if (!g_implicit_factory || g_context_factory != g_implicit_factory)
- return;
- delete g_implicit_factory;
- g_implicit_factory = NULL;
- g_context_factory = NULL;
-}
-
} // namespace
namespace ui {
// static
ContextFactory* ContextFactory::GetInstance() {
- if (!g_context_factory)
- SetupImplicitFactory();
+ DCHECK(g_context_factory);
return g_context_factory;
}
@@ -180,6 +153,8 @@ DefaultContextFactory::OffscreenContextProviderForCompositorThread() {
void DefaultContextFactory::RemoveCompositor(Compositor* compositor) {
}
+bool DefaultContextFactory::DoesCreateTestContexts() { return false; }
+
scoped_ptr<WebKit::WebGraphicsContext3D>
DefaultContextFactory::CreateContextCommon(Compositor* compositor,
bool offscreen) {
@@ -248,6 +223,8 @@ TestContextFactory::OffscreenContextProviderForCompositorThread() {
void TestContextFactory::RemoveCompositor(Compositor* compositor) {
}
+bool TestContextFactory::DoesCreateTestContexts() { return true; }
+
Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor)
: size_(size),
flipped_(flipped),
@@ -410,6 +387,9 @@ Compositor::Compositor(CompositorDelegate* delegate,
next_draw_is_resize_(false),
disable_schedule_composite_(false),
compositor_lock_(NULL) {
+ DCHECK(g_compositor_initialized)
+ << "Compositor::Initialize must be called before creating a Compositor.";
+
root_web_layer_ = cc::Layer::Create();
root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
@@ -417,7 +397,9 @@ Compositor::Compositor(CompositorDelegate* delegate,
cc::LayerTreeSettings settings;
settings.refresh_rate =
- g_test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate;
+ ContextFactory::GetInstance()->DoesCreateTestContexts()
+ ? kTestRefreshRate
+ : kDefaultRefreshRate;
settings.partial_swap_enabled =
!command_line->HasSwitch(cc::switches::kUIDisablePartialSwap);
settings.per_tile_painting_enabled =
@@ -452,6 +434,8 @@ Compositor::Compositor(CompositorDelegate* delegate,
}
Compositor::~Compositor() {
+ DCHECK(g_compositor_initialized);
+
CancelCompositorLock();
DCHECK(!compositor_lock_);
@@ -468,6 +452,41 @@ Compositor::~Compositor() {
}
// static
+void Compositor::InitializeContextFactoryForTests(bool allow_test_contexts) {
+ DCHECK(!g_context_factory) << "ContextFactory already initialized.";
+ DCHECK(!g_implicit_factory) <<
+ "ContextFactory for tests already initialized.";
+
+ bool use_test_contexts = true;
+
+ // Always use test contexts unless the disable command line flag is used.
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ 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::chromeos::IsRunningOnChromeOS())
+ use_test_contexts = false;
+#endif
+
+ if (!allow_test_contexts)
+ use_test_contexts = false;
+
+ if (use_test_contexts) {
+ g_implicit_factory = new ui::TestContextFactory;
+ } else {
+ DVLOG(1) << "Using DefaultContextFactory";
+ scoped_ptr<ui::DefaultContextFactory> instance(
+ new ui::DefaultContextFactory());
+ if (instance->Initialize())
+ g_implicit_factory = instance.release();
+ }
+ g_context_factory = g_implicit_factory;
+}
+
+// static
void Compositor::Initialize() {
#if defined(OS_CHROMEOS)
bool use_thread = !CommandLine::ForCurrentProcess()->HasSwitch(
@@ -483,6 +502,9 @@ void Compositor::Initialize() {
g_compositor_thread = new base::Thread("Browser Compositor");
g_compositor_thread->Start();
}
+
+ DCHECK(!g_compositor_initialized) << "Compositor initialized twice.";
+ g_compositor_initialized = true;
}
// static
@@ -500,11 +522,24 @@ scoped_refptr<base::MessageLoopProxy> Compositor::GetCompositorMessageLoop() {
// static
void Compositor::Terminate() {
+ if (g_context_factory) {
+ if (g_implicit_factory) {
+ delete g_implicit_factory;
+ g_implicit_factory = NULL;
+ }
+ g_context_factory = NULL;
+ }
+
if (g_compositor_thread) {
+ DCHECK(!g_context_factory)
+ << "The ContextFactory should not outlive the compositor thread.";
g_compositor_thread->Stop();
delete g_compositor_thread;
g_compositor_thread = NULL;
}
+
+ DCHECK(g_compositor_initialized) << "Compositor::Initialize() didn't happen.";
+ g_compositor_initialized = false;
}
void Compositor::ScheduleDraw() {
@@ -751,27 +786,4 @@ void Compositor::NotifyEnd() {
OnCompositingEnded(this));
}
-COMPOSITOR_EXPORT void SetupTestCompositor() {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableTestCompositor)) {
- g_test_compositor_enabled = true;
- }
-#if defined(OS_CHROMEOS)
- // If the test is running on the chromeos envrionment (such as
- // device or vm bots), use the real compositor.
- if (base::chromeos::IsRunningOnChromeOS())
- g_test_compositor_enabled = false;
-#endif
- ResetImplicitFactory();
-}
-
-COMPOSITOR_EXPORT void DisableTestCompositor() {
- ResetImplicitFactory();
- g_test_compositor_enabled = false;
-}
-
-COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
- return g_test_compositor_enabled;
-}
-
} // namespace ui
diff --git a/ui/compositor/compositor.gyp b/ui/compositor/compositor.gyp
index 131a6d8..57a4aaf 100644
--- a/ui/compositor/compositor.gyp
+++ b/ui/compositor/compositor.gyp
@@ -28,7 +28,6 @@
'compositor.h',
'compositor_export.h',
'compositor_observer.h',
- 'compositor_setup.h',
'compositor_switches.cc',
'compositor_switches.h',
'context_provider_from_context_factory.cc',
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
index c8689b179..92cdd71 100644
--- a/ui/compositor/compositor.h
+++ b/ui/compositor/compositor.h
@@ -99,6 +99,10 @@ class COMPOSITOR_EXPORT ContextFactory {
// Destroys per-compositor data.
virtual void RemoveCompositor(Compositor* compositor) = 0;
+
+ // When true, the factory uses test contexts that do not do real GL
+ // operations.
+ virtual bool DoesCreateTestContexts() = 0;
};
// The default factory that creates in-process contexts.
@@ -123,6 +127,7 @@ class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory {
virtual scoped_refptr<cc::ContextProvider>
OffscreenContextProviderForCompositorThread() OVERRIDE;
virtual void RemoveCompositor(Compositor* compositor) OVERRIDE;
+ virtual bool DoesCreateTestContexts() OVERRIDE;
bool Initialize();
@@ -161,6 +166,7 @@ class COMPOSITOR_EXPORT TestContextFactory : public ContextFactory {
virtual scoped_refptr<cc::ContextProvider>
OffscreenContextProviderForCompositorThread() OVERRIDE;
virtual void RemoveCompositor(Compositor* compositor) OVERRIDE;
+ virtual bool DoesCreateTestContexts() OVERRIDE;
private:
scoped_refptr<ContextProviderFromContextFactory>
@@ -290,6 +296,14 @@ class COMPOSITOR_EXPORT Compositor
gfx::AcceleratedWidget widget);
virtual ~Compositor();
+ // Set up the compositor ContextFactory for a test environment. Unit tests
+ // that do not have a full content environment need to call this before
+ // initializing the Compositor.
+ // Some tests expect pixel output, and they should pass false for
+ // |allow_test_contexts|. Most unit tests should pass true. Once this has been
+ // called, the Initialize() and Terminate() methods should be used as normal.
+ static void InitializeContextFactoryForTests(bool allow_test_contexts);
+
static void Initialize();
static bool WasInitializedWithThread();
static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop();
diff --git a/ui/compositor/compositor_setup.h b/ui/compositor/compositor_setup.h
deleted file mode 100644
index 254f389..0000000
--- a/ui/compositor/compositor_setup.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2012 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_COMPOSITOR_SETUP_H_
-#define UI_COMPOSITOR_COMPOSITOR_SETUP_H_
-
-#include "ui/compositor/compositor_export.h"
-
-namespace ui {
-
-// Configures the compositor in such a way that it doesn't render anything.
-// Does nothing on platforms that aren't using the compositor.
-#if !defined(USE_AURA)
-// To centralize the ifdef to this file we define the function as doing nothing
-// on all platforms that don't use a compositor.
-static inline void SetupTestCompositor() {}
-static inline void DisableTestCompositor() {}
-#else
-COMPOSITOR_EXPORT void SetupTestCompositor();
-
-// Disables the test compositor so that the normal compositor is used.
-COMPOSITOR_EXPORT void DisableTestCompositor();
-COMPOSITOR_EXPORT bool IsTestCompositorEnabled();
-#endif
-
-} // namespace ui
-
-#endif // UI_COMPOSITOR_COMPOSITOR_SETUP_H_
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index 79ef288..9385dbb 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -17,7 +17,6 @@
#include "cc/test/pixel_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/compositor_observer.h"
-#include "ui/compositor/compositor_setup.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
@@ -82,13 +81,18 @@ class LayerWithRealCompositorTest : public testing::Test {
// Overridden from testing::Test:
virtual void SetUp() OVERRIDE {
- DisableTestCompositor();
+ bool allow_test_contexts = false;
+ Compositor::InitializeContextFactoryForTests(allow_test_contexts);
+ Compositor::Initialize();
+
const gfx::Rect host_bounds(10, 10, 500, 500);
window_.reset(TestCompositorHost::Create(host_bounds));
window_->Show();
}
virtual void TearDown() OVERRIDE {
+ window_.reset();
+ Compositor::Terminate();
}
Compositor* GetCompositor() {
@@ -307,43 +311,7 @@ class TestCompositorObserver : public CompositorObserver {
} // namespace
-#if defined(OS_WIN)
-// These are disabled on windows as they don't run correctly on the buildbot.
-// Reenable once we move to the real compositor.
-#define MAYBE_Delegate DISABLED_Delegate
-#define MAYBE_Draw DISABLED_Draw
-#define MAYBE_DrawTree DISABLED_DrawTree
-#define MAYBE_Hierarchy DISABLED_Hierarchy
-#define MAYBE_HierarchyNoTexture DISABLED_HierarchyNoTexture
-#define MAYBE_DrawPixels DISABLED_DrawPixels
-#define MAYBE_SetRootLayer DISABLED_SetRootLayer
-#define MAYBE_CompositorObservers DISABLED_CompositorObservers
-#define MAYBE_ModifyHierarchy DISABLED_ModifyHierarchy
-#define MAYBE_Opacity DISABLED_Opacity
-#define MAYBE_ScaleUpDown DISABLED_ScaleUpDown
-#define MAYBE_ScaleReparent DISABLED_ScaleReparent
-#define MAYBE_NoScaleCanvas DISABLED_NoScaleCanvas
-#define MAYBE_AddRemoveThreadedAnimations DISABLED_AddRemoveThreadedAnimations
-#define MAYBE_SwitchCCLayerAnimations DISABLED_SwitchCCLayerAnimations
-#else
-#define MAYBE_Delegate Delegate
-#define MAYBE_Draw Draw
-#define MAYBE_DrawTree DrawTree
-#define MAYBE_Hierarchy Hierarchy
-#define MAYBE_HierarchyNoTexture HierarchyNoTexture
-#define MAYBE_DrawPixels DrawPixels
-#define MAYBE_SetRootLayer SetRootLayer
-#define MAYBE_CompositorObservers CompositorObservers
-#define MAYBE_ModifyHierarchy ModifyHierarchy
-#define MAYBE_Opacity Opacity
-#define MAYBE_ScaleUpDown ScaleUpDown
-#define MAYBE_ScaleReparent ScaleReparent
-#define MAYBE_NoScaleCanvas NoScaleCanvas
-#define MAYBE_AddRemoveThreadedAnimations AddRemoveThreadedAnimations
-#define MAYBE_SwitchCCLayerAnimations SwitchCCLayerAnimations
-#endif
-
-TEST_F(LayerWithRealCompositorTest, MAYBE_Draw) {
+TEST_F(LayerWithRealCompositorTest, Draw) {
scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 50, 50)));
DrawTree(layer.get());
@@ -355,7 +323,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_Draw) {
// | +-- L3 - yellow
// +-- L4 - magenta
//
-TEST_F(LayerWithRealCompositorTest, MAYBE_Hierarchy) {
+TEST_F(LayerWithRealCompositorTest, Hierarchy) {
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 400, 400)));
scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
@@ -379,12 +347,16 @@ class LayerWithDelegateTest : public testing::Test, public CompositorDelegate {
// Overridden from testing::Test:
virtual void SetUp() OVERRIDE {
- ui::SetupTestCompositor();
+ bool allow_test_contexts = true;
+ Compositor::InitializeContextFactoryForTests(allow_test_contexts);
+ Compositor::Initialize();
compositor_.reset(new Compositor(this, gfx::kNullAcceleratedWidget));
compositor_->SetScaleAndSize(1.0f, gfx::Size(1000, 1000));
}
virtual void TearDown() OVERRIDE {
+ compositor_.reset();
+ Compositor::Terminate();
}
Compositor* compositor() { return compositor_.get(); }
@@ -491,7 +463,7 @@ TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Medium) {
EXPECT_EQ(point2_in_l3_coords, point2_in_l1_coords);
}
-TEST_F(LayerWithRealCompositorTest, MAYBE_Delegate) {
+TEST_F(LayerWithRealCompositorTest, Delegate) {
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorBLACK,
gfx::Rect(20, 20, 400, 400)));
GetCompositor()->SetRootLayer(l1.get());
@@ -520,7 +492,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_Delegate) {
EXPECT_EQ(delegate.paint_size(), gfx::Size(50, 50));
}
-TEST_F(LayerWithRealCompositorTest, MAYBE_DrawTree) {
+TEST_F(LayerWithRealCompositorTest, DrawTree) {
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 400, 400)));
scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
@@ -554,7 +526,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_DrawTree) {
// | +-- L3 - yellow
// +-- L4 - magenta
//
-TEST_F(LayerWithRealCompositorTest, MAYBE_HierarchyNoTexture) {
+TEST_F(LayerWithRealCompositorTest, HierarchyNoTexture) {
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 400, 400)));
scoped_ptr<Layer> l2(CreateNoTextureLayer(gfx::Rect(10, 10, 350, 350)));
@@ -590,15 +562,11 @@ class LayerWithNullDelegateTest : public LayerWithDelegateTest {
LayerWithNullDelegateTest() {}
virtual ~LayerWithNullDelegateTest() {}
- // Overridden from testing::Test:
virtual void SetUp() OVERRIDE {
LayerWithDelegateTest::SetUp();
default_layer_delegate_.reset(new NullLayerDelegate());
}
- virtual void TearDown() OVERRIDE {
- }
-
virtual Layer* CreateLayer(LayerType type) OVERRIDE {
Layer* layer = new Layer(type);
layer->set_delegate(default_layer_delegate_.get());
@@ -801,35 +769,53 @@ TEST_F(LayerWithNullDelegateTest, SetBoundsSchedulesPaint) {
}
// Checks that pixels are actually drawn to the screen with a read back.
-// Currently disabled on all platforms, see http://crbug.com/148709.
-TEST_F(LayerWithRealCompositorTest, MAYBE_DrawPixels) {
- scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED,
- gfx::Rect(0, 0, 500, 500)));
- scoped_ptr<Layer> layer2(CreateColorLayer(SK_ColorBLUE,
- gfx::Rect(0, 0, 500, 10)));
+TEST_F(LayerWithRealCompositorTest, DrawPixels) {
+ gfx::Size viewport_size = GetCompositor()->size();
+
+ // The window should be some non-trivial size but may not be exactly
+ // 500x500 on all platforms/bots.
+ EXPECT_GE(viewport_size.width(), 200);
+ EXPECT_GE(viewport_size.height(), 200);
+
+ int blue_height = 10;
+
+ scoped_ptr<Layer> layer(
+ CreateColorLayer(SK_ColorRED, gfx::Rect(viewport_size)));
+ scoped_ptr<Layer> layer2(
+ CreateColorLayer(SK_ColorBLUE,
+ gfx::Rect(0, 0, viewport_size.width(), blue_height)));
layer->Add(layer2.get());
DrawTree(layer.get());
SkBitmap bitmap;
- gfx::Size size = GetCompositor()->size();
- ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap,
- gfx::Rect(0, 10,
- size.width(), size.height() - 10)));
+ ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap, gfx::Rect(viewport_size)));
ASSERT_FALSE(bitmap.empty());
SkAutoLockPixels lock(bitmap);
- bool is_all_red = true;
- for (int x = 0; is_all_red && x < 500; x++)
- for (int y = 0; is_all_red && y < 490; y++)
- is_all_red = is_all_red && (bitmap.getColor(x, y) == SK_ColorRED);
-
- EXPECT_TRUE(is_all_red);
+ for (int x = 0; x < viewport_size.width(); x++) {
+ for (int y = 0; y < viewport_size.height(); y++) {
+ SkColor actual_color = bitmap.getColor(x, y);
+ SkColor expected_color = y < blue_height ? SK_ColorBLUE : SK_ColorRED;
+ EXPECT_EQ(expected_color, actual_color)
+ << "Pixel error at x=" << x << " y=" << y << "; "
+ << "actual RGBA=("
+ << SkColorGetR(actual_color) << ","
+ << SkColorGetG(actual_color) << ","
+ << SkColorGetB(actual_color) << ","
+ << SkColorGetA(actual_color) << "); "
+ << "expected RGBA=("
+ << SkColorGetR(expected_color) << ","
+ << SkColorGetG(expected_color) << ","
+ << SkColorGetB(expected_color) << ","
+ << SkColorGetA(expected_color) << ")";
+ }
+ }
}
// Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
-TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) {
+TEST_F(LayerWithRealCompositorTest, SetRootLayer) {
Compositor* compositor = GetCompositor();
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 400, 400)));
@@ -861,7 +847,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) {
// - After ScheduleDraw is called, or
// - Whenever SetBounds, SetOpacity or SetTransform are called.
// TODO(vollick): could be reorganized into compositor_unittest.cc
-TEST_F(LayerWithRealCompositorTest, MAYBE_CompositorObservers) {
+TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 400, 400)));
scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
@@ -935,7 +921,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_CompositorObservers) {
}
// Checks that modifying the hierarchy correctly affects final composite.
-TEST_F(LayerWithRealCompositorTest, MAYBE_ModifyHierarchy) {
+TEST_F(LayerWithRealCompositorTest, ModifyHierarchy) {
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50));
// l0
@@ -1004,7 +990,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ModifyHierarchy) {
// Opacity is rendered correctly.
// Checks that modifying the hierarchy correctly affects final composite.
-TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) {
+TEST_F(LayerWithRealCompositorTest, Opacity) {
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50));
// l0
@@ -1112,7 +1098,7 @@ TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) {
gfx::Rect(10, 10, 30, 30)));
}
-TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) {
+TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220)));
TestLayerDelegate root_delegate;
@@ -1198,7 +1184,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) {
EXPECT_EQ("0.0 0.0", l1_delegate.ToScaleString());
}
-TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) {
+TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220)));
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
@@ -1243,7 +1229,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) {
}
// Tests layer::set_scale_content(false).
-TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) {
+TEST_F(LayerWithRealCompositorTest, NoScaleCanvas) {
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220)));
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
@@ -1358,7 +1344,7 @@ TEST_F(LayerWithDelegateTest, DelegatedLayer) {
}
// Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation.
-TEST_F(LayerWithRealCompositorTest, MAYBE_AddRemoveThreadedAnimations) {
+TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
scoped_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED));
@@ -1405,7 +1391,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_AddRemoveThreadedAnimations) {
// Tests that in-progress threaded animations complete when a Layer's
// cc::Layer changes.
-TEST_F(LayerWithRealCompositorTest, MAYBE_SwitchCCLayerAnimations) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
GetCompositor()->SetRootLayer(root.get());
diff --git a/ui/compositor/test/test_suite.cc b/ui/compositor/test/test_suite.cc
index 58329f2..3f89cce 100644
--- a/ui/compositor/test/test_suite.cc
+++ b/ui/compositor/test/test_suite.cc
@@ -28,19 +28,15 @@ void CompositorTestSuite::Initialize() {
#if defined(USE_X11)
XInitThreads();
#endif
-#if defined(OS_LINUX)
- gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL);
-#endif
+ CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
base::TestSuite::Initialize();
gfx::RegisterPathProvider();
message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
- Compositor::Initialize();
}
void CompositorTestSuite::Shutdown() {
- Compositor::Terminate();
message_loop_.reset();
base::TestSuite::Shutdown();
diff --git a/ui/keyboard/keyboard_test_suite.cc b/ui/keyboard/keyboard_test_suite.cc
index 5b4db504d..dc4ec5b 100644
--- a/ui/keyboard/keyboard_test_suite.cc
+++ b/ui/keyboard/keyboard_test_suite.cc
@@ -4,7 +4,6 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "ui/compositor/compositor_setup.h"
#include "ui/test/test_suite.h"
class KeyboardTestSuite : public ui::test::UITestSuite {
@@ -23,8 +22,6 @@ class KeyboardTestSuite : public ui::test::UITestSuite {
void KeyboardTestSuite::Initialize() {
ui::test::UITestSuite::Initialize();
-
- ui::SetupTestCompositor();
}
void KeyboardTestSuite::Shutdown() {
diff --git a/ui/message_center/test/run_all_unittests.cc b/ui/message_center/test/run_all_unittests.cc
index c9c3318..ff863b6 100644
--- a/ui/message_center/test/run_all_unittests.cc
+++ b/ui/message_center/test/run_all_unittests.cc
@@ -9,10 +9,6 @@
#include "ui/test/test_suite.h"
#include "ui/views/view.h"
-#if defined(TOOLKIT_VIEWS)
-#include "ui/compositor/compositor_setup.h"
-#endif
-
class MessageCenterTestSuite : public ui::test::UITestSuite {
public:
MessageCenterTestSuite(int argc, char** argv)
@@ -29,10 +25,6 @@ class MessageCenterTestSuite : public ui::test::UITestSuite {
void MessageCenterTestSuite::Initialize() {
ui::test::UITestSuite::Initialize();
-
-#if defined(TOOLKIT_VIEWS)
- ui::SetupTestCompositor();
-#endif
}
void MessageCenterTestSuite::Shutdown() {
diff --git a/ui/snapshot/snapshot_aura_unittest.cc b/ui/snapshot/snapshot_aura_unittest.cc
index 206069b..b72629c 100644
--- a/ui/snapshot/snapshot_aura_unittest.cc
+++ b/ui/snapshot/snapshot_aura_unittest.cc
@@ -11,7 +11,6 @@
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
-#include "ui/compositor/compositor_setup.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/gfx_paths.h"
diff --git a/ui/views/run_all_unittests.cc b/ui/views/run_all_unittests.cc
index cd73011..6c425d7 100644
--- a/ui/views/run_all_unittests.cc
+++ b/ui/views/run_all_unittests.cc
@@ -7,7 +7,6 @@
#include "base/test/test_suite.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
-#include "ui/compositor/compositor_setup.h"
#include "ui/views/view.h"
class ViewTestSuite : public base::TestSuite {
@@ -19,8 +18,6 @@ class ViewTestSuite : public base::TestSuite {
base::TestSuite::Initialize();
ui::RegisterPathProvider();
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
-
- ui::SetupTestCompositor();
}
private:
diff --git a/ui/views/widget/desktop_aura/desktop_capture_client_unittest.cc b/ui/views/widget/desktop_aura/desktop_capture_client_unittest.cc
index eafeee6..d96c445 100644
--- a/ui/views/widget/desktop_aura/desktop_capture_client_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_capture_client_unittest.cc
@@ -45,6 +45,14 @@ class DesktopCaptureClientTest : public aura::test::AuraTestBase {
virtual void TearDown() OVERRIDE {
RunAllPendingInMessageLoop();
+
+ second_desktop_position_client_.reset();
+ second_desktop_capture_client_.reset();
+
+ // Kill any active compositors before we hit the compositor shutdown paths.
+ second_root_.reset();
+
+ desktop_position_client_.reset();
desktop_capture_client_.reset();
AuraTestBase::TearDown();