| 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/trees/tree_synchronizer.h" | 5 #include "cc/trees/tree_synchronizer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 if (layer_clip_parent) { | 136 if (layer_clip_parent) { |
| 137 const std::set<Layer*>* clip_children = | 137 const std::set<Layer*>* clip_children = |
| 138 layer_clip_parent->clip_children(); | 138 layer_clip_parent->clip_children(); |
| 139 ASSERT_TRUE(clip_children->find(layer) != clip_children->end()); | 139 ASSERT_TRUE(clip_children->find(layer) != clip_children->end()); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 class TreeSynchronizerTest : public testing::Test { | 144 class TreeSynchronizerTest : public testing::Test { |
| 145 public: | 145 protected: |
| 146 TreeSynchronizerTest() | 146 TreeSynchronizerTest() |
| 147 : client_(FakeLayerTreeHostClient::DIRECT_3D), | 147 : host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {} |
| 148 host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {} | |
| 149 | |
| 150 protected: | |
| 151 FakeLayerTreeHostClient client_; | |
| 152 TestTaskGraphRunner task_graph_runner_; | |
| 153 std::unique_ptr<FakeLayerTreeHost> host_; | |
| 154 | 148 |
| 155 bool is_equal(ScrollTree::ScrollOffsetMap map, | 149 bool is_equal(ScrollTree::ScrollOffsetMap map, |
| 156 ScrollTree::ScrollOffsetMap other) { | 150 ScrollTree::ScrollOffsetMap other) { |
| 157 if (map.size() != other.size()) | 151 if (map.size() != other.size()) |
| 158 return false; | 152 return false; |
| 159 for (auto& map_entry : map) { | 153 for (auto& map_entry : map) { |
| 160 if (other.find(map_entry.first) == other.end()) | 154 if (other.find(map_entry.first) == other.end()) |
| 161 return false; | 155 return false; |
| 162 SyncedScrollOffset& from_map = *map_entry.second.get(); | 156 SyncedScrollOffset& from_map = *map_entry.second.get(); |
| 163 SyncedScrollOffset& from_other = *other[map_entry.first].get(); | 157 SyncedScrollOffset& from_other = *other[map_entry.first].get(); |
| 164 if (from_map.PendingBase() != from_other.PendingBase() || | 158 if (from_map.PendingBase() != from_other.PendingBase() || |
| 165 from_map.ActiveBase() != from_other.ActiveBase() || | 159 from_map.ActiveBase() != from_other.ActiveBase() || |
| 166 from_map.Delta() != from_other.Delta() || | 160 from_map.Delta() != from_other.Delta() || |
| 167 from_map.PendingDelta().get() != from_other.PendingDelta().get()) | 161 from_map.PendingDelta().get() != from_other.PendingDelta().get()) |
| 168 return false; | 162 return false; |
| 169 } | 163 } |
| 170 return true; | 164 return true; |
| 171 } | 165 } |
| 166 |
| 167 FakeLayerTreeHostClient client_; |
| 168 TestTaskGraphRunner task_graph_runner_; |
| 169 std::unique_ptr<FakeLayerTreeHost> host_; |
| 172 }; | 170 }; |
| 173 | 171 |
| 174 // Attempts to synchronizes a null tree. This should not crash, and should | 172 // Attempts to synchronizes a null tree. This should not crash, and should |
| 175 // return a null tree. | 173 // return a null tree. |
| 176 TEST_F(TreeSynchronizerTest, SyncNullTree) { | 174 TEST_F(TreeSynchronizerTest, SyncNullTree) { |
| 177 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL), | 175 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL), |
| 178 host_->active_tree()); | 176 host_->active_tree()); |
| 179 EXPECT_TRUE(!host_->active_tree()->root_layer_for_testing()); | 177 EXPECT_TRUE(!host_->active_tree()->root_layer_for_testing()); |
| 180 } | 178 } |
| 181 | 179 |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 host_->CommitAndCreatePendingTree(); | 697 host_->CommitAndCreatePendingTree(); |
| 700 host_impl->ActivateSyncTree(); | 698 host_impl->ActivateSyncTree(); |
| 701 EXPECT_EQ( | 699 EXPECT_EQ( |
| 702 CombinedAnimationScale(0.f, 0.f), | 700 CombinedAnimationScale(0.f, 0.f), |
| 703 host_impl->active_tree()->property_trees()->GetAnimationScales( | 701 host_impl->active_tree()->property_trees()->GetAnimationScales( |
| 704 transform_layer->transform_tree_index(), host_impl->active_tree())); | 702 transform_layer->transform_tree_index(), host_impl->active_tree())); |
| 705 } | 703 } |
| 706 | 704 |
| 707 } // namespace | 705 } // namespace |
| 708 } // namespace cc | 706 } // namespace cc |
| OLD | NEW |