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) { \
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) { \
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);
28 class ProxyTest
: public LayerTreeTest
{
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
{}
44 DISALLOW_COPY_AND_ASSIGN(ProxyTest
);
47 class ProxyTestScheduledActionsBasic
: public ProxyTest
{
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_
++);
70 virtual void AfterTest() OVERRIDE
{
71 EXPECT_EQ(4, action_phase_
);
74 ProxyTestScheduledActionsBasic() : action_phase_(0) {
76 virtual ~ProxyTestScheduledActionsBasic() {}
81 DISALLOW_COPY_AND_ASSIGN(ProxyTestScheduledActionsBasic
);
84 PROXY_TEST_SCHEDULED_ACTION(ProxyTestScheduledActionsBasic
);
86 class ThreadProxyTest
: public ProxyTest
{
89 virtual ~ThreadProxyTest() {}
91 const ThreadProxy::MainThreadOnly
& ThreadProxyMainOnly() const {
93 DCHECK(proxy()->HasImplThread());
94 return static_cast<const ThreadProxy
*>(proxy())->main();
97 const ThreadProxy::CompositorThreadOnly
& ThreadProxyImplOnly() const {
99 DCHECK(proxy()->HasImplThread());
100 return static_cast<const ThreadProxy
*>(proxy())->impl();
104 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest
);
107 class ThreadProxyTestSetNeedsCommit
: public ThreadProxyTest
{
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
);
130 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommit
);
133 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommit
);