OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 4466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4477 { | 4477 { |
4478 // The first commit completes and causes swap buffer which finishes | 4478 // The first commit completes and causes swap buffer which finishes |
4479 // the promise. | 4479 // the promise. |
4480 base::AutoLock lock(swap_promise_result_[0].lock); | 4480 base::AutoLock lock(swap_promise_result_[0].lock); |
4481 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); | 4481 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); |
4482 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); | 4482 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); |
4483 EXPECT_TRUE(swap_promise_result_[0].dtor_called); | 4483 EXPECT_TRUE(swap_promise_result_[0].dtor_called); |
4484 } | 4484 } |
4485 | 4485 |
4486 { | 4486 { |
4487 // The second commit aborts. | 4487 // The second commit is aborted since it contains no updates. |
4488 base::AutoLock lock(swap_promise_result_[1].lock); | 4488 base::AutoLock lock(swap_promise_result_[1].lock); |
4489 EXPECT_FALSE(swap_promise_result_[1].did_swap_called); | 4489 EXPECT_FALSE(swap_promise_result_[1].did_swap_called); |
4490 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called); | 4490 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called); |
4491 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_[1].reason); | 4491 EXPECT_EQ(SwapPromise::COMMIT_NO_UPDATE, swap_promise_result_[1].reason); |
4492 EXPECT_TRUE(swap_promise_result_[1].dtor_called); | 4492 EXPECT_TRUE(swap_promise_result_[1].dtor_called); |
4493 } | 4493 } |
4494 | 4494 |
4495 { | 4495 { |
4496 // The last commit completes but it does not cause swap buffer because | 4496 // The last commit completes but it does not cause swap buffer because |
4497 // there is no damage in the frame data. | 4497 // there is no damage in the frame data. |
4498 base::AutoLock lock(swap_promise_result_[2].lock); | 4498 base::AutoLock lock(swap_promise_result_[2].lock); |
4499 EXPECT_FALSE(swap_promise_result_[2].did_swap_called); | 4499 EXPECT_FALSE(swap_promise_result_[2].did_swap_called); |
4500 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called); | 4500 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called); |
4501 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason); | 4501 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason); |
4502 EXPECT_TRUE(swap_promise_result_[2].dtor_called); | 4502 EXPECT_TRUE(swap_promise_result_[2].dtor_called); |
4503 } | 4503 } |
4504 } | 4504 } |
4505 | 4505 |
4506 int commit_count_; | 4506 int commit_count_; |
4507 int commit_complete_count_; | 4507 int commit_complete_count_; |
4508 TestSwapPromiseResult swap_promise_result_[3]; | 4508 TestSwapPromiseResult swap_promise_result_[3]; |
4509 }; | 4509 }; |
4510 | 4510 |
4511 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); | 4511 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); |
4512 | 4512 |
| 4513 class LayerTreeHostTestBreakSwapPromiseForAbortedCommit |
| 4514 : public LayerTreeHostTest { |
| 4515 protected: |
| 4516 LayerTreeHostTestBreakSwapPromiseForAbortedCommit() : commit_count_(0) {} |
| 4517 |
| 4518 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 4519 |
| 4520 virtual void WillBeginMainFrame() OVERRIDE { |
| 4521 layer_tree_host()->SetDeferCommits(true); |
| 4522 layer_tree_host()->SetNeedsCommit(); |
| 4523 } |
| 4524 |
| 4525 virtual void DidDeferCommit() OVERRIDE { |
| 4526 layer_tree_host()->SetVisible(false); |
| 4527 layer_tree_host()->SetDeferCommits(false); |
| 4528 |
| 4529 scoped_ptr<SwapPromise> swap_promise( |
| 4530 new TestSwapPromise(&swap_promise_result_)); |
| 4531 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); |
| 4532 } |
| 4533 |
| 4534 virtual void DidCommit() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 4535 |
| 4536 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
| 4537 bool did_handle) OVERRIDE { |
| 4538 EndTest(); |
| 4539 } |
| 4540 |
| 4541 virtual void AfterTest() OVERRIDE { |
| 4542 { |
| 4543 base::AutoLock lock(swap_promise_result_.lock); |
| 4544 EXPECT_FALSE(swap_promise_result_.did_swap_called); |
| 4545 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); |
| 4546 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); |
| 4547 EXPECT_TRUE(swap_promise_result_.dtor_called); |
| 4548 } |
| 4549 } |
| 4550 |
| 4551 int commit_count_; |
| 4552 TestSwapPromiseResult swap_promise_result_; |
| 4553 }; |
| 4554 |
| 4555 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForAbortedCommit); |
| 4556 |
4513 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 4557 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
4514 public: | 4558 public: |
4515 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, | 4559 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, |
4516 LayerTreeHostImpl* layer_tree_host_impl, | 4560 LayerTreeHostImpl* layer_tree_host_impl, |
4517 int* set_needs_commit_count, | 4561 int* set_needs_commit_count, |
4518 int* set_needs_redraw_count) | 4562 int* set_needs_redraw_count) |
4519 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 4563 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), |
4520 set_needs_commit_count_(set_needs_commit_count), | 4564 set_needs_commit_count_(set_needs_commit_count), |
4521 set_needs_redraw_count_(set_needs_redraw_count) {} | 4565 set_needs_redraw_count_(set_needs_redraw_count) {} |
4522 | 4566 |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4894 const gfx::Size bounds_; | 4938 const gfx::Size bounds_; |
4895 FakeContentLayerClient client_; | 4939 FakeContentLayerClient client_; |
4896 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4940 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
4897 scoped_refptr<FakePictureLayer> picture_layer_; | 4941 scoped_refptr<FakePictureLayer> picture_layer_; |
4898 Layer* child_layer_; | 4942 Layer* child_layer_; |
4899 }; | 4943 }; |
4900 | 4944 |
4901 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4945 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
4902 | 4946 |
4903 } // namespace cc | 4947 } // namespace cc |
OLD | NEW |