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

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

Issue 475483002: Revert "Make SingleThreadProxy a SchedulerClient" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 num_draws_++; 84 num_draws_++;
85 if (!impl->active_tree()->source_frame_number()) 85 if (!impl->active_tree()->source_frame_number())
86 EndTest(); 86 EndTest();
87 } 87 }
88 88
89 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 89 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
90 num_commits_++; 90 num_commits_++;
91 } 91 }
92 92
93 virtual void AfterTest() OVERRIDE { 93 virtual void AfterTest() OVERRIDE {
94 EXPECT_LE(1, num_commits_); 94 EXPECT_GE(1, num_commits_);
95 EXPECT_LE(1, num_draws_); 95 EXPECT_GE(1, num_draws_);
96 } 96 }
97 97
98 private: 98 private:
99 int num_commits_; 99 int num_commits_;
100 int num_draws_; 100 int num_draws_;
101 }; 101 };
102 102
103 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); 103 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1);
104 104
105 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that 105 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 687
688 private: 688 private:
689 scoped_refptr<Layer> root_layer_; 689 scoped_refptr<Layer> root_layer_;
690 scoped_refptr<Layer> parent_layer_; 690 scoped_refptr<Layer> parent_layer_;
691 scoped_refptr<Layer> child_layer_; 691 scoped_refptr<Layer> child_layer_;
692 }; 692 };
693 693
694 SINGLE_AND_MULTI_THREAD_TEST_F( 694 SINGLE_AND_MULTI_THREAD_TEST_F(
695 LayerTreeHostTestUndrawnLayersPushContentBoundsLater); 695 LayerTreeHostTestUndrawnLayersPushContentBoundsLater);
696 696
697 class LayerTreeHostTestAbortFrameWhenInvisible : public LayerTreeHostTest {
698 public:
699 LayerTreeHostTestAbortFrameWhenInvisible() {}
700
701 virtual void BeginTest() OVERRIDE {
702 // Request a commit (from the main thread), Which will trigger the commit
703 // flow from the impl side.
704 layer_tree_host()->SetNeedsCommit();
705 // Then mark ourselves as not visible before processing any more messages
706 // on the main thread.
707 layer_tree_host()->SetVisible(false);
708 // If we make it without kicking a frame, we pass!
709 EndTestAfterDelay(1);
710 }
711
712 virtual void Layout() OVERRIDE {
713 ASSERT_FALSE(true);
714 EndTest();
715 }
716
717 virtual void AfterTest() OVERRIDE {}
718 };
719
720 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortFrameWhenInvisible);
721
697 // This test verifies that properties on the layer tree host are commited 722 // This test verifies that properties on the layer tree host are commited
698 // to the impl side. 723 // to the impl side.
699 class LayerTreeHostTestCommit : public LayerTreeHostTest { 724 class LayerTreeHostTestCommit : public LayerTreeHostTest {
700 public: 725 public:
701 LayerTreeHostTestCommit() {} 726 LayerTreeHostTestCommit() {}
702 727
703 virtual void BeginTest() OVERRIDE { 728 virtual void BeginTest() OVERRIDE {
704 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 729 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
705 layer_tree_host()->set_background_color(SK_ColorGRAY); 730 layer_tree_host()->set_background_color(SK_ColorGRAY);
706 731
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 virtual void AfterTest() OVERRIDE { 1911 virtual void AfterTest() OVERRIDE {
1887 EXPECT_EQ(1, num_commits_deferred_); 1912 EXPECT_EQ(1, num_commits_deferred_);
1888 EXPECT_EQ(2, num_complete_commits_); 1913 EXPECT_EQ(2, num_complete_commits_);
1889 } 1914 }
1890 1915
1891 private: 1916 private:
1892 int num_commits_deferred_; 1917 int num_commits_deferred_;
1893 int num_complete_commits_; 1918 int num_complete_commits_;
1894 }; 1919 };
1895 1920
1896 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); 1921 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
1897 1922
1898 class LayerTreeHostWithProxy : public LayerTreeHost { 1923 class LayerTreeHostWithProxy : public LayerTreeHost {
1899 public: 1924 public:
1900 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, 1925 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client,
1901 const LayerTreeSettings& settings, 1926 const LayerTreeSettings& settings,
1902 scoped_ptr<FakeProxy> proxy) 1927 scoped_ptr<FakeProxy> proxy)
1903 : LayerTreeHost(client, NULL, settings) { 1928 : LayerTreeHost(client, NULL, settings) {
1904 proxy->SetLayerTreeHost(this); 1929 proxy->SetLayerTreeHost(this);
1905 InitializeForTesting(proxy.PassAs<Proxy>()); 1930 InitializeForTesting(proxy.PassAs<Proxy>());
1906 } 1931 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 1984
1960 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); 1985 EXPECT_EQ(10u, host.MaxPartialTextureUpdates());
1961 } 1986 }
1962 } 1987 }
1963 1988
1964 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { 1989 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
1965 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 1990 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
1966 1991
1967 LayerTreeSettings settings; 1992 LayerTreeSettings settings;
1968 settings.max_partial_texture_updates = 4; 1993 settings.max_partial_texture_updates = 4;
1969 settings.single_thread_proxy_scheduler = false;
1970 1994
1971 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1995 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1972 new TestSharedBitmapManager()); 1996 new TestSharedBitmapManager());
1973 scoped_ptr<LayerTreeHost> host = 1997 scoped_ptr<LayerTreeHost> host =
1974 LayerTreeHost::CreateSingleThreaded(&client, 1998 LayerTreeHost::CreateSingleThreaded(&client,
1975 &client, 1999 &client,
1976 shared_bitmap_manager.get(), 2000 shared_bitmap_manager.get(),
1977 settings, 2001 settings,
1978 base::MessageLoopProxy::current()); 2002 base::MessageLoopProxy::current());
1979 host->Composite(base::TimeTicks::Now()); 2003 host->Composite(base::TimeTicks::Now());
1980 2004
1981 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2005 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
1982 } 2006 }
1983 2007
1984 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { 2008 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
1985 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); 2009 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE);
1986 2010
1987 LayerTreeSettings settings; 2011 LayerTreeSettings settings;
1988 settings.max_partial_texture_updates = 4; 2012 settings.max_partial_texture_updates = 4;
1989 settings.single_thread_proxy_scheduler = false;
1990 2013
1991 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2014 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1992 new TestSharedBitmapManager()); 2015 new TestSharedBitmapManager());
1993 scoped_ptr<LayerTreeHost> host = 2016 scoped_ptr<LayerTreeHost> host =
1994 LayerTreeHost::CreateSingleThreaded(&client, 2017 LayerTreeHost::CreateSingleThreaded(&client,
1995 &client, 2018 &client,
1996 shared_bitmap_manager.get(), 2019 shared_bitmap_manager.get(),
1997 settings, 2020 settings,
1998 base::MessageLoopProxy::current()); 2021 base::MessageLoopProxy::current());
1999 host->Composite(base::TimeTicks::Now()); 2022 host->Composite(base::TimeTicks::Now());
2000 2023
2001 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2024 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
2002 } 2025 }
2003 2026
2004 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { 2027 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
2005 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); 2028 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D);
2006 2029
2007 LayerTreeSettings settings; 2030 LayerTreeSettings settings;
2008 settings.max_partial_texture_updates = 4; 2031 settings.max_partial_texture_updates = 4;
2009 settings.single_thread_proxy_scheduler = false;
2010 2032
2011 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2033 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2012 new TestSharedBitmapManager()); 2034 new TestSharedBitmapManager());
2013 scoped_ptr<LayerTreeHost> host = 2035 scoped_ptr<LayerTreeHost> host =
2014 LayerTreeHost::CreateSingleThreaded(&client, 2036 LayerTreeHost::CreateSingleThreaded(&client,
2015 &client, 2037 &client,
2016 shared_bitmap_manager.get(), 2038 shared_bitmap_manager.get(),
2017 settings, 2039 settings,
2018 base::MessageLoopProxy::current()); 2040 base::MessageLoopProxy::current());
2019 host->Composite(base::TimeTicks::Now()); 2041 host->Composite(base::TimeTicks::Now());
2020 2042
2021 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); 2043 EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
2022 } 2044 }
2023 2045
2024 TEST(LayerTreeHostTest, 2046 TEST(LayerTreeHostTest,
2025 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { 2047 PartialUpdatesWithDelegatingRendererAndSoftwareContent) {
2026 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); 2048 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE);
2027 2049
2028 LayerTreeSettings settings; 2050 LayerTreeSettings settings;
2029 settings.max_partial_texture_updates = 4; 2051 settings.max_partial_texture_updates = 4;
2030 settings.single_thread_proxy_scheduler = false;
2031 2052
2032 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2053 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2033 new TestSharedBitmapManager()); 2054 new TestSharedBitmapManager());
2034 scoped_ptr<LayerTreeHost> host = 2055 scoped_ptr<LayerTreeHost> host =
2035 LayerTreeHost::CreateSingleThreaded(&client, 2056 LayerTreeHost::CreateSingleThreaded(&client,
2036 &client, 2057 &client,
2037 shared_bitmap_manager.get(), 2058 shared_bitmap_manager.get(),
2038 settings, 2059 settings,
2039 base::MessageLoopProxy::current()); 2060 base::MessageLoopProxy::current());
2040 host->Composite(base::TimeTicks::Now()); 2061 host->Composite(base::TimeTicks::Now());
(...skipping 2478 matching lines...) Expand 10 before | Expand all | Expand 10 after
4519 } 4540 }
4520 4541
4521 int commit_count_; 4542 int commit_count_;
4522 int commit_complete_count_; 4543 int commit_complete_count_;
4523 TestSwapPromiseResult swap_promise_result_[3]; 4544 TestSwapPromiseResult swap_promise_result_[3];
4524 }; 4545 };
4525 4546
4526 // TODO(miletus): Flaky test: crbug.com/393995 4547 // TODO(miletus): Flaky test: crbug.com/393995
4527 // MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); 4548 // MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise);
4528 4549
4529 class LayerTreeHostTestBreakSwapPromiseForVisibilityAbortedCommit 4550 class LayerTreeHostTestBreakSwapPromiseForAbortedCommit
4530 : public LayerTreeHostTest { 4551 : public LayerTreeHostTest {
4531 protected: 4552 protected:
4532 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4553 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
4533 4554
4534 virtual void DidCommit() OVERRIDE { 4555 virtual void DidCommit() OVERRIDE {
4535 layer_tree_host()->SetDeferCommits(true); 4556 layer_tree_host()->SetDeferCommits(true);
4536 layer_tree_host()->SetNeedsCommit(); 4557 layer_tree_host()->SetNeedsCommit();
4537 } 4558 }
4538 4559
4539 virtual void DidDeferCommit() OVERRIDE { 4560 virtual void DidDeferCommit() OVERRIDE {
(...skipping 15 matching lines...) Expand all
4555 EXPECT_FALSE(swap_promise_result_.did_swap_called); 4576 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4556 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); 4577 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4557 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); 4578 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4558 EXPECT_TRUE(swap_promise_result_.dtor_called); 4579 EXPECT_TRUE(swap_promise_result_.dtor_called);
4559 } 4580 }
4560 } 4581 }
4561 4582
4562 TestSwapPromiseResult swap_promise_result_; 4583 TestSwapPromiseResult swap_promise_result_;
4563 }; 4584 };
4564 4585
4565 SINGLE_AND_MULTI_THREAD_TEST_F( 4586 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForAbortedCommit);
4566 LayerTreeHostTestBreakSwapPromiseForVisibilityAbortedCommit);
4567
4568 class LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit
4569 : public LayerTreeHostTest {
4570 protected:
4571 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
4572
4573 virtual void DidCommit() OVERRIDE {
4574 if (TestEnded())
4575 return;
4576 layer_tree_host()->SetDeferCommits(true);
4577 layer_tree_host()->SetNeedsCommit();
4578 }
4579
4580 virtual void DidDeferCommit() OVERRIDE {
4581 layer_tree_host()->DidLoseOutputSurface();
4582 scoped_ptr<SwapPromise> swap_promise(
4583 new TestSwapPromise(&swap_promise_result_));
4584 layer_tree_host()->QueueSwapPromise(swap_promise.Pass());
4585 layer_tree_host()->SetDeferCommits(false);
4586 }
4587
4588 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4589 bool did_handle) OVERRIDE {
4590 EndTest();
4591 // This lets the test finally commit and exit.
4592 MainThreadTaskRunner()->PostTask(
4593 FROM_HERE,
4594 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit::
4595 FindOutputSurface,
4596 base::Unretained(this)));
4597 }
4598
4599 void FindOutputSurface() {
4600 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(true);
4601 }
4602
4603 virtual void AfterTest() OVERRIDE {
4604 {
4605 base::AutoLock lock(swap_promise_result_.lock);
4606 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4607 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4608 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4609 EXPECT_TRUE(swap_promise_result_.dtor_called);
4610 }
4611 }
4612
4613 TestSwapPromiseResult swap_promise_result_;
4614 };
4615
4616 SINGLE_AND_MULTI_THREAD_TEST_F(
4617 LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit);
4618 4587
4619 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { 4588 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
4620 public: 4589 public:
4621 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, 4590 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host,
4622 LayerTreeHostImpl* layer_tree_host_impl, 4591 LayerTreeHostImpl* layer_tree_host_impl,
4623 int* set_needs_commit_count, 4592 int* set_needs_commit_count,
4624 int* set_needs_redraw_count) 4593 int* set_needs_redraw_count)
4625 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 4594 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
4626 set_needs_commit_count_(set_needs_commit_count) {} 4595 set_needs_commit_count_(set_needs_commit_count) {}
4627 4596
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
4692 EXPECT_EQ(3, set_needs_commit_count); 4661 EXPECT_EQ(3, set_needs_commit_count);
4693 EXPECT_EQ(0, set_needs_redraw_count); 4662 EXPECT_EQ(0, set_needs_redraw_count);
4694 } 4663 }
4695 4664
4696 EndTest(); 4665 EndTest();
4697 } 4666 }
4698 4667
4699 virtual void AfterTest() OVERRIDE {} 4668 virtual void AfterTest() OVERRIDE {}
4700 }; 4669 };
4701 4670
4702 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); 4671 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor);
4703 4672
4704 class LayerTreeHostTestHighResRequiredAfterEvictingUIResources 4673 class LayerTreeHostTestHighResRequiredAfterEvictingUIResources
4705 : public LayerTreeHostTest { 4674 : public LayerTreeHostTest {
4706 protected: 4675 protected:
4707 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4676 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
4708 settings->impl_side_painting = true; 4677 settings->impl_side_painting = true;
4709 } 4678 }
4710 4679
4711 virtual void SetupTree() OVERRIDE { 4680 virtual void SetupTree() OVERRIDE {
4712 LayerTreeHostTest::SetupTree(); 4681 LayerTreeHostTest::SetupTree();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
5018 const gfx::Size bounds_; 4987 const gfx::Size bounds_;
5019 FakeContentLayerClient client_; 4988 FakeContentLayerClient client_;
5020 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 4989 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5021 scoped_refptr<FakePictureLayer> picture_layer_; 4990 scoped_refptr<FakePictureLayer> picture_layer_;
5022 Layer* child_layer_; 4991 Layer* child_layer_;
5023 }; 4992 };
5024 4993
5025 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 4994 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5026 4995
5027 } // namespace cc 4996 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_single_thread_client.h ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698