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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
11 #include "cc/layer_tree_host_impl.h" | 11 #include "cc/layer_tree_host_impl.h" |
| 12 #include "cc/test/fake_layer_tree_host_client.h" |
12 #include "cc/thread.h" | 13 #include "cc/thread.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationDelegat
e.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationDelegat
e.h" |
15 | 16 |
| 17 namespace Webkit { |
| 18 class WebGraphicsContext3D; |
| 19 } |
| 20 |
16 namespace cc { | 21 namespace cc { |
17 class LayerImpl; | 22 class LayerImpl; |
18 class LayerTreeHost; | 23 class LayerTreeHost; |
19 class LayerTreeHostClient; | 24 class LayerTreeHostClient; |
20 class LayerTreeHostImpl; | 25 class LayerTreeHostImpl; |
21 | 26 |
22 // Used by test stubs to notify the test when something interesting happens. | 27 // Used by test stubs to notify the test when something interesting happens. |
23 class TestHooks : public WebKit::WebAnimationDelegate { | 28 class TestHooks : public WebKit::WebAnimationDelegate { |
24 public: | 29 public: |
| 30 TestHooks(); |
| 31 virtual ~TestHooks(); |
| 32 |
25 virtual void beginCommitOnThread(LayerTreeHostImpl*) { } | 33 virtual void beginCommitOnThread(LayerTreeHostImpl*) { } |
26 virtual void commitCompleteOnThread(LayerTreeHostImpl*) { } | 34 virtual void commitCompleteOnThread(LayerTreeHostImpl*) { } |
27 virtual bool prepareToDrawOnThread( | 35 virtual bool prepareToDrawOnThread( |
28 LayerTreeHostImpl*, LayerTreeHostImpl::FrameData&, bool result); | 36 LayerTreeHostImpl*, LayerTreeHostImpl::FrameData&, bool result); |
29 virtual void drawLayersOnThread(LayerTreeHostImpl*) { } | 37 virtual void drawLayersOnThread(LayerTreeHostImpl*) { } |
30 virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime
, bool hasUnfinishedAnimation) { } | 38 virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime
, bool hasUnfinishedAnimation) { } |
31 virtual void willAnimateLayers(LayerTreeHostImpl*, base::TimeTicks monotonic
Time) { } | 39 virtual void willAnimateLayers(LayerTreeHostImpl*, base::TimeTicks monotonic
Time) { } |
32 virtual void applyScrollAndScale(gfx::Vector2d, float) { } | 40 virtual void applyScrollAndScale(gfx::Vector2d, float) { } |
33 virtual void animate(base::TimeTicks monotonicTime) { } | 41 virtual void animate(base::TimeTicks monotonicTime) { } |
34 virtual void layout() { } | 42 virtual void layout() { } |
35 virtual void didRecreateOutputSurface(bool succeeded) { } | 43 virtual void didRecreateOutputSurface(bool succeeded) { } |
| 44 virtual void willRetryRecreateOutputSurface() { } |
36 virtual void didAddAnimation() { } | 45 virtual void didAddAnimation() { } |
37 virtual void didCommit() { } | 46 virtual void didCommit() { } |
38 virtual void didCommitAndDrawFrame() { } | 47 virtual void didCommitAndDrawFrame() { } |
39 virtual void scheduleComposite() { } | 48 virtual void scheduleComposite() { } |
40 virtual void didDeferCommit() { } | 49 virtual void didDeferCommit() { } |
41 virtual bool canActivatePendingTree(); | 50 virtual bool canActivatePendingTree(); |
42 | 51 |
43 // Implementation of WebAnimationDelegate | 52 // Implementation of WebAnimationDelegate |
44 virtual void notifyAnimationStarted(double time) OVERRIDE { } | 53 virtual void notifyAnimationStarted(double time) OVERRIDE { } |
45 virtual void notifyAnimationFinished(double time) OVERRIDE { } | 54 virtual void notifyAnimationFinished(double time) OVERRIDE { } |
46 | 55 |
47 virtual scoped_ptr<OutputSurface> createOutputSurface(); | 56 virtual scoped_ptr<OutputSurface> createOutputSurface(); |
| 57 virtual WebKit::WebGraphicsContext3D* OffscreenContext3dForMainThread(); |
| 58 virtual WebKit::WebGraphicsContext3D* OffscreenContext3dForCompositorThread(
); |
| 59 virtual GrContext* OffscreenGrContextForMainThread(); |
| 60 virtual GrContext* OffscreenGrContextForCompositorThread(); |
| 61 |
| 62 private: |
| 63 FakeLayerImplTreeHostClient m_fakeClient; |
48 }; | 64 }; |
49 | 65 |
50 class TimeoutTask; | 66 class TimeoutTask; |
51 class BeginTask; | 67 class BeginTask; |
52 | 68 |
53 class MockLayerImplTreeHostClient : public LayerTreeHostClient { | 69 class MockLayerImplTreeHostClient : public LayerTreeHostClient { |
54 }; | 70 }; |
55 | 71 |
56 // The ThreadedTests runs with the main loop running. It instantiates a single M
ockLayerTreeHost and associated | 72 // The ThreadedTests runs with the main loop running. It instantiates a single M
ockLayerTreeHost and associated |
57 // MockLayerTreeHostImpl/ThreadedMockLayerTreeHostClient. | 73 // MockLayerTreeHostImpl/ThreadedMockLayerTreeHostClient. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ | 187 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ |
172 { \ | 188 { \ |
173 runTest(true); \ | 189 runTest(true); \ |
174 } | 190 } |
175 | 191 |
176 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 192 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
177 SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 193 SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
178 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) | 194 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) |
179 | 195 |
180 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 196 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
OLD | NEW |