| 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
) { } | 29 virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime
) { } |
| 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 void postDidAddAnimationToMainThread(); | 81 void postDidAddAnimationToMainThread(); |
| 85 | 82 |
| 86 void doBeginTest(); | 83 void doBeginTest(); |
| 87 void timeout(); | 84 void timeout(); |
| 88 | 85 |
| 89 LayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } | 86 LayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } |
| 90 | 87 |
| 91 protected: | 88 protected: |
| 92 ThreadedTest(); | 89 ThreadedTest(); |
| 93 | 90 |
| 94 virtual void initializeSettings(LayerTreeSettings&) { } | 91 virtual void initializeSettings(LayerTreeSettings&) { } |
| 95 | 92 |
| 96 virtual void scheduleComposite() OVERRIDE; | 93 virtual void scheduleComposite() OVERRIDE; |
| 97 | 94 |
| 98 void realEndTest(); | 95 void realEndTest(); |
| 99 | 96 |
| 100 void dispatchSetNeedsAnimate(); | |
| 101 void dispatchAddInstantAnimation(); | 97 void dispatchAddInstantAnimation(); |
| 102 void dispatchAddAnimation(Layer*); | 98 void dispatchAddAnimation(Layer*); |
| 103 void dispatchSetNeedsCommit(); | 99 void dispatchSetNeedsCommit(); |
| 104 void dispatchAcquireLayerTextures(); | 100 void dispatchAcquireLayerTextures(); |
| 105 void dispatchSetNeedsRedraw(); | 101 void dispatchSetNeedsRedraw(); |
| 106 void dispatchSetVisible(bool); | 102 void dispatchSetVisible(bool); |
| 107 void dispatchComposite(); | 103 void dispatchComposite(); |
| 108 void dispatchDidAddAnimation(); | 104 void dispatchDidAddAnimation(); |
| 109 | 105 |
| 110 virtual void runTest(bool threaded); | 106 virtual void runTest(bool threaded); |
| 111 | 107 |
| 112 Thread* implThread() { return proxy() ? proxy()->implThread() : 0; } | 108 Thread* implThread() { return proxy() ? proxy()->implThread() : 0; } |
| 113 Proxy* proxy() const { return m_layerTreeHost ? m_layerTreeHost->proxy() : 0
; } | 109 Proxy* proxy() const { return m_layerTreeHost ? m_layerTreeHost->proxy() : 0
; } |
| 114 | 110 |
| 115 LayerTreeSettings m_settings; | 111 LayerTreeSettings m_settings; |
| 116 scoped_ptr<MockLayerImplTreeHostClient> m_client; | 112 scoped_ptr<MockLayerImplTreeHostClient> m_client; |
| 117 scoped_ptr<LayerTreeHost> m_layerTreeHost; | 113 scoped_ptr<LayerTreeHost> m_layerTreeHost; |
| 118 | 114 |
| 119 protected: | |
| 120 scoped_refptr<ScopedThreadProxy> m_mainThreadProxy; | |
| 121 | |
| 122 private: | 115 private: |
| 123 bool m_beginning; | 116 bool m_beginning; |
| 124 bool m_endWhenBeginReturns; | 117 bool m_endWhenBeginReturns; |
| 125 bool m_timedOut; | 118 bool m_timedOut; |
| 126 bool m_scheduled; | 119 bool m_scheduled; |
| 127 bool m_started; | 120 bool m_started; |
| 128 | 121 |
| 129 scoped_ptr<Thread> m_mainCCThread; | 122 scoped_ptr<Thread> m_mainCCThread; |
| 130 scoped_ptr<base::Thread> m_implThread; | 123 scoped_ptr<base::Thread> m_implThread; |
| 131 base::CancelableClosure m_timeout; | 124 base::CancelableClosure m_timeout; |
| 125 base::WeakPtr<ThreadedTest> m_mainThreadWeakPtr; |
| 126 base::WeakPtrFactory<ThreadedTest> m_weakFactory; |
| 132 }; | 127 }; |
| 133 | 128 |
| 134 class ThreadedTestThreadOnly : public ThreadedTest { | 129 class ThreadedTestThreadOnly : public ThreadedTest { |
| 135 public: | 130 public: |
| 136 void runTestThreaded() | 131 void runTestThreaded() |
| 137 { | 132 { |
| 138 ThreadedTest::runTest(true); | 133 ThreadedTest::runTest(true); |
| 139 } | 134 } |
| 140 }; | 135 }; |
| 141 | 136 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ | 169 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ |
| 175 { \ | 170 { \ |
| 176 runTest(true); \ | 171 runTest(true); \ |
| 177 } | 172 } |
| 178 | 173 |
| 179 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 174 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
| 180 SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 175 SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
| 181 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) | 176 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) |
| 182 | 177 |
| 183 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 178 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
| OLD | NEW |