summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 22:39:45 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 22:39:45 +0000
commitfe9d23f2c945bd2cfa39f5893b5e2f000dd6baf3 (patch)
treeaf22261fc6fab81379e571eb9fa42237f2ab0e2f /views
parenta13da216e3642f8b35e1a95e09974bf144ff3f17 (diff)
downloadchromium_src-fe9d23f2c945bd2cfa39f5893b5e2f000dd6baf3.zip
chromium_src-fe9d23f2c945bd2cfa39f5893b5e2f000dd6baf3.tar.gz
chromium_src-fe9d23f2c945bd2cfa39f5893b5e2f000dd6baf3.tar.bz2
Use WebKit compositor in ui::Layer
BUG=99524 TEST=compositor_unittests Review URL: http://codereview.chromium.org/8222028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106606 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/run_all_unittests.cc6
-rw-r--r--views/view_unittest.cc22
-rw-r--r--views/views.gyp1
3 files changed, 29 insertions, 0 deletions
diff --git a/views/run_all_unittests.cc b/views/run_all_unittests.cc
index 90fd4dd..e9749ce 100644
--- a/views/run_all_unittests.cc
+++ b/views/run_all_unittests.cc
@@ -5,6 +5,7 @@
#include "base/test/test_suite.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
+#include "ui/gfx/compositor/compositor_test_support.h"
#include "views/view.h"
class ViewTestSuite : public base::TestSuite {
@@ -22,6 +23,11 @@ class ViewTestSuite : public base::TestSuite {
// Disable GPU browser compositor during unit tests.
views::View::set_use_acceleration_when_possible(false);
#endif
+ ui::CompositorTestSupport::Initialize();
+ }
+
+ virtual void Shutdown() {
+ ui::CompositorTestSupport::Terminate();
}
};
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index ba6579d..0cf7e77 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -2577,19 +2577,28 @@ TEST_F(ViewLayerTest, LayerToggling) {
View* content_view = new View;
widget()->SetContentsView(content_view);
+#if !defined(USE_WEBKIT_COMPOSITOR)
+ // TODO(piman): with the webkit compositor, we don't create Textures on
+ // Layers. We're not supposed to be calling Layer::DrawTree. This test needs
+ // refactoring to fully work in that case.
root_layer->DrawTree();
ui::TestTexture::reset_live_count();
+#endif
// Create v1, give it a bounds and verify everything is set up correctly.
View* v1 = new View;
v1->SetPaintToLayer(true);
+#if !defined(USE_WEBKIT_COMPOSITOR)
root_layer->DrawTree();
EXPECT_EQ(0, ui::TestTexture::live_count());
+#endif
EXPECT_TRUE(v1->layer() != NULL);
v1->SetBounds(20, 30, 140, 150);
content_view->AddChildView(v1);
+#if !defined(USE_WEBKIT_COMPOSITOR)
root_layer->DrawTree();
EXPECT_EQ(1, ui::TestTexture::live_count());
+#endif
ASSERT_TRUE(v1->layer() != NULL);
EXPECT_EQ(root_layer, v1->layer()->parent());
EXPECT_EQ(gfx::Rect(20, 30, 140, 150), v1->layer()->bounds());
@@ -2600,8 +2609,10 @@ TEST_F(ViewLayerTest, LayerToggling) {
EXPECT_TRUE(v2->layer() == NULL);
v2->SetBounds(10, 20, 30, 40);
v2->SetPaintToLayer(true);
+#if !defined(USE_WEBKIT_COMPOSITOR)
root_layer->DrawTree();
EXPECT_EQ(2, ui::TestTexture::live_count());
+#endif
ASSERT_TRUE(v2->layer() != NULL);
EXPECT_EQ(v1->layer(), v2->layer()->parent());
EXPECT_EQ(gfx::Rect(10, 20, 30, 40), v2->layer()->bounds());
@@ -2609,8 +2620,10 @@ TEST_F(ViewLayerTest, LayerToggling) {
// Turn off v1s layer. v2 should still have a layer but its parent should have
// changed.
v1->SetPaintToLayer(false);
+#if !defined(USE_WEBKIT_COMPOSITOR)
root_layer->DrawTree();
EXPECT_EQ(1, ui::TestTexture::live_count());
+#endif
EXPECT_TRUE(v1->layer() == NULL);
EXPECT_TRUE(v2->layer() != NULL);
EXPECT_EQ(root_layer, v2->layer()->parent());
@@ -2624,8 +2637,10 @@ TEST_F(ViewLayerTest, LayerToggling) {
ui::Transform transform;
transform.SetScale(2.0f, 2.0f);
v1->SetTransform(transform);
+#if !defined(USE_WEBKIT_COMPOSITOR)
root_layer->DrawTree();
EXPECT_EQ(2, ui::TestTexture::live_count());
+#endif
EXPECT_TRUE(v1->layer() != NULL);
EXPECT_TRUE(v2->layer() != NULL);
EXPECT_EQ(root_layer, v1->layer()->parent());
@@ -2976,6 +2991,12 @@ class PaintTrackingView : public View {
DISALLOW_COPY_AND_ASSIGN(PaintTrackingView);
};
+#if !defined(USE_WEBKIT_COMPOSITOR)
+// TODO(piman): this test relies on the way the non-webkit compositor works.
+// Layer::DrawTree should not be called with the webkit compositor. In the
+// WebKit case, it needs to go through the "real" compositor (not the test one)
+// to do the paints on the layer/views.
+
// Makes sure child views with layers aren't painted when paint starts at an
// ancestor.
TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
@@ -2996,6 +3017,7 @@ TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
GetRootLayer()->DrawTree();
EXPECT_TRUE(content_view->painted());
}
+#endif
// Tests that the visibility of child layers are updated correctly when a View's
// visibility changes.
diff --git a/views/views.gyp b/views/views.gyp
index 103c7d2..98f3d64 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -555,6 +555,7 @@
'../third_party/icu/icu.gyp:icuuc',
'../ui/base/strings/ui_strings.gyp:ui_strings',
'../ui/gfx/compositor/compositor.gyp:compositor',
+ '../ui/gfx/compositor/compositor.gyp:compositor_test_support',
'../ui/ui.gyp:gfx_resources',
'../ui/ui.gyp:ui',
'../ui/ui.gyp:ui_resources',