OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // | 158 // |
159 // Examples: | 159 // Examples: |
160 // A clip that is four frames long: "0 10 20 30" | 160 // A clip that is four frames long: "0 10 20 30" |
161 // A clip that has a decode error: "60 70 error" | 161 // A clip that has a decode error: "60 70 error" |
162 void QueueFrames(const std::string& str) { | 162 void QueueFrames(const std::string& str) { |
163 for (const std::string& token : | 163 for (const std::string& token : |
164 base::SplitString(str, " ", base::TRIM_WHITESPACE, | 164 base::SplitString(str, " ", base::TRIM_WHITESPACE, |
165 base::SPLIT_WANT_ALL)) { | 165 base::SPLIT_WANT_ALL)) { |
166 if (token == "abort") { | 166 if (token == "abort") { |
167 scoped_refptr<VideoFrame> null_frame; | 167 scoped_refptr<VideoFrame> null_frame; |
168 decode_results_.push_back( | 168 QueueFrame(DecodeStatus::ABORTED, null_frame); |
169 std::make_pair(DecodeStatus::ABORTED, null_frame)); | |
170 continue; | 169 continue; |
171 } | 170 } |
172 | 171 |
173 if (token == "error") { | 172 if (token == "error") { |
174 scoped_refptr<VideoFrame> null_frame; | 173 scoped_refptr<VideoFrame> null_frame; |
175 decode_results_.push_back( | 174 QueueFrame(DecodeStatus::DECODE_ERROR, null_frame); |
176 std::make_pair(DecodeStatus::DECODE_ERROR, null_frame)); | |
177 continue; | 175 continue; |
178 } | 176 } |
179 | 177 |
180 int timestamp_in_ms = 0; | 178 int timestamp_in_ms = 0; |
181 if (base::StringToInt(token, ×tamp_in_ms)) { | 179 if (base::StringToInt(token, ×tamp_in_ms)) { |
182 gfx::Size natural_size = TestVideoConfig::NormalCodedSize(); | 180 gfx::Size natural_size = TestVideoConfig::NormalCodedSize(); |
183 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( | 181 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( |
184 PIXEL_FORMAT_YV12, natural_size, gfx::Rect(natural_size), | 182 PIXEL_FORMAT_YV12, natural_size, gfx::Rect(natural_size), |
185 natural_size, base::TimeDelta::FromMilliseconds(timestamp_in_ms)); | 183 natural_size, base::TimeDelta::FromMilliseconds(timestamp_in_ms)); |
186 decode_results_.push_back(std::make_pair(DecodeStatus::OK, frame)); | 184 QueueFrame(DecodeStatus::OK, frame); |
187 continue; | 185 continue; |
188 } | 186 } |
189 | 187 |
190 CHECK(false) << "Unrecognized decoder buffer token: " << token; | 188 CHECK(false) << "Unrecognized decoder buffer token: " << token; |
191 } | 189 } |
192 } | 190 } |
193 | 191 |
| 192 // Queues video frames to be served by the decoder during rendering. |
| 193 void QueueFrame(DecodeStatus status, scoped_refptr<VideoFrame> frame) { |
| 194 decode_results_.push_back(std::make_pair(status, frame)); |
| 195 } |
| 196 |
194 bool IsReadPending() { | 197 bool IsReadPending() { |
195 return !decode_cb_.is_null(); | 198 return !decode_cb_.is_null(); |
196 } | 199 } |
197 | 200 |
198 void WaitForError(PipelineStatus expected) { | 201 void WaitForError(PipelineStatus expected) { |
199 SCOPED_TRACE(base::StringPrintf("WaitForError(%d)", expected)); | 202 SCOPED_TRACE(base::StringPrintf("WaitForError(%d)", expected)); |
200 | 203 |
201 WaitableMessageLoopEvent event; | 204 WaitableMessageLoopEvent event; |
202 PipelineStatusCB error_cb = event.GetPipelineStatusCB(); | 205 PipelineStatusCB error_cb = event.GetPipelineStatusCB(); |
203 EXPECT_CALL(mock_cb_, OnError(_)) | 206 EXPECT_CALL(mock_cb_, OnError(_)) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 ON_CALL(*decoder_, CanReadWithoutStalling()).WillByDefault(Return(false)); | 291 ON_CALL(*decoder_, CanReadWithoutStalling()).WillByDefault(Return(false)); |
289 | 292 |
290 QueueFrames("0 30 60 90"); | 293 QueueFrames("0 30 60 90"); |
291 | 294 |
292 { | 295 { |
293 WaitableMessageLoopEvent event; | 296 WaitableMessageLoopEvent event; |
294 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 297 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
295 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 298 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
296 .WillOnce(RunClosure(event.GetClosure())); | 299 .WillOnce(RunClosure(event.GetClosure())); |
297 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 300 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 301 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 302 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
298 StartPlayingFrom(0); | 303 StartPlayingFrom(0); |
299 event.RunAndWait(); | 304 event.RunAndWait(); |
300 Mock::VerifyAndClearExpectations(&mock_cb_); | 305 Mock::VerifyAndClearExpectations(&mock_cb_); |
301 } | 306 } |
302 | 307 |
303 renderer_->OnTimeStateChanged(true); | 308 renderer_->OnTimeStateChanged(true); |
304 | 309 |
305 // Advance time slightly, but enough to exceed the duration of the last | 310 // Advance time slightly, but enough to exceed the duration of the last |
306 // frame. | 311 // frame. |
307 // Frames should be dropped and we should NOT signal having nothing. | 312 // Frames should be dropped and we should NOT signal having nothing. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 if (type == UnderflowTestType::CANT_READ_WITHOUT_STALLING) | 365 if (type == UnderflowTestType::CANT_READ_WITHOUT_STALLING) |
361 ON_CALL(*decoder_, CanReadWithoutStalling()).WillByDefault(Return(false)); | 366 ON_CALL(*decoder_, CanReadWithoutStalling()).WillByDefault(Return(false)); |
362 | 367 |
363 QueueFrames("0 20 40 60"); | 368 QueueFrames("0 20 40 60"); |
364 { | 369 { |
365 WaitableMessageLoopEvent event; | 370 WaitableMessageLoopEvent event; |
366 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 371 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
367 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 372 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
368 .WillOnce(RunClosure(event.GetClosure())); | 373 .WillOnce(RunClosure(event.GetClosure())); |
369 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 374 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 375 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 376 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
370 StartPlayingFrom(0); | 377 StartPlayingFrom(0); |
371 event.RunAndWait(); | 378 event.RunAndWait(); |
372 Mock::VerifyAndClearExpectations(&mock_cb_); | 379 Mock::VerifyAndClearExpectations(&mock_cb_); |
373 } | 380 } |
374 | 381 |
375 renderer_->OnTimeStateChanged(true); | 382 renderer_->OnTimeStateChanged(true); |
376 time_source_.StartTicking(); | 383 time_source_.StartTicking(); |
377 | 384 |
378 // Advance time, this should cause have nothing to be signaled. | 385 // Advance time, this should cause have nothing to be signaled. |
379 { | 386 { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 Initialize(); | 501 Initialize(); |
495 Destroy(); | 502 Destroy(); |
496 } | 503 } |
497 | 504 |
498 TEST_F(VideoRendererImplTest, InitializeAndStartPlayingFrom) { | 505 TEST_F(VideoRendererImplTest, InitializeAndStartPlayingFrom) { |
499 Initialize(); | 506 Initialize(); |
500 QueueFrames("0 10 20 30"); | 507 QueueFrames("0 10 20 30"); |
501 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 508 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
502 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 509 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
503 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 510 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 511 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 512 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
504 StartPlayingFrom(0); | 513 StartPlayingFrom(0); |
505 Destroy(); | 514 Destroy(); |
506 } | 515 } |
507 | 516 |
508 TEST_F(VideoRendererImplTest, InitializeAndEndOfStream) { | 517 TEST_F(VideoRendererImplTest, InitializeAndEndOfStream) { |
509 Initialize(); | 518 Initialize(); |
510 StartPlayingFrom(0); | 519 StartPlayingFrom(0); |
511 WaitForPendingRead(); | 520 WaitForPendingRead(); |
512 { | 521 { |
513 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); | 522 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); |
(...skipping 14 matching lines...) Expand all Loading... |
528 CallInitialize(NewExpectedStatusCB(PIPELINE_ERROR_ABORT), false, PIPELINE_OK); | 537 CallInitialize(NewExpectedStatusCB(PIPELINE_ERROR_ABORT), false, PIPELINE_OK); |
529 Destroy(); | 538 Destroy(); |
530 } | 539 } |
531 | 540 |
532 TEST_F(VideoRendererImplTest, DestroyWhileFlushing) { | 541 TEST_F(VideoRendererImplTest, DestroyWhileFlushing) { |
533 Initialize(); | 542 Initialize(); |
534 QueueFrames("0 10 20 30"); | 543 QueueFrames("0 10 20 30"); |
535 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 544 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
536 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 545 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
537 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 546 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 547 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 548 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
538 StartPlayingFrom(0); | 549 StartPlayingFrom(0); |
539 renderer_->Flush(NewExpectedClosure()); | 550 renderer_->Flush(NewExpectedClosure()); |
540 Destroy(); | 551 Destroy(); |
541 } | 552 } |
542 | 553 |
543 TEST_F(VideoRendererImplTest, Play) { | 554 TEST_F(VideoRendererImplTest, Play) { |
544 Initialize(); | 555 Initialize(); |
545 QueueFrames("0 10 20 30"); | 556 QueueFrames("0 10 20 30"); |
546 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 557 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
547 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 558 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
548 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 559 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 560 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 561 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
549 StartPlayingFrom(0); | 562 StartPlayingFrom(0); |
550 Destroy(); | 563 Destroy(); |
551 } | 564 } |
552 | 565 |
553 TEST_F(VideoRendererImplTest, FlushWithNothingBuffered) { | 566 TEST_F(VideoRendererImplTest, FlushWithNothingBuffered) { |
554 Initialize(); | 567 Initialize(); |
555 StartPlayingFrom(0); | 568 StartPlayingFrom(0); |
556 | 569 |
557 // We shouldn't expect a buffering state change since we never reached | 570 // We shouldn't expect a buffering state change since we never reached |
558 // BUFFERING_HAVE_ENOUGH. | 571 // BUFFERING_HAVE_ENOUGH. |
559 Flush(); | 572 Flush(); |
560 Destroy(); | 573 Destroy(); |
561 } | 574 } |
562 | 575 |
563 TEST_F(VideoRendererImplTest, DecodeError_Playing) { | 576 TEST_F(VideoRendererImplTest, DecodeError_Playing) { |
564 Initialize(); | 577 Initialize(); |
565 QueueFrames("0 10 20 30"); | 578 QueueFrames("0 10 20 30"); |
566 EXPECT_CALL(mock_cb_, FrameReceived(_)).Times(testing::AtLeast(1)); | 579 EXPECT_CALL(mock_cb_, FrameReceived(_)).Times(testing::AtLeast(1)); |
567 | 580 |
568 // Consider the case that rendering is faster than we setup the test event. | 581 // Consider the case that rendering is faster than we setup the test event. |
569 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will | 582 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will |
570 // be called. | 583 // be called. |
571 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 584 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
572 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 585 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
573 .Times(testing::AtMost(1)); | 586 .Times(testing::AtMost(1)); |
574 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 587 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 588 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 589 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
575 | 590 |
576 StartPlayingFrom(0); | 591 StartPlayingFrom(0); |
577 renderer_->OnTimeStateChanged(true); | 592 renderer_->OnTimeStateChanged(true); |
578 time_source_.StartTicking(); | 593 time_source_.StartTicking(); |
579 AdvanceTimeInMs(10); | 594 AdvanceTimeInMs(10); |
580 | 595 |
581 QueueFrames("error"); | 596 QueueFrames("error"); |
582 SatisfyPendingRead(); | 597 SatisfyPendingRead(); |
583 WaitForError(PIPELINE_ERROR_DECODE); | 598 WaitForError(PIPELINE_ERROR_DECODE); |
584 Destroy(); | 599 Destroy(); |
585 } | 600 } |
586 | 601 |
587 TEST_F(VideoRendererImplTest, DecodeError_DuringStartPlayingFrom) { | 602 TEST_F(VideoRendererImplTest, DecodeError_DuringStartPlayingFrom) { |
588 Initialize(); | 603 Initialize(); |
589 QueueFrames("error"); | 604 QueueFrames("error"); |
590 EXPECT_CALL(mock_cb_, OnError(PIPELINE_ERROR_DECODE)); | 605 EXPECT_CALL(mock_cb_, OnError(PIPELINE_ERROR_DECODE)); |
591 StartPlayingFrom(0); | 606 StartPlayingFrom(0); |
592 Destroy(); | 607 Destroy(); |
593 } | 608 } |
594 | 609 |
595 TEST_F(VideoRendererImplTest, StartPlayingFrom_Exact) { | 610 TEST_F(VideoRendererImplTest, StartPlayingFrom_Exact) { |
596 Initialize(); | 611 Initialize(); |
597 QueueFrames("50 60 70 80 90"); | 612 QueueFrames("50 60 70 80 90"); |
598 | 613 |
599 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60))); | 614 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60))); |
600 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 615 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
601 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 616 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 617 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 618 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
602 StartPlayingFrom(60); | 619 StartPlayingFrom(60); |
603 Destroy(); | 620 Destroy(); |
604 } | 621 } |
605 | 622 |
606 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightBefore) { | 623 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightBefore) { |
607 Initialize(); | 624 Initialize(); |
608 QueueFrames("50 60 70 80 90"); | 625 QueueFrames("50 60 70 80 90"); |
609 | 626 |
610 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(50))); | 627 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(50))); |
611 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 628 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
612 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 629 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 630 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 631 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
613 StartPlayingFrom(59); | 632 StartPlayingFrom(59); |
614 Destroy(); | 633 Destroy(); |
615 } | 634 } |
616 | 635 |
617 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightAfter) { | 636 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightAfter) { |
618 Initialize(); | 637 Initialize(); |
619 QueueFrames("50 60 70 80 90"); | 638 QueueFrames("50 60 70 80 90"); |
620 | 639 |
621 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60))); | 640 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60))); |
622 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 641 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
623 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 642 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 643 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 644 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
624 StartPlayingFrom(61); | 645 StartPlayingFrom(61); |
625 Destroy(); | 646 Destroy(); |
626 } | 647 } |
627 | 648 |
628 TEST_F(VideoRendererImplTest, StartPlayingFrom_LowDelay) { | 649 TEST_F(VideoRendererImplTest, StartPlayingFrom_LowDelay) { |
629 // In low-delay mode only one frame is required to finish preroll. But frames | 650 // In low-delay mode only one frame is required to finish preroll. But frames |
630 // prior to the start time will not be used. | 651 // prior to the start time will not be used. |
631 InitializeWithLowDelay(true); | 652 InitializeWithLowDelay(true); |
632 QueueFrames("0 10"); | 653 QueueFrames("0 10"); |
633 | 654 |
634 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))); | 655 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))); |
635 // Expect some amount of have enough/nothing due to only requiring one frame. | 656 // Expect some amount of have enough/nothing due to only requiring one frame. |
636 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 657 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
637 .Times(AnyNumber()); | 658 .Times(AnyNumber()); |
638 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 659 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
639 .Times(AnyNumber()); | 660 .Times(AnyNumber()); |
640 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 661 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 662 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 663 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
641 StartPlayingFrom(10); | 664 StartPlayingFrom(10); |
642 | 665 |
643 QueueFrames("20"); | 666 QueueFrames("20"); |
644 SatisfyPendingRead(); | 667 SatisfyPendingRead(); |
645 | 668 |
646 renderer_->OnTimeStateChanged(true); | 669 renderer_->OnTimeStateChanged(true); |
647 time_source_.StartTicking(); | 670 time_source_.StartTicking(); |
648 | 671 |
649 WaitableMessageLoopEvent event; | 672 WaitableMessageLoopEvent event; |
650 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(20))) | 673 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(20))) |
651 .WillOnce(RunClosure(event.GetClosure())); | 674 .WillOnce(RunClosure(event.GetClosure())); |
652 AdvanceTimeInMs(20); | 675 AdvanceTimeInMs(20); |
653 event.RunAndWait(); | 676 event.RunAndWait(); |
654 | 677 |
655 Destroy(); | 678 Destroy(); |
656 } | 679 } |
657 | 680 |
658 // Verify that a late decoder response doesn't break invariants in the renderer. | 681 // Verify that a late decoder response doesn't break invariants in the renderer. |
659 TEST_F(VideoRendererImplTest, DestroyDuringOutstandingRead) { | 682 TEST_F(VideoRendererImplTest, DestroyDuringOutstandingRead) { |
660 Initialize(); | 683 Initialize(); |
661 QueueFrames("0 10 20 30"); | 684 QueueFrames("0 10 20 30"); |
662 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 685 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
663 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 686 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
664 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 687 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 688 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 689 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
665 StartPlayingFrom(0); | 690 StartPlayingFrom(0); |
666 | 691 |
667 // Check that there is an outstanding Read() request. | 692 // Check that there is an outstanding Read() request. |
668 EXPECT_TRUE(IsReadPending()); | 693 EXPECT_TRUE(IsReadPending()); |
669 | 694 |
670 Destroy(); | 695 Destroy(); |
671 } | 696 } |
672 | 697 |
673 TEST_F(VideoRendererImplTest, VideoDecoder_InitFailure) { | 698 TEST_F(VideoRendererImplTest, VideoDecoder_InitFailure) { |
674 InitializeRenderer(false, false); | 699 InitializeRenderer(false, false); |
(...skipping 26 matching lines...) Expand all Loading... |
701 | 726 |
702 // Verifies that the sink is stopped after rendering the first frame if | 727 // Verifies that the sink is stopped after rendering the first frame if |
703 // playback hasn't started. | 728 // playback hasn't started. |
704 TEST_F(VideoRendererImplTest, RenderingStopsAfterFirstFrame) { | 729 TEST_F(VideoRendererImplTest, RenderingStopsAfterFirstFrame) { |
705 InitializeWithLowDelay(true); | 730 InitializeWithLowDelay(true); |
706 QueueFrames("0"); | 731 QueueFrames("0"); |
707 | 732 |
708 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 733 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
709 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 734 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
710 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 735 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 736 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 737 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
711 EXPECT_CALL(mock_cb_, OnEnded()).Times(0); | 738 EXPECT_CALL(mock_cb_, OnEnded()).Times(0); |
712 | 739 |
713 { | 740 { |
714 SCOPED_TRACE("Waiting for sink to stop."); | 741 SCOPED_TRACE("Waiting for sink to stop."); |
715 WaitableMessageLoopEvent event; | 742 WaitableMessageLoopEvent event; |
716 | 743 |
717 null_video_sink_->set_background_render(true); | 744 null_video_sink_->set_background_render(true); |
718 null_video_sink_->set_stop_cb(event.GetClosure()); | 745 null_video_sink_->set_stop_cb(event.GetClosure()); |
719 StartPlayingFrom(0); | 746 StartPlayingFrom(0); |
720 | 747 |
721 EXPECT_TRUE(IsReadPending()); | 748 EXPECT_TRUE(IsReadPending()); |
722 SatisfyPendingReadWithEndOfStream(); | 749 SatisfyPendingReadWithEndOfStream(); |
723 | 750 |
724 event.RunAndWait(); | 751 event.RunAndWait(); |
725 } | 752 } |
726 | 753 |
727 Destroy(); | 754 Destroy(); |
728 } | 755 } |
729 | 756 |
730 // Verifies that the sink is stopped after rendering the first frame if | 757 // Verifies that the sink is stopped after rendering the first frame if |
731 // playback ha started. | 758 // playback ha started. |
732 TEST_F(VideoRendererImplTest, RenderingStopsAfterOneFrameWithEOS) { | 759 TEST_F(VideoRendererImplTest, RenderingStopsAfterOneFrameWithEOS) { |
733 InitializeWithLowDelay(true); | 760 InitializeWithLowDelay(true); |
734 QueueFrames("0"); | 761 QueueFrames("0"); |
735 | 762 |
736 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 763 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
737 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 764 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
738 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 765 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 766 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 767 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
739 | 768 |
740 { | 769 { |
741 SCOPED_TRACE("Waiting for sink to stop."); | 770 SCOPED_TRACE("Waiting for sink to stop."); |
742 WaitableMessageLoopEvent event; | 771 WaitableMessageLoopEvent event; |
743 | 772 |
744 null_video_sink_->set_stop_cb(event.GetClosure()); | 773 null_video_sink_->set_stop_cb(event.GetClosure()); |
745 StartPlayingFrom(0); | 774 StartPlayingFrom(0); |
746 renderer_->OnTimeStateChanged(true); | 775 renderer_->OnTimeStateChanged(true); |
747 | 776 |
748 EXPECT_TRUE(IsReadPending()); | 777 EXPECT_TRUE(IsReadPending()); |
(...skipping 17 matching lines...) Expand all Loading... |
766 // zero value, once we have some decoded frames they should be overwritten. | 795 // zero value, once we have some decoded frames they should be overwritten. |
767 PipelineStatistics last_pipeline_statistics; | 796 PipelineStatistics last_pipeline_statistics; |
768 last_pipeline_statistics.video_frames_dropped = 1; | 797 last_pipeline_statistics.video_frames_dropped = 1; |
769 { | 798 { |
770 WaitableMessageLoopEvent event; | 799 WaitableMessageLoopEvent event; |
771 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 800 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
772 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))) | 801 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))) |
773 .WillOnce(RunClosure(event.GetClosure())); | 802 .WillOnce(RunClosure(event.GetClosure())); |
774 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)) | 803 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)) |
775 .WillRepeatedly(SaveArg<0>(&last_pipeline_statistics)); | 804 .WillRepeatedly(SaveArg<0>(&last_pipeline_statistics)); |
| 805 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 806 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
776 StartPlayingFrom(0); | 807 StartPlayingFrom(0); |
777 event.RunAndWait(); | 808 event.RunAndWait(); |
778 Mock::VerifyAndClearExpectations(&mock_cb_); | 809 Mock::VerifyAndClearExpectations(&mock_cb_); |
779 EXPECT_EQ(0u, last_pipeline_statistics.video_frames_dropped); | 810 EXPECT_EQ(0u, last_pipeline_statistics.video_frames_dropped); |
780 EXPECT_EQ(460800, last_pipeline_statistics.video_memory_usage); | 811 EXPECT_EQ(460800, last_pipeline_statistics.video_memory_usage); |
781 } | 812 } |
782 | 813 |
783 // Consider the case that rendering is faster than we setup the test event. | 814 // Consider the case that rendering is faster than we setup the test event. |
784 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will | 815 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will |
785 // be called. And then during SatisfyPendingReadWithEndOfStream, | 816 // be called. And then during SatisfyPendingReadWithEndOfStream, |
(...skipping 28 matching lines...) Expand all Loading... |
814 | 845 |
815 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { | 846 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { |
816 Initialize(); | 847 Initialize(); |
817 QueueFrames("0 30 60 90"); | 848 QueueFrames("0 30 60 90"); |
818 | 849 |
819 WaitableMessageLoopEvent event; | 850 WaitableMessageLoopEvent event; |
820 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 851 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
821 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 852 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
822 .WillOnce(RunClosure(event.GetClosure())); | 853 .WillOnce(RunClosure(event.GetClosure())); |
823 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 854 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 855 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 856 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
824 StartPlayingFrom(0); | 857 StartPlayingFrom(0); |
825 event.RunAndWait(); | 858 event.RunAndWait(); |
826 | 859 |
827 // Cycle ticking so that we get a non-null reference time. | 860 // Cycle ticking so that we get a non-null reference time. |
828 time_source_.StartTicking(); | 861 time_source_.StartTicking(); |
829 time_source_.StopTicking(); | 862 time_source_.StopTicking(); |
830 | 863 |
831 // Flush and simulate a seek past EOS, where some error prevents the decoder | 864 // Flush and simulate a seek past EOS, where some error prevents the decoder |
832 // from returning any frames. | 865 // from returning any frames. |
833 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); | 866 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); |
(...skipping 13 matching lines...) Expand all Loading... |
847 // after the first frame. | 880 // after the first frame. |
848 ON_CALL(*decoder_, CanReadWithoutStalling()).WillByDefault(Return(false)); | 881 ON_CALL(*decoder_, CanReadWithoutStalling()).WillByDefault(Return(false)); |
849 // Set background rendering to simulate the first couple of Render() calls | 882 // Set background rendering to simulate the first couple of Render() calls |
850 // by VFC. | 883 // by VFC. |
851 null_video_sink_->set_background_render(true); | 884 null_video_sink_->set_background_render(true); |
852 QueueFrames("0 10 20"); | 885 QueueFrames("0 10 20"); |
853 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 886 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
854 .Times(testing::AtMost(1)); | 887 .Times(testing::AtMost(1)); |
855 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 888 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
856 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 889 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 890 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 891 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
857 StartPlayingFrom(0); | 892 StartPlayingFrom(0); |
858 | 893 |
859 renderer_->OnTimeStateChanged(true); | 894 renderer_->OnTimeStateChanged(true); |
860 time_source_.StartTicking(); | 895 time_source_.StartTicking(); |
861 | 896 |
862 WaitableMessageLoopEvent event; | 897 WaitableMessageLoopEvent event; |
863 // Frame "10" should not have been expired. | 898 // Frame "10" should not have been expired. |
864 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))) | 899 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))) |
865 .WillOnce(RunClosure(event.GetClosure())); | 900 .WillOnce(RunClosure(event.GetClosure())); |
866 AdvanceTimeInMs(10); | 901 AdvanceTimeInMs(10); |
867 event.RunAndWait(); | 902 event.RunAndWait(); |
868 | 903 |
869 Destroy(); | 904 Destroy(); |
870 } | 905 } |
871 | 906 |
| 907 TEST_F(VideoRendererImplTest, NaturalSizeChange) { |
| 908 Initialize(); |
| 909 |
| 910 gfx::Size initial_size(8, 8); |
| 911 gfx::Size larger_size(16, 16); |
| 912 |
| 913 QueueFrame(DecodeStatus::OK, |
| 914 VideoFrame::CreateFrame(PIXEL_FORMAT_YV12, initial_size, |
| 915 gfx::Rect(initial_size), initial_size, |
| 916 base::TimeDelta::FromMilliseconds(0))); |
| 917 QueueFrame(DecodeStatus::OK, |
| 918 VideoFrame::CreateFrame(PIXEL_FORMAT_YV12, larger_size, |
| 919 gfx::Rect(larger_size), larger_size, |
| 920 base::TimeDelta::FromMilliseconds(10))); |
| 921 QueueFrame(DecodeStatus::OK, |
| 922 VideoFrame::CreateFrame(PIXEL_FORMAT_YV12, larger_size, |
| 923 gfx::Rect(larger_size), larger_size, |
| 924 base::TimeDelta::FromMilliseconds(20))); |
| 925 QueueFrame(DecodeStatus::OK, |
| 926 VideoFrame::CreateFrame(PIXEL_FORMAT_YV12, initial_size, |
| 927 gfx::Rect(initial_size), initial_size, |
| 928 base::TimeDelta::FromMilliseconds(30))); |
| 929 |
| 930 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 931 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 932 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 933 |
| 934 { |
| 935 // Callback is fired for the first frame. |
| 936 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(initial_size)); |
| 937 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
| 938 StartPlayingFrom(0); |
| 939 renderer_->OnTimeStateChanged(true); |
| 940 time_source_.StartTicking(); |
| 941 } |
| 942 { |
| 943 // Callback should be fired once when switching to the larger size. |
| 944 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(larger_size)); |
| 945 WaitableMessageLoopEvent event; |
| 946 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))) |
| 947 .WillOnce(RunClosure(event.GetClosure())); |
| 948 AdvanceTimeInMs(10); |
| 949 event.RunAndWait(); |
| 950 } |
| 951 { |
| 952 // Called is not fired because frame size does not change. |
| 953 WaitableMessageLoopEvent event; |
| 954 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(20))) |
| 955 .WillOnce(RunClosure(event.GetClosure())); |
| 956 AdvanceTimeInMs(10); |
| 957 event.RunAndWait(); |
| 958 } |
| 959 { |
| 960 // Callback is fired once when switching to the larger size. |
| 961 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(initial_size)); |
| 962 WaitableMessageLoopEvent event; |
| 963 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(30))) |
| 964 .WillOnce(RunClosure(event.GetClosure())); |
| 965 AdvanceTimeInMs(10); |
| 966 event.RunAndWait(); |
| 967 } |
| 968 |
| 969 Destroy(); |
| 970 } |
| 971 |
| 972 TEST_F(VideoRendererImplTest, OpacityChange) { |
| 973 Initialize(); |
| 974 |
| 975 gfx::Size frame_size(8, 8); |
| 976 VideoPixelFormat opaque_format = PIXEL_FORMAT_YV12; |
| 977 VideoPixelFormat non_opaque_format = PIXEL_FORMAT_YV12A; |
| 978 |
| 979 QueueFrame(DecodeStatus::OK, |
| 980 VideoFrame::CreateFrame(non_opaque_format, frame_size, |
| 981 gfx::Rect(frame_size), frame_size, |
| 982 base::TimeDelta::FromMilliseconds(0))); |
| 983 QueueFrame(DecodeStatus::OK, |
| 984 VideoFrame::CreateFrame(non_opaque_format, frame_size, |
| 985 gfx::Rect(frame_size), frame_size, |
| 986 base::TimeDelta::FromMilliseconds(10))); |
| 987 QueueFrame(DecodeStatus::OK, |
| 988 VideoFrame::CreateFrame(opaque_format, frame_size, |
| 989 gfx::Rect(frame_size), frame_size, |
| 990 base::TimeDelta::FromMilliseconds(20))); |
| 991 QueueFrame(DecodeStatus::OK, |
| 992 VideoFrame::CreateFrame(opaque_format, frame_size, |
| 993 gfx::Rect(frame_size), frame_size, |
| 994 base::TimeDelta::FromMilliseconds(30))); |
| 995 |
| 996 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 997 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 998 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(frame_size)).Times(1); |
| 999 |
| 1000 { |
| 1001 // Callback is fired for the first frame. |
| 1002 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(false)); |
| 1003 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
| 1004 StartPlayingFrom(0); |
| 1005 renderer_->OnTimeStateChanged(true); |
| 1006 time_source_.StartTicking(); |
| 1007 } |
| 1008 { |
| 1009 // Callback is not fired because opacity does not change. |
| 1010 WaitableMessageLoopEvent event; |
| 1011 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))) |
| 1012 .WillOnce(RunClosure(event.GetClosure())); |
| 1013 AdvanceTimeInMs(10); |
| 1014 event.RunAndWait(); |
| 1015 } |
| 1016 { |
| 1017 // Called is fired when opacity changes. |
| 1018 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(true)); |
| 1019 WaitableMessageLoopEvent event; |
| 1020 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(20))) |
| 1021 .WillOnce(RunClosure(event.GetClosure())); |
| 1022 AdvanceTimeInMs(10); |
| 1023 event.RunAndWait(); |
| 1024 } |
| 1025 { |
| 1026 // Callback is not fired because opacity does not change. |
| 1027 WaitableMessageLoopEvent event; |
| 1028 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(30))) |
| 1029 .WillOnce(RunClosure(event.GetClosure())); |
| 1030 AdvanceTimeInMs(10); |
| 1031 event.RunAndWait(); |
| 1032 } |
| 1033 |
| 1034 Destroy(); |
| 1035 } |
| 1036 |
872 class VideoRendererImplAsyncAddFrameReadyTest : public VideoRendererImplTest { | 1037 class VideoRendererImplAsyncAddFrameReadyTest : public VideoRendererImplTest { |
873 public: | 1038 public: |
874 VideoRendererImplAsyncAddFrameReadyTest() { | 1039 VideoRendererImplAsyncAddFrameReadyTest() { |
875 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool( | 1040 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool( |
876 new MockGpuMemoryBufferVideoFramePool(&frame_ready_cbs_)); | 1041 new MockGpuMemoryBufferVideoFramePool(&frame_ready_cbs_)); |
877 renderer_->SetGpuMemoryBufferVideoForTesting( | 1042 renderer_->SetGpuMemoryBufferVideoForTesting( |
878 std::move(gpu_memory_buffer_pool)); | 1043 std::move(gpu_memory_buffer_pool)); |
879 } | 1044 } |
880 | 1045 |
881 protected: | 1046 protected: |
882 std::vector<base::Closure> frame_ready_cbs_; | 1047 std::vector<base::Closure> frame_ready_cbs_; |
883 }; | 1048 }; |
884 | 1049 |
885 TEST_F(VideoRendererImplAsyncAddFrameReadyTest, InitializeAndStartPlayingFrom) { | 1050 TEST_F(VideoRendererImplAsyncAddFrameReadyTest, InitializeAndStartPlayingFrom) { |
886 Initialize(); | 1051 Initialize(); |
887 QueueFrames("0 10 20 30"); | 1052 QueueFrames("0 10 20 30"); |
888 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 1053 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
889 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 1054 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
890 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 1055 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 1056 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 1057 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
891 StartPlayingFrom(0); | 1058 StartPlayingFrom(0); |
892 ASSERT_EQ(1u, frame_ready_cbs_.size()); | 1059 ASSERT_EQ(1u, frame_ready_cbs_.size()); |
893 | 1060 |
894 uint32_t frame_ready_index = 0; | 1061 uint32_t frame_ready_index = 0; |
895 while (frame_ready_index < frame_ready_cbs_.size()) { | 1062 while (frame_ready_index < frame_ready_cbs_.size()) { |
896 frame_ready_cbs_[frame_ready_index++].Run(); | 1063 frame_ready_cbs_[frame_ready_index++].Run(); |
897 message_loop_.RunUntilIdle(); | 1064 message_loop_.RunUntilIdle(); |
898 } | 1065 } |
899 Destroy(); | 1066 Destroy(); |
900 } | 1067 } |
901 | 1068 |
902 TEST_F(VideoRendererImplAsyncAddFrameReadyTest, SequenceTokenDiscardOneFrame) { | 1069 TEST_F(VideoRendererImplAsyncAddFrameReadyTest, SequenceTokenDiscardOneFrame) { |
903 Initialize(); | 1070 Initialize(); |
904 QueueFrames("0 10 20 30"); | 1071 QueueFrames("0 10 20 30"); |
905 StartPlayingFrom(0); | 1072 StartPlayingFrom(0); |
906 Flush(); | 1073 Flush(); |
907 ASSERT_EQ(1u, frame_ready_cbs_.size()); | 1074 ASSERT_EQ(1u, frame_ready_cbs_.size()); |
908 // This frame will be discarded. | 1075 // This frame will be discarded. |
909 frame_ready_cbs_.front().Run(); | 1076 frame_ready_cbs_.front().Run(); |
910 Destroy(); | 1077 Destroy(); |
911 } | 1078 } |
912 | 1079 |
913 } // namespace media | 1080 } // namespace media |
OLD | NEW |