OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 5 #ifndef CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
6 #define CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 6 #define CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
7 | 7 |
8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/threading/thread.h" |
10 #include "cc/layer_tree_host.h" | 11 #include "cc/layer_tree_host.h" |
11 #include "cc/layer_tree_host_impl.h" | 12 #include "cc/layer_tree_host_impl.h" |
12 #include "cc/scoped_thread_proxy.h" | 13 #include "cc/scoped_thread_proxy.h" |
13 #include "cc/test/compositor_fake_web_graphics_context_3d.h" | 14 #include "cc/test/compositor_fake_web_graphics_context_3d.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include <public/WebAnimationDelegate.h> | 16 #include <public/WebAnimationDelegate.h> |
16 #include <public/WebThread.h> | |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 class LayerImpl; | 19 class LayerImpl; |
20 class LayerTreeHost; | 20 class LayerTreeHost; |
21 class LayerTreeHostClient; | 21 class LayerTreeHostClient; |
22 class LayerTreeHostImpl; | 22 class LayerTreeHostImpl; |
| 23 class Thread; |
23 } | 24 } |
24 | 25 |
25 namespace WebKitTests { | 26 namespace WebKitTests { |
26 | 27 |
27 // Used by test stubs to notify the test when something interesting happens. | 28 // Used by test stubs to notify the test when something interesting happens. |
28 class TestHooks : public WebKit::WebAnimationDelegate { | 29 class TestHooks : public WebKit::WebAnimationDelegate { |
29 public: | 30 public: |
30 virtual void beginCommitOnThread(cc::LayerTreeHostImpl*) { } | 31 virtual void beginCommitOnThread(cc::LayerTreeHostImpl*) { } |
31 virtual void commitCompleteOnThread(cc::LayerTreeHostImpl*) { } | 32 virtual void commitCompleteOnThread(cc::LayerTreeHostImpl*) { } |
32 virtual bool prepareToDrawOnThread(cc::LayerTreeHostImpl*); | 33 virtual bool prepareToDrawOnThread(cc::LayerTreeHostImpl*); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 void postSetNeedsCommitToMainThread(); | 83 void postSetNeedsCommitToMainThread(); |
83 void postAcquireLayerTextures(); | 84 void postAcquireLayerTextures(); |
84 void postSetNeedsRedrawToMainThread(); | 85 void postSetNeedsRedrawToMainThread(); |
85 void postSetNeedsAnimateAndCommitToMainThread(); | 86 void postSetNeedsAnimateAndCommitToMainThread(); |
86 void postSetVisibleToMainThread(bool visible); | 87 void postSetVisibleToMainThread(bool visible); |
87 void postDidAddAnimationToMainThread(); | 88 void postDidAddAnimationToMainThread(); |
88 | 89 |
89 void doBeginTest(); | 90 void doBeginTest(); |
90 void timeout(); | 91 void timeout(); |
91 | 92 |
92 void clearTimeout() { m_timeoutTask = 0; } | |
93 | |
94 cc::LayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } | 93 cc::LayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } |
95 | 94 |
96 protected: | 95 protected: |
97 ThreadedTest(); | 96 ThreadedTest(); |
98 | 97 |
99 virtual void initializeSettings(cc::LayerTreeSettings&) { } | 98 virtual void initializeSettings(cc::LayerTreeSettings&) { } |
100 | 99 |
101 virtual void scheduleComposite() OVERRIDE; | 100 virtual void scheduleComposite() OVERRIDE; |
102 | 101 |
103 void realEndTest(); | 102 void realEndTest(); |
104 | 103 |
105 void dispatchSetNeedsAnimate(); | 104 void dispatchSetNeedsAnimate(); |
106 void dispatchAddInstantAnimation(); | 105 void dispatchAddInstantAnimation(); |
107 void dispatchAddAnimation(); | 106 void dispatchAddAnimation(); |
108 void dispatchSetNeedsAnimateAndCommit(); | 107 void dispatchSetNeedsAnimateAndCommit(); |
109 void dispatchSetNeedsCommit(); | 108 void dispatchSetNeedsCommit(); |
110 void dispatchAcquireLayerTextures(); | 109 void dispatchAcquireLayerTextures(); |
111 void dispatchSetNeedsRedraw(); | 110 void dispatchSetNeedsRedraw(); |
112 void dispatchSetVisible(bool); | 111 void dispatchSetVisible(bool); |
113 void dispatchComposite(); | 112 void dispatchComposite(); |
114 void dispatchDidAddAnimation(); | 113 void dispatchDidAddAnimation(); |
115 | 114 |
116 virtual void runTest(bool threaded); | 115 virtual void runTest(bool threaded); |
117 WebKit::WebThread* webThread() const { return m_webThread.get(); } | 116 |
| 117 cc::Thread* implThread() { return m_implCCThread.get(); } |
118 | 118 |
119 cc::LayerTreeSettings m_settings; | 119 cc::LayerTreeSettings m_settings; |
120 scoped_ptr<MockLayerImplTreeHostClient> m_client; | 120 scoped_ptr<MockLayerImplTreeHostClient> m_client; |
121 scoped_ptr<cc::LayerTreeHost> m_layerTreeHost; | 121 scoped_ptr<cc::LayerTreeHost> m_layerTreeHost; |
122 | 122 |
123 protected: | 123 protected: |
124 scoped_refptr<cc::ScopedThreadProxy> m_mainThreadProxy; | 124 scoped_refptr<cc::ScopedThreadProxy> m_mainThreadProxy; |
125 | 125 |
126 private: | 126 private: |
127 bool m_beginning; | 127 bool m_beginning; |
128 bool m_endWhenBeginReturns; | 128 bool m_endWhenBeginReturns; |
129 bool m_timedOut; | 129 bool m_timedOut; |
130 bool m_finished; | 130 bool m_finished; |
131 bool m_scheduled; | 131 bool m_scheduled; |
132 bool m_started; | 132 bool m_started; |
133 | 133 |
134 scoped_ptr<WebKit::WebThread> m_webThread; | 134 scoped_ptr<cc::Thread> m_mainCCThread; |
135 TimeoutTask* m_timeoutTask; | 135 scoped_ptr<cc::Thread> m_implCCThread; |
136 BeginTask* m_beginTask; | 136 scoped_ptr<base::Thread> m_implThread; |
| 137 base::CancelableClosure m_timeout; |
137 }; | 138 }; |
138 | 139 |
139 class ThreadedTestThreadOnly : public ThreadedTest { | 140 class ThreadedTestThreadOnly : public ThreadedTest { |
140 public: | 141 public: |
141 void runTestThreaded() | 142 void runTestThreaded() |
142 { | 143 { |
143 ThreadedTest::runTest(true); | 144 ThreadedTest::runTest(true); |
144 } | 145 } |
145 }; | 146 }; |
146 | 147 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ | 201 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ |
201 { \ | 202 { \ |
202 runTest(false); \ | 203 runTest(false); \ |
203 } \ | 204 } \ |
204 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ | 205 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ |
205 { \ | 206 { \ |
206 runTest(true); \ | 207 runTest(true); \ |
207 } | 208 } |
208 | 209 |
209 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 210 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
OLD | NEW |