OLD | NEW |
---|---|
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 EXPECT_EQ(child4, parent_->children()[1]); | 329 EXPECT_EQ(child4, parent_->children()[1]); |
330 EXPECT_EQ(child3_, parent_->children()[2]); | 330 EXPECT_EQ(child3_, parent_->children()[2]); |
331 EXPECT_EQ(parent_.get(), child4->parent()); | 331 EXPECT_EQ(parent_.get(), child4->parent()); |
332 | 332 |
333 // test_layer should no longer have child4, | 333 // test_layer should no longer have child4, |
334 // and child2 should no longer have a parent. | 334 // and child2 should no longer have a parent. |
335 ASSERT_EQ(0U, test_layer->children().size()); | 335 ASSERT_EQ(0U, test_layer->children().size()); |
336 EXPECT_FALSE(child2_->parent()); | 336 EXPECT_FALSE(child2_->parent()); |
337 } | 337 } |
338 | 338 |
339 TEST_F(LayerTest, DeleteRemovedScrollParent) { | |
340 scoped_refptr<Layer> parent = Layer::Create(); | |
341 scoped_refptr<Layer> child1 = Layer::Create(); | |
342 scoped_refptr<Layer> child2 = Layer::Create(); | |
343 | |
344 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | |
345 | |
346 ASSERT_EQ(0U, parent->children().size()); | |
347 | |
348 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | |
349 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | |
350 | |
351 ASSERT_EQ(2U, parent->children().size()); | |
352 EXPECT_EQ(child1, parent->children()[0]); | |
353 EXPECT_EQ(child2, parent->children()[1]); | |
354 | |
355 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | |
356 | |
357 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); | |
358 | |
359 EXPECT_SET_NEEDS_COMMIT(1, child2 = NULL); | |
danakj
2014/09/13 12:49:42
can you also reset child1->needs_push_properties()
Ian Vollick
2014/09/13 14:51:23
Done.
| |
360 | |
361 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(NULL)); | |
362 } | |
363 | |
364 TEST_F(LayerTest, DeleteRemovedScrollChild) { | |
365 scoped_refptr<Layer> parent = Layer::Create(); | |
366 scoped_refptr<Layer> child1 = Layer::Create(); | |
367 scoped_refptr<Layer> child2 = Layer::Create(); | |
368 | |
369 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | |
370 | |
371 ASSERT_EQ(0U, parent->children().size()); | |
372 | |
373 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | |
374 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | |
375 | |
376 ASSERT_EQ(2U, parent->children().size()); | |
377 EXPECT_EQ(child1, parent->children()[0]); | |
378 EXPECT_EQ(child2, parent->children()[1]); | |
379 | |
380 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | |
381 | |
382 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); | |
383 | |
384 EXPECT_SET_NEEDS_COMMIT(1, child1 = NULL); | |
danakj
2014/09/13 12:49:42
can you also reset child2->needs_push_properties()
Ian Vollick
2014/09/13 14:51:23
Done.
| |
385 | |
386 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(NULL)); | |
387 } | |
388 | |
339 TEST_F(LayerTest, ReplaceChildWithSameChild) { | 389 TEST_F(LayerTest, ReplaceChildWithSameChild) { |
340 CreateSimpleTestTree(); | 390 CreateSimpleTestTree(); |
341 | 391 |
342 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the | 392 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the |
343 // same child. | 393 // same child. |
344 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 394 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
345 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0); | 395 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0); |
346 parent_->ReplaceChild(child2_.get(), child2_); | 396 parent_->ReplaceChild(child2_.get(), child2_); |
347 | 397 |
348 VerifyTestTreeInitialState(); | 398 VerifyTestTreeInitialState(); |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 root_layer->AddChild(becomes_not_draws_content); | 1241 root_layer->AddChild(becomes_not_draws_content); |
1192 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1242 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
1193 | 1243 |
1194 becomes_draws_content->SetIsDrawable(true); | 1244 becomes_draws_content->SetIsDrawable(true); |
1195 root_layer->AddChild(becomes_draws_content); | 1245 root_layer->AddChild(becomes_draws_content); |
1196 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1246 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
1197 } | 1247 } |
1198 | 1248 |
1199 } // namespace | 1249 } // namespace |
1200 } // namespace cc | 1250 } // namespace cc |
OLD | NEW |