diff options
author | loyso <loyso@chromium.org> | 2015-11-07 17:26:58 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-08 01:27:45 +0000 |
commit | 2c1247e27b0f29e9a5b8402dd06223b01a8474a3 (patch) | |
tree | fd6fac92aa7a64c30a9ce294a2567255c447ca4f | |
parent | 37a9b18f893843bebf55b85c8f541cdd8517c932 (diff) | |
download | chromium_src-2c1247e27b0f29e9a5b8402dd06223b01a8474a3.zip chromium_src-2c1247e27b0f29e9a5b8402dd06223b01a8474a3.tar.gz chromium_src-2c1247e27b0f29e9a5b8402dd06223b01a8474a3.tar.bz2 |
Graphics Layer Test: Support compositorAnimationTimelines mode.
As a preparation to this change:
https://codereview.chromium.org/1308053006/
BUG=394777
Review URL: https://codereview.chromium.org/1432783003
Cr-Commit-Position: refs/heads/master@{#358542}
-rw-r--r-- | third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp | 83 |
1 files changed, 71 insertions, 12 deletions
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp index 0e74191..756bf7d 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp @@ -25,11 +25,15 @@ #include "config.h" #include "platform/graphics/GraphicsLayer.h" +#include "platform/RuntimeEnabledFeatures.h" #include "platform/scroll/ScrollableArea.h" #include "platform/transforms/Matrix3DTransformOperation.h" #include "platform/transforms/RotateTransformOperation.h" #include "platform/transforms/TranslateTransformOperation.h" #include "public/platform/Platform.h" +#include "public/platform/WebCompositorAnimationPlayer.h" +#include "public/platform/WebCompositorAnimationPlayerClient.h" +#include "public/platform/WebCompositorAnimationTimeline.h" #include "public/platform/WebCompositorSupport.h" #include "public/platform/WebFloatAnimationCurve.h" #include "public/platform/WebGraphicsContext3D.h" @@ -83,6 +87,8 @@ public: m_layerTreeView.clear(); } + WebLayerTreeView* layerTreeView() { return m_layerTreeView.get(); } + protected: WebLayer* m_platformLayer; OwnPtr<GraphicsLayerForTesting> m_graphicsLayer; @@ -94,6 +100,21 @@ private: MockGraphicsLayerClient m_client; }; +class AnimationPlayerForTesting : public WebCompositorAnimationPlayerClient { +public: + AnimationPlayerForTesting() + { + m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()->createAnimationPlayer()); + } + + WebCompositorAnimationPlayer* compositorPlayer() const override + { + return m_compositorPlayer.get(); + } + + OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; +}; + TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) { ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); @@ -102,25 +123,63 @@ TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) curve->add(WebFloatKeyframe(0.0, 0.0)); OwnPtr<WebCompositorAnimation> floatAnimation(adoptPtr(Platform::current()->compositorSupport()->createAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity))); int animationId = floatAnimation->id(); - ASSERT_TRUE(m_platformLayer->addAnimation(floatAnimation.leakPtr())); - ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); + if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { + OwnPtr<WebCompositorAnimationTimeline> compositorTimeline = adoptPtr(Platform::current()->compositorSupport()->createAnimationTimeline()); + AnimationPlayerForTesting player; - m_graphicsLayer->setShouldFlattenTransform(false); + layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline.get()); + compositorTimeline->playerAttached(player); - m_platformLayer = m_graphicsLayer->platformLayer(); - ASSERT_TRUE(m_platformLayer); + player.compositorPlayer()->attachLayer(m_platformLayer); + ASSERT_TRUE(player.compositorPlayer()->isLayerAttached()); - ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); - m_platformLayer->removeAnimation(animationId); - ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); + player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); - m_graphicsLayer->setShouldFlattenTransform(true); + ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); - m_platformLayer = m_graphicsLayer->platformLayer(); - ASSERT_TRUE(m_platformLayer); + m_graphicsLayer->setShouldFlattenTransform(false); - ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); + m_platformLayer = m_graphicsLayer->platformLayer(); + ASSERT_TRUE(m_platformLayer); + + ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); + player.compositorPlayer()->removeAnimation(animationId); + ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); + + m_graphicsLayer->setShouldFlattenTransform(true); + + m_platformLayer = m_graphicsLayer->platformLayer(); + ASSERT_TRUE(m_platformLayer); + + ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); + + player.compositorPlayer()->detachLayer(); + ASSERT_FALSE(player.compositorPlayer()->isLayerAttached()); + + compositorTimeline->playerDestroyed(player); + layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline.get()); + } else { + ASSERT_TRUE(m_platformLayer->addAnimation(floatAnimation.leakPtr())); + + ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); + + m_graphicsLayer->setShouldFlattenTransform(false); + + m_platformLayer = m_graphicsLayer->platformLayer(); + ASSERT_TRUE(m_platformLayer); + + ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); + m_platformLayer->removeAnimation(animationId); + ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); + + m_graphicsLayer->setShouldFlattenTransform(true); + + m_platformLayer = m_graphicsLayer->platformLayer(); + ASSERT_TRUE(m_platformLayer); + + ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); + } } class FakeScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<FakeScrollableArea>, public ScrollableArea { |