Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: media/filters/renderer_impl_unittest.cc

Issue 518613002: Have AudioRendererImpl advance time until it's told to stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/renderer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // Verify that playback rate affects the rate GetMediaTime() advances. 394 // Verify that playback rate affects the rate GetMediaTime() advances.
395 SetPlaybackRate(2.0f); 395 SetPlaybackRate(2.0f);
396 EXPECT_TRUE(IsMediaTimeAdvancing(2.0f)); 396 EXPECT_TRUE(IsMediaTimeAdvancing(2.0f));
397 397
398 // Verify that GetMediaTime() is bounded by audio max time. 398 // Verify that GetMediaTime() is bounded by audio max time.
399 DCHECK_GT(GetMediaTimeMs() + 2000, kAudioUpdateMaxTimeMs); 399 DCHECK_GT(GetMediaTimeMs() + 2000, kAudioUpdateMaxTimeMs);
400 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(2000)); 400 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(2000));
401 EXPECT_EQ(kAudioUpdateMaxTimeMs, GetMediaTimeMs()); 401 EXPECT_EQ(kAudioUpdateMaxTimeMs, GetMediaTimeMs());
402 } 402 }
403 403
404 TEST_F(RendererImplTest, AudioStreamShorterThanVideo) {
405 // Replace what's used for interpolating to simulate wall clock time.
406 renderer_impl_->SetTimeDeltaInterpolatorForTesting(
407 new TimeDeltaInterpolator(&test_tick_clock_));
408
409 InitializeWithAudioAndVideo();
410 Play();
411
412 EXPECT_EQ(kStartPlayingTimeInMs, GetMediaTimeMs());
413
414 // Verify that the clock doesn't advance since it hasn't been started by
415 // a time update from the audio stream.
416 EXPECT_FALSE(IsMediaTimeAdvancing());
417
418 // Signal end of audio stream.
419 audio_ended_cb_.Run();
420 base::RunLoop().RunUntilIdle();
421
422 // Verify that the clock advances.
423 EXPECT_TRUE(IsMediaTimeAdvancing());
424
425 // Signal end of video stream and make sure OnEnded() callback occurs.
426 EXPECT_CALL(time_source_, StopTicking());
427 EXPECT_CALL(callbacks_, OnEnded());
428 video_ended_cb_.Run();
429 base::RunLoop().RunUntilIdle();
430 }
431
432 TEST_F(RendererImplTest, AudioTimeUpdateDuringFlush) { 404 TEST_F(RendererImplTest, AudioTimeUpdateDuringFlush) {
433 // Replace what's used for interpolating to simulate wall clock time. 405 // Replace what's used for interpolating to simulate wall clock time.
434 renderer_impl_->SetTimeDeltaInterpolatorForTesting( 406 renderer_impl_->SetTimeDeltaInterpolatorForTesting(
435 new TimeDeltaInterpolator(&test_tick_clock_)); 407 new TimeDeltaInterpolator(&test_tick_clock_));
436 408
437 InitializeWithAudio(); 409 InitializeWithAudio();
438 Play(); 410 Play();
439 411
440 // Provide an initial time update so that the pipeline transitions out of the 412 // Provide an initial time update so that the pipeline transitions out of the
441 // "waiting for time update" state. 413 // "waiting for time update" state.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 InitializeWithAudio(); 520 InitializeWithAudio();
549 Play(); 521 Play();
550 Flush(false); 522 Flush(false);
551 523
552 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE)); 524 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE));
553 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); 525 audio_error_cb_.Run(PIPELINE_ERROR_DECODE);
554 base::RunLoop().RunUntilIdle(); 526 base::RunLoop().RunUntilIdle();
555 } 527 }
556 528
557 } // namespace media 529 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698