diff options
Diffstat (limited to 'cc/layer_tree_host_unittest.cc')
-rw-r--r-- | cc/layer_tree_host_unittest.cc | 84 |
1 files changed, 38 insertions, 46 deletions
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index 1a9bdb8..030ee97 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -651,7 +651,7 @@ public: virtual void beginTest() OVERRIDE { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + postAddAnimationToMainThread(); } virtual void afterTest() OVERRIDE @@ -694,7 +694,7 @@ public: virtual void beginTest() OVERRIDE { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + postAddAnimationToMainThread(); } // Use willAnimateLayers to set visible false before the animation runs and @@ -732,7 +732,7 @@ public: virtual void beginTest() OVERRIDE { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + postAddAnimationToMainThread(); } virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, base::TimeTicks monotonicTime) OVERRIDE @@ -761,6 +761,40 @@ private: SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAddAnimationWithTimingFunction) +// Ensures that when opacity is being animated, this value does not cause the subtree to be skipped. +class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHostTest { +public: + LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity() + { + } + + virtual void beginTest() OVERRIDE + { + m_layerTreeHost->rootLayer()->setDrawOpacity(1); + m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); + m_layerTreeHost->rootLayer()->setOpacity(0); + postAddAnimationToMainThread(); + } + + virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE + { + // If the subtree was skipped when preparing to draw, the layer's draw opacity + // will not have been updated. It should be set to 0 due to the animation. + // Without the animation, the layer will be skipped since it has zero opacity. + EXPECT_EQ(0, m_layerTreeHost->rootLayer()->drawOpacity()); + endTest(); + } + + virtual void afterTest() OVERRIDE + { + } +}; + +TEST_F(LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread) +{ + runTest(true); +} + // Ensures that main thread animations have their start times synchronized with impl thread animations. class LayerTreeHostTestSynchronizeAnimationStartTimes : public LayerTreeHostTest { public: @@ -771,7 +805,7 @@ public: virtual void beginTest() OVERRIDE { - postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); + postAddAnimationToMainThread(); } // This is guaranteed to be called before CCLayerTreeHostImpl::animateLayers. @@ -1206,48 +1240,6 @@ TEST_F(LayerTreeHostTestOpacityChange, runMultiThread) runTest(true); } -// Ensures that when opacity is being animated, this value does not cause the subtree to be skipped. -class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHostTest { -public: - LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity() - : m_testOpacityChangeDelegate(this) - , m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_testOpacityChangeDelegate)) - { - } - - virtual void beginTest() OVERRIDE - { - m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); - m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer); - m_updateCheckLayer->setOpacity(0); - m_updateCheckLayer->setDrawOpacity(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: - TestOpacityChangeLayerDelegate m_testOpacityChangeDelegate; - scoped_refptr<ContentLayerWithUpdateTracking> m_updateCheckLayer; -}; - -TEST_F(LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread) -{ - runTest(true); -} - class MockContentLayerClient : public ContentLayerClient { public: bool drawsContent() const { return true; } |