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

Unified Diff: cc/layers/layer_unittest.cc

Issue 471233002: Removing the assumption that child->SetParent will not change Drawability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/layers/layer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer_unittest.cc
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index 246ec43420fc3bafcda881af341ee34f54b76a00..61d05270265fc04dd8fbc1f7d174e1155ed35a78 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -56,7 +56,6 @@ class MockLayerPainter : public LayerPainter {
gfx::RectF* opaque) OVERRIDE {}
};
-
class LayerTest : public testing::Test {
public:
LayerTest()
@@ -1152,5 +1151,50 @@ TEST_F(LayerTest, SafeOpaqueBackgroundColor) {
}
}
+class DrawsContentChangeLayer : public Layer {
+ public:
+ static scoped_refptr<DrawsContentChangeLayer> Create() {
+ return make_scoped_refptr(new DrawsContentChangeLayer());
+ }
+
+ virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE {
+ Layer::SetLayerTreeHost(host);
+ SetFakeDrawsContent(!fake_draws_content_);
+ }
+
+ virtual bool HasDrawableContent() const OVERRIDE {
+ return fake_draws_content_ && Layer::HasDrawableContent();
+ }
+
+ void SetFakeDrawsContent(bool fake_draws_content) {
+ fake_draws_content_ = fake_draws_content;
+ UpdateDrawsContent(HasDrawableContent());
+ }
+
+ private:
+ DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {}
+ virtual ~DrawsContentChangeLayer() OVERRIDE {}
+
+ bool fake_draws_content_;
+};
+
+TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) {
+ scoped_refptr<Layer> root_layer = Layer::Create();
+ scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content =
+ DrawsContentChangeLayer::Create();
+ scoped_refptr<DrawsContentChangeLayer> becomes_draws_content =
+ DrawsContentChangeLayer::Create();
+ root_layer->SetIsDrawable(true);
+ becomes_not_draws_content->SetIsDrawable(true);
+ becomes_not_draws_content->SetFakeDrawsContent(true);
+ EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
+ root_layer->AddChild(becomes_not_draws_content);
+ EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
+
+ becomes_draws_content->SetIsDrawable(true);
+ root_layer->AddChild(becomes_draws_content);
+ EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/layers/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698