diff options
-rw-r--r-- | cc/test/layer_tree_test.cc | 1 | ||||
-rw-r--r-- | cc/test/layer_tree_test.h | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_context.cc | 59 |
3 files changed, 61 insertions, 0 deletions
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index d21d43e..10c415e 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -75,6 +75,7 @@ class ThreadProxyForTest : public ThreadProxy { } virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { + test_hooks_->ScheduledActionWillSendBeginMainFrame(); ThreadProxy::ScheduledActionSendBeginMainFrame(); test_hooks_->ScheduledActionSendBeginMainFrame(); } diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index 2c078a1..b111963 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -80,6 +80,7 @@ class TestHooks : public AnimationDelegate { // Hooks for SchedulerClient. virtual void ScheduledActionBeginOutputSurfaceCreation() {} + virtual void ScheduledActionWillSendBeginMainFrame() {} virtual void ScheduledActionSendBeginMainFrame() {} virtual void ScheduledActionCommit() {} virtual void ScheduledActionDrawAndSwapIfPossible() {} diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index 47edbb1..879e534 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( + 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 |