diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-19 07:26:40 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-19 07:26:40 +0000 |
commit | f91a75e00c853bcab5ab23175b97b022055bc9bb (patch) | |
tree | 61439bba56532da0f768f70b2de8c2f9633881fc /cc | |
parent | 25c6cfe167bfab66ae1b63970737642940a54a0c (diff) | |
download | chromium_src-f91a75e00c853bcab5ab23175b97b022055bc9bb.zip chromium_src-f91a75e00c853bcab5ab23175b97b022055bc9bb.tar.gz chromium_src-f91a75e00c853bcab5ab23175b97b022055bc9bb.tar.bz2 |
cc: Move more animation tests to layer_tree_host_unittests_animation.cc
Created FakeContentLayer to replace ContentLayerWithUpdateTracking.
R=enne,jamesr
Review URL: https://codereview.chromium.org/11640006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc_tests.gyp | 2 | ||||
-rw-r--r-- | cc/layer_tree_host_unittest.cc | 340 | ||||
-rw-r--r-- | cc/layer_tree_host_unittest_animation.cc | 335 | ||||
-rw-r--r-- | cc/test/fake_content_layer.cc | 27 | ||||
-rw-r--r-- | cc/test/fake_content_layer.h | 36 | ||||
-rw-r--r-- | cc/test/layer_tree_test_common.h | 22 |
6 files changed, 410 insertions, 352 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index d014128..0c46328 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -64,6 +64,8 @@ 'cc_tests_support_files': [ 'test/animation_test_common.cc', 'test/animation_test_common.h', + 'test/fake_content_layer.cc', + 'test/fake_content_layer.h', 'test/fake_content_layer_client.cc', 'test/fake_content_layer_client.h', 'test/fake_impl_proxy.h', diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index 9fdc178..887454b 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -581,304 +581,6 @@ TEST_F(LayerTreeHostTestAbortFrameWhenInvisible, runMultiThread) runTest(true); } -// Trigger a frame with setNeedsCommit. Then, inside the resulting animate -// callback, requet another frame using setNeedsAnimate. End the test when -// animate gets called yet-again, indicating that the proxy is correctly -// handling the case where setNeedsAnimate() is called inside the begin frame -// flow. -class LayerTreeHostTestSetNeedsAnimateInsideAnimationCallback : public LayerTreeHostTest { -public: - LayerTreeHostTestSetNeedsAnimateInsideAnimationCallback() - : m_numAnimates(0) - { - } - - virtual void beginTest() OVERRIDE - { - postSetNeedsAnimateToMainThread(); - } - - virtual void animate(base::TimeTicks) OVERRIDE - { - if (!m_numAnimates) { - m_layerTreeHost->setNeedsAnimate(); - m_numAnimates++; - return; - } - endTest(); - } - - virtual void afterTest() OVERRIDE - { - } - -private: - int m_numAnimates; -}; - -TEST_F(LayerTreeHostTestSetNeedsAnimateInsideAnimationCallback, runMultiThread) -{ - runTest(true); -} - -// Add a layer animation and confirm that LayerTreeHostImpl::animateLayers does get -// called and continues to get called. -class LayerTreeHostTestAddAnimation : public LayerTreeHostTest { -public: - LayerTreeHostTestAddAnimation() - : m_numAnimates(0) - , m_receivedAnimationStartedNotification(false) - , m_startTime(0) - { - } - - virtual void beginTest() OVERRIDE - { - postAddInstantAnimationToMainThread(); - } - - virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, base::TimeTicks monotonicTime) OVERRIDE - { - if (!m_numAnimates) { - // The animation had zero duration so layerTreeHostImpl should no - // longer need to animate its layers. - EXPECT_FALSE(layerTreeHostImpl->needsAnimateLayers()); - m_numAnimates++; - m_firstMonotonicTime = monotonicTime; - return; - } - EXPECT_LT(0, m_startTime); - EXPECT_TRUE(m_receivedAnimationStartedNotification); - endTest(); - } - - virtual void notifyAnimationStarted(double wallClockTime) OVERRIDE - { - m_receivedAnimationStartedNotification = true; - m_startTime = wallClockTime; - } - - virtual void afterTest() OVERRIDE - { - } - -private: - int m_numAnimates; - bool m_receivedAnimationStartedNotification; - double m_startTime; - base::TimeTicks m_firstMonotonicTime; -}; - -TEST_F(LayerTreeHostTestAddAnimation, runMultiThread) -{ - runTest(true); -} - -// Add a layer animation to a layer, but continually fail to draw. Confirm that after -// a while, we do eventually force a draw. -class LayerTreeHostTestCheckerboardDoesNotStarveDraws : public LayerTreeHostTest { -public: - LayerTreeHostTestCheckerboardDoesNotStarveDraws() - : m_startedAnimating(false) - { - } - - virtual void beginTest() OVERRIDE - { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); - } - - virtual void afterTest() OVERRIDE - { - } - - virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, base::TimeTicks monotonicTime) OVERRIDE - { - m_startedAnimating = true; - } - - virtual void drawLayersOnThread(LayerTreeHostImpl*) OVERRIDE - { - if (m_startedAnimating) - endTest(); - } - - virtual bool prepareToDrawOnThread(LayerTreeHostImpl*) OVERRIDE - { - return false; - } - -private: - bool m_startedAnimating; -}; - -// Starvation can only be an issue with the MT compositor. -TEST_F(LayerTreeHostTestCheckerboardDoesNotStarveDraws, runMultiThread) -{ - runTest(true); -} - -// Ensures that animations continue to be ticked when we are backgrounded. -class LayerTreeHostTestTickAnimationWhileBackgrounded : public LayerTreeHostTest { -public: - LayerTreeHostTestTickAnimationWhileBackgrounded() - : m_numAnimates(0) - { - } - - virtual void beginTest() OVERRIDE - { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); - } - - // Use willAnimateLayers to set visible false before the animation runs and - // causes a commit, so we block the second visible animate in single-thread - // mode. - virtual void willAnimateLayers(LayerTreeHostImpl* layerTreeHostImpl, base::TimeTicks monotonicTime) OVERRIDE - { - if (m_numAnimates < 2) { - if (!m_numAnimates) { - // We have a long animation running. It should continue to tick even if we are not visible. - postSetVisibleToMainThread(false); - } - m_numAnimates++; - return; - } - endTest(); - } - - virtual void afterTest() OVERRIDE - { - } - -private: - int m_numAnimates; -}; - -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestTickAnimationWhileBackgrounded) - -// Ensures that animations continue to be ticked when we are backgrounded. -class LayerTreeHostTestAddAnimationWithTimingFunction : public LayerTreeHostTest { -public: - LayerTreeHostTestAddAnimationWithTimingFunction() - { - } - - virtual void beginTest() OVERRIDE - { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); - } - - virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, base::TimeTicks monotonicTime) OVERRIDE - { - const ActiveAnimation* animation = m_layerTreeHost->rootLayer()->layerAnimationController()->getActiveAnimation(0, ActiveAnimation::Opacity); - if (!animation) - return; - const FloatAnimationCurve* curve = animation->curve()->toFloatAnimationCurve(); - float startOpacity = curve->getValue(0); - float endOpacity = curve->getValue(curve->duration()); - float linearlyInterpolatedOpacity = 0.25 * endOpacity + 0.75 * startOpacity; - double time = curve->duration() * 0.25; - // If the linear timing function associated with this animation was not picked up, - // then the linearly interpolated opacity would be different because of the - // default ease timing function. - EXPECT_FLOAT_EQ(linearlyInterpolatedOpacity, curve->getValue(time)); - - const ActiveAnimation* animationImpl = layerTreeHostImpl->rootLayer()->layerAnimationController()->getActiveAnimation(0, ActiveAnimation::Opacity); - - m_layerTreeHost->rootLayer()->layerAnimationController()->removeAnimation(animation->id()); - layerTreeHostImpl->rootLayer()->layerAnimationController()->removeAnimation(animationImpl->id()); - endTest(); - } - - virtual void afterTest() OVERRIDE - { - } - -private: -}; - -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAddAnimationWithTimingFunction) - -// Ensures that main thread animations have their start times synchronized with impl thread animations. -class LayerTreeHostTestSynchronizeAnimationStartTimes : public LayerTreeHostTest { -public: - LayerTreeHostTestSynchronizeAnimationStartTimes() - : m_mainStartTime(-1) - , m_implStartTime(-1) - { - } - - virtual void beginTest() OVERRIDE - { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); - } - - virtual void notifyAnimationStarted(double time) OVERRIDE - { - LayerAnimationController* controller = m_layerTreeHost->rootLayer()->layerAnimationController(); - ActiveAnimation* animation = controller->getActiveAnimation(0, ActiveAnimation::Opacity); - m_mainStartTime = animation->startTime(); - controller->removeAnimation(animation->id()); - - if (m_implStartTime > 0) - endTest(); - } - - virtual void animateLayers(LayerTreeHostImpl* impl, base::TimeTicks monotonicTime) - { - LayerAnimationController* controller = impl->rootLayer()->layerAnimationController(); - ActiveAnimation* animation = controller->getActiveAnimation(0, ActiveAnimation::Opacity); - if (!animation) - return; - - m_implStartTime = animation->startTime(); - controller->removeAnimation(animation->id()); - - if (m_mainStartTime > 0) - endTest(); - } - - virtual void afterTest() OVERRIDE - { - EXPECT_FLOAT_EQ(m_implStartTime, m_mainStartTime); - } - -private: - double m_mainStartTime; - double m_implStartTime; -}; - -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSynchronizeAnimationStartTimes) - -// Ensures that main thread animations have their start times synchronized with impl thread animations. -class LayerTreeHostTestAnimationFinishedEvents : public LayerTreeHostTest { -public: - LayerTreeHostTestAnimationFinishedEvents() - { - } - - virtual void beginTest() OVERRIDE - { - postAddInstantAnimationToMainThread(); - } - - virtual void notifyAnimationFinished(double time) OVERRIDE - { - const ActiveAnimation* animation = m_layerTreeHost->rootLayer()->layerAnimationController()->getActiveAnimation(0, ActiveAnimation::Opacity); - m_layerTreeHost->rootLayer()->layerAnimationController()->removeAnimation(animation->id()); - endTest(); - } - - virtual void afterTest() OVERRIDE - { - } - -private: -}; - -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAnimationFinishedEvents) - class LayerTreeHostTestScrollSimple : public LayerTreeHostTest { public: LayerTreeHostTestScrollSimple() @@ -1285,48 +987,6 @@ private: virtual ~NoScaleContentLayer() { } }; -// Ensures that when opacity is being animated, this value does not cause the subtree to be skipped. -class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHostTest { -public: - LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity() - : m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_client)) - { - } - - virtual void beginTest() OVERRIDE - { - m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); - m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer); - m_updateCheckLayer->setOpacity(0); - m_updateCheckLayer->drawProperties().opacity = 0; - postAddAnimationToMainThread(m_updateCheckLayer.get()); - } - - virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE - { - endTest(); - } - - virtual void afterTest() OVERRIDE - { - // update() should have been called once, proving that the layer was not skipped. - EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount()); - - // clear m_updateCheckLayer so LayerTreeHost dies. - m_updateCheckLayer = NULL; - } - -private: - FakeContentLayerClient m_client; - scoped_refptr<ContentLayerWithUpdateTracking> m_updateCheckLayer; -}; - -TEST_F(LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread) -{ - runTest(true); -} - - class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public LayerTreeHostTest { public: diff --git a/cc/layer_tree_host_unittest_animation.cc b/cc/layer_tree_host_unittest_animation.cc index e49e825..d4e80c0 100644 --- a/cc/layer_tree_host_unittest_animation.cc +++ b/cc/layer_tree_host_unittest_animation.cc @@ -4,7 +4,12 @@ #include "cc/layer_tree_host.h" +#include "cc/animation_curve.h" #include "cc/layer.h" +#include "cc/layer_animation_controller.h" +#include "cc/layer_impl.h" +#include "cc/test/fake_content_layer.h" +#include "cc/test/fake_content_layer_client.h" #include "cc/test/layer_tree_test_common.h" namespace cc { @@ -64,10 +69,332 @@ class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested int num_commits_; }; -TEST_F(LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested, - runMultiThread) { - runTest(true); -} +MULTI_THREAD_TEST_F( + LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested) + +// Trigger a frame with setNeedsCommit. Then, inside the resulting animate +// callback, requet another frame using setNeedsAnimate. End the test when +// animate gets called yet-again, indicating that the proxy is correctly +// handling the case where setNeedsAnimate() is called inside the begin frame +// flow. +class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback : + public LayerTreeHostAnimationTest { + public: + LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback() + : num_animates_(0) { + } + + virtual void beginTest() OVERRIDE { + postSetNeedsAnimateToMainThread(); + } + + virtual void animate(base::TimeTicks) OVERRIDE { + if (!num_animates_) { + m_layerTreeHost->setNeedsAnimate(); + num_animates_++; + return; + } + endTest(); + } + + virtual void afterTest() OVERRIDE {} + + private: + int num_animates_; +}; + +MULTI_THREAD_TEST_F( + LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback) + +// Add a layer animation and confirm that LayerTreeHostImpl::animateLayers does +// get called and continues to get called. +class LayerTreeHostAnimationTestAddAnimation : + public LayerTreeHostAnimationTest { + public: + LayerTreeHostAnimationTestAddAnimation() + : num_animates_(0) + , received_animation_started_notification_(false) + , start_time_(0) { + } + + virtual void beginTest() OVERRIDE { + postAddInstantAnimationToMainThread(); + } + + virtual void animateLayers( + LayerTreeHostImpl* impl_host, + base::TimeTicks monotonic_time) OVERRIDE { + if (!num_animates_) { + // The animation had zero duration so layerTreeHostImpl should no + // longer need to animate its layers. + EXPECT_FALSE(impl_host->needsAnimateLayers()); + num_animates_++; + first_monotonic_time_ = monotonic_time; + return; + } + EXPECT_LT(0, start_time_); + EXPECT_TRUE(received_animation_started_notification_); + endTest(); + } + + virtual void notifyAnimationStarted(double wall_clock_time) OVERRIDE { + received_animation_started_notification_ = true; + start_time_ = wall_clock_time; + } + + virtual void afterTest() OVERRIDE {} + +private: + int num_animates_; + bool received_animation_started_notification_; + double start_time_; + base::TimeTicks first_monotonic_time_; +}; + +MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAddAnimation) + +// Add a layer animation to a layer, but continually fail to draw. Confirm that +// after a while, we do eventually force a draw. +class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws : + public LayerTreeHostAnimationTest { + public: + LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() + : started_animating_(false) { + } + + virtual void beginTest() OVERRIDE { + postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + } + + virtual void animateLayers( + LayerTreeHostImpl* host_impl, + base::TimeTicks monotonicTime) OVERRIDE { + started_animating_ = true; + } + + virtual void drawLayersOnThread(LayerTreeHostImpl*) OVERRIDE { + if (started_animating_) + endTest(); + } + + virtual bool prepareToDrawOnThread(LayerTreeHostImpl*) OVERRIDE { + return false; + } + + virtual void afterTest() OVERRIDE {} + + private: + bool started_animating_; +}; + +// Starvation can only be an issue with the MT compositor. +MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws) + +// Ensures that animations continue to be ticked when we are backgrounded. +class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded : + public LayerTreeHostAnimationTest { + public: + LayerTreeHostAnimationTestTickAnimationWhileBackgrounded() + : num_animates_(0) { + } + + virtual void beginTest() OVERRIDE { + postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + } + + // Use willAnimateLayers to set visible false before the animation runs and + // causes a commit, so we block the second visible animate in single-thread + // mode. + virtual void willAnimateLayers( + LayerTreeHostImpl* host_impl, + base::TimeTicks monotonicTime) OVERRIDE { + if (num_animates_ < 2) { + if (!num_animates_) { + // We have a long animation running. It should continue to tick even + // if we are not visible. + postSetVisibleToMainThread(false); + } + num_animates_++; + return; + } + endTest(); + } + + virtual void afterTest() OVERRIDE {} + + private: + int num_animates_; +}; + +SINGLE_AND_MULTI_THREAD_TEST_F( + LayerTreeHostAnimationTestTickAnimationWhileBackgrounded) + +// Ensures that animations continue to be ticked when we are backgrounded. +class LayerTreeHostAnimationTestAddAnimationWithTimingFunction : + public LayerTreeHostAnimationTest { +public: + LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} + + virtual void beginTest() OVERRIDE { + postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + } + + virtual void animateLayers( + LayerTreeHostImpl* host_impl, + base::TimeTicks monotonicTime) OVERRIDE { + LayerAnimationController* controller = + m_layerTreeHost->rootLayer()->layerAnimationController(); + ActiveAnimation* animation = + controller->getActiveAnimation(0, ActiveAnimation::Opacity); + if (!animation) + return; + + const FloatAnimationCurve* curve = + animation->curve()->toFloatAnimationCurve(); + float startOpacity = curve->getValue(0); + float endOpacity = curve->getValue(curve->duration()); + float linearly_interpolated_opacity = + 0.25 * endOpacity + 0.75 * startOpacity; + double time = curve->duration() * 0.25; + // If the linear timing function associated with this animation was not + // picked up, then the linearly interpolated opacity would be different + // because of the default ease timing function. + EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->getValue(time)); + + LayerAnimationController* controller_impl = + host_impl->rootLayer()->layerAnimationController(); + ActiveAnimation* animation_impl = + controller_impl->getActiveAnimation(0, ActiveAnimation::Opacity); + + controller->removeAnimation(animation->id()); + controller_impl->removeAnimation(animation_impl->id()); + endTest(); + } + + virtual void afterTest() OVERRIDE {} +}; + +SINGLE_AND_MULTI_THREAD_TEST_F( + LayerTreeHostAnimationTestAddAnimationWithTimingFunction) + +// Ensures that main thread animations have their start times synchronized with +// impl thread animations. +class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes : + public LayerTreeHostAnimationTest { + public: + LayerTreeHostAnimationTestSynchronizeAnimationStartTimes() + : main_start_time_(-1), + impl_start_time_(-1) { + } + + virtual void beginTest() OVERRIDE { + postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + } + + virtual void notifyAnimationStarted(double time) OVERRIDE { + LayerAnimationController* controller = + m_layerTreeHost->rootLayer()->layerAnimationController(); + ActiveAnimation* animation = + controller->getActiveAnimation(0, ActiveAnimation::Opacity); + main_start_time_ = animation->startTime(); + controller->removeAnimation(animation->id()); + + if (impl_start_time_ > 0) + endTest(); + } + + virtual void animateLayers( + LayerTreeHostImpl* impl_host, + base::TimeTicks monotonicTime) OVERRIDE { + LayerAnimationController* controller = + impl_host->rootLayer()->layerAnimationController(); + ActiveAnimation* animation = + controller->getActiveAnimation(0, ActiveAnimation::Opacity); + if (!animation) + return; + + impl_start_time_ = animation->startTime(); + controller->removeAnimation(animation->id()); + + if (main_start_time_ > 0) + endTest(); + } + + virtual void afterTest() OVERRIDE { + EXPECT_FLOAT_EQ(impl_start_time_, main_start_time_); + } + + private: + double main_start_time_; + double impl_start_time_; +}; + +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestSynchronizeAnimationStartTimes) + +// Ensures that notifyAnimationFinished is called. +class LayerTreeHostAnimationTestAnimationFinishedEvents : + public LayerTreeHostAnimationTest { + public: + LayerTreeHostAnimationTestAnimationFinishedEvents() {} + + virtual void beginTest() OVERRIDE { + postAddInstantAnimationToMainThread(); + } + + virtual void notifyAnimationFinished(double time) OVERRIDE { + LayerAnimationController* controller = + m_layerTreeHost->rootLayer()->layerAnimationController(); + ActiveAnimation* animation = + controller->getActiveAnimation(0, ActiveAnimation::Opacity); + controller->removeAnimation(animation->id()); + endTest(); + } + + virtual void afterTest() OVERRIDE {} +}; + +SINGLE_AND_MULTI_THREAD_TEST_F( + LayerTreeHostAnimationTestAnimationFinishedEvents) + +// Ensures that when opacity is being animated, this value does not cause the +// subtree to be skipped. +class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity : + public LayerTreeHostAnimationTest { + public: + LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() + : update_check_layer_(FakeContentLayer::Create(&client_)) { + } + + virtual void setupTree() OVERRIDE { + update_check_layer_->setOpacity(0); + m_layerTreeHost->setRootLayer(update_check_layer_); + LayerTreeHostAnimationTest::setupTree(); + } + + virtual void beginTest() OVERRIDE { + postAddAnimationToMainThread(update_check_layer_.get()); + } + + virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE { + endTest(); + } + + virtual void afterTest() OVERRIDE { + // update() should have been called once, proving that the layer was not + // skipped. + EXPECT_EQ(1, update_check_layer_->update_count()); + + // clear update_check_layer_ so LayerTreeHost dies. + update_check_layer_ = NULL; + } + + private: + FakeContentLayerClient client_; + scoped_refptr<FakeContentLayer> update_check_layer_; +}; + +MULTI_THREAD_TEST_F( + LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity) } // namespace } // namespace cc diff --git a/cc/test/fake_content_layer.cc b/cc/test/fake_content_layer.cc new file mode 100644 index 0000000..f217e93 --- /dev/null +++ b/cc/test/fake_content_layer.cc @@ -0,0 +1,27 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "cc/test/fake_content_layer.h" + +namespace cc { + +FakeContentLayer::FakeContentLayer(ContentLayerClient* client) + : ContentLayer(client), + update_count_(0) { + setAnchorPoint(gfx::PointF(0, 0)); + setBounds(gfx::Size(1, 1)); + setIsDrawable(true); +} + +FakeContentLayer::~FakeContentLayer() {} + +void FakeContentLayer::update( + ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats& stats) { + ContentLayer::update(queue, occlusion, stats); + update_count_++; +} + +} // namespace cc diff --git a/cc/test/fake_content_layer.h b/cc/test/fake_content_layer.h new file mode 100644 index 0000000..7defe6a --- /dev/null +++ b/cc/test/fake_content_layer.h @@ -0,0 +1,36 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_TEST_FAKE_CONTENT_LAYER_H_ +#define CC_TEST_FAKE_CONTENT_LAYER_H_ + +#include "base/memory/scoped_ptr.h" +#include "cc/content_layer.h" + +namespace cc { + +class FakeContentLayer : public ContentLayer { +public: + static scoped_refptr<FakeContentLayer> Create(ContentLayerClient* client) { + return make_scoped_refptr(new FakeContentLayer(client)); + } + + int update_count() { return update_count_; } + void reset_update_count() { update_count_ = 0; } + + virtual void update( + ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats& stats) OVERRIDE; + +private: + explicit FakeContentLayer(ContentLayerClient* client); + virtual ~FakeContentLayer(); + + int update_count_; +}; + +} // namespace cc + +#endif // CC_TEST_FAKE_CONTENT_LAYER_H_ diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h index 91183f2..ee86818 100644 --- a/cc/test/layer_tree_test_common.h +++ b/cc/test/layer_tree_test_common.h @@ -164,14 +164,20 @@ private: } // namespace cc -#define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ - TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ - { \ - runTest(false); \ - } \ - TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ - { \ - runTest(true); \ +#define SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ + TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ + { \ + runTest(false); \ + } + +#define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ + TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ + { \ + runTest(true); \ } +#define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ + SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ + MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) + #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ |