Fix FullScreen crash in Webapp
[platform/framework/web/chromium-efl.git] / media / remoting / integration_test.cc
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.
4
5 #include <memory>
6
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"
11
12 namespace media {
13 namespace remoting {
14
15 constexpr int kAppendTimeSec = 1;
16
17 class MediaRemotingIntegrationTest : public testing::Test,
18                                      public PipelineIntegrationTestBase {
19  public:
20   MediaRemotingIntegrationTest() {
21     SetCreateRendererCB(base::BindRepeating(
22         &MediaRemotingIntegrationTest::CreateEnd2EndTestRenderer,
23         base::Unretained(this)));
24   }
25
26   MediaRemotingIntegrationTest(const MediaRemotingIntegrationTest&) = delete;
27   MediaRemotingIntegrationTest& operator=(const MediaRemotingIntegrationTest&) =
28       delete;
29
30  private:
31   std::unique_ptr<Renderer> CreateEnd2EndTestRenderer(
32       absl::optional<RendererType> renderer_type) {
33     return std::make_unique<End2EndTestRenderer>(
34         this->CreateRendererImpl(renderer_type));
35   }
36 };
37
38 TEST_F(MediaRemotingIntegrationTest, BasicPlayback) {
39   ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", TestTypeFlags::kHashed));
40   Play();
41   ASSERT_TRUE(WaitUntilOnEnded());
42
43   EXPECT_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
44   EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash().ToString());
45 }
46
47 TEST_F(MediaRemotingIntegrationTest, BasicPlayback_MediaSource) {
48   TestMediaSource source("bear-320x240.webm", 219229);
49   EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source));
50   source.EndOfStream();
51
52   Play();
53   ASSERT_TRUE(WaitUntilOnEnded());
54   source.Shutdown();
55   Stop();
56 }
57
58 TEST_F(MediaRemotingIntegrationTest, MediaSource_ConfigChange_WebM) {
59   TestMediaSource source("bear-320x240-16x9-aspect.webm", kAppendWholeFile);
60   EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source));
61
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),
66                                   second_file->data(),
67                                   second_file->data_size()));
68   source.EndOfStream();
69
70   Play();
71   EXPECT_TRUE(WaitUntilOnEnded());
72
73   source.Shutdown();
74   Stop();
75 }
76
77 TEST_F(MediaRemotingIntegrationTest, SeekWhilePlaying) {
78   ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm"));
79
80   base::TimeDelta duration(pipeline_->GetMediaDuration());
81   base::TimeDelta start_seek_time(duration / 4);
82   base::TimeDelta seek_time(duration * 3 / 4);
83
84   Play();
85   ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time));
86   ASSERT_TRUE(Seek(seek_time));
87   EXPECT_GE(pipeline_->GetMediaTime(), seek_time);
88   ASSERT_TRUE(WaitUntilOnEnded());
89
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());
94 }
95
96 }  // namespace remoting
97 }  // namespace media