| Index: trunk/src/ui/compositor/layer_unittest.cc
|
| ===================================================================
|
| --- trunk/src/ui/compositor/layer_unittest.cc (revision 216906)
|
| +++ trunk/src/ui/compositor/layer_unittest.cc (working copy)
|
| @@ -17,6 +17,7 @@
|
| #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"
|
| @@ -81,18 +82,13 @@
|
|
|
| // Overridden from testing::Test:
|
| virtual void SetUp() OVERRIDE {
|
| - bool allow_test_contexts = false;
|
| - Compositor::InitializeContextFactoryForTests(allow_test_contexts);
|
| - Compositor::Initialize();
|
| -
|
| + DisableTestCompositor();
|
| 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() {
|
| @@ -311,7 +307,43 @@
|
|
|
| } // namespace
|
|
|
| -TEST_F(LayerWithRealCompositorTest, Draw) {
|
| +#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) {
|
| scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED,
|
| gfx::Rect(20, 20, 50, 50)));
|
| DrawTree(layer.get());
|
| @@ -323,7 +355,7 @@
|
| // | +-- L3 - yellow
|
| // +-- L4 - magenta
|
| //
|
| -TEST_F(LayerWithRealCompositorTest, Hierarchy) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_Hierarchy) {
|
| scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
|
| gfx::Rect(20, 20, 400, 400)));
|
| scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
|
| @@ -347,16 +379,12 @@
|
|
|
| // Overridden from testing::Test:
|
| virtual void SetUp() OVERRIDE {
|
| - bool allow_test_contexts = true;
|
| - Compositor::InitializeContextFactoryForTests(allow_test_contexts);
|
| - Compositor::Initialize();
|
| + ui::SetupTestCompositor();
|
| 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(); }
|
| @@ -463,7 +491,7 @@
|
| EXPECT_EQ(point2_in_l3_coords, point2_in_l1_coords);
|
| }
|
|
|
| -TEST_F(LayerWithRealCompositorTest, Delegate) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_Delegate) {
|
| scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorBLACK,
|
| gfx::Rect(20, 20, 400, 400)));
|
| GetCompositor()->SetRootLayer(l1.get());
|
| @@ -492,7 +520,7 @@
|
| EXPECT_EQ(delegate.paint_size(), gfx::Size(50, 50));
|
| }
|
|
|
| -TEST_F(LayerWithRealCompositorTest, DrawTree) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_DrawTree) {
|
| scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
|
| gfx::Rect(20, 20, 400, 400)));
|
| scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
|
| @@ -526,7 +554,7 @@
|
| // | +-- L3 - yellow
|
| // +-- L4 - magenta
|
| //
|
| -TEST_F(LayerWithRealCompositorTest, HierarchyNoTexture) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_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)));
|
| @@ -562,11 +590,15 @@
|
| 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());
|
| @@ -769,53 +801,35 @@
|
| }
|
|
|
| // Checks that pixels are actually drawn to the screen with a read back.
|
| -TEST_F(LayerWithRealCompositorTest, DrawPixels) {
|
| - gfx::Size viewport_size = GetCompositor()->size();
|
| +// 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)));
|
|
|
| - // 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;
|
| - ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap, gfx::Rect(viewport_size)));
|
| + gfx::Size size = GetCompositor()->size();
|
| + ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap,
|
| + gfx::Rect(0, 10,
|
| + size.width(), size.height() - 10)));
|
| ASSERT_FALSE(bitmap.empty());
|
|
|
| SkAutoLockPixels lock(bitmap);
|
| - 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) << ")";
|
| - }
|
| - }
|
| + 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);
|
| }
|
|
|
| // Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
|
| -TEST_F(LayerWithRealCompositorTest, SetRootLayer) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) {
|
| Compositor* compositor = GetCompositor();
|
| scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
|
| gfx::Rect(20, 20, 400, 400)));
|
| @@ -847,7 +861,7 @@
|
| // - After ScheduleDraw is called, or
|
| // - Whenever SetBounds, SetOpacity or SetTransform are called.
|
| // TODO(vollick): could be reorganized into compositor_unittest.cc
|
| -TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_CompositorObservers) {
|
| scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
|
| gfx::Rect(20, 20, 400, 400)));
|
| scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
|
| @@ -921,7 +935,7 @@
|
| }
|
|
|
| // Checks that modifying the hierarchy correctly affects final composite.
|
| -TEST_F(LayerWithRealCompositorTest, ModifyHierarchy) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_ModifyHierarchy) {
|
| GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50));
|
|
|
| // l0
|
| @@ -990,7 +1004,7 @@
|
|
|
| // Opacity is rendered correctly.
|
| // Checks that modifying the hierarchy correctly affects final composite.
|
| -TEST_F(LayerWithRealCompositorTest, Opacity) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) {
|
| GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50));
|
|
|
| // l0
|
| @@ -1098,7 +1112,7 @@
|
| gfx::Rect(10, 10, 30, 30)));
|
| }
|
|
|
| -TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) {
|
| scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
|
| gfx::Rect(10, 20, 200, 220)));
|
| TestLayerDelegate root_delegate;
|
| @@ -1184,7 +1198,7 @@
|
| EXPECT_EQ("0.0 0.0", l1_delegate.ToScaleString());
|
| }
|
|
|
| -TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) {
|
| scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
|
| gfx::Rect(10, 20, 200, 220)));
|
| scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
|
| @@ -1229,7 +1243,7 @@
|
| }
|
|
|
| // Tests layer::set_scale_content(false).
|
| -TEST_F(LayerWithRealCompositorTest, NoScaleCanvas) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) {
|
| scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
|
| gfx::Rect(10, 20, 200, 220)));
|
| scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
|
| @@ -1344,7 +1358,7 @@
|
| }
|
|
|
| // Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation.
|
| -TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_AddRemoveThreadedAnimations) {
|
| scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
|
| scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
|
| scoped_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED));
|
| @@ -1391,7 +1405,7 @@
|
|
|
| // Tests that in-progress threaded animations complete when a Layer's
|
| // cc::Layer changes.
|
| -TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
|
| +TEST_F(LayerWithRealCompositorTest, MAYBE_SwitchCCLayerAnimations) {
|
| scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
|
| scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
|
| GetCompositor()->SetRootLayer(root.get());
|
|
|
| Property changes on: trunk/src/ui/compositor/layer_unittest.cc
|
| ___________________________________________________________________
|
| Deleted: svn:mergeinfo
|
|
|
|
|