| Index: ui/compositor/layer_unittest.cc
|
| diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
|
| index 79ef288469e68d724cd4f7a645d9ecd60fa53857..d1882ce5c0dfb1ad069f80b2a00cab2c860b63cc 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() {
|
| @@ -310,21 +314,21 @@ class TestCompositorObserver : public CompositorObserver {
|
| #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
|
| +#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
|
| #else
|
| #define MAYBE_Delegate Delegate
|
| #define MAYBE_Draw Draw
|
| @@ -379,12 +383,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(); }
|
| @@ -590,15 +598,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,7 +805,6 @@ 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)));
|
| @@ -812,20 +815,33 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_DrawPixels) {
|
|
|
| DrawTree(layer.get());
|
|
|
| + // Make sure the compositor will show our layers.
|
| + EXPECT_EQ(gfx::Size(500, 500).ToString(), GetCompositor()->size().ToString());
|
| +
|
| 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(0, 0, 500, 500)));
|
| 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; is_all_red && x < 500; x++) {
|
| + for (int y = 0; is_all_red && y < 500; y++) {
|
| + SkColor actual_color = bitmap.getColor(x, y);
|
| + SkColor expected_color = y < 10 ? 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.
|
|
|