Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: cc/test/animation_timelines_test_common.cc

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/animation_timelines_test_common.h ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 scroll_offset_ = scroll_offset; 173 scroll_offset_ = scroll_offset;
174 } 174 }
175 175
176 gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( 176 gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation(
177 ElementId element_id) const { 177 ElementId element_id) const {
178 return scroll_offset_; 178 return scroll_offset_;
179 } 179 }
180 180
181 void TestHostClient::RegisterElement(ElementId element_id, 181 void TestHostClient::RegisterElement(ElementId element_id,
182 ElementListType list_type) { 182 ElementListType list_type) {
183 LayerIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE 183 ElementIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE
184 ? layers_in_active_tree_ 184 ? layers_in_active_tree_
185 : layers_in_pending_tree_; 185 : layers_in_pending_tree_;
186 DCHECK(layers_in_tree.find(element_id) == layers_in_tree.end()); 186 DCHECK(layers_in_tree.find(element_id) == layers_in_tree.end());
187 layers_in_tree[element_id] = TestLayer::Create(); 187 layers_in_tree[element_id] = TestLayer::Create();
188 188
189 DCHECK(host_); 189 DCHECK(host_);
190 host_->RegisterElement(element_id, list_type); 190 host_->RegisterElement(element_id, list_type);
191 } 191 }
192 192
193 void TestHostClient::UnregisterElement(ElementId element_id, 193 void TestHostClient::UnregisterElement(ElementId element_id,
194 ElementListType list_type) { 194 ElementListType list_type) {
195 DCHECK(host_); 195 DCHECK(host_);
196 host_->UnregisterElement(element_id, list_type); 196 host_->UnregisterElement(element_id, list_type);
197 197
198 LayerIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE 198 ElementIdToTestLayer& layers_in_tree = list_type == ElementListType::ACTIVE
199 ? layers_in_active_tree_ 199 ? layers_in_active_tree_
200 : layers_in_pending_tree_; 200 : layers_in_pending_tree_;
201 auto kv = layers_in_tree.find(element_id); 201 auto kv = layers_in_tree.find(element_id);
202 DCHECK(kv != layers_in_tree.end()); 202 DCHECK(kv != layers_in_tree.end());
203 layers_in_tree.erase(kv); 203 layers_in_tree.erase(kv);
204 } 204 }
205 205
206 bool TestHostClient::IsPropertyMutated(ElementId element_id, 206 bool TestHostClient::IsPropertyMutated(ElementId element_id,
207 ElementListType list_type, 207 ElementListType list_type,
208 TargetProperty::Type property) const { 208 TargetProperty::Type property) const {
209 TestLayer* layer = FindTestLayer(element_id, list_type); 209 TestLayer* layer = FindTestLayer(element_id, list_type);
210 EXPECT_TRUE(layer); 210 EXPECT_TRUE(layer);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 int transform_y) const { 296 int transform_y) const {
297 TestLayer* layer = FindTestLayer(element_id, list_type); 297 TestLayer* layer = FindTestLayer(element_id, list_type);
298 EXPECT_TRUE(layer); 298 EXPECT_TRUE(layer);
299 EXPECT_TRUE(layer->is_property_mutated(TargetProperty::TRANSFORM)); 299 EXPECT_TRUE(layer->is_property_mutated(TargetProperty::TRANSFORM));
300 EXPECT_EQ(transform_x, layer->transform_x()); 300 EXPECT_EQ(transform_x, layer->transform_x());
301 EXPECT_EQ(transform_y, layer->transform_y()); 301 EXPECT_EQ(transform_y, layer->transform_y());
302 } 302 }
303 303
304 TestLayer* TestHostClient::FindTestLayer(ElementId element_id, 304 TestLayer* TestHostClient::FindTestLayer(ElementId element_id,
305 ElementListType list_type) const { 305 ElementListType list_type) const {
306 const LayerIdToTestLayer& layers_in_tree = 306 const ElementIdToTestLayer& layers_in_tree =
307 list_type == ElementListType::ACTIVE ? layers_in_active_tree_ 307 list_type == ElementListType::ACTIVE ? layers_in_active_tree_
308 : layers_in_pending_tree_; 308 : layers_in_pending_tree_;
309 auto kv = layers_in_tree.find(element_id); 309 auto kv = layers_in_tree.find(element_id);
310 if (kv == layers_in_tree.end()) 310 if (kv == layers_in_tree.end())
311 return nullptr; 311 return nullptr;
312 312
313 DCHECK(kv->second); 313 DCHECK(kv->second);
314 return kv->second.get(); 314 return kv->second.get();
315 } 315 }
316 316
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 : client_(ThreadInstance::MAIN), 355 : client_(ThreadInstance::MAIN),
356 client_impl_(ThreadInstance::IMPL), 356 client_impl_(ThreadInstance::IMPL),
357 host_(nullptr), 357 host_(nullptr),
358 host_impl_(nullptr), 358 host_impl_(nullptr),
359 timeline_id_(AnimationIdProvider::NextTimelineId()), 359 timeline_id_(AnimationIdProvider::NextTimelineId()),
360 player_id_(AnimationIdProvider::NextPlayerId()), 360 player_id_(AnimationIdProvider::NextPlayerId()),
361 next_test_layer_id_(0) { 361 next_test_layer_id_(0) {
362 host_ = client_.host(); 362 host_ = client_.host();
363 host_impl_ = client_impl_.host(); 363 host_impl_ = client_impl_.host();
364 364
365 element_id_ = NextTestLayerId(); 365 element_id_ = ElementId(NextTestLayerId(), 0);
366 } 366 }
367 367
368 AnimationTimelinesTest::~AnimationTimelinesTest() { 368 AnimationTimelinesTest::~AnimationTimelinesTest() {
369 } 369 }
370 370
371 void AnimationTimelinesTest::SetUp() { 371 void AnimationTimelinesTest::SetUp() {
372 timeline_ = AnimationTimeline::Create(timeline_id_); 372 timeline_ = AnimationTimeline::Create(timeline_id_);
373 player_ = AnimationPlayer::Create(player_id_); 373 player_ = AnimationPlayer::Create(player_id_);
374 } 374 }
375 375
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 444
445 host_impl_->AnimateLayers(time); 445 host_impl_->AnimateLayers(time);
446 host_impl_->UpdateAnimationState(true, events.get()); 446 host_impl_->UpdateAnimationState(true, events.get());
447 EXPECT_EQ(expect_events, events->events_.size()); 447 EXPECT_EQ(expect_events, events->events_.size());
448 448
449 host_->AnimateLayers(time); 449 host_->AnimateLayers(time);
450 host_->UpdateAnimationState(true, nullptr); 450 host_->UpdateAnimationState(true, nullptr);
451 host_->SetAnimationEvents(std::move(events)); 451 host_->SetAnimationEvents(std::move(events));
452 } 452 }
453 453
454 AnimationPlayer* AnimationTimelinesTest::GetPlayerForLayerId( 454 AnimationPlayer* AnimationTimelinesTest::GetPlayerForElementId(
455 ElementId element_id) { 455 ElementId element_id) {
456 const scoped_refptr<ElementAnimations> element_animations = 456 const scoped_refptr<ElementAnimations> element_animations =
457 host_->GetElementAnimationsForElementId(element_id); 457 host_->GetElementAnimationsForElementId(element_id);
458 return element_animations ? element_animations->players_list().head()->value() 458 return element_animations ? element_animations->players_list().head()->value()
459 : nullptr; 459 : nullptr;
460 } 460 }
461 461
462 AnimationPlayer* AnimationTimelinesTest::GetImplPlayerForLayerId( 462 AnimationPlayer* AnimationTimelinesTest::GetImplPlayerForLayerId(
463 ElementId element_id) { 463 ElementId element_id) {
464 const scoped_refptr<ElementAnimations> element_animations = 464 const scoped_refptr<ElementAnimations> element_animations =
465 host_impl_->GetElementAnimationsForElementId(element_id); 465 host_impl_->GetElementAnimationsForElementId(element_id);
466 return element_animations ? element_animations->players_list().head()->value() 466 return element_animations ? element_animations->players_list().head()->value()
467 : nullptr; 467 : nullptr;
468 } 468 }
469 469
470 int AnimationTimelinesTest::NextTestLayerId() { 470 int AnimationTimelinesTest::NextTestLayerId() {
471 next_test_layer_id_++; 471 next_test_layer_id_++;
472 return next_test_layer_id_; 472 return next_test_layer_id_;
473 } 473 }
474 474
475 } // namespace cc 475 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/animation_timelines_test_common.h ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698