Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 | 135 |
| 136 class WebCompositorSupportMock : public WebCompositorSupport { | 136 class WebCompositorSupportMock : public WebCompositorSupport { |
| 137 public: | 137 public: |
| 138 MOCK_METHOD4(createAnimation, WebCompositorAnimation*(const WebComposito rAnimationCurve& curve, WebCompositorAnimation::TargetProperty target, int group Id, int animationId)); | 138 MOCK_METHOD4(createAnimation, WebCompositorAnimation*(const WebComposito rAnimationCurve& curve, WebCompositorAnimation::TargetProperty target, int group Id, int animationId)); |
| 139 MOCK_METHOD0(createFloatAnimationCurve, WebFloatAnimationCurve*()); | 139 MOCK_METHOD0(createFloatAnimationCurve, WebFloatAnimationCurve*()); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 class PlatformProxy : public Platform { | 143 class PlatformProxy : public Platform { |
| 144 public: | 144 public: |
| 145 PlatformProxy(WebCompositorSupportMock** compositor) : m_compositor(comp ositor) { } | 145 PlatformProxy(WebCompositorSupportMock** compositor) |
| 146 : m_compositor(compositor) | |
| 147 , m_platform(Platform::current()) | |
| 148 { | |
| 149 } | |
| 150 | |
| 151 ~PlatformProxy() | |
| 152 { | |
| 153 Platform::initialize(m_platform); | |
| 154 } | |
| 146 | 155 |
| 147 virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) { ASSERT_NOT_REACHED(); } | 156 virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) { ASSERT_NOT_REACHED(); } |
| 148 const unsigned char* getTraceCategoryEnabledFlag(const char* categoryNam e) override | 157 const unsigned char* getTraceCategoryEnabledFlag(const char* categoryNam e) override |
| 149 { | 158 { |
| 150 static const unsigned char tracingIsDisabled = 0; | 159 static const unsigned char tracingIsDisabled = 0; |
| 151 return &tracingIsDisabled; | 160 return &tracingIsDisabled; |
| 152 } | 161 } |
| 153 | 162 |
| 163 virtual WebThread* currentThread() override | |
| 164 { | |
| 165 if (m_platform) | |
|
Sami
2015/05/19 10:41:51
Will this ever be null?
sof
2015/05/19 16:12:07
We can safely assume that it won't be; thanks, rem
| |
| 166 return m_platform->currentThread(); | |
| 167 | |
| 168 return nullptr; | |
| 169 } | |
| 170 | |
| 154 private: | 171 private: |
| 155 WebCompositorSupportMock** m_compositor; | 172 WebCompositorSupportMock** m_compositor; |
| 156 virtual WebCompositorSupport* compositorSupport() override { return *m_c ompositor; } | 173 virtual WebCompositorSupport* compositorSupport() override { return *m_c ompositor; } |
| 174 | |
| 175 Platform* m_platform; | |
| 157 }; | 176 }; |
| 158 | 177 |
| 159 WebCompositorSupportMock* m_mockCompositor; | 178 WebCompositorSupportMock* m_mockCompositor; |
| 160 PlatformProxy m_proxyPlatform; | 179 PlatformProxy m_proxyPlatform; |
| 161 | 180 |
| 162 protected: | 181 protected: |
| 163 Platform* m_platform; | |
| 164 | |
| 165 virtual void SetUp() | 182 virtual void SetUp() |
| 166 { | 183 { |
| 167 m_mockCompositor = 0; | 184 m_mockCompositor = 0; |
| 168 m_platform = Platform::current(); | |
| 169 Platform::initialize(&m_proxyPlatform); | 185 Platform::initialize(&m_proxyPlatform); |
| 170 } | 186 } |
| 171 | 187 |
| 172 virtual void TearDown() | |
| 173 { | |
| 174 Platform::initialize(m_platform); | |
| 175 } | |
| 176 | |
| 177 void setCompositorForTesting(WebCompositorSupportMock& mock) | 188 void setCompositorForTesting(WebCompositorSupportMock& mock) |
| 178 { | 189 { |
| 179 ASSERT(!m_mockCompositor); | 190 ASSERT(!m_mockCompositor); |
| 180 m_mockCompositor = &mock; | 191 m_mockCompositor = &mock; |
| 181 } | 192 } |
| 182 }; | 193 }; |
| 183 | 194 |
| 184 } | 195 } |
| 185 | 196 |
| 186 #endif | 197 #endif |
| OLD | NEW |