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

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: Fix bug introduced by code in the rebase. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a9d52f942e4f22b0d565f966de468ebf035625df..e9a208495e03b5ad7498a198fe8301723eecb1dd 100644
--- a/media/base/android/media_source_player_unittest.cc
+++ b/media/base/android/media_source_player_unittest.cc
@@ -277,7 +277,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);
+
+ // 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());
@@ -436,15 +452,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());
+ EXPECT_TRUE(StartTimeTicks() != base::TimeTicks());
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));
+ while(GetMediaDecoderJob(true)->is_decoding())
+ manager_->message_loop()->RunUntilIdle();
+
+ // Verify the start time ticks is cleared at this point because the
+ // player is prefetching.
+ EXPECT_TRUE(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));
+ EXPECT_TRUE(StartTimeTicks() != base::TimeTicks());
+
base::TimeTicks current = StartTimeTicks();
EXPECT_LE(100.0, (current - previous).InMillisecondsF());
}
« no previous file with comments | « 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