| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/test/animation_timelines_test_common.h" | 5 #include "cc/test/animation_timelines_test_common.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/animation/animation_events.h" | 8 #include "cc/animation/animation_events.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void TestHostClient::ClearMutatedProperties() { | 72 void TestHostClient::ClearMutatedProperties() { |
| 73 for (auto& kv : layers_in_pending_tree_) | 73 for (auto& kv : layers_in_pending_tree_) |
| 74 kv.second->ClearMutatedProperties(); | 74 kv.second->ClearMutatedProperties(); |
| 75 for (auto& kv : layers_in_active_tree_) | 75 for (auto& kv : layers_in_active_tree_) |
| 76 kv.second->ClearMutatedProperties(); | 76 kv.second->ClearMutatedProperties(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool TestHostClient::IsElementInList(ElementId element_id, | 79 bool TestHostClient::IsElementInList(ElementId element_id, |
| 80 ElementListType list_type) const { | 80 ElementListType list_type) const { |
| 81 return list_type == ElementListType::ACTIVE | 81 return list_type == ElementListType::ACTIVE |
| 82 ? layers_in_active_tree_.count(element_id) | 82 ? layers_in_active_tree_.count(element_id.id) |
| 83 : layers_in_pending_tree_.count(element_id); | 83 : layers_in_pending_tree_.count(element_id.id); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void TestHostClient::SetMutatorsNeedCommit() { | 86 void TestHostClient::SetMutatorsNeedCommit() { |
| 87 mutators_need_commit_ = true; | 87 mutators_need_commit_ = true; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void TestHostClient::SetMutatorsNeedRebuildPropertyTrees() {} | 90 void TestHostClient::SetMutatorsNeedRebuildPropertyTrees() {} |
| 91 | 91 |
| 92 void TestHostClient::SetElementFilterMutated(ElementId element_id, | 92 void TestHostClient::SetElementFilterMutated(ElementId element_id, |
| 93 ElementListType list_type, | 93 ElementListType list_type, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( | 153 gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( |
| 154 ElementId element_id) const { | 154 ElementId element_id) const { |
| 155 return scroll_offset_; | 155 return scroll_offset_; |
| 156 } | 156 } |
| 157 | 157 |
| 158 void TestHostClient::RegisterElement(ElementId element_id, | 158 void TestHostClient::RegisterElement(ElementId element_id, |
| 159 ElementListType list_type) { | 159 ElementListType list_type) { |
| 160 ElementIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE | 160 ElementIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE |
| 161 ? layers_in_active_tree_ | 161 ? layers_in_active_tree_ |
| 162 : layers_in_pending_tree_; | 162 : layers_in_pending_tree_; |
| 163 DCHECK(layers_in_tree.find(element_id) == layers_in_tree.end()); | 163 DCHECK(layers_in_tree.find(element_id.id) == layers_in_tree.end()); |
| 164 layers_in_tree[element_id] = TestLayer::Create(); | 164 layers_in_tree[element_id.id] = TestLayer::Create(); |
| 165 | 165 |
| 166 DCHECK(host_); | 166 DCHECK(host_); |
| 167 host_->RegisterElement(element_id, list_type); | 167 host_->RegisterElement(element_id, list_type); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void TestHostClient::UnregisterElement(ElementId element_id, | 170 void TestHostClient::UnregisterElement(ElementId element_id, |
| 171 ElementListType list_type) { | 171 ElementListType list_type) { |
| 172 DCHECK(host_); | 172 DCHECK(host_); |
| 173 host_->UnregisterElement(element_id, list_type); | 173 host_->UnregisterElement(element_id, list_type); |
| 174 | 174 |
| 175 ElementIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE | 175 ElementIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE |
| 176 ? layers_in_active_tree_ | 176 ? layers_in_active_tree_ |
| 177 : layers_in_pending_tree_; | 177 : layers_in_pending_tree_; |
| 178 auto kv = layers_in_tree.find(element_id); | 178 auto kv = layers_in_tree.find(element_id.id); |
| 179 DCHECK(kv != layers_in_tree.end()); | 179 DCHECK(kv != layers_in_tree.end()); |
| 180 layers_in_tree.erase(kv); | 180 layers_in_tree.erase(kv); |
| 181 } | 181 } |
| 182 | 182 |
| 183 bool TestHostClient::IsPropertyMutated(ElementId element_id, | 183 bool TestHostClient::IsPropertyMutated(ElementId element_id, |
| 184 ElementListType list_type, | 184 ElementListType list_type, |
| 185 TargetProperty::Type property) const { | 185 TargetProperty::Type property) const { |
| 186 TestLayer* layer = FindTestLayer(element_id, list_type); | 186 TestLayer* layer = FindTestLayer(element_id, list_type); |
| 187 EXPECT_TRUE(layer); | 187 EXPECT_TRUE(layer); |
| 188 return layer->is_property_mutated(property); | 188 return layer->is_property_mutated(property); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 EXPECT_TRUE(layer->is_property_mutated(TargetProperty::TRANSFORM)); | 292 EXPECT_TRUE(layer->is_property_mutated(TargetProperty::TRANSFORM)); |
| 293 EXPECT_EQ(transform_x, layer->transform_x()); | 293 EXPECT_EQ(transform_x, layer->transform_x()); |
| 294 EXPECT_EQ(transform_y, layer->transform_y()); | 294 EXPECT_EQ(transform_y, layer->transform_y()); |
| 295 } | 295 } |
| 296 | 296 |
| 297 TestLayer* TestHostClient::FindTestLayer(ElementId element_id, | 297 TestLayer* TestHostClient::FindTestLayer(ElementId element_id, |
| 298 ElementListType list_type) const { | 298 ElementListType list_type) const { |
| 299 const ElementIdToTestLayer& layers_in_tree = | 299 const ElementIdToTestLayer& layers_in_tree = |
| 300 list_type == ElementListType::ACTIVE ? layers_in_active_tree_ | 300 list_type == ElementListType::ACTIVE ? layers_in_active_tree_ |
| 301 : layers_in_pending_tree_; | 301 : layers_in_pending_tree_; |
| 302 auto kv = layers_in_tree.find(element_id); | 302 auto kv = layers_in_tree.find(element_id.id); |
| 303 if (kv == layers_in_tree.end()) | 303 if (kv == layers_in_tree.end()) |
| 304 return nullptr; | 304 return nullptr; |
| 305 | 305 |
| 306 DCHECK(kv->second); | 306 DCHECK(kv->second); |
| 307 return kv->second.get(); | 307 return kv->second.get(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 TestAnimationDelegate::TestAnimationDelegate() | 310 TestAnimationDelegate::TestAnimationDelegate() |
| 311 : started_(false), | 311 : started_(false), |
| 312 finished_(false), | 312 finished_(false), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 : client_(ThreadInstance::MAIN), | 348 : client_(ThreadInstance::MAIN), |
| 349 client_impl_(ThreadInstance::IMPL), | 349 client_impl_(ThreadInstance::IMPL), |
| 350 host_(nullptr), | 350 host_(nullptr), |
| 351 host_impl_(nullptr), | 351 host_impl_(nullptr), |
| 352 timeline_id_(AnimationIdProvider::NextTimelineId()), | 352 timeline_id_(AnimationIdProvider::NextTimelineId()), |
| 353 player_id_(AnimationIdProvider::NextPlayerId()), | 353 player_id_(AnimationIdProvider::NextPlayerId()), |
| 354 next_test_layer_id_(0) { | 354 next_test_layer_id_(0) { |
| 355 host_ = client_.host(); | 355 host_ = client_.host(); |
| 356 host_impl_ = client_impl_.host(); | 356 host_impl_ = client_impl_.host(); |
| 357 | 357 |
| 358 element_id_ = ElementId(NextTestLayerId(), 0); | 358 element_id_.id = NextTestLayerId(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 AnimationTimelinesTest::~AnimationTimelinesTest() { | 361 AnimationTimelinesTest::~AnimationTimelinesTest() { |
| 362 } | 362 } |
| 363 | 363 |
| 364 void AnimationTimelinesTest::SetUp() { | 364 void AnimationTimelinesTest::SetUp() { |
| 365 timeline_ = AnimationTimeline::Create(timeline_id_); | 365 timeline_ = AnimationTimeline::Create(timeline_id_); |
| 366 player_ = AnimationPlayer::Create(player_id_); | 366 player_ = AnimationPlayer::Create(player_id_); |
| 367 } | 367 } |
| 368 | 368 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 488 } |
| 489 | 489 |
| 490 return result; | 490 return result; |
| 491 } | 491 } |
| 492 | 492 |
| 493 void AnimationTimelinesTest::PushProperties() { | 493 void AnimationTimelinesTest::PushProperties() { |
| 494 host_->PushPropertiesTo(host_impl_); | 494 host_->PushPropertiesTo(host_impl_); |
| 495 } | 495 } |
| 496 | 496 |
| 497 } // namespace cc | 497 } // namespace cc |
| OLD | NEW |