Chromium Code Reviews| 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 f76c7616263e98f7eb349917d764e7d1ed2342de..a1ab5b9b92dfdc237f4e5dca59d80d6068015863 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -3851,7 +3851,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; |
| @@ -3874,6 +3873,70 @@ class TestSwapPromise : public SwapPromise { |
| TestSwapPromiseResult* result_; |
| }; |
| +class PinnedLayerTreeSwapPromise : public LayerTreeHostTest { |
| + protected: |
| + PinnedLayerTreeSwapPromise() {} |
|
danakj
2015/08/25 21:37:30
don't need this
Tobias Sargeant
2015/08/26 11:06:49
Done.
|
| + |
| + 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->pending_tree()->QueuePinnedSwapPromise( |
| + make_scoped_ptr( |
| + new TestSwapPromise(&pinned_pending_swap_promise_result_)) |
| + .Pass()); |
|
danakj
2015/08/25 21:37:30
you don't need .Pass() here. make_scoped_ptr's ret
Tobias Sargeant
2015/08/26 11:06:49
Done.
|
| + host_impl->active_tree()->QueuePinnedSwapPromise( |
| + make_scoped_ptr( |
| + new TestSwapPromise(&pinned_active_swap_promise_result_)) |
| + .Pass()); |
|
danakj
2015/08/25 21:37:30
and here, etc
Tobias Sargeant
2015/08/26 11:06:49
Done.
|
| + |
| + host_impl->pending_tree()->QueueSwapPromise( |
| + make_scoped_ptr(new TestSwapPromise(&pending_swap_promise_result_)) |
| + .Pass()); |
| + host_impl->active_tree()->QueueSwapPromise( |
| + make_scoped_ptr(new TestSwapPromise(&active_swap_promise_result_)) |
| + .Pass()); |
| + } |
| + } |
| + |
| + 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 pinned pending swap promise should activate but neither swap nor fail |
| + // to swap. |
| + EXPECT_TRUE(pinned_pending_swap_promise_result_.did_activate_called); |
| + EXPECT_FALSE(pinned_pending_swap_promise_result_.did_swap_called); |
| + EXPECT_FALSE(pinned_pending_swap_promise_result_.did_not_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_, |
|
danakj
2015/08/25 21:37:30
please define one variable per statement.
Tobias Sargeant
2015/08/26 11:06:49
Done.
|
| + pinned_pending_swap_promise_result_, active_swap_promise_result_, |
| + pinned_active_swap_promise_result_; |
| +}; |
| + |
| +MULTI_THREAD_TEST_F(PinnedLayerTreeSwapPromise); |
| + |
| class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { |
| protected: |
| LayerTreeHostTestBreakSwapPromise() |