summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-11 09:43:24 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-11 09:43:24 +0200
commit1b914638db989aaa98631a1c1e02c7b2d44805d8 (patch)
tree87f4fd2c7b38db320079a5de8877890d2ca3c485 /Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
parent2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (diff)
downloadqtwebkit-1b914638db989aaa98631a1c1e02c7b2d44805d8.tar.gz
Imported WebKit commit 9a52e27980f47e8b0d8f8b7cc0fd7b5741bceb92 (http://svn.webkit.org/repository/webkit/trunk@116736)
New snapshot to include QDeclarative* -> QQml* build fixes
Diffstat (limited to 'Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp120
1 files changed, 107 insertions, 13 deletions
diff --git a/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
index fa95a2ac5..1d5409f98 100644
--- a/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
@@ -86,34 +86,45 @@ TEST(CCLayerAnimationControllerTest, createOpacityAnimation)
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());
+
+ EXPECT_EQ(CCAnimationCurve::Transform, activeAnimation->curve()->type());
- animation->setDirection(Animation::AnimationDirectionNormal);
- EXPECT_TRUE(controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0));
+ 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 @@ TEST(CCLayerAnimationControllerTest, createTransformAnimation)
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 @@ TEST(CCLayerAnimationControllerTest, createTransformAnimation)
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;