Index: cc/trees/layer_tree_host_unittest.cc |
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
index 8e569a521c1c06698c179ce75388c5a07eebbba4..efce41f46f0c27cc88b9f02fe7bf26d69eeb491a 100644 |
--- a/cc/trees/layer_tree_host_unittest.cc |
+++ b/cc/trees/layer_tree_host_unittest.cc |
@@ -3925,7 +3925,6 @@ class TestSwapPromise : public SwapPromise { |
void DidSwap(CompositorFrameMetadata* metadata) override { |
base::AutoLock lock(result_->lock); |
- EXPECT_TRUE(result_->did_activate_called); |
EXPECT_FALSE(result_->did_swap_called); |
EXPECT_FALSE(result_->did_not_swap_called); |
result_->did_swap_called = true; |
@@ -3948,6 +3947,53 @@ class TestSwapPromise : public SwapPromise { |
TestSwapPromiseResult* result_; |
}; |
+class PinnedLayerTreeSwapPromise : public LayerTreeHostTest { |
+ protected: |
+ void BeginTest() override { |
+ PostSetNextCommitForcesRedrawToMainThread(); |
+ PostSetNeedsCommitToMainThread(); |
+ } |
+ |
+ void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
+ int frame = host_impl->active_tree()->source_frame_number(); |
+ if (frame == -1) { |
+ host_impl->active_tree()->QueuePinnedSwapPromise(make_scoped_ptr( |
+ new TestSwapPromise(&pinned_active_swap_promise_result_))); |
+ host_impl->pending_tree()->QueueSwapPromise( |
+ make_scoped_ptr(new TestSwapPromise(&pending_swap_promise_result_))); |
+ host_impl->active_tree()->QueueSwapPromise( |
+ make_scoped_ptr(new TestSwapPromise(&active_swap_promise_result_))); |
+ } |
+ } |
+ |
+ void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { |
+ EndTest(); |
+ } |
+ |
+ void AfterTest() override { |
+ // The pending swap promise should activate and swap. |
+ EXPECT_TRUE(pending_swap_promise_result_.did_activate_called); |
+ EXPECT_TRUE(pending_swap_promise_result_.did_swap_called); |
+ |
+ // The active swap promise should fail to swap (it is cancelled by |
+ // the activation of a new frame). |
+ EXPECT_FALSE(active_swap_promise_result_.did_activate_called); |
+ EXPECT_FALSE(active_swap_promise_result_.did_swap_called); |
+ EXPECT_TRUE(active_swap_promise_result_.did_not_swap_called); |
+ EXPECT_EQ(active_swap_promise_result_.reason, SwapPromise::SWAP_FAILS); |
+ |
+ // The pinned active swap promise should not activate, but should swap. |
+ EXPECT_FALSE(pinned_active_swap_promise_result_.did_activate_called); |
+ EXPECT_TRUE(pinned_active_swap_promise_result_.did_swap_called); |
+ } |
+ |
+ TestSwapPromiseResult pending_swap_promise_result_; |
+ TestSwapPromiseResult active_swap_promise_result_; |
+ TestSwapPromiseResult pinned_active_swap_promise_result_; |
+}; |
+ |
+MULTI_THREAD_TEST_F(PinnedLayerTreeSwapPromise); |
+ |
class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { |
protected: |
LayerTreeHostTestBreakSwapPromise() |