roll libyuv to r1437 to resolve msan overread on odd width ARGBToYUY2.
[chromium-blink-merge.git] / cc / trees / layer_tree_host_unittest_proxy.cc
blob66340e7bbfff31d24fba738036a02dfe1f6a7f90
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_TEST_F(TEST_FIXTURE_NAME) \
11 TEST_F(TEST_FIXTURE_NAME, MultiThread) { Run(true); }
13 // Do common tests for single thread proxy and thread proxy.
14 // TODO(simonhong): Add SINGLE_THREAD_PROXY_TEST_F
15 #define PROXY_TEST_SCHEDULED_ACTION(TEST_FIXTURE_NAME) \
16 THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME);
18 namespace cc {
20 class ProxyTest : public LayerTreeTest {
21 protected:
22 ProxyTest() {}
23 ~ProxyTest() override {}
25 void Run(bool threaded) {
26 // We don't need to care about delegating mode.
27 bool delegating_renderer = true;
29 RunTest(threaded, delegating_renderer);
32 void BeginTest() override {}
33 void AfterTest() override {}
35 private:
36 DISALLOW_COPY_AND_ASSIGN(ProxyTest);
39 class ProxyTestScheduledActionsBasic : public ProxyTest {
40 protected:
41 void BeginTest() override { proxy()->SetNeedsCommit(); }
43 void ScheduledActionBeginOutputSurfaceCreation() override {
44 EXPECT_EQ(0, action_phase_++);
47 void ScheduledActionSendBeginMainFrame() override {
48 EXPECT_EQ(1, action_phase_++);
51 void ScheduledActionCommit() override { EXPECT_EQ(2, action_phase_++); }
53 void ScheduledActionDrawAndSwapIfPossible() override {
54 EXPECT_EQ(3, action_phase_++);
55 EndTest();
58 void AfterTest() override { EXPECT_EQ(4, action_phase_); }
60 ProxyTestScheduledActionsBasic() : action_phase_(0) {
62 ~ProxyTestScheduledActionsBasic() override {}
64 private:
65 int action_phase_;
67 DISALLOW_COPY_AND_ASSIGN(ProxyTestScheduledActionsBasic);
70 PROXY_TEST_SCHEDULED_ACTION(ProxyTestScheduledActionsBasic);
72 class ThreadProxyTest : public ProxyTest {
73 protected:
74 ThreadProxyTest() {}
75 ~ThreadProxyTest() override {}
77 const ThreadProxy::MainThreadOnly& ThreadProxyMainOnly() const {
78 DCHECK(proxy());
79 DCHECK(proxy()->HasImplThread());
80 return static_cast<const ThreadProxy*>(proxy())->main();
83 const ThreadProxy::CompositorThreadOnly& ThreadProxyImplOnly() const {
84 DCHECK(proxy());
85 DCHECK(proxy()->HasImplThread());
86 return static_cast<const ThreadProxy*>(proxy())->impl();
89 private:
90 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest);
93 class ThreadProxyTestSetNeedsCommit : public ThreadProxyTest {
94 protected:
95 ThreadProxyTestSetNeedsCommit() {}
96 ~ThreadProxyTestSetNeedsCommit() override {}
98 void BeginTest() override {
99 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested);
100 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
102 proxy()->SetNeedsCommit();
104 EXPECT_TRUE(ThreadProxyMainOnly().commit_requested);
105 EXPECT_TRUE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
108 void DidBeginMainFrame() override {
109 EXPECT_FALSE(ThreadProxyMainOnly().commit_requested);
110 EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread);
112 EndTest();
115 private:
116 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommit);
119 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommit);
121 } // namespace cc