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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « cc/layers/layer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include "cc/animation/keyframed_animation_curve.h" 7 #include "cc/animation/keyframed_animation_curve.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/layers/layer_impl.h" 9 #include "cc/layers/layer_impl.h"
10 #include "cc/resources/layer_painter.h" 10 #include "cc/resources/layer_painter.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 MOCK_METHOD0(SetNeedsFullTreeSync, void()); 49 MOCK_METHOD0(SetNeedsFullTreeSync, void());
50 }; 50 };
51 51
52 class MockLayerPainter : public LayerPainter { 52 class MockLayerPainter : public LayerPainter {
53 public: 53 public:
54 virtual void Paint(SkCanvas* canvas, 54 virtual void Paint(SkCanvas* canvas,
55 const gfx::Rect& content_rect, 55 const gfx::Rect& content_rect,
56 gfx::RectF* opaque) OVERRIDE {} 56 gfx::RectF* opaque) OVERRIDE {}
57 }; 57 };
58 58
59 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.
60 public:
61 static scoped_refptr<DrawsContentChangeLayer> Create() {
62 return make_scoped_refptr(new DrawsContentChangeLayer());
63 }
64
65 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE {
66 Layer::SetLayerTreeHost(host);
67 SetFakeDrawsContent(!fake_draws_content_);
68 }
69
70 virtual bool HasDrawableContent() const OVERRIDE {
71 return fake_draws_content_ && Layer::HasDrawableContent();
72 }
73
74 void SetFakeDrawsContent(bool fake_draws_content) {
75 fake_draws_content_ = fake_draws_content;
76 UpdateDrawsContent(HasDrawableContent());
77 }
78
79 private:
80 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.
81 DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {}
82 virtual ~DrawsContentChangeLayer() OVERRIDE {}
83 };
59 84
60 class LayerTest : public testing::Test { 85 class LayerTest : public testing::Test {
61 public: 86 public:
62 LayerTest() 87 LayerTest()
63 : host_impl_(&proxy_, &shared_bitmap_manager_), 88 : host_impl_(&proxy_, &shared_bitmap_manager_),
64 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} 89 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
65 90
66 protected: 91 protected:
67 virtual void SetUp() OVERRIDE { 92 virtual void SetUp() OVERRIDE {
68 layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_)); 93 layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_));
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 } else { 1170 } else {
1146 EXPECT_NE(SkColorGetA(safe_color), 255u) 1171 EXPECT_NE(SkColorGetA(safe_color), 255u)
1147 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " 1172 << "Flags: " << contents_opaque << ", " << layer_opaque << ", "
1148 << host_opaque << "\n"; 1173 << host_opaque << "\n";
1149 } 1174 }
1150 } 1175 }
1151 } 1176 }
1152 } 1177 }
1153 } 1178 }
1154 1179
1180 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) {
1181 scoped_refptr<Layer> root_layer = Layer::Create();
1182 scoped_refptr<DrawsContentChangeLayer> child_layer =
danakj 2014/08/15 15:40:30 becomes_not_draws_content
awoloszyn 2014/08/15 15:56:46 Done.
1183 DrawsContentChangeLayer::Create();
1184 scoped_refptr<DrawsContentChangeLayer> second_child =
danakj 2014/08/15 15:40:30 becomes_draws_content
awoloszyn 2014/08/15 15:56:46 Done.
1185 DrawsContentChangeLayer::Create();
1186 root_layer->SetIsDrawable(true);
1187 child_layer->SetIsDrawable(true);
1188 child_layer->SetFakeDrawsContent(true);
1189 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
1190 root_layer->AddChild(child_layer);
1191 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
1192
1193 second_child->SetIsDrawable(true);
1194 root_layer->AddChild(second_child);
1195 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent());
1196 }
1197
1155 } // namespace 1198 } // namespace
1156 } // namespace cc 1199 } // namespace cc
OLDNEW
« 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