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

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 231133002: CC::Animations should use TimeTicks & TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review changes. Created 6 years, 7 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "cc/animation/animation_curve.h" 7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/layer_animation_controller.h" 8 #include "cc/animation/layer_animation_controller.h"
9 #include "cc/animation/scroll_offset_animation_curve.h" 9 #include "cc/animation/scroll_offset_animation_curve.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
11 #include "cc/base/time_util.h"
11 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
12 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
13 #include "cc/test/animation_test_common.h" 14 #include "cc/test/animation_test_common.h"
14 #include "cc/test/fake_content_layer.h" 15 #include "cc/test/fake_content_layer.h"
15 #include "cc/test/fake_content_layer_client.h" 16 #include "cc/test/fake_content_layer_client.h"
16 #include "cc/test/layer_tree_test.h" 17 #include "cc/test/layer_tree_test.h"
17 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
18 19
19 namespace cc { 20 namespace cc {
20 namespace { 21 namespace {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 562 }
562 563
563 virtual void NotifyAnimationStarted( 564 virtual void NotifyAnimationStarted(
564 base::TimeTicks monotonic_time, 565 base::TimeTicks monotonic_time,
565 Animation::TargetProperty target_property) OVERRIDE { 566 Animation::TargetProperty target_property) OVERRIDE {
566 LayerAnimationController* controller = 567 LayerAnimationController* controller =
567 layer_tree_host()->root_layer()->children()[0]-> 568 layer_tree_host()->root_layer()->children()[0]->
568 layer_animation_controller(); 569 layer_animation_controller();
569 Animation* animation = 570 Animation* animation =
570 controller->GetAnimation(Animation::Opacity); 571 controller->GetAnimation(Animation::Opacity);
571 main_start_time_ = animation->start_time(); 572 main_start_time_ = TimeUtil::TicksInSecondsF(animation->start_time());
572 controller->RemoveAnimation(animation->id()); 573 controller->RemoveAnimation(animation->id());
573 574
574 if (impl_start_time_ > 0.0) 575 if (impl_start_time_ > 0.0)
575 EndTest(); 576 EndTest();
576 } 577 }
577 578
578 virtual void UpdateAnimationState( 579 virtual void UpdateAnimationState(
579 LayerTreeHostImpl* impl_host, 580 LayerTreeHostImpl* impl_host,
580 bool has_unfinished_animation) OVERRIDE { 581 bool has_unfinished_animation) OVERRIDE {
581 LayerAnimationController* controller = 582 LayerAnimationController* controller =
582 impl_host->active_tree()->root_layer()->children()[0]-> 583 impl_host->active_tree()->root_layer()->children()[0]->
583 layer_animation_controller(); 584 layer_animation_controller();
584 Animation* animation = 585 Animation* animation =
585 controller->GetAnimation(Animation::Opacity); 586 controller->GetAnimation(Animation::Opacity);
586 if (!animation) 587 if (!animation)
587 return; 588 return;
588 589
589 impl_start_time_ = animation->start_time(); 590 impl_start_time_ = TimeUtil::TicksInSecondsF(animation->start_time());
590 controller->RemoveAnimation(animation->id()); 591 controller->RemoveAnimation(animation->id());
591 592
592 if (main_start_time_ > 0.0) 593 if (main_start_time_ > 0.0)
593 EndTest(); 594 EndTest();
594 } 595 }
595 596
596 virtual void AfterTest() OVERRIDE { 597 virtual void AfterTest() OVERRIDE {
597 EXPECT_FLOAT_EQ(impl_start_time_, main_start_time_); 598 EXPECT_FLOAT_EQ(impl_start_time_, main_start_time_);
598 } 599 }
599 600
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 AnimationRegistrar::AnimationControllerMap copy = 1362 AnimationRegistrar::AnimationControllerMap copy =
1362 host_impl->animation_registrar()->active_animation_controllers(); 1363 host_impl->animation_registrar()->active_animation_controllers();
1363 EXPECT_EQ(2u, copy.size()); 1364 EXPECT_EQ(2u, copy.size());
1364 for (AnimationRegistrar::AnimationControllerMap::iterator iter = 1365 for (AnimationRegistrar::AnimationControllerMap::iterator iter =
1365 copy.begin(); 1366 copy.begin();
1366 iter != copy.end(); 1367 iter != copy.end();
1367 ++iter) { 1368 ++iter) {
1368 int id = ((*iter).second->id()); 1369 int id = ((*iter).second->id());
1369 if (id == host_impl->RootLayer()->id()) { 1370 if (id == host_impl->RootLayer()->id()) {
1370 Animation* anim = (*iter).second->GetAnimation(Animation::Transform); 1371 Animation* anim = (*iter).second->GetAnimation(Animation::Transform);
1371 EXPECT_GT(anim->start_time(), 0); 1372 EXPECT_GT(TimeUtil::TicksInSecondsF(anim->start_time()), 0);
1372 } else if (id == host_impl->RootLayer()->children()[0]->id()) { 1373 } else if (id == host_impl->RootLayer()->children()[0]->id()) {
1373 Animation* anim = (*iter).second->GetAnimation(Animation::Opacity); 1374 Animation* anim = (*iter).second->GetAnimation(Animation::Opacity);
1374 EXPECT_GT(anim->start_time(), 0); 1375 EXPECT_GT(TimeUtil::TicksInSecondsF(anim->start_time()), 0);
1375 } 1376 }
1376 } 1377 }
1377 } 1378 }
1378 } 1379 }
1379 1380
1380 virtual void AfterTest() OVERRIDE {} 1381 virtual void AfterTest() OVERRIDE {}
1381 1382
1382 private: 1383 private:
1383 scoped_refptr<Layer> content_; 1384 scoped_refptr<Layer> content_;
1384 int num_swap_buffers_; 1385 int num_swap_buffers_;
1385 }; 1386 };
1386 1387
1387 SINGLE_AND_MULTI_THREAD_TEST_F( 1388 SINGLE_AND_MULTI_THREAD_TEST_F(
1388 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1389 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1389 1390
1390 } // namespace 1391 } // namespace
1391 } // namespace cc 1392 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698