| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // Verify that playback rate affects the rate GetMediaTime() advances. | 391 // Verify that playback rate affects the rate GetMediaTime() advances. |
| 392 SetPlaybackRate(2.0f); | 392 SetPlaybackRate(2.0f); |
| 393 EXPECT_TRUE(IsMediaTimeAdvancing(2.0f)); | 393 EXPECT_TRUE(IsMediaTimeAdvancing(2.0f)); |
| 394 | 394 |
| 395 // Verify that GetMediaTime() is bounded by audio max time. | 395 // Verify that GetMediaTime() is bounded by audio max time. |
| 396 DCHECK_GT(GetMediaTimeMs() + 2000, kAudioUpdateMaxTimeMs); | 396 DCHECK_GT(GetMediaTimeMs() + 2000, kAudioUpdateMaxTimeMs); |
| 397 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(2000)); | 397 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(2000)); |
| 398 EXPECT_EQ(kAudioUpdateMaxTimeMs, GetMediaTimeMs()); | 398 EXPECT_EQ(kAudioUpdateMaxTimeMs, GetMediaTimeMs()); |
| 399 } | 399 } |
| 400 | 400 |
| 401 TEST_F(RendererImplTest, AudioStreamShorterThanVideo) { | |
| 402 // Replace what's used for interpolating to simulate wall clock time. | |
| 403 renderer_impl_->SetTimeDeltaInterpolatorForTesting( | |
| 404 new TimeDeltaInterpolator(&test_tick_clock_)); | |
| 405 | |
| 406 InitializeWithAudioAndVideo(); | |
| 407 Play(); | |
| 408 | |
| 409 EXPECT_EQ(kStartPlayingTimeInMs, GetMediaTimeMs()); | |
| 410 | |
| 411 // Verify that the clock doesn't advance since it hasn't been started by | |
| 412 // a time update from the audio stream. | |
| 413 EXPECT_FALSE(IsMediaTimeAdvancing()); | |
| 414 | |
| 415 // Signal end of audio stream. | |
| 416 audio_ended_cb_.Run(); | |
| 417 base::RunLoop().RunUntilIdle(); | |
| 418 | |
| 419 // Verify that the clock advances. | |
| 420 EXPECT_TRUE(IsMediaTimeAdvancing()); | |
| 421 | |
| 422 // Signal end of video stream and make sure OnEnded() callback occurs. | |
| 423 EXPECT_CALL(time_source_, StopTicking()); | |
| 424 EXPECT_CALL(callbacks_, OnEnded()); | |
| 425 video_ended_cb_.Run(); | |
| 426 base::RunLoop().RunUntilIdle(); | |
| 427 } | |
| 428 | |
| 429 TEST_F(RendererImplTest, AudioTimeUpdateDuringFlush) { | 401 TEST_F(RendererImplTest, AudioTimeUpdateDuringFlush) { |
| 430 // Replace what's used for interpolating to simulate wall clock time. | 402 // Replace what's used for interpolating to simulate wall clock time. |
| 431 renderer_impl_->SetTimeDeltaInterpolatorForTesting( | 403 renderer_impl_->SetTimeDeltaInterpolatorForTesting( |
| 432 new TimeDeltaInterpolator(&test_tick_clock_)); | 404 new TimeDeltaInterpolator(&test_tick_clock_)); |
| 433 | 405 |
| 434 InitializeWithAudio(); | 406 InitializeWithAudio(); |
| 435 Play(); | 407 Play(); |
| 436 | 408 |
| 437 // Provide an initial time update so that the pipeline transitions out of the | 409 // Provide an initial time update so that the pipeline transitions out of the |
| 438 // "waiting for time update" state. | 410 // "waiting for time update" state. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 InitializeWithAudio(); | 517 InitializeWithAudio(); |
| 546 Play(); | 518 Play(); |
| 547 Flush(false); | 519 Flush(false); |
| 548 | 520 |
| 549 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE)); | 521 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE)); |
| 550 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); | 522 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); |
| 551 base::RunLoop().RunUntilIdle(); | 523 base::RunLoop().RunUntilIdle(); |
| 552 } | 524 } |
| 553 | 525 |
| 554 } // namespace media | 526 } // namespace media |
| OLD | NEW |