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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 240163005: Deliver IPC messages together with SwapCompositorFrame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable browsertest for android for realz this time Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 4482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4493 { 4493 {
4494 // The first commit completes and causes swap buffer which finishes 4494 // The first commit completes and causes swap buffer which finishes
4495 // the promise. 4495 // the promise.
4496 base::AutoLock lock(swap_promise_result_[0].lock); 4496 base::AutoLock lock(swap_promise_result_[0].lock);
4497 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); 4497 EXPECT_TRUE(swap_promise_result_[0].did_swap_called);
4498 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); 4498 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called);
4499 EXPECT_TRUE(swap_promise_result_[0].dtor_called); 4499 EXPECT_TRUE(swap_promise_result_[0].dtor_called);
4500 } 4500 }
4501 4501
4502 { 4502 {
4503 // The second commit aborts. 4503 // The second commit is aborted since it contains no updates.
4504 base::AutoLock lock(swap_promise_result_[1].lock); 4504 base::AutoLock lock(swap_promise_result_[1].lock);
4505 EXPECT_FALSE(swap_promise_result_[1].did_swap_called); 4505 EXPECT_FALSE(swap_promise_result_[1].did_swap_called);
4506 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called); 4506 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called);
4507 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_[1].reason); 4507 EXPECT_EQ(SwapPromise::COMMIT_NO_UPDATE, swap_promise_result_[1].reason);
4508 EXPECT_TRUE(swap_promise_result_[1].dtor_called); 4508 EXPECT_TRUE(swap_promise_result_[1].dtor_called);
4509 } 4509 }
4510 4510
4511 { 4511 {
4512 // The last commit completes but it does not cause swap buffer because 4512 // The last commit completes but it does not cause swap buffer because
4513 // there is no damage in the frame data. 4513 // there is no damage in the frame data.
4514 base::AutoLock lock(swap_promise_result_[2].lock); 4514 base::AutoLock lock(swap_promise_result_[2].lock);
4515 EXPECT_FALSE(swap_promise_result_[2].did_swap_called); 4515 EXPECT_FALSE(swap_promise_result_[2].did_swap_called);
4516 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called); 4516 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called);
4517 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason); 4517 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason);
4518 EXPECT_TRUE(swap_promise_result_[2].dtor_called); 4518 EXPECT_TRUE(swap_promise_result_[2].dtor_called);
4519 } 4519 }
4520 } 4520 }
4521 4521
4522 int commit_count_; 4522 int commit_count_;
4523 int commit_complete_count_; 4523 int commit_complete_count_;
4524 TestSwapPromiseResult swap_promise_result_[3]; 4524 TestSwapPromiseResult swap_promise_result_[3];
4525 }; 4525 };
4526 4526
4527 // TODO(miletus): Flaky test: crbug.com/393995 4527 // TODO(miletus): Flaky test: crbug.com/393995
4528 // MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); 4528 // MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise);
4529 4529
4530 class LayerTreeHostTestBreakSwapPromiseForAbortedCommit
4531 : public LayerTreeHostTest {
4532 protected:
4533 LayerTreeHostTestBreakSwapPromiseForAbortedCommit() : commit_count_(0) {}
4534
4535 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
4536
4537 virtual void WillBeginMainFrame() OVERRIDE {
4538 layer_tree_host()->SetDeferCommits(true);
4539 layer_tree_host()->SetNeedsCommit();
4540 }
4541
4542 virtual void DidDeferCommit() OVERRIDE {
4543 layer_tree_host()->SetVisible(false);
4544 layer_tree_host()->SetDeferCommits(false);
4545
4546 scoped_ptr<SwapPromise> swap_promise(
4547 new TestSwapPromise(&swap_promise_result_));
4548 layer_tree_host()->QueueSwapPromise(swap_promise.Pass());
4549 }
4550
4551 virtual void DidCommit() OVERRIDE { PostSetNeedsCommitToMainThread(); }
4552
4553 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4554 bool did_handle) OVERRIDE {
4555 EndTest();
4556 }
4557
4558 virtual void AfterTest() OVERRIDE {
4559 {
4560 base::AutoLock lock(swap_promise_result_.lock);
4561 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4562 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4563 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4564 EXPECT_TRUE(swap_promise_result_.dtor_called);
4565 }
4566 }
4567
4568 int commit_count_;
4569 TestSwapPromiseResult swap_promise_result_;
4570 };
4571
4572 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForAbortedCommit);
4573
4530 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { 4574 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
4531 public: 4575 public:
4532 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, 4576 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host,
4533 LayerTreeHostImpl* layer_tree_host_impl, 4577 LayerTreeHostImpl* layer_tree_host_impl,
4534 int* set_needs_commit_count, 4578 int* set_needs_commit_count,
4535 int* set_needs_redraw_count) 4579 int* set_needs_redraw_count)
4536 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 4580 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
4537 set_needs_commit_count_(set_needs_commit_count), 4581 set_needs_commit_count_(set_needs_commit_count),
4538 set_needs_redraw_count_(set_needs_redraw_count) {} 4582 set_needs_redraw_count_(set_needs_redraw_count) {}
4539 4583
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
4911 const gfx::Size bounds_; 4955 const gfx::Size bounds_;
4912 FakeContentLayerClient client_; 4956 FakeContentLayerClient client_;
4913 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 4957 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
4914 scoped_refptr<FakePictureLayer> picture_layer_; 4958 scoped_refptr<FakePictureLayer> picture_layer_;
4915 Layer* child_layer_; 4959 Layer* child_layer_;
4916 }; 4960 };
4917 4961
4918 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 4962 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
4919 4963
4920 } // namespace cc 4964 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698