| 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 #include "cc/test/layer_tree_test_common.h" | 5 #include "cc/test/layer_tree_test_common.h" |
| 6 | 6 |
| 7 #include "cc/animation.h" | 7 #include "cc/animation.h" |
| 8 #include "cc/animation_registrar.h" | 8 #include "cc/animation_registrar.h" |
| 9 #include "cc/content_layer.h" | 9 #include "cc/content_layer.h" |
| 10 #include "cc/input_handler.h" | 10 #include "cc/input_handler.h" |
| 11 #include "cc/layer.h" | 11 #include "cc/layer.h" |
| 12 #include "cc/layer_animation_controller.h" | 12 #include "cc/layer_animation_controller.h" |
| 13 #include "cc/layer_impl.h" | 13 #include "cc/layer_impl.h" |
| 14 #include "cc/layer_tree_host_impl.h" | 14 #include "cc/layer_tree_host_impl.h" |
| 15 #include "cc/single_thread_proxy.h" | 15 #include "cc/single_thread_proxy.h" |
| 16 #include "cc/thread_impl.h" | 16 #include "cc/thread_impl.h" |
| 17 #include "cc/test/animation_test_common.h" | 17 #include "cc/test/animation_test_common.h" |
| 18 #include "cc/test/fake_layer_tree_host_client.h" |
| 18 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
| 19 #include "cc/test/occlusion_tracker_test_common.h" | 20 #include "cc/test/occlusion_tracker_test_common.h" |
| 20 #include "cc/test/tiled_layer_test_common.h" | 21 #include "cc/test/tiled_layer_test_common.h" |
| 21 #include "cc/timing_function.h" | 22 #include "cc/timing_function.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperation.
h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperation.
h" |
| 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" |
| 25 #include "ui/gfx/size_conversions.h" | 26 #include "ui/gfx/size_conversions.h" |
| 26 | 27 |
| 27 using namespace WebKit; | 28 using namespace WebKit; |
| 28 | 29 |
| 29 namespace cc { | 30 namespace cc { |
| 30 | 31 |
| 32 TestHooks::TestHooks() |
| 33 { |
| 34 bool useSoftwareRendering = false; |
| 35 bool useDelegatingRenderer = false; |
| 36 m_fakeClient.reset(new FakeLayerImplTreeHostClient(useSoftwareRendering, useDe
legatingRenderer)); |
| 37 } |
| 38 |
| 39 TestHooks::~TestHooks() { } |
| 40 |
| 31 bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*, LayerTreeHostImpl:
:FrameData&, bool) | 41 bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*, LayerTreeHostImpl:
:FrameData&, bool) |
| 32 { | 42 { |
| 33 return true; | 43 return true; |
| 34 } | 44 } |
| 35 | 45 |
| 36 bool TestHooks::canActivatePendingTree() | 46 bool TestHooks::canActivatePendingTree() |
| 37 { | 47 { |
| 38 return true; | 48 return true; |
| 39 } | 49 } |
| 40 | 50 |
| 41 scoped_ptr<OutputSurface> TestHooks::createOutputSurface() | 51 scoped_ptr<OutputSurface> TestHooks::createOutputSurface() |
| 42 { | 52 { |
| 43 return createFakeOutputSurface(); | 53 return createFakeOutputSurface(); |
| 44 } | 54 } |
| 45 | 55 |
| 56 scoped_refptr<ui::ContextProvider> TestHooks::OffscreenContextProviderForMainThr
ead() |
| 57 { |
| 58 return m_fakeClient->OffscreenContextProviderForMainThread(); |
| 59 } |
| 60 |
| 61 scoped_refptr<ui::ContextProvider> TestHooks::OffscreenContextProviderForComposi
torThread() |
| 62 { |
| 63 return m_fakeClient->OffscreenContextProviderForCompositorThread(); |
| 64 } |
| 65 |
| 46 scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testH
ooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy*
proxy) | 66 scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testH
ooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy*
proxy) |
| 47 { | 67 { |
| 48 return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client
, proxy)); | 68 return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client
, proxy)); |
| 49 } | 69 } |
| 50 | 70 |
| 51 void MockLayerTreeHostImpl::beginCommit() | 71 void MockLayerTreeHostImpl::beginCommit() |
| 52 { | 72 { |
| 53 LayerTreeHostImpl::beginCommit(); | 73 LayerTreeHostImpl::beginCommit(); |
| 54 m_testHooks->beginCommitOnThread(this); | 74 m_testHooks->beginCommitOnThread(this); |
| 55 } | 75 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE | 211 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE |
| 192 { | 212 { |
| 193 return m_testHooks->createOutputSurface(); | 213 return m_testHooks->createOutputSurface(); |
| 194 } | 214 } |
| 195 | 215 |
| 196 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE | 216 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE |
| 197 { | 217 { |
| 198 m_testHooks->didRecreateOutputSurface(succeeded); | 218 m_testHooks->didRecreateOutputSurface(succeeded); |
| 199 } | 219 } |
| 200 | 220 |
| 221 virtual void willRetryRecreateOutputSurface() OVERRIDE |
| 222 { |
| 223 m_testHooks->willRetryRecreateOutputSurface(); |
| 224 } |
| 225 |
| 201 virtual scoped_ptr<InputHandler> createInputHandler() OVERRIDE | 226 virtual scoped_ptr<InputHandler> createInputHandler() OVERRIDE |
| 202 { | 227 { |
| 203 return scoped_ptr<InputHandler>(); | 228 return scoped_ptr<InputHandler>(); |
| 204 } | 229 } |
| 205 | 230 |
| 206 virtual void willCommit() OVERRIDE | 231 virtual void willCommit() OVERRIDE |
| 207 { | 232 { |
| 208 } | 233 } |
| 209 | 234 |
| 210 virtual void didCommit() OVERRIDE | 235 virtual void didCommit() OVERRIDE |
| 211 { | 236 { |
| 212 m_testHooks->didCommit(); | 237 m_testHooks->didCommit(); |
| 213 } | 238 } |
| 214 | 239 |
| 215 virtual void didCommitAndDrawFrame() OVERRIDE | 240 virtual void didCommitAndDrawFrame() OVERRIDE |
| 216 { | 241 { |
| 217 m_testHooks->didCommitAndDrawFrame(); | 242 m_testHooks->didCommitAndDrawFrame(); |
| 218 } | 243 } |
| 219 | 244 |
| 220 virtual void didCompleteSwapBuffers() OVERRIDE | 245 virtual void didCompleteSwapBuffers() OVERRIDE |
| 221 { | 246 { |
| 222 } | 247 } |
| 223 | 248 |
| 224 virtual void scheduleComposite() OVERRIDE | 249 virtual void scheduleComposite() OVERRIDE |
| 225 { | 250 { |
| 226 m_testHooks->scheduleComposite(); | 251 m_testHooks->scheduleComposite(); |
| 227 } | 252 } |
| 228 | 253 |
| 254 virtual scoped_refptr<ui::ContextProvider> OffscreenContextProviderForMainTh
read() OVERRIDE |
| 255 { |
| 256 return m_testHooks->OffscreenContextProviderForMainThread(); |
| 257 } |
| 258 |
| 259 virtual scoped_refptr<ui::ContextProvider> OffscreenContextProviderForCompos
itorThread() OVERRIDE |
| 260 { |
| 261 return m_testHooks->OffscreenContextProviderForCompositorThread(); |
| 262 } |
| 263 |
| 229 private: | 264 private: |
| 230 explicit ThreadedMockLayerTreeHostClient(TestHooks* testHooks) : m_testHooks
(testHooks) { } | 265 explicit ThreadedMockLayerTreeHostClient(TestHooks* testHooks) : m_testHooks
(testHooks) { } |
| 231 | 266 |
| 232 TestHooks* m_testHooks; | 267 TestHooks* m_testHooks; |
| 233 }; | 268 }; |
| 234 | 269 |
| 235 ThreadedTest::ThreadedTest() | 270 ThreadedTest::ThreadedTest() |
| 236 : m_beginning(false) | 271 : m_beginning(false) |
| 237 , m_endWhenBeginReturns(false) | 272 , m_endWhenBeginReturns(false) |
| 238 , m_timedOut(false) | 273 , m_timedOut(false) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 340 |
| 306 m_started = true; | 341 m_started = true; |
| 307 m_beginning = true; | 342 m_beginning = true; |
| 308 setupTree(); | 343 setupTree(); |
| 309 m_layerTreeHost->setSurfaceReady(); | 344 m_layerTreeHost->setSurfaceReady(); |
| 310 beginTest(); | 345 beginTest(); |
| 311 m_beginning = false; | 346 m_beginning = false; |
| 312 if (m_endWhenBeginReturns) | 347 if (m_endWhenBeginReturns) |
| 313 realEndTest(); | 348 realEndTest(); |
| 314 | 349 |
| 315 LayerTreeHost::setNeedsFilterContext(false); | |
| 316 | |
| 317 // Allow commits to happen once beginTest() has had a chance to post tasks | 350 // Allow commits to happen once beginTest() has had a chance to post tasks |
| 318 // so that those tasks will happen before the first commit. | 351 // so that those tasks will happen before the first commit. |
| 319 if (m_layerTreeHost) | 352 if (m_layerTreeHost) |
| 320 static_cast<MockLayerTreeHost*>(m_layerTreeHost.get())->setTestStarted(t
rue); | 353 static_cast<MockLayerTreeHost*>(m_layerTreeHost.get())->setTestStarted(t
rue); |
| 321 } | 354 } |
| 322 | 355 |
| 323 void ThreadedTest::setupTree() | 356 void ThreadedTest::setupTree() |
| 324 { | 357 { |
| 325 if (!m_layerTreeHost->rootLayer()) { | 358 if (!m_layerTreeHost->rootLayer()) { |
| 326 scoped_refptr<Layer> rootLayer = Layer::create(); | 359 scoped_refptr<Layer> rootLayer = Layer::create(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 ASSERT_FALSE(m_layerTreeHost.get()); | 470 ASSERT_FALSE(m_layerTreeHost.get()); |
| 438 m_client.reset(); | 471 m_client.reset(); |
| 439 if (m_timedOut) { | 472 if (m_timedOut) { |
| 440 FAIL() << "Test timed out"; | 473 FAIL() << "Test timed out"; |
| 441 return; | 474 return; |
| 442 } | 475 } |
| 443 afterTest(); | 476 afterTest(); |
| 444 } | 477 } |
| 445 | 478 |
| 446 } // namespace cc | 479 } // namespace cc |
| OLD | NEW |