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

Unified Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp

Issue 2051513002: Fix 2D canvas entiring invalid state when painted during hibernation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
index 7bb092d31005f6c9a877d4446e06569cfbd62f50..350b948b4b0fdfd50fe4c11ba23b412de882d4e1 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
@@ -800,6 +800,58 @@ TEST_F(Canvas2DLayerBridgeTest, DISABLED_TeardownWhileHibernating)
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
+#if CANVAS2D_HIBERNATION_ENABLED
+TEST_F(Canvas2DLayerBridgeTest, SnapshotWhileHibernating)
+#else
+TEST_F(Canvas2DLayerBridgeTest, DISABLED_SnapshotWhileHibernating)
+#endif
+{
+ FakeGLES2Interface gl;
+ OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("TestThread"));
+
+ // The Canvas2DLayerBridge has to be created on the thread that will use it
+ // to avoid WeakPtr thread check issues.
+ Canvas2DLayerBridgePtr bridge;
+ postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl, this);
+
+ // Register an alternate Logger for tracking hibernation events
+ OwnPtr<MockLogger> mockLogger = adoptPtr(new MockLogger);
+ MockLogger* mockLoggerPtr = mockLogger.get();
+ bridge->setLoggerForTesting(std::move(mockLogger));
+
+ // Test entering hibernation
+ OwnPtr<WaitableEvent> hibernationStartedEvent = adoptPtr(new WaitableEvent());
+ EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::HibernationScheduled));
+ EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
+ .WillOnce(testing::Invoke(hibernationStartedEvent.get(), &WaitableEvent::signal));
+ postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
+ hibernationStartedEvent->wait();
+ ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
+ EXPECT_FALSE(bridge->isAccelerated());
+ EXPECT_TRUE(bridge->isHibernating());
+ EXPECT_TRUE(bridge->checkSurfaceValid());
+
+ // Take a snapshot and verify that it is not accelerated due to hibernation
+ RefPtr<SkImage> image = bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnknown);
+ EXPECT_FALSE(image->isTextureBacked());
+ image.clear();
+
+ // Verify that taking a snapshot did not affect the state of bridge
+ EXPECT_FALSE(bridge->isAccelerated());
+ EXPECT_TRUE(bridge->isHibernating());
+ EXPECT_TRUE(bridge->checkSurfaceValid());
+
+ // End hibernation normally
+ OwnPtr<WaitableEvent> hibernationEndedEvent = adoptPtr(new WaitableEvent());
+ EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::HibernationEndedNormally))
+ .WillOnce(testing::InvokeWithoutArgs(hibernationEndedEvent.get(), &WaitableEvent::signal));
+ postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
+ hibernationEndedEvent->wait();
+
+ // Tear down the bridge while hibernating
+ postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
+}
+
class IdleFenceTask : public WebThread::IdleTask {
public:
IdleFenceTask(WaitableEvent* doneEvent)
@@ -1048,4 +1100,5 @@ TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering)
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698