Chromium Code Reviews| Index: media/filters/chunk_demuxer_unittest.cc |
| diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc |
| index ecbcbee080c3b528ed8c38bbc8de7fdfc844012b..a8d0ccd0d0973422f4063c49d0c7f69dbfb2947c 100644 |
| --- a/media/filters/chunk_demuxer_unittest.cc |
| +++ b/media/filters/chunk_demuxer_unittest.cc |
| @@ -16,7 +16,6 @@ using ::testing::AnyNumber; |
| using ::testing::InSequence; |
| using ::testing::Return; |
| using ::testing::SetArgumentPointee; |
| -using ::testing::NiceMock; |
| using ::testing::_; |
| namespace media { |
| @@ -192,6 +191,20 @@ class ChunkDemuxerTest : public testing::Test { |
| cb->AddSimpleBlock(track_num, timecode, 0, data.get(), size); |
| } |
| + MOCK_METHOD1(OnRead, void(int64 timestamp_in_ms)); |
| + |
| + void ReadDone(const scoped_refptr<Buffer>& buffer) { |
| + int64 ts = buffer->GetTimestamp().InMilliseconds(); |
| + EXPECT_FALSE(buffer->IsEndOfStream()); |
| + OnRead(ts); |
| + } |
| + |
| + void ExpectRead(DemuxerStream* stream, int64 timestamp_in_ms) { |
| + EXPECT_CALL(*this, OnRead(timestamp_in_ms)); |
|
scherkus (not reviewing)
2011/12/20 18:26:17
alternatively I *think* you can declare a gmock ma
acolwell GONE FROM CHROMIUM
2011/12/20 19:11:53
Nice! Done.
|
| + stream->Read(base::Bind(&ChunkDemuxerTest::ReadDone, |
| + base::Unretained(this))); |
| + } |
| + |
| MOCK_METHOD1(Checkpoint, void(int id)); |
| MockDemuxerHost mock_demuxer_host_; |
| @@ -277,6 +290,57 @@ TEST_F(ChunkDemuxerTest, TestAppendDataAfterSeek) { |
| Checkpoint(2); |
| } |
| +// Test the case where a Seek() is requested while the parser |
| +// is in the middle of cluster. This is to verify that the parser |
| +// resets itself on seek and is in the right state when data from |
| +// the new seek point arrives. |
| +TEST_F(ChunkDemuxerTest, TestSeekWhileParsingCluster) { |
| + InitDemuxer(true, true); |
| + |
| + scoped_refptr<DemuxerStream> audio = |
| + demuxer_->GetStream(DemuxerStream::AUDIO); |
| + scoped_refptr<DemuxerStream> video = |
| + demuxer_->GetStream(DemuxerStream::VIDEO); |
| + |
| + InSequence s; |
| + |
| + ClusterBuilder cb; |
| + cb.SetClusterTimecode(0); |
| + AddSimpleBlock(&cb, kAudioTrackNum, 1); |
| + AddSimpleBlock(&cb, kVideoTrackNum, 2); |
| + AddSimpleBlock(&cb, kAudioTrackNum, 10); |
| + AddSimpleBlock(&cb, kVideoTrackNum, 20); |
| + scoped_ptr<Cluster> clusterA(cb.Finish()); |
|
scherkus (not reviewing)
2011/12/20 18:26:17
clusterA -> cluster_a
acolwell GONE FROM CHROMIUM
2011/12/20 19:11:53
Done & fixed all other instances in this file.
|
| + |
| + cb.SetClusterTimecode(5000); |
| + AddSimpleBlock(&cb, kAudioTrackNum, 5000); |
| + AddSimpleBlock(&cb, kVideoTrackNum, 5005); |
| + AddSimpleBlock(&cb, kAudioTrackNum, 5007); |
| + AddSimpleBlock(&cb, kVideoTrackNum, 5035); |
| + scoped_ptr<Cluster> clusterB(cb.Finish()); |
|
scherkus (not reviewing)
2011/12/20 18:26:17
ditto
acolwell GONE FROM CHROMIUM
2011/12/20 19:11:53
Done.
|
| + |
| + // Append all but the last byte so that everything but |
| + // the last block can be parsed. |
| + AppendData(clusterA->data(), clusterA->size() - 1); |
| + |
| + ExpectRead(audio, 1); |
| + ExpectRead(video, 2); |
| + ExpectRead(audio, 10); |
| + |
| + demuxer_->FlushData(); |
| + demuxer_->Seek(base::TimeDelta::FromSeconds(5), |
| + NewExpectedStatusCB(PIPELINE_OK)); |
| + |
| + |
| + // Append the new cluster and verify that only the blocks |
| + // in the new cluster are returned. |
| + AppendData(clusterB->data(), clusterB->size()); |
| + ExpectRead(audio, 5000); |
| + ExpectRead(video, 5005); |
| + ExpectRead(audio, 5007); |
| + ExpectRead(video, 5035); |
| +} |
| + |
| // Test the case where AppendData() is called before Init(). |
| TEST_F(ChunkDemuxerTest, TestAppendDataBeforeInit) { |
| scoped_array<uint8> info_tracks; |