diff options
author | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-22 18:24:16 +0000 |
---|---|---|
committer | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-22 18:24:16 +0000 |
commit | 35ff8a00599034d0803fcf4532b48c11e14342ef (patch) | |
tree | 480ef9bcf27b2bd756e2f69a426d5a98a2410ec7 /cc/animation | |
parent | 4643d699bdfa6d5c3567714c68869d7bc3b57265 (diff) | |
download | chromium_src-35ff8a00599034d0803fcf4532b48c11e14342ef.zip chromium_src-35ff8a00599034d0803fcf4532b48c11e14342ef.tar.gz chromium_src-35ff8a00599034d0803fcf4532b48c11e14342ef.tar.bz2 |
Enable tests for AnimationFinished notifications
This enables checks that animations finished, in tests that were added
by https://codereview.chromium.org/13613003. These checks can now be
enabled, since https://codereview.chromium.org/13465014 has landed.
This also changes animation_test_common.cc to use AnimationIdProvider
to obtain animation group ids, rather than always using group id 0.
Using unique group ids is required for enabling one of the
AnimationFinished checks.
BUG=None
Review URL: https://chromiumcodereview.appspot.com/14293012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation')
-rw-r--r-- | cc/animation/layer_animation_controller_unittest.cc | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc index a5c815b..4600f12 100644 --- a/cc/animation/layer_animation_controller_unittest.cc +++ b/cc/animation/layer_animation_controller_unittest.cc @@ -36,15 +36,17 @@ TEST(LayerAnimationControllerTest, SyncNewAnimation) { LayerAnimationController::Create(0)); controller->AddValueObserver(&dummy); - EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); AddOpacityTransitionToController(controller, 1, 0, 1, false); + int group_id = controller->GetAnimation(Animation::Opacity)->group(); controller->PushAnimationUpdatesTo(controller_impl.get()); - EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); EXPECT_EQ(Animation::WaitingForTargetAvailability, - controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); + controller_impl->GetAnimation(group_id, + Animation::Opacity)->run_state()); } // If an animation is started on the impl thread before it is ticked on the main @@ -59,15 +61,17 @@ TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { LayerAnimationController::Create(0)); controller->AddValueObserver(&dummy); - EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); AddOpacityTransitionToController(controller, 1, 0, 1, false); + int group_id = controller->GetAnimation(Animation::Opacity)->group(); controller->PushAnimationUpdatesTo(controller_impl.get()); - EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); EXPECT_EQ(Animation::WaitingForTargetAvailability, - controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); + controller_impl->GetAnimation(group_id, + Animation::Opacity)->run_state()); AnimationEventsVector events; controller_impl->Animate(1.0); @@ -76,14 +80,18 @@ TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { // Synchronize the start times. EXPECT_EQ(1u, events.size()); controller->NotifyAnimationStarted(events[0], 0.0); - EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), - controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); + EXPECT_EQ(controller->GetAnimation(group_id, + Animation::Opacity)->start_time(), + controller_impl->GetAnimation(group_id, + Animation::Opacity)->start_time()); // Start the animation on the main thread. Should not affect the start time. controller->Animate(1.5); controller->UpdateState(true, NULL); - EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), - controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); + EXPECT_EQ(controller->GetAnimation(group_id, + Animation::Opacity)->start_time(), + controller_impl->GetAnimation(group_id, + Animation::Opacity)->start_time()); } TEST(LayerAnimationControllerTest, SyncPauseAndResume) { @@ -96,15 +104,17 @@ TEST(LayerAnimationControllerTest, SyncPauseAndResume) { LayerAnimationController::Create(0)); controller->AddValueObserver(&dummy); - EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); AddOpacityTransitionToController(controller, 1, 0, 1, false); + int group_id = controller->GetAnimation(Animation::Opacity)->group(); controller->PushAnimationUpdatesTo(controller_impl.get()); - EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); EXPECT_EQ(Animation::WaitingForTargetAvailability, - controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); + controller_impl->GetAnimation(group_id, + Animation::Opacity)->run_state()); // Start the animations on each controller. AnimationEventsVector events; @@ -113,29 +123,35 @@ TEST(LayerAnimationControllerTest, SyncPauseAndResume) { controller->Animate(0.0); controller->UpdateState(true, NULL); EXPECT_EQ(Animation::Running, - controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); + controller_impl->GetAnimation(group_id, + Animation::Opacity)->run_state()); EXPECT_EQ(Animation::Running, - controller->GetAnimation(0, Animation::Opacity)->run_state()); + controller->GetAnimation(group_id, + Animation::Opacity)->run_state()); // Pause the main-thread animation. controller->SuspendAnimations(1.0); EXPECT_EQ(Animation::Paused, - controller->GetAnimation(0, Animation::Opacity)->run_state()); + controller->GetAnimation(group_id, + Animation::Opacity)->run_state()); // The pause run state change should make it to the impl thread controller. controller->PushAnimationUpdatesTo(controller_impl.get()); EXPECT_EQ(Animation::Paused, - controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); + controller_impl->GetAnimation(group_id, + Animation::Opacity)->run_state()); // Resume the main-thread animation. controller->ResumeAnimations(2.0); EXPECT_EQ(Animation::Running, - controller->GetAnimation(0, Animation::Opacity)->run_state()); + controller->GetAnimation(group_id, + Animation::Opacity)->run_state()); // The pause run state change should make it to the impl thread controller. controller->PushAnimationUpdatesTo(controller_impl.get()); EXPECT_EQ(Animation::Running, - controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); + controller_impl->GetAnimation(group_id, + Animation::Opacity)->run_state()); } TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { @@ -148,32 +164,34 @@ TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { LayerAnimationController::Create(0)); controller->AddValueObserver(&dummy); - EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); int animation_id = AddOpacityTransitionToController(controller, 1, 0, 1, false); + int group_id = controller->GetAnimation(Animation::Opacity)->group(); controller->PushAnimationUpdatesTo(controller_impl.get()); - EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); + EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); EXPECT_EQ(Animation::WaitingForTargetAvailability, - controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); + controller_impl->GetAnimation(group_id, + Animation::Opacity)->run_state()); // Notify main thread controller that the animation has started. AnimationEvent animation_started_event( - AnimationEvent::Started, 0, 0, Animation::Opacity, 0); + AnimationEvent::Started, 0, group_id, Animation::Opacity, 0); controller->NotifyAnimationStarted(animation_started_event, 0.0); // Force animation to complete on impl thread. controller_impl->RemoveAnimation(animation_id); - EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); + EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); controller->PushAnimationUpdatesTo(controller_impl.get()); // Even though the main thread has a 'new' animation, it should not be pushed // because the animation has already completed on the impl thread. - EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); + EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); } // Ensure that a finished animation is eventually deleted by both the |