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

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: Use LayerTreeTest harness Created 6 years, 8 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 namespace cc {
11
12 // Helper class to access private data in ThreadProxy.
13 class ThreadProxyTestAPI {
danakj 2014/04/24 16:03:15 You could also make accessors for these on the Lay
simonhong 2014/04/25 00:42:35 Done.
14 public:
15 explicit ThreadProxyTestAPI(ThreadProxy* proxy) : proxy_(proxy) {}
16 virtual ~ThreadProxyTestAPI() {}
17
18 ThreadProxy::MainThreadOnly& main() {
danakj 2014/04/24 16:03:15 const&?
simonhong 2014/04/25 00:42:35 Done.
19 return proxy_->main();
20 }
21
22 ThreadProxy::CompositorThreadOnly& impl() {
danakj 2014/04/24 16:03:15 const&
simonhong 2014/04/25 00:42:35 Done.
23 return proxy_->impl();
24 }
25
26 private:
27 ThreadProxy* proxy_;
28
29 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestAPI);
30 };
31
32 class ThreadProxyTest : public LayerTreeTest {
33 public:
34 virtual void WillBeginTest() OVERRIDE {
35 LayerTreeTest::WillBeginTest();
36 test_api_.reset(new ThreadProxyTestAPI(
37 static_cast<ThreadProxy*>(proxy())));
38 }
39
40 protected:
41 scoped_ptr<ThreadProxyTestAPI> test_api_;
42
43 ThreadProxyTest() {}
44 virtual ~ThreadProxyTest() {}
45
46 void RunTest() {
47 // We don't need to care about delegating, impl side painting because
48 // ThreadProxyTest only cover ThreadProxy itself.
49 // So, true is passed to all parameters.
50 bool threaded = true;
51 bool delegating_renderer = true;
52 bool impl_side_painting = true;
53 LayerTreeTest::RunTest(threaded, delegating_renderer, impl_side_painting);
54 }
55
56 private:
57 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest);
58 };
59
60 class ThreadProxyTestSetNeedsCommit : public ThreadProxyTest {
61 public:
62 void BeginTest() OVERRIDE {
63 EXPECT_FALSE(test_api_->main().commit_requested);
64 EXPECT_FALSE(test_api_->main().commit_request_sent_to_impl_thread);
65
66 proxy()->SetNeedsCommit();
67
68 EXPECT_TRUE(test_api_->main().commit_requested);
69 EXPECT_TRUE(test_api_->main().commit_request_sent_to_impl_thread);
70 }
71
72 void DidBeginMainFrame() OVERRIDE {
73 EXPECT_FALSE(test_api_->main().commit_requested);
74 EXPECT_FALSE(test_api_->main().commit_request_sent_to_impl_thread);
75
76 EndTest();
77 }
78
79 void AfterTest() OVERRIDE {}
80
81 protected:
82 ThreadProxyTestSetNeedsCommit() {}
83 virtual ~ThreadProxyTestSetNeedsCommit() {}
84
85 private:
86 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommit);
87 };
88
89 TEST_F(ThreadProxyTestSetNeedsCommit, SetNeedsCommitTest) {
90 RunTest();
91 }
92
93 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698