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 child1->reset_needs_push_properties_for_testing(); |
| 360 |
| 361 EXPECT_SET_NEEDS_COMMIT(1, child2 = NULL); |
| 362 |
| 363 EXPECT_TRUE(child1->needs_push_properties()); |
| 364 |
| 365 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(NULL)); |
| 366 } |
| 367 |
| 368 TEST_F(LayerTest, DeleteRemovedScrollChild) { |
| 369 scoped_refptr<Layer> parent = Layer::Create(); |
| 370 scoped_refptr<Layer> child1 = Layer::Create(); |
| 371 scoped_refptr<Layer> child2 = Layer::Create(); |
| 372 |
| 373 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 374 |
| 375 ASSERT_EQ(0U, parent->children().size()); |
| 376 |
| 377 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
| 378 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
| 379 |
| 380 ASSERT_EQ(2U, parent->children().size()); |
| 381 EXPECT_EQ(child1, parent->children()[0]); |
| 382 EXPECT_EQ(child2, parent->children()[1]); |
| 383 |
| 384 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
| 385 |
| 386 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); |
| 387 |
| 388 child2->reset_needs_push_properties_for_testing(); |
| 389 |
| 390 EXPECT_SET_NEEDS_COMMIT(1, child1 = NULL); |
| 391 |
| 392 EXPECT_TRUE(child2->needs_push_properties()); |
| 393 |
| 394 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(NULL)); |
| 395 } |
| 396 |
339 TEST_F(LayerTest, ReplaceChildWithSameChild) { | 397 TEST_F(LayerTest, ReplaceChildWithSameChild) { |
340 CreateSimpleTestTree(); | 398 CreateSimpleTestTree(); |
341 | 399 |
342 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the | 400 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the |
343 // same child. | 401 // same child. |
344 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 402 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
345 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0); | 403 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0); |
346 parent_->ReplaceChild(child2_.get(), child2_); | 404 parent_->ReplaceChild(child2_.get(), child2_); |
347 | 405 |
348 VerifyTestTreeInitialState(); | 406 VerifyTestTreeInitialState(); |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 root_layer->AddChild(becomes_not_draws_content); | 1249 root_layer->AddChild(becomes_not_draws_content); |
1192 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1250 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
1193 | 1251 |
1194 becomes_draws_content->SetIsDrawable(true); | 1252 becomes_draws_content->SetIsDrawable(true); |
1195 root_layer->AddChild(becomes_draws_content); | 1253 root_layer->AddChild(becomes_draws_content); |
1196 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1254 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
1197 } | 1255 } |
1198 | 1256 |
1199 } // namespace | 1257 } // namespace |
1200 } // namespace cc | 1258 } // namespace cc |
OLD | NEW |