1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "media/base/test_data_util.h"
8 #include "media/remoting/end2end_test_renderer.h"
9 #include "media/test/pipeline_integration_test_base.h"
10 #include "media/test/test_media_source.h"
15 constexpr int kAppendTimeSec = 1;
17 class MediaRemotingIntegrationTest : public testing::Test,
18 public PipelineIntegrationTestBase {
20 MediaRemotingIntegrationTest() {
21 SetCreateRendererCB(base::BindRepeating(
22 &MediaRemotingIntegrationTest::CreateEnd2EndTestRenderer,
23 base::Unretained(this)));
26 MediaRemotingIntegrationTest(const MediaRemotingIntegrationTest&) = delete;
27 MediaRemotingIntegrationTest& operator=(const MediaRemotingIntegrationTest&) =
31 std::unique_ptr<Renderer> CreateEnd2EndTestRenderer(
32 absl::optional<RendererType> renderer_type) {
33 return std::make_unique<End2EndTestRenderer>(
34 this->CreateRendererImpl(renderer_type));
38 TEST_F(MediaRemotingIntegrationTest, BasicPlayback) {
39 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", TestTypeFlags::kHashed));
41 ASSERT_TRUE(WaitUntilOnEnded());
43 EXPECT_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
44 EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash().ToString());
47 TEST_F(MediaRemotingIntegrationTest, BasicPlayback_MediaSource) {
48 TestMediaSource source("bear-320x240.webm", 219229);
49 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source));
53 ASSERT_TRUE(WaitUntilOnEnded());
58 TEST_F(MediaRemotingIntegrationTest, MediaSource_ConfigChange_WebM) {
59 TestMediaSource source("bear-320x240-16x9-aspect.webm", kAppendWholeFile);
60 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source));
62 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1);
63 scoped_refptr<DecoderBuffer> second_file =
64 ReadTestDataFile("bear-640x360.webm");
65 ASSERT_TRUE(source.AppendAtTime(base::Seconds(kAppendTimeSec),
67 second_file->data_size()));
71 EXPECT_TRUE(WaitUntilOnEnded());
77 TEST_F(MediaRemotingIntegrationTest, SeekWhilePlaying) {
78 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm"));
80 base::TimeDelta duration(pipeline_->GetMediaDuration());
81 base::TimeDelta start_seek_time(duration / 4);
82 base::TimeDelta seek_time(duration * 3 / 4);
85 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time));
86 ASSERT_TRUE(Seek(seek_time));
87 EXPECT_GE(pipeline_->GetMediaTime(), seek_time);
88 ASSERT_TRUE(WaitUntilOnEnded());
90 // Make sure seeking after reaching the end works as expected.
91 ASSERT_TRUE(Seek(seek_time));
92 EXPECT_GE(pipeline_->GetMediaTime(), seek_time);
93 ASSERT_TRUE(WaitUntilOnEnded());
96 } // namespace remoting