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 1570beac5b8fc57a119404aa6e58819ab5ff54a4..d064c582db04d0793904a86f019dda45f25689d6 100644 |
| --- a/media/filters/chunk_demuxer_unittest.cc |
| +++ b/media/filters/chunk_demuxer_unittest.cc |
| @@ -47,6 +47,8 @@ static const int kVideoBlockDuration = 33; |
| static const char* kSourceId = "SourceId"; |
| static const char* kDefaultFirstClusterRange = "{ [0,46) }"; |
| +static const int kDefaultFirstClusterDuration = 66; |
| +static const int kDefaultSecondClusterDuration = 132; |
|
acolwell GONE FROM CHROMIUM
2012/08/01 17:09:45
nit: Duration is misleading here. The cluster isn'
vrk (LEFT CHROMIUM)
2012/08/02 18:23:00
Done.
|
| base::TimeDelta kDefaultDuration() { |
| return base::TimeDelta::FromMilliseconds(201224); |
| @@ -1100,6 +1102,8 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamWithPendingReads) { |
| end_of_stream_helper_1.CheckIfReadDonesWereCalled(false); |
| end_of_stream_helper_2.CheckIfReadDonesWereCalled(false); |
| + EXPECT_CALL(host_, SetDuration( |
| + base::TimeDelta::FromMilliseconds(kVideoBlockDuration))); |
| demuxer_->EndOfStream(PIPELINE_OK); |
| end_of_stream_helper_1.CheckIfReadDonesWereCalled(true); |
| @@ -1139,6 +1143,8 @@ TEST_F(ChunkDemuxerTest, TestReadsAfterEndOfStream) { |
| EXPECT_TRUE(video_read_done_1); |
| end_of_stream_helper_1.CheckIfReadDonesWereCalled(false); |
| + EXPECT_CALL(host_, SetDuration( |
| + base::TimeDelta::FromMilliseconds(kVideoBlockDuration))); |
| EXPECT_TRUE(demuxer_->EndOfStream(PIPELINE_OK)); |
| end_of_stream_helper_1.CheckIfReadDonesWereCalled(true); |
| @@ -1697,6 +1703,7 @@ TEST_F(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) { |
| CheckExpectedRanges("{ [0,90) }"); |
| + EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(100))); |
| demuxer_->EndOfStream(PIPELINE_OK); |
| CheckExpectedRanges("{ [0,100) }"); |
| @@ -1813,6 +1820,7 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamFailures) { |
| // Make sure that end of stream fails because there is a gap between |
| // the current position(0) and the end of the appended data. |
| + EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(50))); |
| ASSERT_FALSE(demuxer_->EndOfStream(PIPELINE_OK)); |
| // Seek to an time that is inside the last ranges for both streams |
| @@ -1863,6 +1871,8 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamDuringSeek) { |
| demuxer_->StartWaitingForSeek(); |
| ASSERT_TRUE(AppendData(cluster_b->data(), cluster_b->size())); |
| + EXPECT_CALL(host_, SetDuration( |
| + base::TimeDelta::FromMilliseconds(kDefaultSecondClusterDuration))); |
| demuxer_->EndOfStream(PIPELINE_OK); |
| demuxer_->Seek(base::TimeDelta::FromSeconds(0), |
| @@ -2133,20 +2143,42 @@ TEST_F(ChunkDemuxerTest, TestTimestampOffsetMidParse) { |
| TEST_F(ChunkDemuxerTest, TestDurationChange) { |
| ASSERT_TRUE(InitDemuxer(true, true, false)); |
| + static const int kStreamDuration = kDefaultDuration().InMilliseconds(); |
| // Add data leading up to the currently set duration. |
| scoped_ptr<Cluster> first_cluster = GenerateCluster( |
| - kDefaultDuration().InMilliseconds() - kAudioBlockDuration, |
| - kDefaultDuration().InMilliseconds() - kVideoBlockDuration, 2); |
| + kStreamDuration - kAudioBlockDuration, |
| + kStreamDuration - kVideoBlockDuration, 2); |
| ASSERT_TRUE(AppendData(first_cluster->data(), first_cluster->size())); |
| - // Now add data past the duration and expect a new duration to be signalled. |
| + std::stringstream first_range; |
| + first_range << "{ [" << kStreamDuration - kVideoBlockDuration << "," << |
| + kStreamDuration << ") }"; |
| + CheckExpectedRanges(kSourceId, first_range.str()); |
|
acolwell GONE FROM CHROMIUM
2012/08/01 17:09:45
Just explicitly put the strings here and below. I'
vrk (LEFT CHROMIUM)
2012/08/02 18:23:00
Done, and I agree I think it's clearer this way.
|
| + |
| + // Add data at the currently set duration. The duration should not increase. |
| scoped_ptr<Cluster> second_cluster = GenerateCluster( |
| - kDefaultDuration().InMilliseconds(), 4); |
| - EXPECT_CALL(host_, SetDuration( |
| - kDefaultDuration() + base::TimeDelta::FromMilliseconds( |
| - kAudioBlockDuration * 2))); |
| + kDefaultDuration().InMilliseconds(), 2); |
| ASSERT_TRUE(AppendData(second_cluster->data(), second_cluster->size())); |
| + |
| + // Range should not be affected. |
| + CheckExpectedRanges(kSourceId, first_range.str()); |
| + |
| + // Now add data past the duration and expect a new duration to be signalled. |
| + static const int kNewStreamDuration = |
| + kStreamDuration + kAudioBlockDuration * 2; |
| + scoped_ptr<Cluster> third_cluster = GenerateCluster( |
| + kStreamDuration + kAudioBlockDuration, |
| + kStreamDuration + kVideoBlockDuration, 2); |
| + EXPECT_CALL(host_, SetDuration( |
| + base::TimeDelta::FromMilliseconds(kNewStreamDuration))); |
| + ASSERT_TRUE(AppendData(third_cluster->data(), third_cluster->size())); |
| + |
| + // See that the range has increased appropriately. |
| + std::stringstream second_range; |
| + second_range << "{ [" << kStreamDuration - kVideoBlockDuration << "," << |
| + kNewStreamDuration << ") }"; |
| + CheckExpectedRanges(kSourceId, second_range.str()); |
| } |
| TEST_F(ChunkDemuxerTest, TestDurationChangeTimestampOffset) { |
| @@ -2162,4 +2194,15 @@ TEST_F(ChunkDemuxerTest, TestDurationChangeTimestampOffset) { |
| ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); |
| } |
| +TEST_F(ChunkDemuxerTest, TestEndOfStreamTruncateDuration) { |
| + ASSERT_TRUE(InitDemuxer(true, true, false)); |
| + |
| + scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); |
| + ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); |
| + |
| + EXPECT_CALL(host_, SetDuration( |
| + base::TimeDelta::FromMilliseconds(kDefaultFirstClusterDuration))); |
| + demuxer_->EndOfStream(PIPELINE_OK); |
| +} |
| + |
| } // namespace media |