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

Unified Diff: media/base/android/media_source_player_unittest.cc

Issue 23620012: Fix MediaSourcePlayer unittests and minor code cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/media_source_player_unittest.cc
diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc
index e3dbf20465445cc7dc20ce31a0f78f07c97fdc5a..b4e495aeb75006b07cfbd9e8c1529632073e6d76 100644
--- a/media/base/android/media_source_player_unittest.cc
+++ b/media/base/android/media_source_player_unittest.cc
@@ -268,7 +268,23 @@ TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) {
// Initiate a seek
player_->SeekTo(base::TimeDelta());
+
+ // Verify that the seek does not occur until the initial prefetch
+ // completes.
+ EXPECT_EQ(0u, manager_->last_seek_request_id());
+
+ // Simulate aborted read caused by the seek. This aborts the initial
+ // prefetch.
+ DemuxerData data;
+ data.type = DemuxerStream::AUDIO;
+ data.access_units.resize(1);
+ data.access_units[0].status = DemuxerStream::kAborted;
+ player_->ReadFromDemuxerAck(data);
acolwell GONE FROM CHROMIUM 2013/08/30 18:27:38 The new implementation always expects to hear back
qinmin 2013/08/30 22:27:43 Previously, if a ReadFromDemuxerAck comes back whi
acolwell GONE FROM CHROMIUM 2013/09/06 00:34:55 Unfortunately, I can't remove the ID yet. Multiple
+
+ // Verify that the seek is requested now that the initial prefetch
+ // has completed.
EXPECT_EQ(1u, manager_->last_seek_request_id());
+
// Sending back the seek ACK, this should trigger the player to call
// OnReadFromDemuxer() again.
player_->OnSeekRequestAck(manager_->last_seek_request_id());
@@ -427,15 +443,31 @@ TEST_F(MediaSourcePlayerTest, StartTimeTicksResetAfterDecoderUnderruns) {
// The decoder job should finish and a new request will be sent.
EXPECT_EQ(5, manager_->num_requests());
- EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding());
+ EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding());
base::TimeTicks previous = StartTimeTicks();
// Let the decoder timeout and execute the OnDecoderStarved() callback.
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
+
+ EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding());
+ DCHECK(StartTimeTicks() != base::TimeTicks());
qinmin 2013/08/30 22:27:43 EXPECT_TRUE? Same for all the DCHECKs below.
acolwell GONE FROM CHROMIUM 2013/09/06 00:34:55 Done.
manager_->message_loop()->RunUntilIdle();
- // Send new data to the decoder. This should reset the start time ticks.
- player_->ReadFromDemuxerAck(CreateEOSAck(true));
+ // Send new data to the decoder so it can finish the currently
+ // pending decode.
+ player_->ReadFromDemuxerAck(CreateReadFromDemuxerAckForAudio(3));
acolwell GONE FROM CHROMIUM 2013/08/30 18:27:38 The new implementation has to complete the pending
+ while(GetMediaDecoderJob(true)->is_decoding())
+ manager_->message_loop()->RunUntilIdle();
+
+ // Verify the start time ticks is cleared at this point because the
+ // player is prefetching.
+ DCHECK(StartTimeTicks() == base::TimeTicks());
+
+ // Send new data to the decoder so it can finish prefetching. This should
+ // reset the start time ticks.
+ player_->ReadFromDemuxerAck(CreateReadFromDemuxerAckForAudio(3));
+ DCHECK(StartTimeTicks() != base::TimeTicks());
+
base::TimeTicks current = StartTimeTicks();
EXPECT_LE(100.0, (current - previous).InMillisecondsF());
}
« media/base/android/media_source_player.cc ('K') | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698