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

Unified Diff: cc/layer_animation_controller_unittest.cc

Issue 12453010: Allow impl-only animations, and return opacity values via AnimationEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: cc/layer_animation_controller_unittest.cc
diff --git a/cc/layer_animation_controller_unittest.cc b/cc/layer_animation_controller_unittest.cc
index c451952a1260227847feeb30471787d6ae546b33..38f3886b5e458fc09930f07ae25e4c845e8da020 100644
--- a/cc/layer_animation_controller_unittest.cc
+++ b/cc/layer_animation_controller_unittest.cc
@@ -67,8 +67,9 @@ TEST(LayerAnimationControllerTest, doNotClobberStartTimes)
controllerImpl->animate(1);
controllerImpl->updateState(&events);
- // Synchronize the start times.
- EXPECT_EQ(1u, events.size());
+ // Synchronize the start times. This will also have a property update
+ // event for opacity.
+ EXPECT_EQ(2u, events.size());
controller->OnAnimationStarted(events[0]);
EXPECT_EQ(controller->getAnimation(0, Animation::Opacity)->startTime(), controllerImpl->getAnimation(0, Animation::Opacity)->startTime());
@@ -156,6 +157,18 @@ TEST(LayerAnimationControllerTest, doNotSyncFinishedAnimation)
}
// Tests that transitioning opacity from 0 to 1 works as expected.
+
+static const AnimationEvent* getLastPropertyUpdateOpacityEvent(const AnimationEventsVector* events)
+{
+ const AnimationEvent* event = 0;
+ for (size_t i = 0; i < events->size(); ++i)
+ if ((*events)[i].type == AnimationEvent::PropertyUpdate &&
+ (*events)[i].targetProperty == Animation::Opacity)
+ event = &(*events)[i];
+
+ return event;
+}
+
Ian Vollick 2013/03/06 01:00:57 I would like 3 new tests rather than these tweaks
wjmaclean 2013/03/06 17:03:13 Now that non implOnly animations do not send back
TEST(LayerAnimationControllerTest, TrivialTransition)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
@@ -170,10 +183,18 @@ TEST(LayerAnimationControllerTest, TrivialTransition)
controller->updateState(events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(2, events->size());
+ const AnimationEvent* startOpacityEvent = getLastPropertyUpdateOpacityEvent(events.get());
+ ASSERT_TRUE(startOpacityEvent);
+ EXPECT_EQ(0, startOpacityEvent->value);
controller->animate(1);
controller->updateState(events.get());
EXPECT_EQ(1, dummy.opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
+ EXPECT_EQ(4, events->size());
+ const AnimationEvent* endOpacityEvent = getLastPropertyUpdateOpacityEvent(events.get());
+ ASSERT_TRUE(endOpacityEvent);
+ EXPECT_EQ(1, endOpacityEvent->value);
}
// Tests animations that are waiting for a synchronized start time do not finish.
@@ -640,9 +661,12 @@ TEST(LayerAnimationControllerTest, SkipUpdateState)
events.reset(new AnimationEventsVector);
controller->updateState(events.get());
- // Should have one Started event and one Finished event.
- EXPECT_EQ(2, events->size());
+ // Should have one Started event, one Finished event, and one
+ // opacity property update event.
+ EXPECT_EQ(3, events->size());
EXPECT_NE((*events)[0].type, (*events)[1].type);
+ EXPECT_NE((*events)[0].type, (*events)[2].type);
+ EXPECT_NE((*events)[1].type, (*events)[2].type);
// The float transition should still be at its starting point.
EXPECT_TRUE(controller->hasActiveAnimation());

Powered by Google App Engine
This is Rietveld 408576698