Index: cc/CCLayerTreeHostImplTest.cpp |
diff --git a/cc/CCLayerTreeHostImplTest.cpp b/cc/CCLayerTreeHostImplTest.cpp |
index f46cfdaf35403129ce164ed5bc4af9bcf8605dac..8dc6752db6be8816cb666ea4d31a116cac496784 100644 |
--- a/cc/CCLayerTreeHostImplTest.cpp |
+++ b/cc/CCLayerTreeHostImplTest.cpp |
@@ -50,7 +50,8 @@ namespace { |
class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImplClient { |
public: |
CCLayerTreeHostImplTest() |
- : m_didRequestCommit(false) |
+ : m_onCanDrawStateChangedCalled(false) |
+ , m_didRequestCommit(false) |
, m_didRequestRedraw(false) |
{ |
CCLayerTreeSettings settings; |
@@ -64,6 +65,7 @@ public: |
virtual void didLoseContextOnImplThread() OVERRIDE { } |
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
virtual void onVSyncParametersChanged(double, double) OVERRIDE { } |
+ virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawStateChangedCalled = true; } |
virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = true; } |
virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; } |
virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE { } |
@@ -165,6 +167,7 @@ protected: |
DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
OwnPtr<CCLayerTreeHostImpl> m_hostImpl; |
+ bool m_onCanDrawStateChangedCalled; |
bool m_didRequestCommit; |
bool m_didRequestRedraw; |
CCScopedSettings m_scopedSettings; |
@@ -175,6 +178,53 @@ public: |
virtual bool makeContextCurrent() { return false; } |
}; |
+TEST_F(CCLayerTreeHostImplTest, notifyIfCanDrawChanged) |
+{ |
+ // Note: It is not possible to disable the renderer once it has been set, |
+ // so we do not need to test that disabling the renderer notifies us |
+ // that canDraw changed. |
+ EXPECT_FALSE(m_hostImpl->canDraw()); |
+ m_onCanDrawStateChangedCalled = false; |
+ |
+ setupScrollAndContentsLayers(IntSize(100, 100)); |
+ EXPECT_TRUE(m_hostImpl->canDraw()); |
+ EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
+ m_onCanDrawStateChangedCalled = false; |
+ |
+ // Toggle the root layer to make sure it toggles canDraw |
+ m_hostImpl->setRootLayer(adoptPtr<CCLayerImpl>(0)); |
+ EXPECT_FALSE(m_hostImpl->canDraw()); |
+ EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
+ m_onCanDrawStateChangedCalled = false; |
+ |
+ setupScrollAndContentsLayers(IntSize(100, 100)); |
+ EXPECT_TRUE(m_hostImpl->canDraw()); |
+ EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
+ m_onCanDrawStateChangedCalled = false; |
+ |
+ // Toggle the device viewport size to make sure it toggles canDraw. |
+ m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(0, 0)); |
+ EXPECT_FALSE(m_hostImpl->canDraw()); |
+ EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
+ m_onCanDrawStateChangedCalled = false; |
+ |
+ m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); |
+ EXPECT_TRUE(m_hostImpl->canDraw()); |
+ EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
+ m_onCanDrawStateChangedCalled = false; |
+ |
+ // Toggle contents textures purged to make sure it toggles canDraw |
+ m_hostImpl->releaseContentsTextures(); |
+ EXPECT_FALSE(m_hostImpl->canDraw()); |
+ EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
+ m_onCanDrawStateChangedCalled = false; |
+ |
+ m_hostImpl->resetContentsTexturesPurged(); |
+ EXPECT_TRUE(m_hostImpl->canDraw()); |
+ EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
+ m_onCanDrawStateChangedCalled = false; |
+} |
+ |
TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers) |
{ |
ASSERT_FALSE(m_hostImpl->rootLayer()); |