summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 09:05:31 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 09:05:31 +0000
commit28c21938e07097ef261d40d8d1c72bdca78f2071 (patch)
tree091ad013545974fd411377a47908dff539eb64c5 /ui
parent25828ee90b4a1748fca561945eda5bf715cdbbb9 (diff)
downloadchromium_src-28c21938e07097ef261d40d8d1c72bdca78f2071.zip
chromium_src-28c21938e07097ef261d40d8d1c72bdca78f2071.tar.gz
chromium_src-28c21938e07097ef261d40d8d1c72bdca78f2071.tar.bz2
Add test for Layer::SetBounds when invisible
BUG=122093 TEST=LayerWithDelegateTest.SetBoundsWhenInvisible Review URL: https://chromiumcodereview.appspot.com/10388016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/compositor/layer_unittest.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index b0aa874..3af502d 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -1184,4 +1184,48 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) {
EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString());
}
+// Verifies that when changing bounds on a layer that is invisible, and then
+// made visible, the right thing happens:
+// - if just a move, then no painting should happen.
+// - if a resize, the layer should be repainted.
+TEST_F(LayerWithDelegateTest, SetBoundsWhenInvisible) {
+ scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000)));
+
+ scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
+ child->SetBounds(gfx::Rect(0, 0, 500, 500));
+ DrawTreeLayerDelegate delegate;
+ child->set_delegate(&delegate);
+ root->Add(child.get());
+
+ // Paint once for initial damage.
+ child->SetVisible(true);
+ DrawTree(root.get());
+
+ // Reset into invisible state.
+ child->SetVisible(false);
+ DrawTree(root.get());
+ schedule_draw_invoked_ = false;
+ delegate.Reset();
+
+ // Move layer.
+ child->SetBounds(gfx::Rect(200, 200, 500, 500));
+ child->SetVisible(true);
+ EXPECT_TRUE(schedule_draw_invoked_);
+ DrawTree(root.get());
+ EXPECT_FALSE(delegate.painted());
+
+ // Reset into invisible state.
+ child->SetVisible(false);
+ DrawTree(root.get());
+ schedule_draw_invoked_ = false;
+ delegate.Reset();
+
+ // Resize layer.
+ child->SetBounds(gfx::Rect(200, 200, 400, 400));
+ child->SetVisible(true);
+ EXPECT_TRUE(schedule_draw_invoked_);
+ DrawTree(root.get());
+ EXPECT_TRUE(delegate.painted());
+}
+
} // namespace ui