| 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 10 matching lines...) Expand all Loading... |
| 21 using ::testing::_; | 21 using ::testing::_; |
| 22 using ::testing::DoAll; | 22 using ::testing::DoAll; |
| 23 using ::testing::Mock; | 23 using ::testing::Mock; |
| 24 using ::testing::NiceMock; | 24 using ::testing::NiceMock; |
| 25 using ::testing::Return; | 25 using ::testing::Return; |
| 26 using ::testing::SaveArg; | 26 using ::testing::SaveArg; |
| 27 using ::testing::StrictMock; | 27 using ::testing::StrictMock; |
| 28 | 28 |
| 29 namespace media { | 29 namespace media { |
| 30 | 30 |
| 31 class PipelineControllerTest : public ::testing::Test { | 31 class PipelineControllerTest : public ::testing::Test, public Pipeline::Client { |
| 32 public: | 32 public: |
| 33 PipelineControllerTest() | 33 PipelineControllerTest() |
| 34 : pipeline_controller_(&pipeline_, | 34 : pipeline_controller_(&pipeline_, |
| 35 base::Bind(&PipelineControllerTest::CreateRenderer, | 35 base::Bind(&PipelineControllerTest::CreateRenderer, |
| 36 base::Unretained(this)), | 36 base::Unretained(this)), |
| 37 base::Bind(&PipelineControllerTest::OnSeeked, | 37 base::Bind(&PipelineControllerTest::OnSeeked, |
| 38 base::Unretained(this)), | 38 base::Unretained(this)), |
| 39 base::Bind(&PipelineControllerTest::OnSuspended, | 39 base::Bind(&PipelineControllerTest::OnSuspended, |
| 40 base::Unretained(this)), | 40 base::Unretained(this)), |
| 41 base::Bind(&PipelineControllerTest::OnError, | 41 base::Bind(&PipelineControllerTest::OnError, |
| 42 base::Unretained(this))) {} | 42 base::Unretained(this))) {} |
| 43 | 43 |
| 44 ~PipelineControllerTest() override {} | 44 ~PipelineControllerTest() override {} |
| 45 | 45 |
| 46 PipelineStatusCB StartPipeline(bool is_streaming, bool is_static) { | 46 PipelineStatusCB StartPipeline(bool is_streaming, bool is_static) { |
| 47 EXPECT_FALSE(pipeline_controller_.IsStable()); | 47 EXPECT_FALSE(pipeline_controller_.IsStable()); |
| 48 PipelineStatusCB start_cb; | 48 PipelineStatusCB start_cb; |
| 49 EXPECT_CALL(pipeline_, Start(_, _, _, _, _, _, _, _, _, _)) | 49 EXPECT_CALL(pipeline_, Start(_, _, _, _)).WillOnce(SaveArg<3>(&start_cb)); |
| 50 .WillOnce(SaveArg<4>(&start_cb)); | 50 pipeline_controller_.Start(&demuxer_, this, is_streaming, is_static); |
| 51 pipeline_controller_.Start(&demuxer_, is_streaming, is_static, | |
| 52 base::Closure(), PipelineMetadataCB(), | |
| 53 BufferingStateCB(), base::Closure(), | |
| 54 AddTextTrackCB(), base::Closure()); | |
| 55 Mock::VerifyAndClear(&pipeline_); | 51 Mock::VerifyAndClear(&pipeline_); |
| 56 EXPECT_FALSE(pipeline_controller_.IsStable()); | 52 EXPECT_FALSE(pipeline_controller_.IsStable()); |
| 57 return start_cb; | 53 return start_cb; |
| 58 } | 54 } |
| 59 | 55 |
| 60 PipelineStatusCB StartPipeline() { return StartPipeline(false, true); } | 56 PipelineStatusCB StartPipeline() { return StartPipeline(false, true); } |
| 61 | 57 |
| 62 PipelineStatusCB StartPipeline_WithDynamicData() { | 58 PipelineStatusCB StartPipeline_WithDynamicData() { |
| 63 return StartPipeline(false, false); | 59 return StartPipeline(false, false); |
| 64 } | 60 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return std::unique_ptr<Renderer>(); | 109 return std::unique_ptr<Renderer>(); |
| 114 } | 110 } |
| 115 | 111 |
| 116 void OnSeeked(bool time_updated) { | 112 void OnSeeked(bool time_updated) { |
| 117 was_seeked_ = true; | 113 was_seeked_ = true; |
| 118 last_seeked_time_updated_ = time_updated; | 114 last_seeked_time_updated_ = time_updated; |
| 119 } | 115 } |
| 120 | 116 |
| 121 void OnSuspended() { was_suspended_ = true; } | 117 void OnSuspended() { was_suspended_ = true; } |
| 122 | 118 |
| 123 void OnError(PipelineStatus status) { NOTREACHED(); } | 119 // Pipeline::Client overrides |
| 120 void OnError(PipelineStatus status) override { NOTREACHED(); } |
| 121 void OnEnded() override{}; |
| 122 void OnMetadata(PipelineMetadata metadata) override{}; |
| 123 void OnBufferingStateChange(BufferingState state) override{}; |
| 124 void OnDurationChange() override{}; |
| 125 void OnAddTextTrack(const TextTrackConfig& config, |
| 126 const AddTextTrackDoneCB& done_cb) override{}; |
| 127 void OnWaitingForDecryptionKey() override{}; |
| 124 | 128 |
| 125 base::MessageLoop message_loop_; | 129 base::MessageLoop message_loop_; |
| 126 | 130 |
| 127 NiceMock<MockDemuxer> demuxer_; | 131 NiceMock<MockDemuxer> demuxer_; |
| 128 StrictMock<MockPipeline> pipeline_; | 132 StrictMock<MockPipeline> pipeline_; |
| 129 PipelineController pipeline_controller_; | 133 PipelineController pipeline_controller_; |
| 130 | 134 |
| 131 bool was_seeked_ = false; | 135 bool was_seeked_ = false; |
| 132 bool last_seeked_time_updated_ = false; | 136 bool last_seeked_time_updated_ = false; |
| 133 bool was_suspended_ = false; | 137 bool was_suspended_ = false; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 // Request a seek to the same time again. | 314 // Request a seek to the same time again. |
| 311 pipeline_controller_.Seek(seek_time, true); | 315 pipeline_controller_.Seek(seek_time, true); |
| 312 message_loop_.RunUntilIdle(); | 316 message_loop_.RunUntilIdle(); |
| 313 | 317 |
| 314 // Expect the second seek to trigger when the first seek completes. | 318 // Expect the second seek to trigger when the first seek completes. |
| 315 EXPECT_CALL(pipeline_, Seek(seek_time, _)); | 319 EXPECT_CALL(pipeline_, Seek(seek_time, _)); |
| 316 Complete(seek_cb_1); | 320 Complete(seek_cb_1); |
| 317 } | 321 } |
| 318 | 322 |
| 319 } // namespace media | 323 } // namespace media |
| OLD | NEW |