| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 using ::testing::StrictMock; | 45 using ::testing::StrictMock; |
| 46 using ::testing::_; | 46 using ::testing::_; |
| 47 | 47 |
| 48 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ | 48 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ |
| 49 do { \ | 49 do { \ |
| 50 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ | 50 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ |
| 51 code_to_test; \ | 51 code_to_test; \ |
| 52 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ | 52 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ |
| 53 } while (false) | 53 } while (false) |
| 54 | 54 |
| 55 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ | 55 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ |
| 56 code_to_test; \ | 56 code_to_test; \ |
| 57 root->layer_tree_host()->BuildPropertyTreesForTesting(); \ | 57 root->layer_tree_host()->BuildPropertyTreesForTesting(); \ |
| 58 EXPECT_TRUE(root->subtree_property_changed()); \ | 58 EXPECT_TRUE(root->subtree_property_changed()); \ |
| 59 EXPECT_TRUE(root->needs_push_properties()); \ | 59 EXPECT_TRUE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 60 EXPECT_TRUE(child->subtree_property_changed()); \ | 60 root.get())); \ |
| 61 EXPECT_TRUE(child->needs_push_properties()); \ | 61 EXPECT_TRUE(child->subtree_property_changed()); \ |
| 62 EXPECT_TRUE(grand_child->subtree_property_changed()); \ | 62 EXPECT_TRUE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 63 EXPECT_TRUE(grand_child->needs_push_properties()); | 63 child.get())); \ |
| 64 EXPECT_TRUE(grand_child->subtree_property_changed()); \ |
| 65 EXPECT_TRUE( \ |
| 66 grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 67 grand_child.get())); |
| 64 | 68 |
| 65 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test) \ | 69 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test) \ |
| 66 code_to_test; \ | 70 code_to_test; \ |
| 67 EXPECT_FALSE(root->subtree_property_changed()); \ | 71 EXPECT_FALSE(root->subtree_property_changed()); \ |
| 68 EXPECT_FALSE(root->needs_push_properties()); \ | 72 EXPECT_FALSE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 69 EXPECT_FALSE(child->subtree_property_changed()); \ | 73 root.get())); \ |
| 70 EXPECT_FALSE(child->needs_push_properties()); \ | 74 EXPECT_FALSE(child->subtree_property_changed()); \ |
| 71 EXPECT_FALSE(grand_child->subtree_property_changed()); \ | 75 EXPECT_FALSE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 72 EXPECT_FALSE(grand_child->needs_push_properties()); | 76 child.get())); \ |
| 77 EXPECT_FALSE(grand_child->subtree_property_changed()); \ |
| 78 EXPECT_FALSE( \ |
| 79 grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 80 grand_child.get())); |
| 73 | 81 |
| 74 namespace cc { | 82 namespace cc { |
| 75 | 83 |
| 76 // This class is a friend of Layer, and is used as a wrapper for all the tests | 84 // This class is a friend of Layer, and is used as a wrapper for all the tests |
| 77 // related to proto serialization. This is done so that it is unnecessary to | 85 // related to proto serialization. This is done so that it is unnecessary to |
| 78 // add FRIEND_TEST_ALL_PREFIXES in //cc/layers/layer.h for all the tests. | 86 // add FRIEND_TEST_ALL_PREFIXES in //cc/layers/layer.h for all the tests. |
| 79 // It is in the cc namespace so that it can be a friend of Layer. | 87 // It is in the cc namespace so that it can be a friend of Layer. |
| 80 // The tests still have helpful names, and a test with the name FooBar would | 88 // The tests still have helpful names, and a test with the name FooBar would |
| 81 // have a wrapper method in this class called RunFooBarTest. | 89 // have a wrapper method in this class called RunFooBarTest. |
| 82 class LayerSerializationTest : public testing::Test { | 90 class LayerSerializationTest : public testing::Test { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 102 src->SetLayerTreeHost(layer_tree_host_.get()); | 110 src->SetLayerTreeHost(layer_tree_host_.get()); |
| 103 | 111 |
| 104 // The following member is reset during serialization, so store the original | 112 // The following member is reset during serialization, so store the original |
| 105 // values. | 113 // values. |
| 106 gfx::Rect update_rect = src->update_rect_; | 114 gfx::Rect update_rect = src->update_rect_; |
| 107 | 115 |
| 108 // Serialize |src| to protobuf and read the first entry in the | 116 // Serialize |src| to protobuf and read the first entry in the |
| 109 // LayerUpdate. There are no descendants, so the serialization | 117 // LayerUpdate. There are no descendants, so the serialization |
| 110 // of |src| is the only entry. | 118 // of |src| is the only entry. |
| 111 proto::LayerUpdate layer_update; | 119 proto::LayerUpdate layer_update; |
| 112 EXPECT_FALSE(src->ToLayerPropertiesProto(&layer_update)); | 120 src->ToLayerPropertiesProto(&layer_update); |
| 113 ASSERT_EQ(1, layer_update.layers_size()); | 121 ASSERT_EQ(1, layer_update.layers_size()); |
| 114 proto::LayerProperties props = layer_update.layers(0); | 122 proto::LayerProperties props = layer_update.layers(0); |
| 115 | 123 |
| 116 // The |dest| layer needs to be able to lookup the scroll and clip parents. | 124 // The |dest| layer needs to be able to lookup the scroll and clip parents. |
| 117 if (src->scroll_parent_) | 125 if (src->scroll_parent_) |
| 118 layer_tree_host_->RegisterLayer(src->scroll_parent_); | 126 layer_tree_host_->RegisterLayer(src->scroll_parent_); |
| 119 if (src->scroll_children_) { | 127 if (src->scroll_children_) { |
| 120 for (auto* child : *(src->scroll_children_)) | 128 for (auto* child : *(src->scroll_children_)) |
| 121 layer_tree_host_->RegisterLayer(child); | 129 layer_tree_host_->RegisterLayer(child); |
| 122 } | 130 } |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 1320 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
| 1313 | 1321 |
| 1314 ASSERT_EQ(2U, parent->children().size()); | 1322 ASSERT_EQ(2U, parent->children().size()); |
| 1315 EXPECT_EQ(child1, parent->children()[0]); | 1323 EXPECT_EQ(child1, parent->children()[0]); |
| 1316 EXPECT_EQ(child2, parent->children()[1]); | 1324 EXPECT_EQ(child2, parent->children()[1]); |
| 1317 | 1325 |
| 1318 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | 1326 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
| 1319 | 1327 |
| 1320 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); | 1328 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); |
| 1321 | 1329 |
| 1322 child1->reset_needs_push_properties_for_testing(); | 1330 child1->ResetNeedsPushPropertiesForTesting(); |
| 1323 | 1331 |
| 1324 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); | 1332 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); |
| 1325 | 1333 |
| 1326 EXPECT_TRUE(child1->needs_push_properties()); | 1334 EXPECT_TRUE( |
| 1335 layer_tree_host_->LayerNeedsPushPropertiesForTesting(child1.get())); |
| 1327 | 1336 |
| 1328 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 1337 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| 1329 } | 1338 } |
| 1330 | 1339 |
| 1331 TEST_F(LayerTest, DeleteRemovedScrollChild) { | 1340 TEST_F(LayerTest, DeleteRemovedScrollChild) { |
| 1332 scoped_refptr<Layer> parent = Layer::Create(); | 1341 scoped_refptr<Layer> parent = Layer::Create(); |
| 1333 scoped_refptr<Layer> child1 = Layer::Create(); | 1342 scoped_refptr<Layer> child1 = Layer::Create(); |
| 1334 scoped_refptr<Layer> child2 = Layer::Create(); | 1343 scoped_refptr<Layer> child2 = Layer::Create(); |
| 1335 | 1344 |
| 1336 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 1345 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 1337 | 1346 |
| 1338 ASSERT_EQ(0U, parent->children().size()); | 1347 ASSERT_EQ(0U, parent->children().size()); |
| 1339 | 1348 |
| 1340 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 1349 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
| 1341 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 1350 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
| 1342 | 1351 |
| 1343 ASSERT_EQ(2U, parent->children().size()); | 1352 ASSERT_EQ(2U, parent->children().size()); |
| 1344 EXPECT_EQ(child1, parent->children()[0]); | 1353 EXPECT_EQ(child1, parent->children()[0]); |
| 1345 EXPECT_EQ(child2, parent->children()[1]); | 1354 EXPECT_EQ(child2, parent->children()[1]); |
| 1346 | 1355 |
| 1347 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | 1356 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
| 1348 | 1357 |
| 1349 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); | 1358 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); |
| 1350 | 1359 |
| 1351 child2->reset_needs_push_properties_for_testing(); | 1360 child2->ResetNeedsPushPropertiesForTesting(); |
| 1352 | 1361 |
| 1353 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); | 1362 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); |
| 1354 | 1363 |
| 1355 EXPECT_TRUE(child2->needs_push_properties()); | 1364 EXPECT_TRUE( |
| 1365 layer_tree_host_->LayerNeedsPushPropertiesForTesting(child2.get())); |
| 1356 | 1366 |
| 1357 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 1367 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| 1358 } | 1368 } |
| 1359 | 1369 |
| 1360 TEST_F(LayerTest, ReplaceChildWithSameChild) { | 1370 TEST_F(LayerTest, ReplaceChildWithSameChild) { |
| 1361 CreateSimpleTestTree(); | 1371 CreateSimpleTestTree(); |
| 1362 | 1372 |
| 1363 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the | 1373 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the |
| 1364 // same child. | 1374 // same child. |
| 1365 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 1375 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2436 TEST_F(LayerSerializationTest, | 2446 TEST_F(LayerSerializationTest, |
| 2437 NonDestructiveDeserializationMoveChildEarlierTest) { | 2447 NonDestructiveDeserializationMoveChildEarlierTest) { |
| 2438 RunNonDestructiveDeserializationMoveChildEarlierTest(); | 2448 RunNonDestructiveDeserializationMoveChildEarlierTest(); |
| 2439 } | 2449 } |
| 2440 | 2450 |
| 2441 TEST_F(LayerSerializationTest, | 2451 TEST_F(LayerSerializationTest, |
| 2442 NonDestructiveDeserializationMoveChildLaterTest) { | 2452 NonDestructiveDeserializationMoveChildLaterTest) { |
| 2443 RunNonDestructiveDeserializationMoveChildLaterTest(); | 2453 RunNonDestructiveDeserializationMoveChildLaterTest(); |
| 2444 } | 2454 } |
| 2445 | 2455 |
| 2446 TEST_F(LayerTest, SimplePropertiesSerialization) { | |
| 2447 /* Testing serialization of properties for a tree that looks like this: | |
| 2448 root+ | |
| 2449 / \ | |
| 2450 a* b*+[mask:*,replica] | |
| 2451 / \ | |
| 2452 c d* | |
| 2453 Layers marked with * have changed properties. | |
| 2454 Layers marked with + have descendants with changed properties. | |
| 2455 Layer b also has a mask layer and a replica layer. | |
| 2456 */ | |
| 2457 scoped_refptr<Layer> layer_src_root = Layer::Create(); | |
| 2458 scoped_refptr<Layer> layer_src_a = Layer::Create(); | |
| 2459 scoped_refptr<Layer> layer_src_b = Layer::Create(); | |
| 2460 scoped_refptr<Layer> layer_src_b_mask = Layer::Create(); | |
| 2461 scoped_refptr<Layer> layer_src_b_replica = Layer::Create(); | |
| 2462 scoped_refptr<Layer> layer_src_c = Layer::Create(); | |
| 2463 scoped_refptr<Layer> layer_src_d = Layer::Create(); | |
| 2464 layer_src_root->AddChild(layer_src_a); | |
| 2465 layer_src_root->AddChild(layer_src_b); | |
| 2466 layer_src_a->AddChild(layer_src_c); | |
| 2467 layer_src_b->AddChild(layer_src_d); | |
| 2468 layer_src_b->SetMaskLayer(layer_src_b_mask.get()); | |
| 2469 layer_src_b->SetReplicaLayer(layer_src_b_replica.get()); | |
| 2470 | |
| 2471 proto::LayerUpdate layer_update_root; | |
| 2472 // Only layers with descendants that require pushing properties will | |
| 2473 // return true from ToLayerPropertiesProto and AddChild will change the | |
| 2474 // stacking order of child which will make it push properties. | |
| 2475 EXPECT_TRUE(layer_src_root->ToLayerPropertiesProto(&layer_update_root)); | |
| 2476 proto::LayerUpdate layer_update_a; | |
| 2477 EXPECT_TRUE(layer_src_a->ToLayerPropertiesProto(&layer_update_a)); | |
| 2478 proto::LayerUpdate layer_update_b; | |
| 2479 EXPECT_TRUE(layer_src_b->ToLayerPropertiesProto(&layer_update_b)); | |
| 2480 proto::LayerUpdate layer_update_c; | |
| 2481 EXPECT_FALSE(layer_src_c->ToLayerPropertiesProto(&layer_update_c)); | |
| 2482 proto::LayerUpdate layer_update_d; | |
| 2483 EXPECT_FALSE(layer_src_d->ToLayerPropertiesProto(&layer_update_d)); | |
| 2484 layer_update_root.Clear(); | |
| 2485 layer_update_a.Clear(); | |
| 2486 layer_update_b.Clear(); | |
| 2487 layer_update_c.Clear(); | |
| 2488 layer_update_d.Clear(); | |
| 2489 | |
| 2490 layer_src_a->SetNeedsPushProperties(); | |
| 2491 layer_src_b->SetNeedsPushProperties(); | |
| 2492 layer_src_b_mask->SetNeedsPushProperties(); | |
| 2493 layer_src_d->SetNeedsPushProperties(); | |
| 2494 | |
| 2495 // Only layers with descendants that require pushing properties will | |
| 2496 // return true from ToLayerPropertiesProto. | |
| 2497 EXPECT_TRUE(layer_src_root->ToLayerPropertiesProto(&layer_update_root)); | |
| 2498 EXPECT_FALSE(layer_src_a->ToLayerPropertiesProto(&layer_update_a)); | |
| 2499 EXPECT_TRUE(layer_src_b->ToLayerPropertiesProto(&layer_update_b)); | |
| 2500 proto::LayerUpdate layer_update_b_mask; | |
| 2501 EXPECT_FALSE(layer_src_b_mask->ToLayerPropertiesProto(&layer_update_b_mask)); | |
| 2502 proto::LayerUpdate layer_update_b_replica; | |
| 2503 EXPECT_FALSE( | |
| 2504 layer_src_b_replica->ToLayerPropertiesProto(&layer_update_b_replica)); | |
| 2505 EXPECT_FALSE(layer_src_c->ToLayerPropertiesProto(&layer_update_c)); | |
| 2506 EXPECT_FALSE(layer_src_d->ToLayerPropertiesProto(&layer_update_d)); | |
| 2507 | |
| 2508 // All flags for pushing properties should have been cleared. | |
| 2509 EXPECT_FALSE(layer_src_root->needs_push_properties()); | |
| 2510 EXPECT_FALSE(layer_src_root->descendant_needs_push_properties()); | |
| 2511 EXPECT_FALSE(layer_src_a->needs_push_properties()); | |
| 2512 EXPECT_FALSE(layer_src_a->descendant_needs_push_properties()); | |
| 2513 EXPECT_FALSE(layer_src_b->needs_push_properties()); | |
| 2514 EXPECT_FALSE(layer_src_b->descendant_needs_push_properties()); | |
| 2515 EXPECT_FALSE(layer_src_b_mask->needs_push_properties()); | |
| 2516 EXPECT_FALSE(layer_src_b_mask->descendant_needs_push_properties()); | |
| 2517 EXPECT_FALSE(layer_src_b_replica->needs_push_properties()); | |
| 2518 EXPECT_FALSE(layer_src_b_replica->descendant_needs_push_properties()); | |
| 2519 EXPECT_FALSE(layer_src_c->needs_push_properties()); | |
| 2520 EXPECT_FALSE(layer_src_c->descendant_needs_push_properties()); | |
| 2521 EXPECT_FALSE(layer_src_d->needs_push_properties()); | |
| 2522 EXPECT_FALSE(layer_src_d->descendant_needs_push_properties()); | |
| 2523 | |
| 2524 // Only 5 of the layers should have been serialized. | |
| 2525 ASSERT_EQ(1, layer_update_root.layers_size()); | |
| 2526 EXPECT_EQ(layer_src_root->id(), layer_update_root.layers(0).id()); | |
| 2527 proto::LayerProperties dest_root = layer_update_root.layers(0); | |
| 2528 ASSERT_EQ(1, layer_update_a.layers_size()); | |
| 2529 EXPECT_EQ(layer_src_a->id(), layer_update_a.layers(0).id()); | |
| 2530 proto::LayerProperties dest_a = layer_update_a.layers(0); | |
| 2531 ASSERT_EQ(1, layer_update_b.layers_size()); | |
| 2532 EXPECT_EQ(layer_src_b->id(), layer_update_b.layers(0).id()); | |
| 2533 proto::LayerProperties dest_b = layer_update_b.layers(0); | |
| 2534 ASSERT_EQ(1, layer_update_b_mask.layers_size()); | |
| 2535 EXPECT_EQ(layer_src_b_mask->id(), layer_update_b_mask.layers(0).id()); | |
| 2536 proto::LayerProperties dest_b_mask = layer_update_b_mask.layers(0); | |
| 2537 EXPECT_EQ(0, layer_update_b_replica.layers_size()); | |
| 2538 EXPECT_EQ(0, layer_update_c.layers_size()); | |
| 2539 ASSERT_EQ(1, layer_update_d.layers_size()); | |
| 2540 EXPECT_EQ(layer_src_d->id(), layer_update_d.layers(0).id()); | |
| 2541 proto::LayerProperties dest_d = layer_update_d.layers(0); | |
| 2542 | |
| 2543 // Ensure the properties and dependants metadata is correctly serialized. | |
| 2544 EXPECT_FALSE(dest_root.needs_push_properties()); | |
| 2545 EXPECT_EQ(2, dest_root.num_dependents_need_push_properties()); | |
| 2546 EXPECT_FALSE(dest_root.has_base()); | |
| 2547 | |
| 2548 EXPECT_TRUE(dest_a.needs_push_properties()); | |
| 2549 EXPECT_EQ(0, dest_a.num_dependents_need_push_properties()); | |
| 2550 EXPECT_TRUE(dest_a.has_base()); | |
| 2551 | |
| 2552 EXPECT_TRUE(dest_b.needs_push_properties()); | |
| 2553 EXPECT_EQ(2, dest_b.num_dependents_need_push_properties()); | |
| 2554 EXPECT_TRUE(dest_b.has_base()); | |
| 2555 | |
| 2556 EXPECT_TRUE(dest_d.needs_push_properties()); | |
| 2557 EXPECT_EQ(0, dest_d.num_dependents_need_push_properties()); | |
| 2558 EXPECT_TRUE(dest_d.has_base()); | |
| 2559 | |
| 2560 EXPECT_TRUE(dest_b_mask.needs_push_properties()); | |
| 2561 EXPECT_EQ(0, dest_b_mask.num_dependents_need_push_properties()); | |
| 2562 EXPECT_TRUE(dest_b_mask.has_base()); | |
| 2563 } | |
| 2564 | |
| 2565 TEST_F(LayerSerializationTest, SimplePropertiesDeserialization) { | |
| 2566 scoped_refptr<Layer> layer = Layer::Create(); | |
| 2567 layer->SetLayerTreeHost(layer_tree_host_.get()); | |
| 2568 proto::LayerProperties properties; | |
| 2569 properties.set_id(layer->id()); | |
| 2570 | |
| 2571 properties.set_needs_push_properties(true); | |
| 2572 properties.set_num_dependents_need_push_properties(2); | |
| 2573 properties.mutable_base(); | |
| 2574 layer->FromLayerPropertiesProto(properties); | |
| 2575 EXPECT_TRUE(layer->needs_push_properties()); | |
| 2576 EXPECT_TRUE(layer->descendant_needs_push_properties()); | |
| 2577 | |
| 2578 properties.set_needs_push_properties(false); | |
| 2579 properties.mutable_base()->Clear(); | |
| 2580 layer->FromLayerPropertiesProto(properties); | |
| 2581 EXPECT_FALSE(layer->needs_push_properties()); | |
| 2582 EXPECT_TRUE(layer->descendant_needs_push_properties()); | |
| 2583 | |
| 2584 properties.set_num_dependents_need_push_properties(0); | |
| 2585 layer->FromLayerPropertiesProto(properties); | |
| 2586 EXPECT_FALSE(layer->needs_push_properties()); | |
| 2587 EXPECT_FALSE(layer->descendant_needs_push_properties()); | |
| 2588 | |
| 2589 properties.set_needs_push_properties(true); | |
| 2590 properties.mutable_base(); | |
| 2591 layer->FromLayerPropertiesProto(properties); | |
| 2592 EXPECT_TRUE(layer->needs_push_properties()); | |
| 2593 EXPECT_FALSE(layer->descendant_needs_push_properties()); | |
| 2594 | |
| 2595 layer->SetLayerTreeHost(nullptr); | |
| 2596 } | |
| 2597 | |
| 2598 TEST_F(LayerSerializationTest, NoMembersChanged) { | 2456 TEST_F(LayerSerializationTest, NoMembersChanged) { |
| 2599 RunNoMembersChangedTest(); | 2457 RunNoMembersChangedTest(); |
| 2600 } | 2458 } |
| 2601 | 2459 |
| 2602 TEST_F(LayerSerializationTest, ArbitraryMembersChanged) { | 2460 TEST_F(LayerSerializationTest, ArbitraryMembersChanged) { |
| 2603 RunArbitraryMembersChangedTest(); | 2461 RunArbitraryMembersChangedTest(); |
| 2604 } | 2462 } |
| 2605 | 2463 |
| 2606 TEST_F(LayerSerializationTest, AllMembersChanged) { | 2464 TEST_F(LayerSerializationTest, AllMembersChanged) { |
| 2607 RunAllMembersChangedTest(); | 2465 RunAllMembersChangedTest(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2628 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2486 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2629 | 2487 |
| 2630 test_layer->PushPropertiesTo(impl_layer.get()); | 2488 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2631 | 2489 |
| 2632 EXPECT_EQ(2lu, impl_layer->element_id()); | 2490 EXPECT_EQ(2lu, impl_layer->element_id()); |
| 2633 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2491 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2634 } | 2492 } |
| 2635 | 2493 |
| 2636 } // namespace | 2494 } // namespace |
| 2637 } // namespace cc | 2495 } // namespace cc |
| OLD | NEW |