Chromium Code Reviews| Index: media/test/pipeline_integration_test.cc |
| diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc |
| index 2cd26bd8431ad268ee157359f97459347b75dfd3..3124c5e5a6ccf43777e944009398b74992631f94 100644 |
| --- a/media/test/pipeline_integration_test.cc |
| +++ b/media/test/pipeline_integration_test.cc |
| @@ -944,6 +944,83 @@ TEST_F(PipelineIntegrationTest, BasicPlaybackHashed) { |
| EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
| } |
| +TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) { |
| + ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
| + |
| + // Disable audio. |
| + std::vector<MediaTrack::Id> empty; |
| + pipeline_->OnEnabledAudioTracksChanged(empty); |
| + message_loop_.RunUntilIdle(); |
| + |
| + // Seek to flush the pipeline and ensure there's no prerolled audio data. |
| + ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(0))); |
| + |
| + Play(); |
| + const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); |
| + ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); |
| + Pause(); |
| + |
| + // Verify that no audio has been rendered, since we disabled audio tracks. |
| + EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash()); |
| + |
| + // Re-enable audio. |
| + std::vector<MediaTrack::Id> audioTrackId; |
| + audioTrackId.push_back("2"); |
| + pipeline_->OnEnabledAudioTracksChanged(audioTrackId); |
| + message_loop_.RunUntilIdle(); |
| + |
| + // Restart playback from 500ms position. |
| + ASSERT_TRUE(Seek(k500ms)); |
| + Play(); |
| + ASSERT_TRUE(WaitUntilOnEnded()); |
| + |
| + // Verify that audio has been rendered after being enabled. |
| + EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash()); |
| +} |
| + |
| +TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) { |
| + ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
| + |
| + // Disable video. |
| + std::vector<MediaTrack::Id> empty; |
| + pipeline_->OnSelectedVideoTrackChanged(empty); |
| + message_loop_.RunUntilIdle(); |
| + |
| + // Seek to flush the pipeline and ensure there's no prerolled video data. |
| + ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(0))); |
| + |
| + // Reset the video hash in case some of the prerolled video frames have been |
| + // hashed already. |
| + ResetVideoHash(); |
| + |
| + Play(); |
| + const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); |
| + ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); |
| + Pause(); |
| + |
| + // Verify that no audio has been rendered, since we disabled audio tracks. |
| + EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); |
| + |
| + // Re-enable video. |
| + std::vector<MediaTrack::Id> videoTrackId; |
| + videoTrackId.push_back("1"); |
| + pipeline_->OnSelectedVideoTrackChanged(videoTrackId); |
| + message_loop_.RunUntilIdle(); |
| + |
| + // Seek to flush video pipeline and reset the video hash again to clear state |
| + // if some prerolled frames got hashed after enabling video. |
| + ASSERT_TRUE(Seek(base::TimeDelta())); |
| + ResetVideoHash(); |
| + |
| + // Restart playback from 500ms position. |
| + ASSERT_TRUE(Seek(k500ms)); |
| + Play(); |
| + ASSERT_TRUE(WaitUntilOnEnded()); |
| + |
| + // Verify that video has been rendered after being enabled. |
| + EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); |
|
chcunningham
2016/06/29 22:58:29
Make sure you run these 10 times or so on your loc
servolk
2016/06/29 23:40:13
Yes, my first attempts were also flaky at first, s
|
| +} |
| + |
| TEST_F(PipelineIntegrationTest, |
| MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { |
| ASSERT_EQ(PIPELINE_OK, |