[chromium] Make use of common animation unit test methods
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2012 21:34:55 +0000 (21:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2012 21:34:55 +0000 (21:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82357

Patch by Dana Jansens <danakj@chromium.org> on 2012-03-27
Reviewed by Adrienne Walker.

* tests/CCAnimationTestCommon.cpp:
(WebKitTests::addAnimatedTransformToController):
(WebKitTests):
* tests/CCAnimationTestCommon.h:
(WebKitTests):
* tests/CCLayerTreeHostCommonTest.cpp:
(WebKitTests::TEST):
* tests/CCOcclusionTrackerTest.cpp:
(WebKitTests):
(WebKitTests::CCOcclusionTrackerTestAnimationOpacity1OnMainThread::runMyTest):
(WebKitTests::CCOcclusionTrackerTestAnimationOpacity0OnMainThread::runMyTest):
(WebKitTests::CCOcclusionTrackerTestAnimationTranslateOnMainThread::runMyTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112317 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
Source/WebKit/chromium/tests/CCAnimationTestCommon.h
Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp

index ab4cf96ab2df9bd1f5bdde8bd8459dd899f7719e..0fde05b95346c6774a03312e18d653bb9e3ca8f4 100644 (file)
@@ -1,3 +1,23 @@
+2012-03-27  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Make use of common animation unit test methods
+        https://bugs.webkit.org/show_bug.cgi?id=82357
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCAnimationTestCommon.cpp:
+        (WebKitTests::addAnimatedTransformToController):
+        (WebKitTests):
+        * tests/CCAnimationTestCommon.h:
+        (WebKitTests):
+        * tests/CCLayerTreeHostCommonTest.cpp:
+        (WebKitTests::TEST):
+        * tests/CCOcclusionTrackerTest.cpp:
+        (WebKitTests):
+        (WebKitTests::CCOcclusionTrackerTestAnimationOpacity1OnMainThread::runMyTest):
+        (WebKitTests::CCOcclusionTrackerTestAnimationOpacity0OnMainThread::runMyTest):
+        (WebKitTests::CCOcclusionTrackerTestAnimationTranslateOnMainThread::runMyTest):
+
 2012-03-27  Sami Kyostila  <skyostil@chromium.org>
 
         [chromium] Add TextureCopier for copying texture contents
 2012-03-27  Sami Kyostila  <skyostil@chromium.org>
 
         [chromium] Add TextureCopier for copying texture contents
index e47a14c8b470b28b3ed31b17bca703b0d437904c..36f79818ef09e838cc9827b8fa1625881950da42 100644 (file)
@@ -148,6 +148,11 @@ void addOpacityTransitionToController(WebCore::CCLayerAnimationController& contr
     addOpacityTransition(controller, duration, startOpacity, endOpacity, useTimingFunction);
 }
 
     addOpacityTransition(controller, duration, startOpacity, endOpacity, useTimingFunction);
 }
 
+void addAnimatedTransformToController(WebCore::CCLayerAnimationController& controller, double duration, int deltaX, int deltaY)
+{
+    addAnimatedTransform(controller, duration, deltaX, deltaY);
+}
+
 void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
 {
     addOpacityTransition(layer, duration, startOpacity, endOpacity, useTimingFunction);
 void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
 {
     addOpacityTransition(layer, duration, startOpacity, endOpacity, useTimingFunction);
index 2033bf9d00e3ac90e771b19c389842c1458a1b1d..3edae5494b6ca4ec71136bfa4fe9a8588cea910a 100644 (file)
@@ -97,6 +97,7 @@ private:
 };
 
 void addOpacityTransitionToController(WebCore::CCLayerAnimationController&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
 };
 
 void addOpacityTransitionToController(WebCore::CCLayerAnimationController&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
+void addAnimatedTransformToController(WebCore::CCLayerAnimationController&, double duration, int deltaX, int deltaY);
 
 void addOpacityTransitionToLayer(WebCore::LayerChromium&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
 void addOpacityTransitionToLayer(WebCore::CCLayerImpl&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
 
 void addOpacityTransitionToLayer(WebCore::LayerChromium&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
 void addOpacityTransitionToLayer(WebCore::CCLayerImpl&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
index 9efddf9fb1a78252a08080e37d45f7aabf8e3e37..90a393a45579371cd2e764f7cd69000e6385cd33 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "cc/CCLayerTreeHostCommon.h"
 
 
 #include "cc/CCLayerTreeHostCommon.h"
 
+#include "CCAnimationTestCommon.h"
 #include "CCLayerTreeTestCommon.h"
 #include "LayerChromium.h"
 #include "TransformationMatrix.h"
 #include "CCLayerTreeTestCommon.h"
 #include "LayerChromium.h"
 #include "TransformationMatrix.h"
@@ -36,6 +37,7 @@
 #include <gtest/gtest.h>
 
 using namespace WebCore;
 #include <gtest/gtest.h>
 
 using namespace WebCore;
+using namespace WebKitTests;
 
 namespace {
 
 
 namespace {
 
@@ -651,38 +653,6 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces)
     EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id());
 }
 
     EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id());
 }
 
-static int addOpacityAnimationToLayer(LayerChromium* layer, float startValue, float endValue, double duration)
-{
-    static int id = 0;
-    WebCore::KeyframeValueList values(AnimatedPropertyOpacity);
-    values.insert(new FloatAnimationValue(0, startValue));
-    values.insert(new FloatAnimationValue(duration, endValue));
-
-    RefPtr<Animation> animation = Animation::create();
-    animation->setDuration(duration);
-
-    IntSize boxSize;
-    layer->layerAnimationController()->addAnimation(values, boxSize, animation.get(), id, 0, 0);
-    return id++;
-}
-
-static int addTransformAnimationToLayer(LayerChromium* layer, double duration)
-{
-    static int id = 0;
-    WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform);
-
-    TransformOperations operations1;
-    operations1.operations().append(TranslateTransformOperation::create(Length(2, WebCore::Fixed), Length(0, WebCore::Fixed), TransformOperation::TRANSLATE_X));
-    values.insert(new TransformAnimationValue(0, &operations1));
-
-    RefPtr<Animation> animation = Animation::create();
-    animation->setDuration(duration);
-
-    IntSize boxSize;
-    layer->layerAnimationController()->addAnimation(values, boxSize, animation.get(), id, 0, 0);
-    return id++;
-}
-
 TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
 {
     RefPtr<LayerChromium> parent = LayerChromium::create();
 TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
 {
     RefPtr<LayerChromium> parent = LayerChromium::create();
@@ -705,11 +675,11 @@ TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
     childOfRS2->addChild(grandChildOfRS2);
 
     // In combination with descendantDrawsContent, opacity != 1 forces the layer to have a new renderSurface.
     childOfRS2->addChild(grandChildOfRS2);
 
     // In combination with descendantDrawsContent, opacity != 1 forces the layer to have a new renderSurface.
-    addOpacityAnimationToLayer(renderSurface1.get(), 1, 0, 10);
-    addOpacityAnimationToLayer(renderSurface2.get(), 1, 0, 10);
+    addOpacityTransitionToController(*renderSurface1->layerAnimationController(), 10, 1, 0, false);
+    addOpacityTransitionToController(*renderSurface2->layerAnimationController(), 10, 1, 0, false);
 
     // Also put an animation on a layer without descendants.
 
     // Also put an animation on a layer without descendants.
-    addOpacityAnimationToLayer(grandChildOfRoot.get(), 1, 0, 10);
+    addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController(), 10, 1, 0, false);
 
     TransformationMatrix layerTransform;
     layerTransform.translate(1.0, 1.0);
 
     TransformationMatrix layerTransform;
     layerTransform.translate(1.0, 1.0);
@@ -717,10 +687,10 @@ TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
     sublayerTransform.scale3d(10.0, 1.0, 1.0);
 
     // Put transform animations on child, renderSurface2, grandChildOfRoot, and grandChildOfRS2
     sublayerTransform.scale3d(10.0, 1.0, 1.0);
 
     // Put transform animations on child, renderSurface2, grandChildOfRoot, and grandChildOfRS2
-    addTransformAnimationToLayer(childOfRoot.get(), 10);
-    addTransformAnimationToLayer(grandChildOfRoot.get(), 10);
-    addTransformAnimationToLayer(renderSurface2.get(), 10);
-    addTransformAnimationToLayer(grandChildOfRS2.get(), 10);
+    addAnimatedTransformToController(*childOfRoot->layerAnimationController(), 10, 30, 0);
+    addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController(), 10, 30, 0);
+    addAnimatedTransformToController(*renderSurface2->layerAnimationController(), 10, 30, 0);
+    addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController(), 10, 30, 0);
 
     setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false);
     setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false);
 
     setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false);
     setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false);
