Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 using ::testing::StrictMock; | 46 using ::testing::StrictMock; |
| 47 using ::testing::_; | 47 using ::testing::_; |
| 48 | 48 |
| 49 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ | 49 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ |
| 50 do { \ | 50 do { \ |
| 51 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ | 51 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ |
| 52 code_to_test; \ | 52 code_to_test; \ |
| 53 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ | 53 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ |
| 54 } while (false) | 54 } while (false) |
| 55 | 55 |
| 56 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ | |
| 57 code_to_test; \ | |
| 58 root->layer_tree_host()->BuildPropertyTreesForTesting(); \ | |
| 59 EXPECT_TRUE(root->subtree_property_changed()); \ | |
| 60 EXPECT_TRUE(child->subtree_property_changed()); \ | |
| 61 EXPECT_TRUE(grand_child->subtree_property_changed()); | |
|
ajuma
2016/02/10 15:31:32
Also verify that needs_push_properties is true for
jaydasika
2016/02/10 16:33:40
Do we need to push properties if layer_property_ch
ajuma
2016/02/10 16:40:18
If we don't push properties, would the layer_prope
jaydasika
2016/02/10 19:18:25
Added SetNeedsPushProperties to SetSubtreeProeprty
| |
| 62 | |
| 56 namespace cc { | 63 namespace cc { |
| 57 | 64 |
| 58 // This class is a friend of Layer, and is used as a wrapper for all the tests | 65 // This class is a friend of Layer, and is used as a wrapper for all the tests |
| 59 // related to proto serialization. This is done so that it is unnecessary to | 66 // related to proto serialization. This is done so that it is unnecessary to |
| 60 // add FRIEND_TEST_ALL_PREFIXES in //cc/layers/layer.h for all the tests. | 67 // add FRIEND_TEST_ALL_PREFIXES in //cc/layers/layer.h for all the tests. |
| 61 // It is in the cc namespace so that it can be a friend of Layer. | 68 // It is in the cc namespace so that it can be a friend of Layer. |
| 62 // The tests still have helpful names, and a test with the name FooBar would | 69 // The tests still have helpful names, and a test with the name FooBar would |
| 63 // have a wrapper method in this class called RunFooBarTest. | 70 // have a wrapper method in this class called RunFooBarTest. |
| 64 class LayerSerializationTest : public testing::Test { | 71 class LayerSerializationTest : public testing::Test { |
| 65 public: | 72 public: |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 ASSERT_TRUE(test_layer.get()); | 501 ASSERT_TRUE(test_layer.get()); |
| 495 | 502 |
| 496 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 503 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
| 497 test_layer->SetLayerTreeHost(layer_tree_host_.get()); | 504 test_layer->SetLayerTreeHost(layer_tree_host_.get()); |
| 498 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 505 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 499 | 506 |
| 500 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 507 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
| 501 test_layer->SetLayerTreeHost(nullptr); | 508 test_layer->SetLayerTreeHost(nullptr); |
| 502 } | 509 } |
| 503 | 510 |
| 511 TEST_F(LayerTest, LayerPropertyChangedForSubtree) { | |
| 512 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); | |
| 513 scoped_refptr<Layer> root = Layer::Create(layer_settings_); | |
| 514 scoped_refptr<Layer> child = Layer::Create(layer_settings_); | |
| 515 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings_); | |
| 516 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); | |
| 517 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); | |
| 518 | |
| 519 layer_tree_host_->SetRootLayer(root); | |
| 520 root->AddChild(child); | |
| 521 child->AddChild(grand_child); | |
| 522 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; | |
| 523 | |
| 524 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | |
| 525 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); | |
|
ajuma
2016/02/10 15:31:32
Does the subtree_property_changed() bit get cleare
jaydasika
2016/02/10 19:18:25
Added code to reset it.
| |
| 526 | |
| 527 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
| 528 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); | |
| 529 | |
| 530 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
| 531 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); | |
| 532 | |
| 533 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | |
| 534 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get())); | |
| 535 | |
| 536 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
| 537 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); | |
| 538 | |
| 539 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
| 540 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->Set3dSortingContextId(1)); | |
| 541 | |
| 542 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
| 543 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetDoubleSided(false)); | |
| 544 | |
| 545 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
| 546 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetHideLayerAndSubtree(true)); | |
| 547 | |
| 548 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
| 549 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBlendMode(arbitrary_blend_mode)); | |
| 550 } | |
| 551 | |
| 504 TEST_F(LayerTest, AddAndRemoveChild) { | 552 TEST_F(LayerTest, AddAndRemoveChild) { |
| 505 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); | 553 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
| 506 scoped_refptr<Layer> child = Layer::Create(layer_settings_); | 554 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
| 507 | 555 |
| 508 // Upon creation, layers should not have children or parent. | 556 // Upon creation, layers should not have children or parent. |
| 509 ASSERT_EQ(0U, parent->children().size()); | 557 ASSERT_EQ(0U, parent->children().size()); |
| 510 EXPECT_FALSE(child->parent()); | 558 EXPECT_FALSE(child->parent()); |
| 511 | 559 |
| 512 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 560 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 513 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); | 561 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); |
| (...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2118 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2166 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2119 | 2167 |
| 2120 test_layer->PushPropertiesTo(impl_layer.get()); | 2168 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2121 | 2169 |
| 2122 EXPECT_EQ(2lu, impl_layer->element_id()); | 2170 EXPECT_EQ(2lu, impl_layer->element_id()); |
| 2123 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2171 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2124 } | 2172 } |
| 2125 | 2173 |
| 2126 } // namespace | 2174 } // namespace |
| 2127 } // namespace cc | 2175 } // namespace cc |
| OLD | NEW |