From be01689f43cf6882cf670d33df49ead1f570c53a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 27 May 2012 21:51:42 +0200 Subject: Imported WebKit commit 8d6c5efc74f0222dfc7bcce8d845d4a2707ed9e6 (http://svn.webkit.org/repository/webkit/trunk@118629) --- .../WebKit/chromium/tests/CCLayerTreeHostTest.cpp | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp') diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp index 9e28a5b82..1275ec854 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp @@ -26,6 +26,7 @@ #include "cc/CCLayerTreeHost.h" +#include "AnimationIdVendor.h" #include "CCAnimationTestCommon.h" #include "CCOcclusionTrackerTestCommon.h" #include "CCTiledLayerTestCommon.h" @@ -44,6 +45,7 @@ #include "cc/CCScopedThreadProxy.h" #include "cc/CCTextureUpdater.h" #include "cc/CCThreadTask.h" +#include "cc/CCTimingFunction.h" #include "platform/WebThread.h" #include #include @@ -181,14 +183,27 @@ public: return MockLayerTreeHostImpl::create(m_testHooks, copySettings, client); } + virtual void didAddAnimation() OVERRIDE + { + m_didAddAnimationWasCalled = true; + CCLayerTreeHost::didAddAnimation(); + } + + bool didAddAnimationWasCalled() + { + return m_didAddAnimationWasCalled; + } + private: MockLayerTreeHost(TestHooks* testHooks, CCLayerTreeHostClient* client, const CCSettings& settings) : CCLayerTreeHost(client, settings) , m_testHooks(testHooks) + , m_didAddAnimationWasCalled(false) { } TestHooks* m_testHooks; + bool m_didAddAnimationWasCalled; }; class CompositorFakeWebGraphicsContext3DWithTextureTracking : public CompositorFakeWebGraphicsContext3D { @@ -2814,4 +2829,37 @@ private: SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestFinishAllRendering) +// Layers added to tree with existing active animations should have the animation +// correctly recognized. +class CCLayerTreeHostTestLayerAddedWithAnimation : public CCLayerTreeHostTest { +public: + CCLayerTreeHostTestLayerAddedWithAnimation() { } + + virtual void beginTest() + { + EXPECT_FALSE(static_cast(layerTreeHost())->didAddAnimationWasCalled()); + + RefPtr layer = LayerChromium::create(); + layer->setLayerAnimationDelegate(&m_animationDelegate); + + // Any valid CCAnimationCurve will do here. + OwnPtr curve(CCEaseTimingFunction::create()); + OwnPtr animation(CCActiveAnimation::create(curve.release(), AnimationIdVendor::getNextAnimationId(), AnimationIdVendor::getNextGroupId(), CCActiveAnimation::Opacity)); + layer->layerAnimationController()->add(animation.release()); + + // We add the animation *before* attaching the layer to the tree. + m_layerTreeHost->rootLayer()->addChild(layer); + EXPECT_TRUE(static_cast(layerTreeHost())->didAddAnimationWasCalled()); + + endTest(); + } + + virtual void afterTest() { } + +private: + ::TestHooks m_animationDelegate; +}; + +SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation) + } // namespace -- cgit v1.2.1