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

Unified Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 321193002: cc: Test losing the output surface during deferred commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « cc/test/layer_tree_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest_context.cc
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 47edbb144a3d11b40e71b21a18370491a1e13abe..879e5347e311078e380b072780e3c6ff6f393cd9 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -1473,5 +1473,64 @@ class LayerTreeHostContextTestSurfaceCreateCallback
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback);
+class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame
+ : public LayerTreeHostContextTest {
+ protected:
+ virtual void BeginTest() OVERRIDE {
+ deferred_ = false;
+ PostSetNeedsCommitToMainThread();
+ }
+
+ virtual void ScheduledActionWillSendBeginMainFrame() OVERRIDE {
+ if (deferred_)
+ return;
+ deferred_ = true;
+
+ // Defer commits before the BeginFrame arrives, causing it to be delayed.
+ MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
+ DeferCommitsOnMainThread,
+ base::Unretained(this),
+ true));
+ // Meanwhile, lose the context while we are in defer commits.
+ ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
+ LoseContextOnImplThread,
+ base::Unretained(this)));
+ }
+
+ void LoseContextOnImplThread() {
+ LoseContext();
+
+ // After losing the context, stop deferring commits.
+ MainThreadTaskRunner()->PostTask(
enne (OOO) 2014/06/10 18:43:32 This seems racy. Couldn't DeferCommitsOnMainThrea
danakj 2014/06/10 18:46:24 I think not because after ScheduledActionWillSendB
enne (OOO) 2014/06/10 18:59:43 Oh, right. ScheduledActionWillSendBeginMainFrame
+ FROM_HERE,
+ base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
+ DeferCommitsOnMainThread,
+ base::Unretained(this),
+ false));
+ }
+
+ void DeferCommitsOnMainThread(bool defer_commits) {
+ layer_tree_host()->SetDeferCommits(defer_commits);
+ }
+
+ virtual void WillBeginMainFrame() OVERRIDE {
+ // Don't begin a frame with a lost surface.
+ EXPECT_FALSE(layer_tree_host()->output_surface_lost());
+ }
+
+ virtual void DidCommitAndDrawFrame() OVERRIDE { EndTest(); }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ bool deferred_;
+};
+
+// TODO(danakj): We don't use scheduler with SingleThreadProxy yet.
+MULTI_THREAD_TEST_F(LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698