Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef TestingPlatformSupport_h | 31 #ifndef TestingPlatformSupport_h |
| 32 #define TestingPlatformSupport_h | 32 #define TestingPlatformSupport_h |
| 33 | 33 |
| 34 #include "base/logging.h" | |
|
Takashi Toyoshima
2017/01/11 08:35:19
removed
| |
| 34 #include "platform/PlatformExport.h" | 35 #include "platform/PlatformExport.h" |
| 35 #include "platform/WebTaskRunner.h" | 36 #include "platform/WebTaskRunner.h" |
| 36 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
| 37 #include "public/platform/WebCompositorSupport.h" | 38 #include "public/platform/WebCompositorSupport.h" |
| 38 #include "public/platform/WebScheduler.h" | 39 #include "public/platform/WebScheduler.h" |
| 39 #include "public/platform/WebThread.h" | 40 #include "public/platform/WebThread.h" |
| 40 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
| 41 #include <memory> | 42 #include <memory> |
| 42 | 43 |
| 43 namespace base { | 44 namespace base { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 | 182 |
| 182 protected: | 183 protected: |
| 183 static double getTestTime(); | 184 static double getTestTime(); |
| 184 | 185 |
| 185 std::unique_ptr<base::SimpleTestTickClock> m_clock; | 186 std::unique_ptr<base::SimpleTestTickClock> m_clock; |
| 186 scoped_refptr<cc::OrderedSimpleTaskRunner> m_mockTaskRunner; | 187 scoped_refptr<cc::OrderedSimpleTaskRunner> m_mockTaskRunner; |
| 187 std::unique_ptr<scheduler::RendererSchedulerImpl> m_scheduler; | 188 std::unique_ptr<scheduler::RendererSchedulerImpl> m_scheduler; |
| 188 std::unique_ptr<WebThread> m_thread; | 189 std::unique_ptr<WebThread> m_thread; |
| 189 }; | 190 }; |
| 190 | 191 |
| 192 template <class T> | |
| 193 class ScopedTestingPlatformSupport { | |
| 194 public: | |
| 195 ScopedTestingPlatformSupport() : m_originalPlatform(Platform::current()) {} | |
| 196 explicit ScopedTestingPlatformSupport(T* testingPlatformSupport) | |
|
jbroman
2016/12/22 15:27:54
Taking ownership by raw pointer, here and below, i
Takashi Toyoshima
2017/01/11 08:35:19
Done.
| |
| 197 : m_originalPlatform(Platform::current()) { | |
| 198 reset(testingPlatformSupport); | |
| 199 } | |
| 200 void reset(T* testingPlatformSupport) { | |
| 201 DCHECK_NE(m_testingPlatformSupport.get(), testingPlatformSupport); | |
| 202 if (testingPlatformSupport) | |
| 203 Platform::setCurrentPlatformForTesting(testingPlatformSupport); | |
| 204 m_testingPlatformSupport.reset(testingPlatformSupport); | |
| 205 } | |
| 206 ~ScopedTestingPlatformSupport() { | |
| 207 m_testingPlatformSupport.reset(); | |
| 208 if (m_originalPlatform) | |
| 209 Platform::setCurrentPlatformForTesting(m_originalPlatform); | |
| 210 } | |
| 211 const T* operator->() const { return m_testingPlatformSupport.get(); } | |
| 212 T* operator->() { return m_testingPlatformSupport.get(); } | |
| 213 | |
| 214 private: | |
| 215 Platform* m_originalPlatform; | |
| 216 std::unique_ptr<T> m_testingPlatformSupport; | |
| 217 }; | |
| 218 | |
| 191 class ScopedUnittestsEnvironmentSetup { | 219 class ScopedUnittestsEnvironmentSetup { |
| 192 WTF_MAKE_NONCOPYABLE(ScopedUnittestsEnvironmentSetup); | 220 WTF_MAKE_NONCOPYABLE(ScopedUnittestsEnvironmentSetup); |
| 193 | 221 |
| 194 public: | 222 public: |
| 195 ScopedUnittestsEnvironmentSetup(int argc, char** argv); | 223 ScopedUnittestsEnvironmentSetup(int argc, char** argv); |
| 196 ~ScopedUnittestsEnvironmentSetup(); | 224 ~ScopedUnittestsEnvironmentSetup(); |
| 197 | 225 |
| 198 private: | 226 private: |
| 199 class DummyPlatform; | 227 class DummyPlatform; |
| 200 std::unique_ptr<base::TestDiscardableMemoryAllocator> | 228 std::unique_ptr<base::TestDiscardableMemoryAllocator> |
| 201 m_discardableMemoryAllocator; | 229 m_discardableMemoryAllocator; |
| 202 std::unique_ptr<DummyPlatform> m_platform; | 230 std::unique_ptr<DummyPlatform> m_platform; |
| 203 std::unique_ptr<cc_blink::WebCompositorSupportImpl> m_compositorSupport; | 231 std::unique_ptr<cc_blink::WebCompositorSupportImpl> m_compositorSupport; |
| 204 TestingPlatformSupport::Config m_testingPlatformConfig; | 232 TestingPlatformSupport::Config m_testingPlatformConfig; |
| 205 std::unique_ptr<TestingPlatformSupport> m_testingPlatformSupport; | 233 ScopedTestingPlatformSupport<TestingPlatformSupport> m_testingPlatformSupport; |
| 206 }; | 234 }; |
| 207 | 235 |
| 208 } // namespace blink | 236 } // namespace blink |
| 209 | 237 |
| 210 #endif // TestingPlatformSupport_h | 238 #endif // TestingPlatformSupport_h |
| OLD | NEW |