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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCThreadedTest.h" | 7 #include "CCThreadedTest.h" |
8 | 8 |
9 #include "CCActiveAnimation.h" | 9 #include "CCActiveAnimation.h" |
10 #include "CCInputHandler.h" | 10 #include "CCInputHandler.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chSetVisible, visible)); | 371 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chSetVisible, visible)); |
372 } | 372 } |
373 | 373 |
374 void CCThreadedTest::postDidAddAnimationToMainThread() | 374 void CCThreadedTest::postDidAddAnimationToMainThread() |
375 { | 375 { |
376 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chDidAddAnimation)); | 376 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chDidAddAnimation)); |
377 } | 377 } |
378 | 378 |
379 void CCThreadedTest::doBeginTest() | 379 void CCThreadedTest::doBeginTest() |
380 { | 380 { |
381 ASSERT(CCProxy::isMainThread()); | 381 DCHECK(CCProxy::isMainThread()); |
382 m_client = MockLayerTreeHostClient::create(this); | 382 m_client = MockLayerTreeHostClient::create(this); |
383 | 383 |
384 scoped_refptr<LayerChromium> rootLayer = LayerChromium::create(); | 384 scoped_refptr<LayerChromium> rootLayer = LayerChromium::create(); |
385 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer,
m_settings); | 385 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer,
m_settings); |
386 ASSERT_TRUE(m_layerTreeHost.get()); | 386 ASSERT_TRUE(m_layerTreeHost.get()); |
387 rootLayer->setLayerTreeHost(m_layerTreeHost.get()); | 387 rootLayer->setLayerTreeHost(m_layerTreeHost.get()); |
388 m_layerTreeHost->setSurfaceReady(); | 388 m_layerTreeHost->setSurfaceReady(); |
389 | 389 |
390 m_started = true; | 390 m_started = true; |
391 m_beginning = true; | 391 m_beginning = true; |
(...skipping 12 matching lines...) Expand all Loading... |
404 void CCThreadedTest::scheduleComposite() | 404 void CCThreadedTest::scheduleComposite() |
405 { | 405 { |
406 if (!m_started || m_scheduled || m_finished) | 406 if (!m_started || m_scheduled || m_finished) |
407 return; | 407 return; |
408 m_scheduled = true; | 408 m_scheduled = true; |
409 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chComposite)); | 409 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chComposite)); |
410 } | 410 } |
411 | 411 |
412 void CCThreadedTest::realEndTest() | 412 void CCThreadedTest::realEndTest() |
413 { | 413 { |
414 ASSERT(CCProxy::isMainThread()); | 414 DCHECK(CCProxy::isMainThread()); |
415 WebKit::Platform::current()->currentThread()->exitRunLoop(); | 415 WebKit::Platform::current()->currentThread()->exitRunLoop(); |
416 } | 416 } |
417 | 417 |
418 void CCThreadedTest::dispatchSetNeedsAnimate() | 418 void CCThreadedTest::dispatchSetNeedsAnimate() |
419 { | 419 { |
420 ASSERT(CCProxy::isMainThread()); | 420 DCHECK(CCProxy::isMainThread()); |
421 | 421 |
422 if (m_finished) | 422 if (m_finished) |
423 return; | 423 return; |
424 | 424 |
425 if (m_layerTreeHost.get()) | 425 if (m_layerTreeHost.get()) |
426 m_layerTreeHost->setNeedsAnimate(); | 426 m_layerTreeHost->setNeedsAnimate(); |
427 } | 427 } |
428 | 428 |
429 void CCThreadedTest::dispatchAddInstantAnimation() | 429 void CCThreadedTest::dispatchAddInstantAnimation() |
430 { | 430 { |
431 ASSERT(CCProxy::isMainThread()); | 431 DCHECK(CCProxy::isMainThread()); |
432 | 432 |
433 if (m_finished) | 433 if (m_finished) |
434 return; | 434 return; |
435 | 435 |
436 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) | 436 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) |
437 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 0, 0, 0.5, fa
lse); | 437 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 0, 0, 0.5, fa
lse); |
438 } | 438 } |
439 | 439 |
440 void CCThreadedTest::dispatchAddAnimation() | 440 void CCThreadedTest::dispatchAddAnimation() |
441 { | 441 { |
442 ASSERT(CCProxy::isMainThread()); | 442 DCHECK(CCProxy::isMainThread()); |
443 | 443 |
444 if (m_finished) | 444 if (m_finished) |
445 return; | 445 return; |
446 | 446 |
447 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) | 447 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) |
448 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 10, 0, 0.5, t
rue); | 448 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 10, 0, 0.5, t
rue); |
449 } | 449 } |
450 | 450 |
451 void CCThreadedTest::dispatchSetNeedsAnimateAndCommit() | 451 void CCThreadedTest::dispatchSetNeedsAnimateAndCommit() |
452 { | 452 { |
453 ASSERT(CCProxy::isMainThread()); | 453 DCHECK(CCProxy::isMainThread()); |
454 | 454 |
455 if (m_finished) | 455 if (m_finished) |
456 return; | 456 return; |
457 | 457 |
458 if (m_layerTreeHost.get()) { | 458 if (m_layerTreeHost.get()) { |
459 m_layerTreeHost->setNeedsAnimate(); | 459 m_layerTreeHost->setNeedsAnimate(); |
460 m_layerTreeHost->setNeedsCommit(); | 460 m_layerTreeHost->setNeedsCommit(); |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 void CCThreadedTest::dispatchSetNeedsCommit() | 464 void CCThreadedTest::dispatchSetNeedsCommit() |
465 { | 465 { |
466 ASSERT(CCProxy::isMainThread()); | 466 DCHECK(CCProxy::isMainThread()); |
467 | 467 |
468 if (m_finished) | 468 if (m_finished) |
469 return; | 469 return; |
470 | 470 |
471 if (m_layerTreeHost.get()) | 471 if (m_layerTreeHost.get()) |
472 m_layerTreeHost->setNeedsCommit(); | 472 m_layerTreeHost->setNeedsCommit(); |
473 } | 473 } |
474 | 474 |
475 void CCThreadedTest::dispatchAcquireLayerTextures() | 475 void CCThreadedTest::dispatchAcquireLayerTextures() |
476 { | 476 { |
477 ASSERT(CCProxy::isMainThread()); | 477 DCHECK(CCProxy::isMainThread()); |
478 | 478 |
479 if (m_finished) | 479 if (m_finished) |
480 return; | 480 return; |
481 | 481 |
482 if (m_layerTreeHost.get()) | 482 if (m_layerTreeHost.get()) |
483 m_layerTreeHost->acquireLayerTextures(); | 483 m_layerTreeHost->acquireLayerTextures(); |
484 } | 484 } |
485 | 485 |
486 void CCThreadedTest::dispatchSetNeedsRedraw() | 486 void CCThreadedTest::dispatchSetNeedsRedraw() |
487 { | 487 { |
488 ASSERT(CCProxy::isMainThread()); | 488 DCHECK(CCProxy::isMainThread()); |
489 | 489 |
490 if (m_finished) | 490 if (m_finished) |
491 return; | 491 return; |
492 | 492 |
493 if (m_layerTreeHost.get()) | 493 if (m_layerTreeHost.get()) |
494 m_layerTreeHost->setNeedsRedraw(); | 494 m_layerTreeHost->setNeedsRedraw(); |
495 } | 495 } |
496 | 496 |
497 void CCThreadedTest::dispatchSetVisible(bool visible) | 497 void CCThreadedTest::dispatchSetVisible(bool visible) |
498 { | 498 { |
499 ASSERT(CCProxy::isMainThread()); | 499 DCHECK(CCProxy::isMainThread()); |
500 | 500 |
501 if (m_finished) | 501 if (m_finished) |
502 return; | 502 return; |
503 | 503 |
504 if (m_layerTreeHost.get()) | 504 if (m_layerTreeHost.get()) |
505 m_layerTreeHost->setVisible(visible); | 505 m_layerTreeHost->setVisible(visible); |
506 } | 506 } |
507 | 507 |
508 void CCThreadedTest::dispatchComposite() | 508 void CCThreadedTest::dispatchComposite() |
509 { | 509 { |
510 m_scheduled = false; | 510 m_scheduled = false; |
511 if (m_layerTreeHost.get() && !m_finished) | 511 if (m_layerTreeHost.get() && !m_finished) |
512 m_layerTreeHost->composite(); | 512 m_layerTreeHost->composite(); |
513 } | 513 } |
514 | 514 |
515 void CCThreadedTest::dispatchDidAddAnimation() | 515 void CCThreadedTest::dispatchDidAddAnimation() |
516 { | 516 { |
517 ASSERT(CCProxy::isMainThread()); | 517 DCHECK(CCProxy::isMainThread()); |
518 | 518 |
519 if (m_finished) | 519 if (m_finished) |
520 return; | 520 return; |
521 | 521 |
522 if (m_layerTreeHost.get()) | 522 if (m_layerTreeHost.get()) |
523 m_layerTreeHost->didAddAnimation(); | 523 m_layerTreeHost->didAddAnimation(); |
524 } | 524 } |
525 | 525 |
526 void CCThreadedTest::runTest(bool threaded) | 526 void CCThreadedTest::runTest(bool threaded) |
527 { | 527 { |
528 // For these tests, we will enable threaded animations. | 528 // For these tests, we will enable threaded animations. |
529 Platform::current()->compositorSupport()->setAcceleratedAnimationEnabled(tru
e); | 529 Platform::current()->compositorSupport()->setAcceleratedAnimationEnabled(tru
e); |
530 | 530 |
531 if (threaded) { | 531 if (threaded) { |
532 m_webThread.reset(WebKit::Platform::current()->createThread("CCThreadedT
est")); | 532 m_webThread.reset(WebKit::Platform::current()->createThread("CCThreadedT
est")); |
533 Platform::current()->compositorSupport()->initialize(m_webThread.get()); | 533 Platform::current()->compositorSupport()->initialize(m_webThread.get()); |
534 } else | 534 } else |
535 Platform::current()->compositorSupport()->initialize(0); | 535 Platform::current()->compositorSupport()->initialize(0); |
536 | 536 |
537 ASSERT(CCProxy::isMainThread()); | 537 DCHECK(CCProxy::isMainThread()); |
538 m_mainThreadProxy = CCScopedThreadProxy::create(CCProxy::mainThread()); | 538 m_mainThreadProxy = CCScopedThreadProxy::create(CCProxy::mainThread()); |
539 | 539 |
540 initializeSettings(m_settings); | 540 initializeSettings(m_settings); |
541 | 541 |
542 m_beginTask = new BeginTask(this); | 542 m_beginTask = new BeginTask(this); |
543 WebKit::Platform::current()->currentThread()->postDelayedTask(m_beginTask, 0
); // postDelayedTask takes ownership of the task | 543 WebKit::Platform::current()->currentThread()->postDelayedTask(m_beginTask, 0
); // postDelayedTask takes ownership of the task |
544 m_timeoutTask = new TimeoutTask(this); | 544 m_timeoutTask = new TimeoutTask(this); |
545 WebKit::Platform::current()->currentThread()->postDelayedTask(m_timeoutTask,
5000); | 545 WebKit::Platform::current()->currentThread()->postDelayedTask(m_timeoutTask,
5000); |
546 WebKit::Platform::current()->currentThread()->enterRunLoop(); | 546 WebKit::Platform::current()->currentThread()->enterRunLoop(); |
547 | 547 |
548 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) | 548 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) |
549 m_layerTreeHost->rootLayer()->setLayerTreeHost(0); | 549 m_layerTreeHost->rootLayer()->setLayerTreeHost(0); |
550 m_layerTreeHost.reset(); | 550 m_layerTreeHost.reset(); |
551 | 551 |
552 if (m_timeoutTask) | 552 if (m_timeoutTask) |
553 m_timeoutTask->clearTest(); | 553 m_timeoutTask->clearTest(); |
554 | 554 |
555 ASSERT_FALSE(m_layerTreeHost.get()); | 555 ASSERT_FALSE(m_layerTreeHost.get()); |
556 m_client.reset(); | 556 m_client.reset(); |
557 if (m_timedOut) { | 557 if (m_timedOut) { |
558 FAIL() << "Test timed out"; | 558 FAIL() << "Test timed out"; |
559 Platform::current()->compositorSupport()->shutdown(); | 559 Platform::current()->compositorSupport()->shutdown(); |
560 return; | 560 return; |
561 } | 561 } |
562 afterTest(); | 562 afterTest(); |
563 Platform::current()->compositorSupport()->shutdown(); | 563 Platform::current()->compositorSupport()->shutdown(); |
564 } | 564 } |
565 | 565 |
566 } // namespace WebKitTests | 566 } // namespace WebKitTests |
OLD | NEW |