Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 16896017: Add a hide_layer_and_subtree() flag to cc::Layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hide-subtree-flag: SetIsDrawable on the new cc_layer Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | ui/compositor/layer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index ed6dd2c9fc5f250c3bc9b3fe0d5c2c579800c5d0..66deed96287654e248195ad9362adc894913c510 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -161,6 +161,99 @@ class LayerTreeHostTestSetNeedsCommit2 : public LayerTreeHostTest {
MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2);
+// Verify that we pass property values in PushPropertiesTo.
+class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
+ protected:
+ virtual void SetupTree() OVERRIDE {
+ scoped_refptr<Layer> root = Layer::Create();
+ root->SetBounds(gfx::Size(10, 10));
+ layer_tree_host()->SetRootLayer(root);
+ LayerTreeHostTest::SetupTree();
+ }
+
+ enum Properties {
+ STARTUP,
+ BOUNDS,
+ HIDE_LAYER_AND_SUBTREE,
+ DRAWS_CONTENT,
+ DONE,
+ };
+
+ virtual void BeginTest() OVERRIDE {
+ index_ = STARTUP;
+ PostSetNeedsCommitToMainThread();
+ }
+
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ VerifyAfterValues(impl->active_tree()->root_layer());
+ }
+
+ virtual void DidCommitAndDrawFrame() OVERRIDE {
+ SetBeforeValues(layer_tree_host()->root_layer());
+ VerifyBeforeValues(layer_tree_host()->root_layer());
+
+ ++index_;
+ if (index_ == DONE) {
+ EndTest();
+ return;
+ }
+
+ SetAfterValues(layer_tree_host()->root_layer());
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ void VerifyBeforeValues(Layer* layer) {
+ EXPECT_EQ(gfx::Size(10, 10).ToString(), layer->bounds().ToString());
+ EXPECT_FALSE(layer->hide_layer_and_subtree());
+ EXPECT_FALSE(layer->DrawsContent());
+ }
+
+ void SetBeforeValues(Layer* layer) {
+ layer->SetBounds(gfx::Size(10, 10));
+ layer->SetHideLayerAndSubtree(false);
+ layer->SetIsDrawable(false);
+ }
+
+ void VerifyAfterValues(LayerImpl* layer) {
+ switch (static_cast<Properties>(index_)) {
+ case STARTUP:
+ case DONE:
+ break;
+ case BOUNDS:
+ EXPECT_EQ(gfx::Size(20, 20).ToString(), layer->bounds().ToString());
+ break;
+ case HIDE_LAYER_AND_SUBTREE:
+ EXPECT_TRUE(layer->hide_layer_and_subtree());
+ break;
+ case DRAWS_CONTENT:
+ EXPECT_TRUE(layer->DrawsContent());
+ break;
+ }
+ }
+
+ void SetAfterValues(Layer* layer) {
+ switch (static_cast<Properties>(index_)) {
+ case STARTUP:
+ case DONE:
+ break;
+ case BOUNDS:
+ layer->SetBounds(gfx::Size(20, 20));
+ break;
+ case HIDE_LAYER_AND_SUBTREE:
+ layer->SetHideLayerAndSubtree(true);
+ break;
+ case DRAWS_CONTENT:
+ layer->SetIsDrawable(true);
+ break;
+ }
+ }
+
+ int index_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesTo);
+
// 1 setNeedsRedraw after the first commit has completed should lead to 1
// additional draw.
class LayerTreeHostTestSetNeedsRedraw : public LayerTreeHostTest {
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698