Index: media/remoting/integration_test.cc |
diff --git a/media/remoting/integration_test.cc b/media/remoting/integration_test.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..79b2ad803bca7eacf054a13c365bed7c2abf398e |
--- /dev/null |
+++ b/media/remoting/integration_test.cc |
@@ -0,0 +1,240 @@ |
+// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/memory/ptr_util.h" |
+#include "media/base/test_data_util.h" |
+#include "media/remoting/end2end_test_renderer.h" |
+#include "media/test/pipeline_integration_test_base.h" |
+ |
+namespace media { |
+namespace remoting { |
+ |
+namespace { |
+ |
+constexpr char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; |
+constexpr char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; |
+constexpr char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; |
+constexpr int kAppendTimeSec = 1; |
+ |
+class TestRendererFactory final : public PipelineTestRendererFactory { |
+ public: |
+ explicit TestRendererFactory( |
+ std::unique_ptr<PipelineTestRendererFactory> renderer_factory) |
+ : default_renderer_factory_(std::move(renderer_factory)) {} |
+ ~TestRendererFactory() override {} |
+ |
+ // PipelineTestRendererFactory implementation. |
+ std::unique_ptr<Renderer> CreateRenderer( |
+ CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(), |
DaleCurtis
2017/04/20 18:24:50
Style for unused arguments is to put the parameter
xjz
2017/04/20 21:26:09
Done.
|
+ CreateAudioDecodersCB prepend_audio_decoders_cb = |
+ CreateAudioDecodersCB()) override { |
+ std::unique_ptr<Renderer> renderer_impl = |
+ default_renderer_factory_->CreateRenderer(prepend_video_decoders_cb, |
+ prepend_audio_decoders_cb); |
+ return base::MakeUnique<End2EndTestRenderer>(std::move(renderer_impl)); |
+ } |
+ |
+ private: |
+ std::unique_ptr<PipelineTestRendererFactory> default_renderer_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TestRendererFactory); |
+}; |
+ |
+} // namespace |
+ |
+class MediaRemotingIntegrationTest : public testing::Test, |
+ public PipelineIntegrationTestBase { |
+ public: |
+ MediaRemotingIntegrationTest() { |
+ std::unique_ptr<PipelineTestRendererFactory> factory = |
+ std::move(renderer_factory_); |
+ renderer_factory_.reset(new TestRendererFactory(std::move(factory))); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MediaRemotingIntegrationTest); |
+}; |
+ |
+TEST_F(MediaRemotingIntegrationTest, BasicPlayback) { |
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, BasicPlaybackHashed) { |
DaleCurtis
2017/04/20 18:24:51
I think you can remove this or replace the BasicPl
xjz
2017/04/20 21:26:09
Done.
|
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", TestTypeFlags::kHashed)); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+ |
+ EXPECT_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
+ EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
+ EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
DaleCurtis
2017/04/20 18:24:50
Delete; not relevant to your testing.
xjz
2017/04/20 21:26:09
Done.
|
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, BasicPlayback_MediaSource) { |
+ MockMediaSource source("bear-320x240.webm", kWebM, 219229); |
+ EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
+ source.EndOfStream(); |
+ |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+ EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
DaleCurtis
2017/04/20 18:24:51
Delete.
xjz
2017/04/20 21:26:09
Done.
|
+ source.Shutdown(); |
+ Stop(); |
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, MediaSource_ConfigChange_WebM) { |
+ MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
+ kAppendWholeFile); |
+ EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
+ |
+ EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
+ scoped_refptr<DecoderBuffer> second_file = |
+ ReadTestDataFile("bear-640x360.webm"); |
+ ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
+ second_file->data(), |
+ second_file->data_size())); |
+ source.EndOfStream(); |
+ |
+ Play(); |
+ EXPECT_TRUE(WaitUntilOnEnded()); |
+ |
+ source.Shutdown(); |
+ Stop(); |
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, SeekWhilePaused) { |
DaleCurtis
2017/04/20 18:24:50
Probably only need one of these seek tests since t
xjz
2017/04/20 21:26:09
Done.
|
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
+ |
+ base::TimeDelta duration(pipeline_->GetMediaDuration()); |
+ base::TimeDelta start_seek_time(duration / 4); |
+ base::TimeDelta seek_time(duration * 3 / 4); |
+ |
+ Play(); |
+ ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
+ Pause(); |
+ ASSERT_TRUE(Seek(seek_time)); |
+ EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+ |
+ // Make sure seeking after reaching the end works as expected. |
+ Pause(); |
+ ASSERT_TRUE(Seek(seek_time)); |
+ EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, SeekWhilePlaying) { |
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
+ |
+ base::TimeDelta duration(pipeline_->GetMediaDuration()); |
+ base::TimeDelta start_seek_time(duration / 4); |
+ base::TimeDelta seek_time(duration * 3 / 4); |
+ |
+ Play(); |
+ ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
+ ASSERT_TRUE(Seek(seek_time)); |
+ EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+ |
+ // Make sure seeking after reaching the end works as expected. |
+ ASSERT_TRUE(Seek(seek_time)); |
+ EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, SuspendWhilePaused) { |
DaleCurtis
2017/04/20 18:24:51
Delete, not necessary here.
xjz
2017/04/20 21:26:09
Done.
|
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
+ |
+ base::TimeDelta duration(pipeline_->GetMediaDuration()); |
+ base::TimeDelta start_seek_time(duration / 4); |
+ base::TimeDelta seek_time(duration * 3 / 4); |
+ |
+ Play(); |
+ ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
+ Pause(); |
+ |
+ // Suspend while paused. |
+ ASSERT_TRUE(Suspend()); |
+ |
+ // Resuming the pipeline will create a new Renderer, |
+ // which in turn will trigger video size and opacity notifications. |
+ EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); |
+ EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); |
+ |
+ ASSERT_TRUE(Resume(seek_time)); |
+ EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, SuspendWhilePlaying) { |
DaleCurtis
2017/04/20 18:24:50
Delete.
xjz
2017/04/20 21:26:09
Done.
|
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
+ |
+ base::TimeDelta duration(pipeline_->GetMediaDuration()); |
+ base::TimeDelta start_seek_time(duration / 4); |
+ base::TimeDelta seek_time(duration * 3 / 4); |
+ |
+ Play(); |
+ ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
+ ASSERT_TRUE(Suspend()); |
+ |
+ // Resuming the pipeline will create a new Renderer, |
+ // which in turn will trigger video size and opacity notifications. |
+ EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); |
+ EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); |
+ |
+ ASSERT_TRUE(Resume(seek_time)); |
+ EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+} |
+ |
+// Verify audio decoder & renderer can handle aborted demuxer reads. |
DaleCurtis
2017/04/20 18:24:50
Delete.
xjz
2017/04/20 21:26:09
Done.
|
+TEST_F(MediaRemotingIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) { |
+ ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM, |
+ 16384, base::TimeDelta::FromMilliseconds(464), |
+ base::TimeDelta::FromMilliseconds(617), 0x10CA, |
+ 19730)); |
+} |
+ |
+// Verify video decoder & renderer can handle aborted demuxer reads. |
DaleCurtis
2017/04/20 18:24:50
Delete.
xjz
2017/04/20 21:26:09
Done.
|
+TEST_F(MediaRemotingIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
+ ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, |
+ 32768, base::TimeDelta::FromMilliseconds(167), |
+ base::TimeDelta::FromMilliseconds(1668), |
+ 0x1C896, 65536)); |
+} |
+ |
+// Tests that we signal ended even when audio runs longer than video track. |
DaleCurtis
2017/04/20 18:24:50
Probably delete.
xjz
2017/04/20 21:26:09
Done.
|
+TEST_F(MediaRemotingIntegrationTest, BasicPlaybackAudioLongerThanVideo) { |
+ ASSERT_EQ(PIPELINE_OK, Start("bear_audio_longer_than_video.ogv")); |
+ // Audio track is 2000ms. Video track is 1001ms. Duration should be higher |
+ // of the two. |
+ EXPECT_EQ(2000, pipeline_->GetMediaDuration().InMilliseconds()); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+} |
+ |
+// Tests that we signal ended even when audio runs shorter than video track. |
+TEST_F(MediaRemotingIntegrationTest, BasicPlaybackAudioShorterThanVideo) { |
+ ASSERT_EQ(PIPELINE_OK, Start("bear_audio_shorter_than_video.ogv")); |
+ // Audio track is 500ms. Video track is 1001ms. Duration should be higher of |
+ // the two. |
+ EXPECT_EQ(1001, pipeline_->GetMediaDuration().InMilliseconds()); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+} |
+ |
+TEST_F(MediaRemotingIntegrationTest, BasicPlaybackPositiveStartTime) { |
+ ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
+ Play(); |
+ ASSERT_TRUE(WaitUntilOnEnded()); |
+ ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
+ demuxer_->GetStartTime()); |
+} |
+ |
+} // names |
+} // namespace media |