Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: cc/test/layer_tree_test_common.cc

Issue 11348256: Use an auxiliary list of animation controllers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit tests pass! Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/input_handler.h" 10 #include "cc/input_handler.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks); 155 layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks);
156 156
157 return layerTreeHost.Pass(); 157 return layerTreeHost.Pass();
158 } 158 }
159 159
160 virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerT reeHostImplClient* client) 160 virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerT reeHostImplClient* client)
161 { 161 {
162 return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, pr oxy()).PassAs<cc::LayerTreeHostImpl>(); 162 return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, pr oxy()).PassAs<cc::LayerTreeHostImpl>();
163 } 163 }
164 164
165 virtual void didAddAnimation() OVERRIDE
166 {
167 LayerTreeHost::didAddAnimation();
168 m_testHooks->didAddAnimation();
169 }
170
171 virtual void setNeedsCommit() OVERRIDE 165 virtual void setNeedsCommit() OVERRIDE
172 { 166 {
173 if (!m_testStarted) 167 if (!m_testStarted)
174 return; 168 return;
175 LayerTreeHost::setNeedsCommit(); 169 LayerTreeHost::setNeedsCommit();
176 } 170 }
177 171
172 virtual void Register(cc::LayerAnimationController* controller) OVERRIDE
173 {
174 LayerTreeHost::Register(controller);
175 m_testHooks->didAddAnimation();
176 }
177
178 void setTestStarted(bool started) { m_testStarted = started; } 178 void setTestStarted(bool started) { m_testStarted = started; }
179 179
180 virtual void didDeferCommit() OVERRIDE 180 virtual void didDeferCommit() OVERRIDE
181 { 181 {
182 m_testHooks->didDeferCommit(); 182 m_testHooks->didDeferCommit();
183 } 183 }
184 184
185 private: 185 private:
186 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con st cc::LayerTreeSettings& settings) 186 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con st cc::LayerTreeSettings& settings)
187 : LayerTreeHost(client, settings) 187 : LayerTreeHost(client, settings)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void ThreadedTest::postSetNeedsAnimateAndCommitToMainThread() 334 void ThreadedTest::postSetNeedsAnimateAndCommitToMainThread()
335 { 335 {
336 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet NeedsAnimateAndCommit, base::Unretained(this))); 336 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet NeedsAnimateAndCommit, base::Unretained(this)));
337 } 337 }
338 338
339 void ThreadedTest::postSetVisibleToMainThread(bool visible) 339 void ThreadedTest::postSetVisibleToMainThread(bool visible)
340 { 340 {
341 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet Visible, base::Unretained(this), visible)); 341 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet Visible, base::Unretained(this), visible));
342 } 342 }
343 343
344 void ThreadedTest::postDidAddAnimationToMainThread()
345 {
346 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchDid AddAnimation, base::Unretained(this)));
347 }
348
349 void ThreadedTest::doBeginTest() 344 void ThreadedTest::doBeginTest()
350 { 345 {
351 m_client = ThreadedMockLayerTreeHostClient::create(this); 346 m_client = ThreadedMockLayerTreeHostClient::create(this);
352 347
353 scoped_refptr<Layer> rootLayer = Layer::create(); 348 scoped_refptr<Layer> rootLayer = Layer::create();
354 scoped_ptr<cc::Thread> implCCThread(NULL); 349 scoped_ptr<cc::Thread> implCCThread(NULL);
355 if (m_implThread) 350 if (m_implThread)
356 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me ssage_loop_proxy()); 351 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me ssage_loop_proxy());
357 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, implCCThread.Pass()); 352 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, implCCThread.Pass());
358 ASSERT_TRUE(m_layerTreeHost.get()); 353 ASSERT_TRUE(m_layerTreeHost.get());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 m_layerTreeHost->setVisible(visible); 476 m_layerTreeHost->setVisible(visible);
482 } 477 }
483 478
484 void ThreadedTest::dispatchComposite() 479 void ThreadedTest::dispatchComposite()
485 { 480 {
486 m_scheduled = false; 481 m_scheduled = false;
487 if (m_layerTreeHost.get() && !m_finished) 482 if (m_layerTreeHost.get() && !m_finished)
488 m_layerTreeHost->composite(); 483 m_layerTreeHost->composite();
489 } 484 }
490 485
491 void ThreadedTest::dispatchDidAddAnimation()
492 {
493 DCHECK(!proxy() || proxy()->isMainThread());
494
495 if (m_finished)
496 return;
497
498 if (m_layerTreeHost.get())
499 m_layerTreeHost->didAddAnimation();
500 }
501
502 void ThreadedTest::runTest(bool threaded) 486 void ThreadedTest::runTest(bool threaded)
503 { 487 {
504 if (threaded) { 488 if (threaded) {
505 m_implThread.reset(new base::Thread("ThreadedTest")); 489 m_implThread.reset(new base::Thread("ThreadedTest"));
506 ASSERT_TRUE(m_implThread->Start()); 490 ASSERT_TRUE(m_implThread->Start());
507 } 491 }
508 492
509 m_mainCCThread = cc::ThreadImpl::createForCurrentThread(); 493 m_mainCCThread = cc::ThreadImpl::createForCurrentThread();
510 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get()); 494 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get());
511 495
(...skipping 12 matching lines...) Expand all
524 ASSERT_FALSE(m_layerTreeHost.get()); 508 ASSERT_FALSE(m_layerTreeHost.get());
525 m_client.reset(); 509 m_client.reset();
526 if (m_timedOut) { 510 if (m_timedOut) {
527 FAIL() << "Test timed out"; 511 FAIL() << "Test timed out";
528 return; 512 return;
529 } 513 }
530 afterTest(); 514 afterTest();
531 } 515 }
532 516
533 } // namespace WebKitTests 517 } // namespace WebKitTests
OLDNEW
« cc/layer_tree_host.h ('K') | « cc/test/layer_tree_test_common.h ('k') | cc/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698