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

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
60 class LayerTest : public testing::Test { 59 class LayerTest : public testing::Test {
61 public: 60 public:
62 LayerTest() 61 LayerTest()
63 : host_impl_(&proxy_, &shared_bitmap_manager_), 62 : host_impl_(&proxy_, &shared_bitmap_manager_),
64 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} 63 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
65 64
66 protected: 65 protected:
67 virtual void SetUp() OVERRIDE { 66 virtual void SetUp() OVERRIDE {
68 layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_)); 67 layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_));
69 } 68 }
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 } else { 1144 } else {
1146 EXPECT_NE(SkColorGetA(safe_color), 255u) 1145 EXPECT_NE(SkColorGetA(safe_color), 255u)
1147 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " 1146 << "Flags: " << contents_opaque << ", " << layer_opaque << ", "
1148 << host_opaque << "\n"; 1147 << host_opaque << "\n";
1149 } 1148 }
1150 } 1149 }
1151 } 1150 }
1152 } 1151 }
1153 } 1152 }
1154 1153
1154 class DrawsContentChangeLayer : public Layer {
1155 public:
1156 static scoped_refptr<DrawsContentChangeLayer> Create() {
1157 return make_scoped_refptr(new DrawsContentChangeLayer());
1158 }
1159
1160 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE {
1161 Layer::SetLayerTreeHost(host);
1162 SetFakeDrawsContent(!fake_draws_content_);
1163 }
1164
1165 virtual bool HasDrawableContent() const OVERRIDE {
1166 return fake_draws_content_ && Layer::HasDrawableContent();
1167 }
1168
1169 void SetFakeDrawsContent(bool fake_draws_content) {
1170 fake_draws_content_ = fake_draws_content;
1171 UpdateDrawsContent(HasDrawableContent());
1172 }
1173
1174 private:
1175 DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {}
1176 virtual ~DrawsContentChangeLayer() OVERRIDE {}
1177
1178 bool fake_draws_content_;
1179 };
1180
1181 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) {
1182 scoped_refptr<Layer> root_layer = Layer::Create();
1183 scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content =
1184 DrawsContentChangeLayer::Create();
1185 scoped_refptr<DrawsContentChangeLayer> becomes_draws_content =
1186 DrawsContentChangeLayer::Create();
1187 root_layer->SetIsDrawable(true);
1188 becomes_not_draws_content->SetIsDrawable(true);
1189 becomes_not_draws_content->SetFakeDrawsContent(true);
1190 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
1191 root_layer->AddChild(becomes_not_draws_content);
1192 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent());
1193
1194 becomes_draws_content->SetIsDrawable(true);
1195 root_layer->AddChild(becomes_draws_content);
1196 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent());
1197 }
1198
1155 } // namespace 1199 } // namespace
1156 } // namespace cc 1200 } // 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