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

Unified Diff: cc/layer_animation_controller_unittest.cc

Issue 11443004: Maintain global lists of animation controllers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 29b6e6eeca9c57cf7ea45f6972751a41331c2818..37467a43e88938455107ffed13af445b5453659e 100644
--- a/cc/layer_animation_controller_unittest.cc
+++ b/cc/layer_animation_controller_unittest.cc
@@ -6,6 +6,7 @@
#include "cc/active_animation.h"
#include "cc/animation_curve.h"
+#include "cc/animation_registrar.h"
#include "cc/test/animation_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -28,10 +29,8 @@ scoped_ptr<ActiveAnimation> createActiveAnimation(scoped_ptr<AnimationCurve> cur
TEST(LayerAnimationControllerTest, syncNewAnimation)
{
- FakeLayerAnimationControllerClient dummyImpl;
- scoped_ptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(&dummyImpl));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(AnimationRegistrar::MainThread));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity));
@@ -47,10 +46,8 @@ TEST(LayerAnimationControllerTest, syncNewAnimation)
// thread, we must be sure to respect the synchronized start time.
TEST(LayerAnimationControllerTest, doNotClobberStartTimes)
{
- FakeLayerAnimationControllerClient dummyImpl;
- scoped_ptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(&dummyImpl));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(AnimationRegistrar::MainThread));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity));
@@ -76,10 +73,8 @@ TEST(LayerAnimationControllerTest, doNotClobberStartTimes)
TEST(LayerAnimationControllerTest, syncPauseAndResume)
{
- FakeLayerAnimationControllerClient dummyImpl;
- scoped_ptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(&dummyImpl));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(AnimationRegistrar::MainThread));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity));
@@ -116,10 +111,8 @@ TEST(LayerAnimationControllerTest, syncPauseAndResume)
TEST(LayerAnimationControllerTest, doNotSyncFinishedAnimation)
{
- FakeLayerAnimationControllerClient dummyImpl;
- scoped_ptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(&dummyImpl));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(AnimationRegistrar::MainThread));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity));
@@ -149,18 +142,16 @@ TEST(LayerAnimationControllerTest, doNotSyncFinishedAnimation)
TEST(LayerAnimationControllerTest, TrivialTransition)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
controller->addAnimation(toAdd.Pass());
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(1, events.get());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -168,9 +159,7 @@ TEST(LayerAnimationControllerTest, TrivialTransition)
TEST(LayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDuration)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
toAdd->setNeedsSynchronizedStartTime(true);
@@ -179,18 +168,18 @@ TEST(LayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfThe
controller->addAnimation(toAdd.Pass());
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(1, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(2, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
// Send the synchronized start time.
controller->notifyAnimationStarted(AnimationEvent(AnimationEvent::Started, 0, 1, ActiveAnimation::Opacity, 2));
controller->animate(5, events.get());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -198,21 +187,19 @@ TEST(LayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfThe
TEST(LayerAnimationControllerTest, TrivialQueuing)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity));
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(1, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
controller->animate(2, events.get());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -220,13 +207,12 @@ TEST(LayerAnimationControllerTest, TrivialQueuing)
TEST(LayerAnimationControllerTest, Interrupt)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
+
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity));
toAdd->setRunState(ActiveAnimation::WaitingForNextTick, 0);
@@ -236,9 +222,9 @@ TEST(LayerAnimationControllerTest, Interrupt)
// this call to animate.
controller->animate(0.5, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
controller->animate(1.5, events.get());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -246,24 +232,23 @@ TEST(LayerAnimationControllerTest, Interrupt)
TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
+ controller->setOpacity(0);
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Transform));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Transform));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity));
controller->animate(0, events.get());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
EXPECT_TRUE(controller->hasActiveAnimation());
controller->animate(1, events.get());
// Should not have started the float transition yet.
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
// The float animation should have started at time 1 and should be done.
controller->animate(2, events.get());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -273,9 +258,7 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked)
TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(2)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Transform));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
@@ -284,18 +267,18 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting)
// Animations with id 1 should both start now.
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
// The opacity animation should have finished at time 1, but the group
// of animations with id 1 don't finish until time 2 because of the length
// of the transform animation.
controller->animate(2, events.get());
// Should not have started the float transition yet.
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
// The second opacity animation should start at time 2 and should be done by time 3
controller->animate(3, events.get());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -303,10 +286,9 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting)
TEST(LayerAnimationControllerTest, ScheduleAnimation)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
+ controller->setOpacity(0);
scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
toAdd->setRunState(ActiveAnimation::WaitingForStartTime, 0);
toAdd->setStartTime(1);
@@ -314,12 +296,12 @@ TEST(LayerAnimationControllerTest, ScheduleAnimation)
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(1, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(2, events.get());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -327,9 +309,7 @@ TEST(LayerAnimationControllerTest, ScheduleAnimation)
TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimation)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
@@ -341,15 +321,15 @@ TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimation)
// First 2s opacity transition should start immediately.
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(0.5, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.25, dummy.opacity());
+ EXPECT_EQ(0.25, controller->opacity());
controller->animate(1, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
controller->animate(2, events.get());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -358,9 +338,7 @@ TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimation)
TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
@@ -374,19 +352,19 @@ TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimationW
// First 2s opacity transition should start immediately.
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(0.5, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.25, dummy.opacity());
+ EXPECT_EQ(0.25, controller->opacity());
EXPECT_TRUE(controller->hasActiveAnimation());
controller->animate(1, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
controller->animate(3, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(4, events.get());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
EXPECT_FALSE(controller->hasActiveAnimation());
}
@@ -394,9 +372,7 @@ TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimationW
TEST(LayerAnimationControllerTest, TrivialLooping)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity));
toAdd->setIterations(3);
@@ -404,35 +380,33 @@ TEST(LayerAnimationControllerTest, TrivialLooping)
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(1.25, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.25, dummy.opacity());
+ EXPECT_EQ(0.25, controller->opacity());
controller->animate(1.75, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
controller->animate(2.25, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.25, dummy.opacity());
+ EXPECT_EQ(0.25, controller->opacity());
controller->animate(2.75, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
controller->animate(3, events.get());
EXPECT_FALSE(controller->hasActiveAnimation());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
// Just be extra sure.
controller->animate(4, events.get());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
}
// Test that an infinitely looping animation does indeed go until aborted.
TEST(LayerAnimationControllerTest, InfiniteLooping)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
const int id = 1;
scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), id, ActiveAnimation::Opacity));
@@ -441,69 +415,65 @@ TEST(LayerAnimationControllerTest, InfiniteLooping)
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(1.25, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.25, dummy.opacity());
+ EXPECT_EQ(0.25, controller->opacity());
controller->animate(1.75, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
controller->animate(1073741824.25, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.25, dummy.opacity());
+ EXPECT_EQ(0.25, controller->opacity());
controller->animate(1073741824.75, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity));
controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Aborted, 0.75);
EXPECT_FALSE(controller->hasActiveAnimation());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
}
// Test that pausing and resuming work as expected.
TEST(LayerAnimationControllerTest, PauseResume)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
const int id = 1;
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), id, ActiveAnimation::Opacity));
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(0.5, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity));
controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Paused, 0.5);
controller->animate(1024, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity));
controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Running, 1024);
controller->animate(1024.25, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
controller->animate(1024.5, events.get());
EXPECT_FALSE(controller->hasActiveAnimation());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
}
TEST(LayerAnimationControllerTest, AbortAGroupedAnimation)
{
scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
const int id = 1;
controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), id, ActiveAnimation::Transform));
@@ -512,29 +482,25 @@ TEST(LayerAnimationControllerTest, AbortAGroupedAnimation)
controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0, dummy.opacity());
+ EXPECT_EQ(0, controller->opacity());
controller->animate(1, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(0.5, dummy.opacity());
+ EXPECT_EQ(0.5, controller->opacity());
EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity));
controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Aborted, 1);
controller->animate(1, events.get());
EXPECT_TRUE(controller->hasActiveAnimation());
- EXPECT_EQ(1, dummy.opacity());
+ EXPECT_EQ(1, controller->opacity());
controller->animate(2, events.get());
EXPECT_TRUE(!controller->hasActiveAnimation());
- EXPECT_EQ(0.75, dummy.opacity());
+ EXPECT_EQ(0.75, controller->opacity());
}
TEST(LayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded)
{
- FakeLayerAnimationControllerClient dummyImpl;
- scoped_ptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(&dummyImpl));
- scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
- FakeLayerAnimationControllerClient dummy;
- scoped_ptr<LayerAnimationController> controller(
- LayerAnimationController::create(&dummy));
+ scoped_refptr<LayerAnimationController> controllerImpl(LayerAnimationController::create(AnimationRegistrar::MainThread));
+ scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(AnimationRegistrar::MainThread));
scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 0, ActiveAnimation::Opacity));
toAdd->setNeedsSynchronizedStartTime(true);

Powered by Google App Engine
This is Rietveld 408576698