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

Unified Diff: Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp

Issue 10384167: Merge 116554 - [chromium] Add impl-thread support for fill-mode and direction css animation propert… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
===================================================================
--- Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp (revision 116999)
+++ Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp (working copy)
@@ -86,34 +86,45 @@
EXPECT_EQ(1, curve->getValue(duration));
}
-TEST(CCLayerAnimationControllerTest, ignoreUnsupportedAnimationDirections)
+TEST(CCLayerAnimationControllerTest, createTransformAnimation)
{
FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
const double duration = 1;
- WebCore::KeyframeValueList values(AnimatedPropertyOpacity);
- values.insert(new FloatAnimationValue(0, 0));
- values.insert(new FloatAnimationValue(duration, 1));
+ WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform);
+ TransformOperations operations1;
+ operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X));
+ values.insert(new TransformAnimationValue(0, &operations1));
+
+ TransformOperations operations2;
+ operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X));
+ values.insert(new TransformAnimationValue(duration, &operations2));
+
RefPtr<Animation> animation = Animation::create();
animation->setDuration(duration);
IntSize boxSize;
+ controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0);
- animation->setDirection(Animation::AnimationDirectionAlternate);
- EXPECT_FALSE(controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0));
+ EXPECT_TRUE(controller->hasActiveAnimation());
- animation->setDirection(Animation::AnimationDirectionAlternateReverse);
- EXPECT_FALSE(controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0));
+ CCActiveAnimation* activeAnimation = controller->getActiveAnimation(0, CCActiveAnimation::Transform);
+ EXPECT_TRUE(activeAnimation);
- animation->setDirection(Animation::AnimationDirectionReverse);
- EXPECT_FALSE(controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0));
+ EXPECT_EQ(1, activeAnimation->iterations());
+ EXPECT_EQ(CCActiveAnimation::Transform, activeAnimation->targetProperty());
- animation->setDirection(Animation::AnimationDirectionNormal);
- EXPECT_TRUE(controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0));
+ EXPECT_EQ(CCAnimationCurve::Transform, activeAnimation->curve()->type());
+
+ const CCTransformAnimationCurve* curve = activeAnimation->curve()->toTransformAnimationCurve();
+ EXPECT_TRUE(curve);
+
+ expectTranslateX(2, curve->getValue(0, boxSize));
+ expectTranslateX(4, curve->getValue(duration, boxSize));
}
-TEST(CCLayerAnimationControllerTest, createTransformAnimation)
+TEST(CCLayerAnimationControllerTest, createReversedAnimation)
{
FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
@@ -130,6 +141,7 @@
RefPtr<Animation> animation = Animation::create();
animation->setDuration(duration);
+ animation->setDirection(Animation::AnimationDirectionReverse);
IntSize boxSize;
controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0);
@@ -147,10 +159,92 @@
const CCTransformAnimationCurve* curve = activeAnimation->curve()->toTransformAnimationCurve();
EXPECT_TRUE(curve);
+ expectTranslateX(4, curve->getValue(0, boxSize));
+ expectTranslateX(2, curve->getValue(duration, boxSize));
+}
+
+TEST(CCLayerAnimationControllerTest, createAlternatingAnimation)
+{
+ FakeLayerAnimationControllerClient dummy;
+ OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
+ const double duration = 1;
+ WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform);
+
+ TransformOperations operations1;
+ operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X));
+ values.insert(new TransformAnimationValue(0, &operations1));
+
+ TransformOperations operations2;
+ operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X));
+ values.insert(new TransformAnimationValue(duration, &operations2));
+
+ RefPtr<Animation> animation = Animation::create();
+ animation->setDuration(duration);
+ animation->setDirection(Animation::AnimationDirectionAlternate);
+ animation->setIterationCount(2);
+
+ IntSize boxSize;
+ controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0);
+
+ EXPECT_TRUE(controller->hasActiveAnimation());
+
+ CCActiveAnimation* activeAnimation = controller->getActiveAnimation(0, CCActiveAnimation::Transform);
+ EXPECT_TRUE(activeAnimation);
+ EXPECT_TRUE(activeAnimation->alternatesDirection());
+
+ EXPECT_EQ(2, activeAnimation->iterations());
+ EXPECT_EQ(CCActiveAnimation::Transform, activeAnimation->targetProperty());
+
+ EXPECT_EQ(CCAnimationCurve::Transform, activeAnimation->curve()->type());
+
+ const CCTransformAnimationCurve* curve = activeAnimation->curve()->toTransformAnimationCurve();
+ EXPECT_TRUE(curve);
+
expectTranslateX(2, curve->getValue(0, boxSize));
expectTranslateX(4, curve->getValue(duration, boxSize));
}
+TEST(CCLayerAnimationControllerTest, createReversedAlternatingAnimation)
+{
+ FakeLayerAnimationControllerClient dummy;
+ OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
+ const double duration = 1;
+ WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform);
+
+ TransformOperations operations1;
+ operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X));
+ values.insert(new TransformAnimationValue(0, &operations1));
+
+ TransformOperations operations2;
+ operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X));
+ values.insert(new TransformAnimationValue(duration, &operations2));
+
+ RefPtr<Animation> animation = Animation::create();
+ animation->setDuration(duration);
+ animation->setDirection(Animation::AnimationDirectionAlternateReverse);
+ animation->setIterationCount(2);
+
+ IntSize boxSize;
+ controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0);
+
+ EXPECT_TRUE(controller->hasActiveAnimation());
+
+ CCActiveAnimation* activeAnimation = controller->getActiveAnimation(0, CCActiveAnimation::Transform);
+ EXPECT_TRUE(activeAnimation);
+ EXPECT_TRUE(activeAnimation->alternatesDirection());
+
+ EXPECT_EQ(2, activeAnimation->iterations());
+ EXPECT_EQ(CCActiveAnimation::Transform, activeAnimation->targetProperty());
+
+ EXPECT_EQ(CCAnimationCurve::Transform, activeAnimation->curve()->type());
+
+ const CCTransformAnimationCurve* curve = activeAnimation->curve()->toTransformAnimationCurve();
+ EXPECT_TRUE(curve);
+
+ expectTranslateX(4, curve->getValue(0, boxSize));
+ expectTranslateX(2, curve->getValue(duration, boxSize));
+}
+
TEST(CCLayerAnimationControllerTest, syncNewAnimation)
{
FakeLayerAnimationControllerClient dummyImpl;
« no previous file with comments | « Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698