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

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

Issue 242783003: cc: Add testing stubs for proxy test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Makes proxy test more general for single & threaded proxy Created 6 years, 7 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h"
7 #include "cc/test/layer_tree_test.h"
8 #include "cc/trees/thread_proxy.h"
9
10 #define THREAD_PROXY_NO_IMPL_TEST_F(TEST_FIXTURE_NAME) \
11 TEST_F(TEST_FIXTURE_NAME, Run_MainThreadPaint) { \
12 Run(true, false); \
13 }
14
15 #define THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME) \
16 THREAD_PROXY_NO_IMPL_TEST_F(TEST_FIXTURE_NAME); \
17 TEST_F(TEST_FIXTURE_NAME, Run_ImplSidePaint) { \
18 Run(true, true); \
19 }
20
21 namespace cc {
22
23 class ProxyTest : public LayerTreeTest {
24 public:
25 ProxyTest() : threaded_(false) {}
26 virtual ~ProxyTest() {}
27
28 void Run(bool threaded, bool impl_side_painting) {
29 // We don't need to care about delegating mode.
30 bool delegating_renderer = true;
31
32 threaded_ = threaded;
33 RunTest(threaded, delegating_renderer, impl_side_painting);
34 }
35
36 const ThreadProxy::MainThreadOnly& ThreadProxyMainOnly() const {
37 DCHECK(proxy());
38 DCHECK(proxy()->HasImplThread());
39 return static_cast<const ThreadProxy*>(proxy())->main();
40 }
41
42 const ThreadProxy::CompositorThreadOnly& ThreadProxyImplOnly() const {
43 DCHECK(proxy());
44 DCHECK(proxy()->HasImplThread());
45 return static_cast<const ThreadProxy*>(proxy())->impl();
46 }
47
48 bool threaded () const { return threaded_; }
49
50 private:
51 bool threaded_;
52
53 DISALLOW_COPY_AND_ASSIGN(ProxyTest);
54 };
55
56 class ProxyTestOutputSurfaceCreationRequest : public ProxyTest {
57 public:
58 virtual void BeginTest() OVERRIDE {
59 EXPECT_FALSE(has_sent_output_surface_creation_request_);
60 proxy()->SetNeedsCommit();
61 }
62
63 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {
64 has_sent_output_surface_creation_request_ = true;
65 EndTest();
66 }
67
68 virtual void AfterTest() OVERRIDE {
69 EXPECT_TRUE(has_sent_output_surface_creation_request_);
70 }
71
72 protected:
73 ProxyTestOutputSurfaceCreationRequest()
74 : has_sent_output_surface_creation_request_(false) {
75 }
76 virtual ~ProxyTestOutputSurfaceCreationRequest() {}
77
78 private:
79 bool has_sent_output_surface_creation_request_;
80
81 DISALLOW_COPY_AND_ASSIGN(ProxyTestOutputSurfaceCreationRequest);
82 };
83
84 THREAD_PROXY_TEST_F(ProxyTestOutputSurfaceCreationRequest);
85
86 class ProxyTestSetNeedsCommit : public ProxyTest {
87 public:
88 virtual void BeginTest() OVERRIDE {
89 if (threaded()) {
90 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested);
91 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
92 }
93
94 proxy()->SetNeedsCommit();
95
96 if (threaded()) {
97 EXPECT_TRUE(ThreadProxyMainOnly().commit_requested);
98 EXPECT_TRUE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
99 }
100 }
101
102 virtual void DidBeginMainFrame() OVERRIDE {
103 if (threaded()) {
104 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested);
105 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
106 }
107
108 EndTest();
109 }
110
111 virtual void AfterTest() OVERRIDE {}
112
113 protected:
114 ProxyTestSetNeedsCommit() {}
115 virtual ~ProxyTestSetNeedsCommit() {}
116
117 private:
118 DISALLOW_COPY_AND_ASSIGN(ProxyTestSetNeedsCommit);
119 };
120
121 THREAD_PROXY_TEST_F(ProxyTestSetNeedsCommit);
122
123 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698