Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3420)

Unified Diff: cc/CCLayerTreeHostImplTest.cpp

Issue 10907075: Roll cc snapshot up to 127605 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCLayerTreeHostTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCLayerTreeHostTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698