| 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 "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "cc/active_animation.h" | 8 #include "cc/active_animation.h" |
| 9 #include "cc/content_layer.h" | 9 #include "cc/content_layer.h" |
| 10 #include "cc/font_atlas.h" | 10 #include "cc/font_atlas.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks); | 157 layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks); |
| 158 | 158 |
| 159 return layerTreeHost.Pass(); | 159 return layerTreeHost.Pass(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerT
reeHostImplClient* client) | 162 virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerT
reeHostImplClient* client) |
| 163 { | 163 { |
| 164 return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, pr
oxy()).PassAs<cc::LayerTreeHostImpl>(); | 164 return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, pr
oxy()).PassAs<cc::LayerTreeHostImpl>(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 virtual void didAddAnimation() OVERRIDE | |
| 168 { | |
| 169 LayerTreeHost::didAddAnimation(); | |
| 170 m_testHooks->didAddAnimation(); | |
| 171 } | |
| 172 | |
| 173 virtual void setNeedsCommit() OVERRIDE | 167 virtual void setNeedsCommit() OVERRIDE |
| 174 { | 168 { |
| 175 if (!m_testStarted) | 169 if (!m_testStarted) |
| 176 return; | 170 return; |
| 177 LayerTreeHost::setNeedsCommit(); | 171 LayerTreeHost::setNeedsCommit(); |
| 178 } | 172 } |
| 179 | 173 |
| 174 virtual void DidActivateAnimationController(cc::LayerAnimationController* co
ntroller) OVERRIDE |
| 175 { |
| 176 LayerTreeHost::DidActivateAnimationController(controller); |
| 177 m_testHooks->didAddAnimation(); |
| 178 } |
| 179 |
| 180 void setTestStarted(bool started) { m_testStarted = started; } | 180 void setTestStarted(bool started) { m_testStarted = started; } |
| 181 | 181 |
| 182 virtual void didDeferCommit() OVERRIDE | 182 virtual void didDeferCommit() OVERRIDE |
| 183 { | 183 { |
| 184 m_testHooks->didDeferCommit(); | 184 m_testHooks->didDeferCommit(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 private: | 187 private: |
| 188 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con
st cc::LayerTreeSettings& settings) | 188 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con
st cc::LayerTreeSettings& settings) |
| 189 : LayerTreeHost(client, settings) | 189 : LayerTreeHost(client, settings) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 void ThreadedTest::postSetNeedsRedrawToMainThread() | 336 void ThreadedTest::postSetNeedsRedrawToMainThread() |
| 337 { | 337 { |
| 338 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet
NeedsRedraw, base::Unretained(this))); | 338 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet
NeedsRedraw, base::Unretained(this))); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void ThreadedTest::postSetVisibleToMainThread(bool visible) | 341 void ThreadedTest::postSetVisibleToMainThread(bool visible) |
| 342 { | 342 { |
| 343 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet
Visible, base::Unretained(this), visible)); | 343 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet
Visible, base::Unretained(this), visible)); |
| 344 } | 344 } |
| 345 | 345 |
| 346 void ThreadedTest::postDidAddAnimationToMainThread() | |
| 347 { | |
| 348 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchDid
AddAnimation, base::Unretained(this))); | |
| 349 } | |
| 350 | |
| 351 void ThreadedTest::doBeginTest() | 346 void ThreadedTest::doBeginTest() |
| 352 { | 347 { |
| 353 m_client = ThreadedMockLayerTreeHostClient::create(this); | 348 m_client = ThreadedMockLayerTreeHostClient::create(this); |
| 354 | 349 |
| 355 scoped_refptr<Layer> rootLayer = Layer::create(); | 350 scoped_refptr<Layer> rootLayer = Layer::create(); |
| 356 scoped_ptr<cc::Thread> implCCThread(NULL); | 351 scoped_ptr<cc::Thread> implCCThread(NULL); |
| 357 if (m_implThread) | 352 if (m_implThread) |
| 358 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me
ssage_loop_proxy()); | 353 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me
ssage_loop_proxy()); |
| 359 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer,
m_settings, implCCThread.Pass()); | 354 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer,
m_settings, implCCThread.Pass()); |
| 360 ASSERT_TRUE(m_layerTreeHost.get()); | 355 ASSERT_TRUE(m_layerTreeHost.get()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 m_layerTreeHost->setVisible(visible); | 465 m_layerTreeHost->setVisible(visible); |
| 471 } | 466 } |
| 472 | 467 |
| 473 void ThreadedTest::dispatchComposite() | 468 void ThreadedTest::dispatchComposite() |
| 474 { | 469 { |
| 475 m_scheduled = false; | 470 m_scheduled = false; |
| 476 if (m_layerTreeHost.get() && !m_finished) | 471 if (m_layerTreeHost.get() && !m_finished) |
| 477 m_layerTreeHost->composite(); | 472 m_layerTreeHost->composite(); |
| 478 } | 473 } |
| 479 | 474 |
| 480 void ThreadedTest::dispatchDidAddAnimation() | |
| 481 { | |
| 482 DCHECK(!proxy() || proxy()->isMainThread()); | |
| 483 | |
| 484 if (m_finished) | |
| 485 return; | |
| 486 | |
| 487 if (m_layerTreeHost.get()) | |
| 488 m_layerTreeHost->didAddAnimation(); | |
| 489 } | |
| 490 | |
| 491 void ThreadedTest::runTest(bool threaded) | 475 void ThreadedTest::runTest(bool threaded) |
| 492 { | 476 { |
| 493 if (threaded) { | 477 if (threaded) { |
| 494 m_implThread.reset(new base::Thread("ThreadedTest")); | 478 m_implThread.reset(new base::Thread("ThreadedTest")); |
| 495 ASSERT_TRUE(m_implThread->Start()); | 479 ASSERT_TRUE(m_implThread->Start()); |
| 496 } | 480 } |
| 497 | 481 |
| 498 m_mainCCThread = cc::ThreadImpl::createForCurrentThread(); | 482 m_mainCCThread = cc::ThreadImpl::createForCurrentThread(); |
| 499 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get()); | 483 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get()); |
| 500 | 484 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 513 ASSERT_FALSE(m_layerTreeHost.get()); | 497 ASSERT_FALSE(m_layerTreeHost.get()); |
| 514 m_client.reset(); | 498 m_client.reset(); |
| 515 if (m_timedOut) { | 499 if (m_timedOut) { |
| 516 FAIL() << "Test timed out"; | 500 FAIL() << "Test timed out"; |
| 517 return; | 501 return; |
| 518 } | 502 } |
| 519 afterTest(); | 503 afterTest(); |
| 520 } | 504 } |
| 521 | 505 |
| 522 } // namespace WebKitTests | 506 } // namespace WebKitTests |
| OLD | NEW |