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 ~ProxyTest() override
{}
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 void BeginTest() override
{}
41 void AfterTest() override
{}
44 DISALLOW_COPY_AND_ASSIGN(ProxyTest
);
47 class ProxyTestScheduledActionsBasic
: public ProxyTest
{
49 void BeginTest() override
{ proxy()->SetNeedsCommit(); }
51 void ScheduledActionBeginOutputSurfaceCreation() override
{
52 EXPECT_EQ(0, action_phase_
++);
55 void ScheduledActionSendBeginMainFrame() override
{
56 EXPECT_EQ(1, action_phase_
++);
59 void ScheduledActionCommit() override
{ EXPECT_EQ(2, action_phase_
++); }
61 void ScheduledActionDrawAndSwapIfPossible() override
{
62 EXPECT_EQ(3, action_phase_
++);
66 void AfterTest() override
{ EXPECT_EQ(4, action_phase_
); }
68 ProxyTestScheduledActionsBasic() : action_phase_(0) {
70 ~ProxyTestScheduledActionsBasic() override
{}
75 DISALLOW_COPY_AND_ASSIGN(ProxyTestScheduledActionsBasic
);
78 PROXY_TEST_SCHEDULED_ACTION(ProxyTestScheduledActionsBasic
);
80 class ThreadProxyTest
: public ProxyTest
{
83 ~ThreadProxyTest() override
{}
85 const ThreadProxy::MainThreadOnly
& ThreadProxyMainOnly() const {
87 DCHECK(proxy()->HasImplThread());
88 return static_cast<const ThreadProxy
*>(proxy())->main();
91 const ThreadProxy::CompositorThreadOnly
& ThreadProxyImplOnly() const {
93 DCHECK(proxy()->HasImplThread());
94 return static_cast<const ThreadProxy
*>(proxy())->impl();
98 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest
);
101 class ThreadProxyTestSetNeedsCommit
: public ThreadProxyTest
{
103 ThreadProxyTestSetNeedsCommit() {}
104 ~ThreadProxyTestSetNeedsCommit() override
{}
106 void BeginTest() override
{
107 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested
);
108 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread
);
110 proxy()->SetNeedsCommit();
112 EXPECT_TRUE(ThreadProxyMainOnly().commit_requested
);
113 EXPECT_TRUE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread
);
116 void DidBeginMainFrame() override
{
117 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested
);
118 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread
);
124 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommit
);
127 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommit
);