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

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

Issue 1148473003: Fix deferred video underflow if audio underflows first. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove CHECK. Created 5 years, 7 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/renderers/renderer_impl.cc ('k') | media/renderers/video_renderer_impl.cc » ('j') | 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 video_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); 557 video_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING);
558 Mock::VerifyAndClearExpectations(&time_source_); 558 Mock::VerifyAndClearExpectations(&time_source_);
559 559
560 EXPECT_CALL(time_source_, StopTicking()); 560 EXPECT_CALL(time_source_, StopTicking());
561 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); 561 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING);
562 562
563 // Nothing else should primed on the message loop. 563 // Nothing else should primed on the message loop.
564 base::RunLoop().RunUntilIdle(); 564 base::RunLoop().RunUntilIdle();
565 } 565 }
566 566
567 TEST_F(RendererImplTest, VideoUnderflowWithAudioFlush) {
568 InitializeWithAudioAndVideo();
569 Play();
570
571 // Set a massive threshold such that it shouldn't fire within this test.
572 renderer_impl_->set_video_underflow_threshold_for_testing(
573 base::TimeDelta::FromSeconds(100));
574
575 // Simulate the cases where audio underflows and then video underflows.
576 EXPECT_CALL(time_source_, StopTicking());
577 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING);
578 video_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING);
579 Mock::VerifyAndClearExpectations(&time_source_);
580
581 // Flush the audio and video renderers, both think they're in an underflow
582 // state, but if the video renderer underflow was deferred, RendererImpl would
583 // think it still has enough data.
584 EXPECT_CALL(*audio_renderer_, Flush(_)).WillOnce(RunClosure<0>());
585 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>());
586 EXPECT_CALL(callbacks_, OnFlushed());
587 renderer_impl_->Flush(
588 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_)));
589 base::RunLoop().RunUntilIdle();
590
591 // Start playback after the flush, but never return BUFFERING_HAVE_ENOUGH from
592 // the video renderer (which simulates spool up time for the video renderer).
593 const base::TimeDelta kStartTime;
594 EXPECT_CALL(time_source_, SetMediaTime(kStartTime));
595 EXPECT_CALL(*audio_renderer_, StartPlaying())
596 .WillOnce(
597 SetBufferingState(&audio_buffering_state_cb_, BUFFERING_HAVE_ENOUGH));
598 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime));
599 renderer_impl_->StartPlayingFrom(kStartTime);
600
601 // Nothing else should primed on the message loop.
602 base::RunLoop().RunUntilIdle();
603 }
604
567 } // namespace media 605 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/renderer_impl.cc ('k') | media/renderers/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698