| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/pipeline_controller.h" | 5 #include "media/filters/pipeline_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 using ::testing::StrictMock; | 28 using ::testing::StrictMock; |
| 29 | 29 |
| 30 namespace media { | 30 namespace media { |
| 31 | 31 |
| 32 class PipelineControllerTest : public ::testing::Test, public Pipeline::Client { | 32 class PipelineControllerTest : public ::testing::Test, public Pipeline::Client { |
| 33 public: | 33 public: |
| 34 PipelineControllerTest() | 34 PipelineControllerTest() |
| 35 : pipeline_controller_(&pipeline_, | 35 : pipeline_controller_(&pipeline_, |
| 36 base::Bind(&PipelineControllerTest::CreateRenderer, | 36 base::Bind(&PipelineControllerTest::CreateRenderer, |
| 37 base::Unretained(this)), | 37 base::Unretained(this)), |
| 38 base::Bind(&PipelineControllerTest::OnStartDone, |
| 39 base::Unretained(this)), |
| 38 base::Bind(&PipelineControllerTest::OnSeeked, | 40 base::Bind(&PipelineControllerTest::OnSeeked, |
| 39 base::Unretained(this)), | 41 base::Unretained(this)), |
| 40 base::Bind(&PipelineControllerTest::OnSuspended, | 42 base::Bind(&PipelineControllerTest::OnSuspended, |
| 41 base::Unretained(this)), | 43 base::Unretained(this)), |
| 42 base::Bind(&PipelineControllerTest::OnError, | 44 base::Bind(&PipelineControllerTest::OnError, |
| 43 base::Unretained(this))) {} | 45 base::Unretained(this))) { |
| 46 EXPECT_CALL(*this, OnError(_)).Times(0); |
| 47 } |
| 44 | 48 |
| 45 ~PipelineControllerTest() override {} | 49 ~PipelineControllerTest() override {} |
| 46 | 50 |
| 47 PipelineStatusCB StartPipeline(bool is_streaming, bool is_static) { | 51 PipelineStatusCB StartPipeline(bool is_streaming, bool is_static) { |
| 48 EXPECT_FALSE(pipeline_controller_.IsStable()); | 52 EXPECT_FALSE(pipeline_controller_.IsStable()); |
| 53 EXPECT_CALL(*this, OnStartDone(_)).Times(1); |
| 49 PipelineStatusCB start_cb; | 54 PipelineStatusCB start_cb; |
| 50 EXPECT_CALL(pipeline_, Start(_, _, _, _)).WillOnce(SaveArg<3>(&start_cb)); | 55 EXPECT_CALL(pipeline_, Start(_, _, _, _)).WillOnce(SaveArg<3>(&start_cb)); |
| 51 pipeline_controller_.Start(&demuxer_, this, is_streaming, is_static); | 56 pipeline_controller_.Start(&demuxer_, this, is_streaming, is_static); |
| 52 Mock::VerifyAndClear(&pipeline_); | 57 Mock::VerifyAndClear(&pipeline_); |
| 53 EXPECT_FALSE(pipeline_controller_.IsStable()); | 58 EXPECT_FALSE(pipeline_controller_.IsStable()); |
| 54 return start_cb; | 59 return start_cb; |
| 55 } | 60 } |
| 56 | 61 |
| 57 PipelineStatusCB StartPipeline() { return StartPipeline(false, true); } | 62 PipelineStatusCB StartPipeline() { return StartPipeline(false, true); } |
| 58 | 63 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 protected: | 115 protected: |
| 111 std::unique_ptr<Renderer> CreateRenderer() { | 116 std::unique_ptr<Renderer> CreateRenderer() { |
| 112 return std::unique_ptr<Renderer>(); | 117 return std::unique_ptr<Renderer>(); |
| 113 } | 118 } |
| 114 | 119 |
| 115 void OnSeeked(bool time_updated) { | 120 void OnSeeked(bool time_updated) { |
| 116 was_seeked_ = true; | 121 was_seeked_ = true; |
| 117 last_seeked_time_updated_ = time_updated; | 122 last_seeked_time_updated_ = time_updated; |
| 118 } | 123 } |
| 119 | 124 |
| 125 MOCK_METHOD1(OnStartDone, void(PipelineStatus status)); |
| 126 |
| 120 void OnSuspended() { was_suspended_ = true; } | 127 void OnSuspended() { was_suspended_ = true; } |
| 121 | 128 |
| 122 // Pipeline::Client overrides | 129 // Pipeline::Client overrides |
| 123 void OnError(PipelineStatus status) override { NOTREACHED(); } | 130 MOCK_METHOD1(OnError, void(PipelineStatus status)); |
| 124 void OnEnded() override {} | 131 void OnEnded() override {} |
| 125 void OnMetadata(PipelineMetadata metadata) override {} | 132 void OnMetadata(PipelineMetadata metadata) override {} |
| 126 void OnBufferingStateChange(BufferingState state) override {} | 133 void OnBufferingStateChange(BufferingState state) override {} |
| 127 void OnDurationChange() override {} | 134 void OnDurationChange() override {} |
| 128 void OnAddTextTrack(const TextTrackConfig& config, | 135 void OnAddTextTrack(const TextTrackConfig& config, |
| 129 const AddTextTrackDoneCB& done_cb) override {} | 136 const AddTextTrackDoneCB& done_cb) override {} |
| 130 void OnWaitingForDecryptionKey() override {} | 137 void OnWaitingForDecryptionKey() override {} |
| 131 void OnVideoNaturalSizeChange(const gfx::Size& size) override {} | 138 void OnVideoNaturalSizeChange(const gfx::Size& size) override {} |
| 132 void OnVideoOpacityChange(bool opaque) override {} | 139 void OnVideoOpacityChange(bool opaque) override {} |
| 133 | 140 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 PipelineStatusCB start_cb = StartPipeline(); | 156 PipelineStatusCB start_cb = StartPipeline(); |
| 150 EXPECT_FALSE(was_seeked_); | 157 EXPECT_FALSE(was_seeked_); |
| 151 | 158 |
| 152 Complete(start_cb); | 159 Complete(start_cb); |
| 153 EXPECT_TRUE(was_seeked_); | 160 EXPECT_TRUE(was_seeked_); |
| 154 EXPECT_FALSE(last_seeked_time_updated_); | 161 EXPECT_FALSE(last_seeked_time_updated_); |
| 155 EXPECT_FALSE(was_suspended_); | 162 EXPECT_FALSE(was_suspended_); |
| 156 EXPECT_TRUE(pipeline_controller_.IsStable()); | 163 EXPECT_TRUE(pipeline_controller_.IsStable()); |
| 157 } | 164 } |
| 158 | 165 |
| 166 TEST_F(PipelineControllerTest, StartupFailed) { |
| 167 EXPECT_CALL(*this, OnError(PIPELINE_ERROR_INITIALIZATION_FAILED)).Times(1); |
| 168 PipelineStatusCB start_cb = StartPipeline(); |
| 169 start_cb.Run(PIPELINE_ERROR_INITIALIZATION_FAILED); |
| 170 base::RunLoop().RunUntilIdle(); |
| 171 } |
| 172 |
| 159 TEST_F(PipelineControllerTest, SuspendResume) { | 173 TEST_F(PipelineControllerTest, SuspendResume) { |
| 160 Complete(StartPipeline()); | 174 Complete(StartPipeline()); |
| 161 EXPECT_TRUE(was_seeked_); | 175 EXPECT_TRUE(was_seeked_); |
| 162 was_seeked_ = false; | 176 was_seeked_ = false; |
| 163 | 177 |
| 164 Complete(SuspendPipeline()); | 178 Complete(SuspendPipeline()); |
| 165 EXPECT_TRUE(was_suspended_); | 179 EXPECT_TRUE(was_suspended_); |
| 166 EXPECT_FALSE(pipeline_controller_.IsStable()); | 180 EXPECT_FALSE(pipeline_controller_.IsStable()); |
| 167 | 181 |
| 168 Complete(ResumePipeline()); | 182 Complete(ResumePipeline()); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // Request a seek to the same time again. | 333 // Request a seek to the same time again. |
| 320 pipeline_controller_.Seek(seek_time, true); | 334 pipeline_controller_.Seek(seek_time, true); |
| 321 base::RunLoop().RunUntilIdle(); | 335 base::RunLoop().RunUntilIdle(); |
| 322 | 336 |
| 323 // Expect the second seek to trigger when the first seek completes. | 337 // Expect the second seek to trigger when the first seek completes. |
| 324 EXPECT_CALL(pipeline_, Seek(seek_time, _)); | 338 EXPECT_CALL(pipeline_, Seek(seek_time, _)); |
| 325 Complete(seek_cb_1); | 339 Complete(seek_cb_1); |
| 326 } | 340 } |
| 327 | 341 |
| 328 } // namespace media | 342 } // namespace media |
| OLD | NEW |