index cd7bf20ad34cd513d64c2a2757d75ce42aab0d4f..8d40d24ab01d37b09b66cd5f809753dd2f22c338 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "cc/CCOcclusionTracker.h"
 
 
 #include "cc/CCOcclusionTracker.h"
 
+#include "CCAnimationTestCommon.h"
 #include "FilterOperations.h"
 #include "LayerChromium.h"
 #include "Region.h"
 #include "FilterOperations.h"
 #include "LayerChromium.h"
 #include "Region.h"
@@ -40,6 +41,7 @@
 #include <gtest/gtest.h>
 
 using namespace WebCore;
 #include <gtest/gtest.h>
 
 using namespace WebCore;
+using namespace WebKitTests;
 
 #define EXPECT_EQ_RECT(a, b) \
     EXPECT_EQ(a.x(), b.x()); \
 
 #define EXPECT_EQ_RECT(a, b) \
     EXPECT_EQ(a.x(), b.x()); \
@@ -1677,40 +1679,6 @@ protected:
 
 MAIN_THREAD_TEST(CCOcclusionTrackerTestPerspectiveTransformBehindCamera);
 
 
 MAIN_THREAD_TEST(CCOcclusionTrackerTestPerspectiveTransformBehindCamera);
 
-template<typename LayerType>
-static int addOpacityAnimationToLayer(LayerType* layer, float startValue, float endValue, double duration)
-{
-    static int id = 0;
-    WebCore::KeyframeValueList values(AnimatedPropertyOpacity);
-    values.insert(new FloatAnimationValue(0, startValue));
-    values.insert(new FloatAnimationValue(duration, endValue));
-
-    RefPtr<Animation> animation = Animation::create();
-    animation->setDuration(duration);
-
-    IntSize boxSize;
-    layer->layerAnimationController()->addAnimation(values, boxSize, animation.get(), id, 0, 0);
-    return id++;
-}
-
-template<typename LayerType>
-static int addTransformAnimationToLayer(LayerType* layer, double duration)
-{
-    static int id = 0;
-    WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform);
-
-    TransformOperations operations1;
-    operations1.operations().append(TranslateTransformOperation::create(Length(2, WebCore::Fixed), Length(0, WebCore::Fixed), TransformOperation::TRANSLATE_X));
-    values.insert(new TransformAnimationValue(0, &operations1));
-
-    RefPtr<Animation> animation = Animation::create();
-    animation->setDuration(duration);
-
-    IntSize boxSize;
-    layer->layerAnimationController()->addAnimation(values, boxSize, animation.get(), id, 0, 0);
-    return id++;
-}
-
 template<class Types, bool opaqueLayers>
 class CCOcclusionTrackerTestAnimationOpacity1OnMainThread : public CCOcclusionTrackerTest<Types, opaqueLayers> {
 protected:
 template<class Types, bool opaqueLayers>
 class CCOcclusionTrackerTestAnimationOpacity1OnMainThread : public CCOcclusionTrackerTest<Types, opaqueLayers> {
 protected:
@@ -1722,8 +1690,8 @@ protected:
         typename Types::ContentLayerType* surfaceChild = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 300), true);
         typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
 
         typename Types::ContentLayerType* surfaceChild = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 300), true);
         typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
 
