integration_test.cc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright (c) 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <memory>
  5. #include "media/base/test_data_util.h"
  6. #include "media/remoting/end2end_test_renderer.h"
  7. #include "media/test/pipeline_integration_test_base.h"
  8. #include "media/test/test_media_source.h"
  9. namespace media {
  10. namespace remoting {
  11. constexpr int kAppendTimeSec = 1;
  12. class MediaRemotingIntegrationTest : public testing::Test,
  13. public PipelineIntegrationTestBase {
  14. public:
  15. MediaRemotingIntegrationTest() {
  16. SetCreateRendererCB(base::BindRepeating(
  17. &MediaRemotingIntegrationTest::CreateEnd2EndTestRenderer,
  18. base::Unretained(this)));
  19. }
  20. MediaRemotingIntegrationTest(const MediaRemotingIntegrationTest&) = delete;
  21. MediaRemotingIntegrationTest& operator=(const MediaRemotingIntegrationTest&) =
  22. delete;
  23. private:
  24. std::unique_ptr<Renderer> CreateEnd2EndTestRenderer(
  25. absl::optional<RendererType> renderer_type) {
  26. return std::make_unique<End2EndTestRenderer>(
  27. this->CreateDefaultRenderer(renderer_type));
  28. }
  29. };
  30. TEST_F(MediaRemotingIntegrationTest, BasicPlayback) {
  31. ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", TestTypeFlags::kHashed));
  32. Play();
  33. ASSERT_TRUE(WaitUntilOnEnded());
  34. EXPECT_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
  35. EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash());
  36. }
  37. TEST_F(MediaRemotingIntegrationTest, BasicPlayback_MediaSource) {
  38. TestMediaSource source("bear-320x240.webm", 219229);
  39. EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source));
  40. source.EndOfStream();
  41. Play();
  42. ASSERT_TRUE(WaitUntilOnEnded());
  43. source.Shutdown();
  44. Stop();
  45. }
  46. TEST_F(MediaRemotingIntegrationTest, MediaSource_ConfigChange_WebM) {
  47. TestMediaSource source("bear-320x240-16x9-aspect.webm", kAppendWholeFile);
  48. EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source));
  49. EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1);
  50. scoped_refptr<DecoderBuffer> second_file =
  51. ReadTestDataFile("bear-640x360.webm");
  52. ASSERT_TRUE(source.AppendAtTime(base::Seconds(kAppendTimeSec),
  53. second_file->data(),
  54. second_file->data_size()));
  55. source.EndOfStream();
  56. Play();
  57. EXPECT_TRUE(WaitUntilOnEnded());
  58. source.Shutdown();
  59. Stop();
  60. }
  61. TEST_F(MediaRemotingIntegrationTest, SeekWhilePlaying) {
  62. ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm"));
  63. base::TimeDelta duration(pipeline_->GetMediaDuration());
  64. base::TimeDelta start_seek_time(duration / 4);
  65. base::TimeDelta seek_time(duration * 3 / 4);
  66. Play();
  67. ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time));
  68. ASSERT_TRUE(Seek(seek_time));
  69. EXPECT_GE(pipeline_->GetMediaTime(), seek_time);
  70. ASSERT_TRUE(WaitUntilOnEnded());
  71. // Make sure seeking after reaching the end works as expected.
  72. ASSERT_TRUE(Seek(seek_time));
  73. EXPECT_GE(pipeline_->GetMediaTime(), seek_time);
  74. ASSERT_TRUE(WaitUntilOnEnded());
  75. }
  76. } // namespace remoting
  77. } // namespace media