| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 class VideoRendererImplTest : public ::testing::Test { | 47 class VideoRendererImplTest : public ::testing::Test { |
| 48 public: | 48 public: |
| 49 VideoRendererImplTest() | 49 VideoRendererImplTest() |
| 50 : tick_clock_(new base::SimpleTestTickClock()), | 50 : tick_clock_(new base::SimpleTestTickClock()), |
| 51 decoder_(new MockVideoDecoder()), | 51 decoder_(new MockVideoDecoder()), |
| 52 demuxer_stream_(DemuxerStream::VIDEO) { | 52 demuxer_stream_(DemuxerStream::VIDEO) { |
| 53 ScopedVector<VideoDecoder> decoders; | 53 ScopedVector<VideoDecoder> decoders; |
| 54 decoders.push_back(decoder_); | 54 decoders.push_back(decoder_); |
| 55 | 55 |
| 56 renderer_.reset(new VideoRendererImpl(message_loop_.message_loop_proxy(), | 56 renderer_.reset(new VideoRendererImpl(message_loop_.message_loop_proxy(), |
| 57 &mock_cb_, |
| 57 decoders.Pass(), true, | 58 decoders.Pass(), true, |
| 58 new MediaLog())); | 59 new MediaLog())); |
| 59 renderer_->SetTickClockForTesting(scoped_ptr<base::TickClock>(tick_clock_)); | 60 renderer_->SetTickClockForTesting(scoped_ptr<base::TickClock>(tick_clock_)); |
| 60 | 61 |
| 61 // Start wallclock time at a non-zero value. | 62 // Start wallclock time at a non-zero value. |
| 62 AdvanceWallclockTimeInMs(12345); | 63 AdvanceWallclockTimeInMs(12345); |
| 63 | 64 |
| 64 demuxer_stream_.set_video_decoder_config(TestVideoConfig::Normal()); | 65 demuxer_stream_.set_video_decoder_config(TestVideoConfig::Normal()); |
| 65 | 66 |
| 66 // We expect these to be called but we don't care how/when. | 67 // We expect these to be called but we don't care how/when. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 demuxer_stream_.set_liveness(DemuxerStream::LIVENESS_LIVE); | 102 demuxer_stream_.set_liveness(DemuxerStream::LIVENESS_LIVE); |
| 102 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)).WillOnce( | 103 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)).WillOnce( |
| 103 DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(decoder_status))); | 104 DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(decoder_status))); |
| 104 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 105 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
| 105 renderer_->Initialize( | 106 renderer_->Initialize( |
| 106 &demuxer_stream_, status_cb, media::SetDecryptorReadyCB(), | 107 &demuxer_stream_, status_cb, media::SetDecryptorReadyCB(), |
| 107 base::Bind(&VideoRendererImplTest::OnStatisticsUpdate, | 108 base::Bind(&VideoRendererImplTest::OnStatisticsUpdate, |
| 108 base::Unretained(this)), | 109 base::Unretained(this)), |
| 109 base::Bind(&StrictMock<MockCB>::BufferingStateChange, | 110 base::Bind(&StrictMock<MockCB>::BufferingStateChange, |
| 110 base::Unretained(&mock_cb_)), | 111 base::Unretained(&mock_cb_)), |
| 111 base::Bind(&StrictMock<MockCB>::Display, base::Unretained(&mock_cb_)), | |
| 112 ended_event_.GetClosure(), error_event_.GetPipelineStatusCB(), | 112 ended_event_.GetClosure(), error_event_.GetPipelineStatusCB(), |
| 113 base::Bind(&VideoRendererImplTest::GetWallClockTime, | 113 base::Bind(&VideoRendererImplTest::GetWallClockTime, |
| 114 base::Unretained(this)), | 114 base::Unretained(this)), |
| 115 base::Bind(&VideoRendererImplTest::OnWaitingForDecryptionKey, | 115 base::Bind(&VideoRendererImplTest::OnWaitingForDecryptionKey, |
| 116 base::Unretained(this))); | 116 base::Unretained(this))); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void StartPlayingFrom(int milliseconds) { | 119 void StartPlayingFrom(int milliseconds) { |
| 120 SCOPED_TRACE(base::StringPrintf("StartPlayingFrom(%d)", milliseconds)); | 120 SCOPED_TRACE(base::StringPrintf("StartPlayingFrom(%d)", milliseconds)); |
| 121 renderer_->StartPlayingFrom( | 121 renderer_->StartPlayingFrom( |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 258 } |
| 259 | 259 |
| 260 protected: | 260 protected: |
| 261 // Fixture members. | 261 // Fixture members. |
| 262 scoped_ptr<VideoRendererImpl> renderer_; | 262 scoped_ptr<VideoRendererImpl> renderer_; |
| 263 base::SimpleTestTickClock* tick_clock_; // Owned by |renderer_|. | 263 base::SimpleTestTickClock* tick_clock_; // Owned by |renderer_|. |
| 264 MockVideoDecoder* decoder_; // Owned by |renderer_|. | 264 MockVideoDecoder* decoder_; // Owned by |renderer_|. |
| 265 NiceMock<MockDemuxerStream> demuxer_stream_; | 265 NiceMock<MockDemuxerStream> demuxer_stream_; |
| 266 | 266 |
| 267 // Use StrictMock<T> to catch missing/extra callbacks. | 267 // Use StrictMock<T> to catch missing/extra callbacks. |
| 268 class MockCB { | 268 // TODO(dalecurtis): Mocks won't be useful for the new rendering path, we'll |
| 269 // need fake callback generators like we have for the audio path. |
| 270 // http://crbug.com/473424 |
| 271 class MockCB : public VideoRendererSink { |
| 269 public: | 272 public: |
| 270 MOCK_METHOD1(Display, void(const scoped_refptr<VideoFrame>&)); | 273 MOCK_METHOD1(Start, void(VideoRendererSink::RenderCallback*)); |
| 274 MOCK_METHOD0(Stop, void()); |
| 275 MOCK_METHOD1(PaintFrameUsingOldRenderingPath, |
| 276 void(const scoped_refptr<VideoFrame>&)); |
| 271 MOCK_METHOD1(BufferingStateChange, void(BufferingState)); | 277 MOCK_METHOD1(BufferingStateChange, void(BufferingState)); |
| 272 }; | 278 }; |
| 273 StrictMock<MockCB> mock_cb_; | 279 StrictMock<MockCB> mock_cb_; |
| 274 | 280 |
| 275 private: | 281 private: |
| 276 base::TimeTicks GetWallClockTime(base::TimeDelta time) { | 282 base::TimeTicks GetWallClockTime(base::TimeDelta time) { |
| 277 base::AutoLock l(lock_); | 283 base::AutoLock l(lock_); |
| 278 return tick_clock_->NowTicks() + (time - time_); | 284 return tick_clock_->NowTicks() + (time - time_); |
| 279 } | 285 } |
| 280 | 286 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 348 } |
| 343 | 349 |
| 344 TEST_F(VideoRendererImplTest, Initialize) { | 350 TEST_F(VideoRendererImplTest, Initialize) { |
| 345 Initialize(); | 351 Initialize(); |
| 346 Destroy(); | 352 Destroy(); |
| 347 } | 353 } |
| 348 | 354 |
| 349 TEST_F(VideoRendererImplTest, InitializeAndStartPlayingFrom) { | 355 TEST_F(VideoRendererImplTest, InitializeAndStartPlayingFrom) { |
| 350 Initialize(); | 356 Initialize(); |
| 351 QueueFrames("0 10 20 30"); | 357 QueueFrames("0 10 20 30"); |
| 352 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))); | 358 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(0))); |
| 353 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 359 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 354 StartPlayingFrom(0); | 360 StartPlayingFrom(0); |
| 355 Destroy(); | 361 Destroy(); |
| 356 } | 362 } |
| 357 | 363 |
| 358 TEST_F(VideoRendererImplTest, DestroyWhileInitializing) { | 364 TEST_F(VideoRendererImplTest, DestroyWhileInitializing) { |
| 359 CallInitialize(NewExpectedStatusCB(PIPELINE_ERROR_ABORT), false, PIPELINE_OK); | 365 CallInitialize(NewExpectedStatusCB(PIPELINE_ERROR_ABORT), false, PIPELINE_OK); |
| 360 Destroy(); | 366 Destroy(); |
| 361 } | 367 } |
| 362 | 368 |
| 363 TEST_F(VideoRendererImplTest, DestroyWhileFlushing) { | 369 TEST_F(VideoRendererImplTest, DestroyWhileFlushing) { |
| 364 Initialize(); | 370 Initialize(); |
| 365 QueueFrames("0 10 20 30"); | 371 QueueFrames("0 10 20 30"); |
| 366 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))); | 372 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(0))); |
| 367 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 373 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 368 StartPlayingFrom(0); | 374 StartPlayingFrom(0); |
| 369 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)); | 375 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)); |
| 370 renderer_->Flush(NewExpectedClosure()); | 376 renderer_->Flush(NewExpectedClosure()); |
| 371 Destroy(); | 377 Destroy(); |
| 372 } | 378 } |
| 373 | 379 |
| 374 TEST_F(VideoRendererImplTest, Play) { | 380 TEST_F(VideoRendererImplTest, Play) { |
| 375 Initialize(); | 381 Initialize(); |
| 376 QueueFrames("0 10 20 30"); | 382 QueueFrames("0 10 20 30"); |
| 377 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))); | 383 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(0))); |
| 378 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 384 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 379 StartPlayingFrom(0); | 385 StartPlayingFrom(0); |
| 380 Destroy(); | 386 Destroy(); |
| 381 } | 387 } |
| 382 | 388 |
| 383 TEST_F(VideoRendererImplTest, FlushWithNothingBuffered) { | 389 TEST_F(VideoRendererImplTest, FlushWithNothingBuffered) { |
| 384 Initialize(); | 390 Initialize(); |
| 385 StartPlayingFrom(0); | 391 StartPlayingFrom(0); |
| 386 | 392 |
| 387 // We shouldn't expect a buffering state change since we never reached | 393 // We shouldn't expect a buffering state change since we never reached |
| 388 // BUFFERING_HAVE_ENOUGH. | 394 // BUFFERING_HAVE_ENOUGH. |
| 389 Flush(); | 395 Flush(); |
| 390 Destroy(); | 396 Destroy(); |
| 391 } | 397 } |
| 392 | 398 |
| 393 TEST_F(VideoRendererImplTest, DecodeError_Playing) { | 399 TEST_F(VideoRendererImplTest, DecodeError_Playing) { |
| 394 Initialize(); | 400 Initialize(); |
| 395 QueueFrames("0 10 20 30"); | 401 QueueFrames("0 10 20 30"); |
| 396 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))); | 402 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(0))); |
| 397 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 403 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 398 StartPlayingFrom(0); | 404 StartPlayingFrom(0); |
| 399 | 405 |
| 400 QueueFrames("error"); | 406 QueueFrames("error"); |
| 401 SatisfyPendingRead(); | 407 SatisfyPendingRead(); |
| 402 WaitForError(PIPELINE_ERROR_DECODE); | 408 WaitForError(PIPELINE_ERROR_DECODE); |
| 403 Destroy(); | 409 Destroy(); |
| 404 } | 410 } |
| 405 | 411 |
| 406 TEST_F(VideoRendererImplTest, DecodeError_DuringStartPlayingFrom) { | 412 TEST_F(VideoRendererImplTest, DecodeError_DuringStartPlayingFrom) { |
| 407 Initialize(); | 413 Initialize(); |
| 408 QueueFrames("error"); | 414 QueueFrames("error"); |
| 409 StartPlayingFrom(0); | 415 StartPlayingFrom(0); |
| 410 Destroy(); | 416 Destroy(); |
| 411 } | 417 } |
| 412 | 418 |
| 413 TEST_F(VideoRendererImplTest, StartPlayingFrom_Exact) { | 419 TEST_F(VideoRendererImplTest, StartPlayingFrom_Exact) { |
| 414 Initialize(); | 420 Initialize(); |
| 415 QueueFrames("50 60 70 80 90"); | 421 QueueFrames("50 60 70 80 90"); |
| 416 | 422 |
| 417 EXPECT_CALL(mock_cb_, Display(HasTimestamp(60))); | 423 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(60))); |
| 418 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 424 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 419 StartPlayingFrom(60); | 425 StartPlayingFrom(60); |
| 420 Destroy(); | 426 Destroy(); |
| 421 } | 427 } |
| 422 | 428 |
| 423 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightBefore) { | 429 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightBefore) { |
| 424 Initialize(); | 430 Initialize(); |
| 425 QueueFrames("50 60 70 80 90"); | 431 QueueFrames("50 60 70 80 90"); |
| 426 | 432 |
| 427 EXPECT_CALL(mock_cb_, Display(HasTimestamp(50))); | 433 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(50))); |
| 428 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 434 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 429 StartPlayingFrom(59); | 435 StartPlayingFrom(59); |
| 430 Destroy(); | 436 Destroy(); |
| 431 } | 437 } |
| 432 | 438 |
| 433 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightAfter) { | 439 TEST_F(VideoRendererImplTest, StartPlayingFrom_RightAfter) { |
| 434 Initialize(); | 440 Initialize(); |
| 435 QueueFrames("50 60 70 80 90"); | 441 QueueFrames("50 60 70 80 90"); |
| 436 | 442 |
| 437 EXPECT_CALL(mock_cb_, Display(HasTimestamp(60))); | 443 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(60))); |
| 438 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 444 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 439 StartPlayingFrom(61); | 445 StartPlayingFrom(61); |
| 440 Destroy(); | 446 Destroy(); |
| 441 } | 447 } |
| 442 | 448 |
| 443 TEST_F(VideoRendererImplTest, StartPlayingFrom_LowDelay) { | 449 TEST_F(VideoRendererImplTest, StartPlayingFrom_LowDelay) { |
| 444 // In low-delay mode only one frame is required to finish preroll. | 450 // In low-delay mode only one frame is required to finish preroll. |
| 445 InitializeWithLowDelay(true); | 451 InitializeWithLowDelay(true); |
| 446 QueueFrames("0"); | 452 QueueFrames("0"); |
| 447 | 453 |
| 448 // Expect some amount of have enough/nothing due to only requiring one frame. | 454 // Expect some amount of have enough/nothing due to only requiring one frame. |
| 449 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))); | 455 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(0))); |
| 450 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 456 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 451 .Times(AnyNumber()); | 457 .Times(AnyNumber()); |
| 452 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) | 458 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 453 .Times(AnyNumber()); | 459 .Times(AnyNumber()); |
| 454 StartPlayingFrom(0); | 460 StartPlayingFrom(0); |
| 455 | 461 |
| 456 QueueFrames("10"); | 462 QueueFrames("10"); |
| 457 SatisfyPendingRead(); | 463 SatisfyPendingRead(); |
| 458 | 464 |
| 459 WaitableMessageLoopEvent event; | 465 WaitableMessageLoopEvent event; |
| 460 EXPECT_CALL(mock_cb_, Display(HasTimestamp(10))) | 466 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(10))) |
| 461 .WillOnce(RunClosure(event.GetClosure())); | 467 .WillOnce(RunClosure(event.GetClosure())); |
| 462 AdvanceTimeInMs(10); | 468 AdvanceTimeInMs(10); |
| 463 event.RunAndWait(); | 469 event.RunAndWait(); |
| 464 | 470 |
| 465 Destroy(); | 471 Destroy(); |
| 466 } | 472 } |
| 467 | 473 |
| 468 // Verify that a late decoder response doesn't break invariants in the renderer. | 474 // Verify that a late decoder response doesn't break invariants in the renderer. |
| 469 TEST_F(VideoRendererImplTest, DestroyDuringOutstandingRead) { | 475 TEST_F(VideoRendererImplTest, DestroyDuringOutstandingRead) { |
| 470 Initialize(); | 476 Initialize(); |
| 471 QueueFrames("0 10 20 30"); | 477 QueueFrames("0 10 20 30"); |
| 472 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))); | 478 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(0))); |
| 473 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 479 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 474 StartPlayingFrom(0); | 480 StartPlayingFrom(0); |
| 475 | 481 |
| 476 // Check that there is an outstanding Read() request. | 482 // Check that there is an outstanding Read() request. |
| 477 EXPECT_TRUE(IsReadPending()); | 483 EXPECT_TRUE(IsReadPending()); |
| 478 | 484 |
| 479 Destroy(); | 485 Destroy(); |
| 480 } | 486 } |
| 481 | 487 |
| 482 TEST_F(VideoRendererImplTest, VideoDecoder_InitFailure) { | 488 TEST_F(VideoRendererImplTest, VideoDecoder_InitFailure) { |
| 483 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED, false); | 489 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED, false); |
| 484 Destroy(); | 490 Destroy(); |
| 485 } | 491 } |
| 486 | 492 |
| 487 TEST_F(VideoRendererImplTest, Underflow) { | 493 TEST_F(VideoRendererImplTest, Underflow) { |
| 488 Initialize(); | 494 Initialize(); |
| 489 QueueFrames("0 10 20 30"); | 495 QueueFrames("0 10 20 30"); |
| 490 | 496 |
| 491 { | 497 { |
| 492 WaitableMessageLoopEvent event; | 498 WaitableMessageLoopEvent event; |
| 493 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))); | 499 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(0))); |
| 494 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 500 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 495 .WillOnce(RunClosure(event.GetClosure())); | 501 .WillOnce(RunClosure(event.GetClosure())); |
| 496 StartPlayingFrom(0); | 502 StartPlayingFrom(0); |
| 497 event.RunAndWait(); | 503 event.RunAndWait(); |
| 498 Mock::VerifyAndClearExpectations(&mock_cb_); | 504 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 499 } | 505 } |
| 500 | 506 |
| 501 // Advance time slightly, but enough to exceed the duration of the last frame. | 507 // Advance time slightly, but enough to exceed the duration of the last frame. |
| 502 // Frames should be dropped and we should NOT signal having nothing. | 508 // Frames should be dropped and we should NOT signal having nothing. |
| 503 { | 509 { |
| 504 SCOPED_TRACE("Waiting for frame drops"); | 510 SCOPED_TRACE("Waiting for frame drops"); |
| 505 WaitableMessageLoopEvent event; | 511 WaitableMessageLoopEvent event; |
| 506 EXPECT_CALL(mock_cb_, Display(HasTimestamp(10))).Times(0); | 512 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(10))) |
| 507 EXPECT_CALL(mock_cb_, Display(HasTimestamp(20))).Times(0); | 513 .Times(0); |
| 508 EXPECT_CALL(mock_cb_, Display(HasTimestamp(30))) | 514 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(20))) |
| 515 .Times(0); |
| 516 EXPECT_CALL(mock_cb_, PaintFrameUsingOldRenderingPath(HasTimestamp(30))) |
| 509 .WillOnce(RunClosure(event.GetClosure())); | 517 .WillOnce(RunClosure(event.GetClosure())); |
| 510 AdvanceTimeInMs(31); | 518 AdvanceTimeInMs(31); |
| 511 event.RunAndWait(); | 519 event.RunAndWait(); |
| 512 Mock::VerifyAndClearExpectations(&mock_cb_); | 520 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 513 } | 521 } |
| 514 | 522 |
| 515 // Advance time more, such that a new frame should have been displayed by now. | 523 // Advance time more. Now we should signal having nothing. And put |
| 524 // the last frame up for display. |
| 516 { | 525 { |
| 517 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); | 526 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); |
| 518 WaitableMessageLoopEvent event; | 527 WaitableMessageLoopEvent event; |
| 519 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) | 528 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 520 .WillOnce(RunClosure(event.GetClosure())); | 529 .WillOnce(RunClosure(event.GetClosure())); |
| 521 AdvanceWallclockTimeInMs(9); | 530 AdvanceWallclockTimeInMs(9); |
| 522 event.RunAndWait(); | 531 event.RunAndWait(); |
| 523 Mock::VerifyAndClearExpectations(&mock_cb_); | 532 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 524 } | 533 } |
| 525 | 534 |
| 526 // Receiving end of stream should signal having enough. | 535 // Receiving end of stream should signal having enough. |
| 527 { | 536 { |
| 528 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); | 537 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); |
| 529 WaitableMessageLoopEvent event; | 538 WaitableMessageLoopEvent event; |
| 530 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 539 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 531 .WillOnce(RunClosure(event.GetClosure())); | 540 .WillOnce(RunClosure(event.GetClosure())); |
| 532 SatisfyPendingReadWithEndOfStream(); | 541 SatisfyPendingReadWithEndOfStream(); |
| 533 event.RunAndWait(); | 542 event.RunAndWait(); |
| 534 } | 543 } |
| 535 | 544 |
| 536 WaitForEnded(); | 545 WaitForEnded(); |
| 537 Destroy(); | 546 Destroy(); |
| 538 } | 547 } |
| 539 | 548 |
| 540 } // namespace media | 549 } // namespace media |
| OLD | NEW |