-        addOpacityAnimationToLayer(layer, 0, 1, 10);
-        addOpacityAnimationToLayer(surface, 0, 1, 10);
+        addOpacityTransitionToController(*layer->layerAnimationController(), 10, 0, 1, false);
+        addOpacityTransitionToController(*surface->layerAnimationController(), 10, 0, 1, false);
         this->calcDrawEtc(parent);
 
         EXPECT_TRUE(layer->drawOpacityIsAnimating());
         this->calcDrawEtc(parent);
 
         EXPECT_TRUE(layer->drawOpacityIsAnimating());
@@ -1763,8 +1731,8 @@ protected:
         typename Types::ContentLayerType* surfaceChild = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 300), true);
         typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
 
         typename Types::ContentLayerType* surfaceChild = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 300), true);
         typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
 
-        addOpacityAnimationToLayer(layer, 1, 0, 10);
-        addOpacityAnimationToLayer(surface, 1, 0, 10);
+        addOpacityTransitionToController(*layer->layerAnimationController(), 10, 1, 0, false);
+        addOpacityTransitionToController(*surface->layerAnimationController(), 10, 1, 0, false);
         this->calcDrawEtc(parent);
 
         EXPECT_TRUE(layer->drawOpacityIsAnimating());
         this->calcDrawEtc(parent);
 
         EXPECT_TRUE(layer->drawOpacityIsAnimating());
@@ -1805,9 +1773,9 @@ protected:
         typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
         typename Types::ContentLayerType* surface2 = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(50, 300), true);
 
         typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
         typename Types::ContentLayerType* surface2 = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(50, 300), true);
 
-        addTransformAnimationToLayer(layer, 10);
-        addTransformAnimationToLayer(surface, 10);
-        addTransformAnimationToLayer(surfaceChild, 10);
+        addAnimatedTransformToController(*layer->layerAnimationController(), 10, 30, 0);
+        addAnimatedTransformToController(*surface->layerAnimationController(), 10, 30, 0);
+        addAnimatedTransformToController(*surfaceChild->layerAnimationController(), 10, 30, 0);
         this->calcDrawEtc(parent);
 
         EXPECT_TRUE(layer->drawTransformIsAnimating());
         this->calcDrawEtc(parent);
 
         EXPECT_TRUE(layer->drawTransformIsAnimating());