OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 Flush(); | 502 Flush(); |
503 QueuePrerollFrames(kFrameDurationInMs * 6); | 503 QueuePrerollFrames(kFrameDurationInMs * 6); |
504 | 504 |
505 Preroll(kFrameDurationInMs * 6 + 1, PIPELINE_OK); | 505 Preroll(kFrameDurationInMs * 6 + 1, PIPELINE_OK); |
506 EXPECT_EQ(kFrameDurationInMs * 6, GetCurrentTimestampInMs()); | 506 EXPECT_EQ(kFrameDurationInMs * 6, GetCurrentTimestampInMs()); |
507 Shutdown(); | 507 Shutdown(); |
508 } | 508 } |
509 | 509 |
510 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Initialized) { | 510 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Initialized) { |
511 Initialize(); | 511 Initialize(); |
512 EXPECT_TRUE(GetCurrentFrame()); // Due to prerolling. | 512 EXPECT_TRUE(GetCurrentFrame().get()); // Due to prerolling. |
513 Shutdown(); | 513 Shutdown(); |
514 } | 514 } |
515 | 515 |
516 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Playing) { | 516 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Playing) { |
517 Initialize(); | 517 Initialize(); |
518 Play(); | 518 Play(); |
519 EXPECT_TRUE(GetCurrentFrame()); | 519 EXPECT_TRUE(GetCurrentFrame().get()); |
520 Shutdown(); | 520 Shutdown(); |
521 } | 521 } |
522 | 522 |
523 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Paused) { | 523 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Paused) { |
524 Initialize(); | 524 Initialize(); |
525 Play(); | 525 Play(); |
526 Pause(); | 526 Pause(); |
527 EXPECT_TRUE(GetCurrentFrame()); | 527 EXPECT_TRUE(GetCurrentFrame().get()); |
528 Shutdown(); | 528 Shutdown(); |
529 } | 529 } |
530 | 530 |
531 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Flushed) { | 531 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Flushed) { |
532 Initialize(); | 532 Initialize(); |
533 Play(); | 533 Play(); |
534 Pause(); | 534 Pause(); |
535 | 535 |
536 // Frame shouldn't be updated. | 536 // Frame shouldn't be updated. |
537 ResetCurrentFrame(); | 537 ResetCurrentFrame(); |
538 Flush(); | 538 Flush(); |
539 EXPECT_FALSE(GetCurrentFrame()); | 539 EXPECT_FALSE(GetCurrentFrame().get()); |
540 | 540 |
541 Shutdown(); | 541 Shutdown(); |
542 } | 542 } |
543 | 543 |
544 TEST_F(VideoRendererBaseTest, GetCurrentFrame_EndOfStream) { | 544 TEST_F(VideoRendererBaseTest, GetCurrentFrame_EndOfStream) { |
545 Initialize(); | 545 Initialize(); |
546 Play(); | 546 Play(); |
547 Pause(); | 547 Pause(); |
548 Flush(); | 548 Flush(); |
549 | 549 |
550 // Preroll only end of stream frames. | 550 // Preroll only end of stream frames. |
551 QueueEndOfStream(); | 551 QueueEndOfStream(); |
552 | 552 |
553 // Frame shouldn't be updated. | 553 // Frame shouldn't be updated. |
554 ResetCurrentFrame(); | 554 ResetCurrentFrame(); |
555 Preroll(0, PIPELINE_OK); | 555 Preroll(0, PIPELINE_OK); |
556 EXPECT_FALSE(GetCurrentFrame()); | 556 EXPECT_FALSE(GetCurrentFrame().get()); |
557 | 557 |
558 // Start playing, we should immediately get notified of end of stream. | 558 // Start playing, we should immediately get notified of end of stream. |
559 Play(); | 559 Play(); |
560 WaitForEnded(); | 560 WaitForEnded(); |
561 | 561 |
562 Shutdown(); | 562 Shutdown(); |
563 } | 563 } |
564 | 564 |
565 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Shutdown) { | 565 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Shutdown) { |
566 Initialize(); | 566 Initialize(); |
567 | 567 |
568 // Frame shouldn't be updated. | 568 // Frame shouldn't be updated. |
569 ResetCurrentFrame(); | 569 ResetCurrentFrame(); |
570 Shutdown(); | 570 Shutdown(); |
571 EXPECT_FALSE(GetCurrentFrame()); | 571 EXPECT_FALSE(GetCurrentFrame().get()); |
572 } | 572 } |
573 | 573 |
574 // Stop() is called immediately during an error. | 574 // Stop() is called immediately during an error. |
575 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Error) { | 575 TEST_F(VideoRendererBaseTest, GetCurrentFrame_Error) { |
576 Initialize(); | 576 Initialize(); |
577 | 577 |
578 // Frame shouldn't be updated. | 578 // Frame shouldn't be updated. |
579 ResetCurrentFrame(); | 579 ResetCurrentFrame(); |
580 Stop(); | 580 Stop(); |
581 EXPECT_FALSE(GetCurrentFrame()); | 581 EXPECT_FALSE(GetCurrentFrame().get()); |
582 } | 582 } |
583 | 583 |
584 // Verify that a late decoder response doesn't break invariants in the renderer. | 584 // Verify that a late decoder response doesn't break invariants in the renderer. |
585 TEST_F(VideoRendererBaseTest, StopDuringOutstandingRead) { | 585 TEST_F(VideoRendererBaseTest, StopDuringOutstandingRead) { |
586 Initialize(); | 586 Initialize(); |
587 Play(); | 587 Play(); |
588 | 588 |
589 // Advance time a bit to trigger a Read(). | 589 // Advance time a bit to trigger a Read(). |
590 AdvanceTimeInMs(kFrameDurationInMs); | 590 AdvanceTimeInMs(kFrameDurationInMs); |
591 WaitForPendingRead(); | 591 WaitForPendingRead(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 InSequence s; | 642 InSequence s; |
643 | 643 |
644 EXPECT_CALL(*decoder_, Initialize(_, _, _)) | 644 EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
645 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); | 645 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); |
646 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); | 646 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); |
647 | 647 |
648 Stop(); | 648 Stop(); |
649 } | 649 } |
650 | 650 |
651 } // namespace media | 651 } // namespace media |
OLD | NEW |