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

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..7534cc4f6c81c1e548e36c374bca22072a712863 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -56,6 +56,31 @@ class MockLayerPainter : public LayerPainter {
gfx::RectF* opaque) OVERRIDE {}
};
+class DrawsContentChangeLayer : public Layer {
danakj 2014/08/15 15:40:30 Can you put this just above the test so it's close
awoloszyn 2014/08/15 15:56:46 Done.
+ 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:
+ bool fake_draws_content_;
danakj 2014/08/15 15:40:30 move variable below methods, and a blank line betw
awoloszyn 2014/08/15 15:56:45 Done.
+ DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {}
+ virtual ~DrawsContentChangeLayer() OVERRIDE {}
+};
class LayerTest : public testing::Test {
public:
@@ -1152,5 +1177,23 @@ TEST_F(LayerTest, SafeOpaqueBackgroundColor) {
}
}
+TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) {
+ scoped_refptr<Layer> root_layer = Layer::Create();
+ scoped_refptr<DrawsContentChangeLayer> child_layer =
danakj 2014/08/15 15:40:30 becomes_not_draws_content
awoloszyn 2014/08/15 15:56:46 Done.
+ DrawsContentChangeLayer::Create();
+ scoped_refptr<DrawsContentChangeLayer> second_child =
danakj 2014/08/15 15:40:30 becomes_draws_content
awoloszyn 2014/08/15 15:56:46 Done.
+ DrawsContentChangeLayer::Create();
+ root_layer->SetIsDrawable(true);
+ child_layer->SetIsDrawable(true);
+ child_layer->SetFakeDrawsContent(true);
+ EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
+ root_layer->AddChild(child_layer);
+ EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
+
+ second_child->SetIsDrawable(true);
+ root_layer->AddChild(second_child);
+ 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