Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / trees / layer_tree_host_unittest_proxy.cc
blob4f79311f64995d79e2513d49959312d71cd28031
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.
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"
10 #define THREAD_PROXY_NO_IMPL_TEST_F(TEST_FIXTURE_NAME) \
11 TEST_F(TEST_FIXTURE_NAME, Run_MainThreadPaint) { \
12 Run(true, false); \
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); \
21 // Do common tests for single thread proxy and thread proxy.
22 // TODO(simonhong): Add SINGLE_THREAD_PROXY_TEST_F
23 #define PROXY_TEST_SCHEDULED_ACTION(TEST_FIXTURE_NAME) \
24 THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME);
26 namespace cc {
28 class ProxyTest : public LayerTreeTest {
29 protected:
30 ProxyTest() {}
31 virtual ~ProxyTest() {}
33 void Run(bool threaded, bool impl_side_painting) {
34 // We don't need to care about delegating mode.
35 bool delegating_renderer = true;
37 RunTest(threaded, delegating_renderer, impl_side_painting);
40 virtual void BeginTest() OVERRIDE {}
41 virtual void AfterTest() OVERRIDE {}
43 private:
44 DISALLOW_COPY_AND_ASSIGN(ProxyTest);
47 class ProxyTestScheduledActionsBasic : public ProxyTest {
48 protected:
49 virtual void BeginTest() OVERRIDE {
50 proxy()->SetNeedsCommit();
53 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {
54 EXPECT_EQ(0, action_phase_++);
57 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {
58 EXPECT_EQ(1, action_phase_++);
61 virtual void ScheduledActionCommit() OVERRIDE {
62 EXPECT_EQ(2, action_phase_++);
65 virtual void ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
66 EXPECT_EQ(3, action_phase_++);
67 EndTest();
70 virtual void AfterTest() OVERRIDE {
71 EXPECT_EQ(4, action_phase_);
74 ProxyTestScheduledActionsBasic() : action_phase_(0) {
76 virtual ~ProxyTestScheduledActionsBasic() {}
78 private:
79 int action_phase_;
81 DISALLOW_COPY_AND_ASSIGN(ProxyTestScheduledActionsBasic);
84 PROXY_TEST_SCHEDULED_ACTION(ProxyTestScheduledActionsBasic);
86 class ThreadProxyTest : public ProxyTest {
87 protected:
88 ThreadProxyTest() {}
89 virtual ~ThreadProxyTest() {}
91 const ThreadProxy::MainThreadOnly& ThreadProxyMainOnly() const {
92 DCHECK(proxy());
93 DCHECK(proxy()->HasImplThread());
94 return static_cast<const ThreadProxy*>(proxy())->main();
97 const ThreadProxy::CompositorThreadOnly& ThreadProxyImplOnly() const {
98 DCHECK(proxy());
99 DCHECK(proxy()->HasImplThread());
100 return static_cast<const ThreadProxy*>(proxy())->impl();
103 private:
104 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest);
107 class ThreadProxyTestSetNeedsCommit : public ThreadProxyTest {
108 protected:
109 ThreadProxyTestSetNeedsCommit() {}
110 virtual ~ThreadProxyTestSetNeedsCommit() {}
112 virtual void BeginTest() OVERRIDE {
113 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested);
114 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
116 proxy()->SetNeedsCommit();
118 EXPECT_TRUE(ThreadProxyMainOnly().commit_requested);
119 EXPECT_TRUE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
122 virtual void DidBeginMainFrame() OVERRIDE {
123 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested);
124 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
126 EndTest();
129 private:
130 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommit);
133 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommit);
135 } // namespace cc