| 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/scoped_thread_proxy.h" | 12 #include "cc/thread.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationDelegat
e.h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationDelegat
e.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 class LayerImpl; | 17 class LayerImpl; |
| 18 class LayerTreeHost; | 18 class LayerTreeHost; |
| 19 class LayerTreeHostClient; | 19 class LayerTreeHostClient; |
| 20 class LayerTreeHostImpl; | 20 class LayerTreeHostImpl; |
| 21 class Thread; | |
| 22 | |
| 23 | 21 |
| 24 // Used by test stubs to notify the test when something interesting happens. | 22 // Used by test stubs to notify the test when something interesting happens. |
| 25 class TestHooks : public WebKit::WebAnimationDelegate { | 23 class TestHooks : public WebKit::WebAnimationDelegate { |
| 26 public: | 24 public: |
| 27 virtual void beginCommitOnThread(LayerTreeHostImpl*) { } | 25 virtual void beginCommitOnThread(LayerTreeHostImpl*) { } |
| 28 virtual void commitCompleteOnThread(LayerTreeHostImpl*) { } | 26 virtual void commitCompleteOnThread(LayerTreeHostImpl*) { } |
| 29 virtual bool prepareToDrawOnThread(LayerTreeHostImpl*); | 27 virtual bool prepareToDrawOnThread(LayerTreeHostImpl*); |
| 30 virtual void drawLayersOnThread(LayerTreeHostImpl*) { } | 28 virtual void drawLayersOnThread(LayerTreeHostImpl*) { } |
| 31 virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime
, bool hasUnfinishedAnimation) { } | 29 virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime
, bool hasUnfinishedAnimation) { } |
| 32 virtual void willAnimateLayers(LayerTreeHostImpl*, base::TimeTicks monotonic
Time) { } | 30 virtual void willAnimateLayers(LayerTreeHostImpl*, base::TimeTicks monotonic
Time) { } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 public: | 65 public: |
| 68 virtual ~ThreadedTest(); | 66 virtual ~ThreadedTest(); |
| 69 | 67 |
| 70 virtual void afterTest() = 0; | 68 virtual void afterTest() = 0; |
| 71 virtual void beginTest() = 0; | 69 virtual void beginTest() = 0; |
| 72 virtual void setupTree(); | 70 virtual void setupTree(); |
| 73 | 71 |
| 74 void endTest(); | 72 void endTest(); |
| 75 void endTestAfterDelay(int delayMilliseconds); | 73 void endTestAfterDelay(int delayMilliseconds); |
| 76 | 74 |
| 77 void postSetNeedsAnimateToMainThread(); | |
| 78 void postAddAnimationToMainThread(Layer*); | 75 void postAddAnimationToMainThread(Layer*); |
| 79 void postAddInstantAnimationToMainThread(); | 76 void postAddInstantAnimationToMainThread(); |
| 80 void postSetNeedsCommitToMainThread(); | 77 void postSetNeedsCommitToMainThread(); |
| 81 void postAcquireLayerTextures(); | 78 void postAcquireLayerTextures(); |
| 82 void postSetNeedsRedrawToMainThread(); | 79 void postSetNeedsRedrawToMainThread(); |
| 83 void postSetVisibleToMainThread(bool visible); | 80 void postSetVisibleToMainThread(bool visible); |
| 84 | 81 |
| 85 void doBeginTest(); | 82 void doBeginTest(); |
| 86 void timeout(); | 83 void timeout(); |
| 87 | 84 |
| 88 LayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } | 85 LayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } |
| 89 | 86 |
| 90 protected: | 87 protected: |
| 91 ThreadedTest(); | 88 ThreadedTest(); |
| 92 | 89 |
| 93 virtual void initializeSettings(LayerTreeSettings&) { } | 90 virtual void initializeSettings(LayerTreeSettings&) { } |
| 94 | 91 |
| 95 virtual void scheduleComposite() OVERRIDE; | 92 virtual void scheduleComposite() OVERRIDE; |
| 96 | 93 |
| 97 void realEndTest(); | 94 void realEndTest(); |
| 98 | 95 |
| 99 void dispatchSetNeedsAnimate(); | |
| 100 void dispatchAddInstantAnimation(); | 96 void dispatchAddInstantAnimation(); |
| 101 void dispatchAddAnimation(Layer*); | 97 void dispatchAddAnimation(Layer*); |
| 102 void dispatchSetNeedsCommit(); | 98 void dispatchSetNeedsCommit(); |
| 103 void dispatchAcquireLayerTextures(); | 99 void dispatchAcquireLayerTextures(); |
| 104 void dispatchSetNeedsRedraw(); | 100 void dispatchSetNeedsRedraw(); |
| 105 void dispatchSetVisible(bool); | 101 void dispatchSetVisible(bool); |
| 106 void dispatchComposite(); | 102 void dispatchComposite(); |
| 107 void dispatchDidAddAnimation(); | 103 void dispatchDidAddAnimation(); |
| 108 | 104 |
| 109 virtual void runTest(bool threaded); | 105 virtual void runTest(bool threaded); |
| 110 | 106 |
| 111 Thread* implThread() { return proxy() ? proxy()->implThread() : 0; } | 107 Thread* implThread() { return proxy() ? proxy()->implThread() : 0; } |
| 112 Proxy* proxy() const { return m_layerTreeHost ? m_layerTreeHost->proxy() : 0
; } | 108 Proxy* proxy() const { return m_layerTreeHost ? m_layerTreeHost->proxy() : 0
; } |
| 113 | 109 |
| 114 LayerTreeSettings m_settings; | 110 LayerTreeSettings m_settings; |
| 115 scoped_ptr<MockLayerImplTreeHostClient> m_client; | 111 scoped_ptr<MockLayerImplTreeHostClient> m_client; |
| 116 scoped_ptr<LayerTreeHost> m_layerTreeHost; | 112 scoped_ptr<LayerTreeHost> m_layerTreeHost; |
| 117 | 113 |
| 118 protected: | |
| 119 scoped_refptr<ScopedThreadProxy> m_mainThreadProxy; | |
| 120 | |
| 121 private: | 114 private: |
| 122 bool m_beginning; | 115 bool m_beginning; |
| 123 bool m_endWhenBeginReturns; | 116 bool m_endWhenBeginReturns; |
| 124 bool m_timedOut; | 117 bool m_timedOut; |
| 125 bool m_scheduled; | 118 bool m_scheduled; |
| 126 bool m_started; | 119 bool m_started; |
| 127 | 120 |
| 128 scoped_ptr<Thread> m_mainCCThread; | 121 scoped_ptr<Thread> m_mainCCThread; |
| 129 scoped_ptr<base::Thread> m_implThread; | 122 scoped_ptr<base::Thread> m_implThread; |
| 130 base::CancelableClosure m_timeout; | 123 base::CancelableClosure m_timeout; |
| 124 base::WeakPtr<ThreadedTest> m_mainThreadWeakPtr; |
| 125 base::WeakPtrFactory<ThreadedTest> m_weakFactory; |
| 131 }; | 126 }; |
| 132 | 127 |
| 133 class ThreadedTestThreadOnly : public ThreadedTest { | 128 class ThreadedTestThreadOnly : public ThreadedTest { |
| 134 public: | 129 public: |
| 135 void runTestThreaded() | 130 void runTestThreaded() |
| 136 { | 131 { |
| 137 ThreadedTest::runTest(true); | 132 ThreadedTest::runTest(true); |
| 138 } | 133 } |
| 139 }; | 134 }; |
| 140 | 135 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME() \ | 208 TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME() \ |
| 214 : TEST_FIXTURE_NAME(P1, P2) {} \ | 209 : TEST_FIXTURE_NAME(P1, P2) {} \ |
| 215 }; \ | 210 }; \ |
| 216 SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME) | 211 SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME) |
| 217 | 212 |
| 218 #define SINGLE_AND_MULTI_THREAD_TEST_P2(TEST_FIXTURE_NAME, P1_NAME, P1, P2_NAME,
P2) \ | 213 #define SINGLE_AND_MULTI_THREAD_TEST_P2(TEST_FIXTURE_NAME, P1_NAME, P1, P2_NAME,
P2) \ |
| 219 SINGLE_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1, P2) \ | 214 SINGLE_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1, P2) \ |
| 220 MULTI_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1, P2) | 215 MULTI_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1, P2) |
| 221 | 216 |
| 222 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 217 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
| OLD | NEW |