Chromium Code Reviews| 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 |