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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 MojoRendererService::InitiateSurfaceRequestCB(), | 70 MojoRendererService::InitiateSurfaceRequestCB(), |
71 mojo::MakeRequest(&remote_renderer)); | 71 mojo::MakeRequest(&remote_renderer)); |
72 | 72 |
73 mojo_renderer_.reset( | 73 mojo_renderer_.reset( |
74 new MojoRenderer(message_loop_.task_runner(), | 74 new MojoRenderer(message_loop_.task_runner(), |
75 std::unique_ptr<VideoOverlayFactory>(nullptr), nullptr, | 75 std::unique_ptr<VideoOverlayFactory>(nullptr), nullptr, |
76 std::move(remote_renderer))); | 76 std::move(remote_renderer))); |
77 | 77 |
78 // CreateAudioStream() and CreateVideoStream() overrides expectations for | 78 // CreateAudioStream() and CreateVideoStream() overrides expectations for |
79 // expected non-NULL streams. | 79 // expected non-NULL streams. |
80 EXPECT_CALL(demuxer_, GetStream(_)).WillRepeatedly(Return(nullptr)); | 80 EXPECT_CALL(demuxer_, GetStreams()).WillRepeatedly(Return(streams_)); |
81 | 81 |
82 EXPECT_CALL(*mock_renderer_, GetMediaTime()) | 82 EXPECT_CALL(*mock_renderer_, GetMediaTime()) |
83 .WillRepeatedly(Return(base::TimeDelta())); | 83 .WillRepeatedly(Return(base::TimeDelta())); |
84 } | 84 } |
85 | 85 |
86 virtual ~MojoRendererTest() {} | 86 virtual ~MojoRendererTest() {} |
87 | 87 |
88 void Destroy() { | 88 void Destroy() { |
89 mojo_renderer_.reset(); | 89 mojo_renderer_.reset(); |
90 base::RunLoop().RunUntilIdle(); | 90 base::RunLoop().RunUntilIdle(); |
91 } | 91 } |
92 | 92 |
93 // Completion callbacks. | 93 // Completion callbacks. |
94 MOCK_METHOD1(OnInitialized, void(PipelineStatus)); | 94 MOCK_METHOD1(OnInitialized, void(PipelineStatus)); |
95 MOCK_METHOD0(OnFlushed, void()); | 95 MOCK_METHOD0(OnFlushed, void()); |
96 MOCK_METHOD1(OnCdmAttached, void(bool)); | 96 MOCK_METHOD1(OnCdmAttached, void(bool)); |
97 MOCK_METHOD1(OnSurfaceRequestToken, void(const base::UnguessableToken&)); | 97 MOCK_METHOD1(OnSurfaceRequestToken, void(const base::UnguessableToken&)); |
98 | 98 |
99 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream( | 99 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream( |
100 DemuxerStream::Type type) { | 100 DemuxerStream::Type type) { |
101 std::unique_ptr<StrictMock<MockDemuxerStream>> stream( | 101 std::unique_ptr<StrictMock<MockDemuxerStream>> stream( |
102 new StrictMock<MockDemuxerStream>(type)); | 102 new StrictMock<MockDemuxerStream>(type)); |
103 return stream; | 103 return stream; |
104 } | 104 } |
105 | 105 |
106 void CreateAudioStream() { | 106 void CreateAudioStream() { |
107 audio_stream_ = CreateStream(DemuxerStream::AUDIO); | 107 audio_stream_ = CreateStream(DemuxerStream::AUDIO); |
108 EXPECT_CALL(demuxer_, GetStream(DemuxerStream::AUDIO)) | 108 streams_.push_back(audio_stream_.get()); |
109 .WillRepeatedly(Return(audio_stream_.get())); | 109 EXPECT_CALL(demuxer_, GetStreams()).WillRepeatedly(Return(streams_)); |
110 } | 110 } |
111 | 111 |
112 void CreateVideoStream(bool is_encrypted = false) { | 112 void CreateVideoStream(bool is_encrypted = false) { |
113 video_stream_ = CreateStream(DemuxerStream::VIDEO); | 113 video_stream_ = CreateStream(DemuxerStream::VIDEO); |
114 video_stream_->set_video_decoder_config( | 114 video_stream_->set_video_decoder_config( |
115 is_encrypted ? TestVideoConfig::NormalEncrypted() | 115 is_encrypted ? TestVideoConfig::NormalEncrypted() |
116 : TestVideoConfig::Normal()); | 116 : TestVideoConfig::Normal()); |
117 EXPECT_CALL(demuxer_, GetStream(DemuxerStream::VIDEO)) | 117 std::vector<DemuxerStream*> streams; |
118 .WillRepeatedly(Return(video_stream_.get())); | 118 streams_.push_back(audio_stream_.get()); |
| 119 EXPECT_CALL(demuxer_, GetStreams()).WillRepeatedly(Return(streams_)); |
119 } | 120 } |
120 | 121 |
121 void InitializeAndExpect(PipelineStatus status) { | 122 void InitializeAndExpect(PipelineStatus status) { |
122 DVLOG(1) << __func__ << ": " << status; | 123 DVLOG(1) << __func__ << ": " << status; |
123 EXPECT_CALL(*this, OnInitialized(status)); | 124 EXPECT_CALL(*this, OnInitialized(status)); |
124 mojo_renderer_->Initialize( | 125 mojo_renderer_->Initialize( |
125 &demuxer_, &renderer_client_, | 126 &demuxer_, &renderer_client_, |
126 base::Bind(&MojoRendererTest::OnInitialized, base::Unretained(this))); | 127 base::Bind(&MojoRendererTest::OnInitialized, base::Unretained(this))); |
127 base::RunLoop().RunUntilIdle(); | 128 base::RunLoop().RunUntilIdle(); |
128 } | 129 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 204 |
204 // Client side mocks and helpers. | 205 // Client side mocks and helpers. |
205 StrictMock<MockRendererClient> renderer_client_; | 206 StrictMock<MockRendererClient> renderer_client_; |
206 StrictMock<MockCdmContext> cdm_context_; | 207 StrictMock<MockCdmContext> cdm_context_; |
207 mojom::ContentDecryptionModulePtr remote_cdm_; | 208 mojom::ContentDecryptionModulePtr remote_cdm_; |
208 | 209 |
209 // Client side mock demuxer and demuxer streams. | 210 // Client side mock demuxer and demuxer streams. |
210 StrictMock<MockDemuxer> demuxer_; | 211 StrictMock<MockDemuxer> demuxer_; |
211 std::unique_ptr<StrictMock<MockDemuxerStream>> audio_stream_; | 212 std::unique_ptr<StrictMock<MockDemuxerStream>> audio_stream_; |
212 std::unique_ptr<StrictMock<MockDemuxerStream>> video_stream_; | 213 std::unique_ptr<StrictMock<MockDemuxerStream>> video_stream_; |
| 214 std::vector<DemuxerStream*> streams_; |
213 | 215 |
214 // Service side mocks and helpers. | 216 // Service side mocks and helpers. |
215 StrictMock<MockRenderer>* mock_renderer_; | 217 StrictMock<MockRenderer>* mock_renderer_; |
216 MojoCdmServiceContext mojo_cdm_service_context_; | 218 MojoCdmServiceContext mojo_cdm_service_context_; |
217 RendererClient* remote_renderer_client_; | 219 RendererClient* remote_renderer_client_; |
218 DefaultCdmFactory cdm_factory_; | 220 DefaultCdmFactory cdm_factory_; |
219 | 221 |
220 mojo::StrongBindingPtr<mojom::Renderer> renderer_binding_; | 222 mojo::StrongBindingPtr<mojom::Renderer> renderer_binding_; |
221 | 223 |
222 private: | 224 private: |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 Play(); | 461 Play(); |
460 remote_renderer_client_->OnError(PIPELINE_ERROR_DECODE); | 462 remote_renderer_client_->OnError(PIPELINE_ERROR_DECODE); |
461 base::RunLoop().RunUntilIdle(); | 463 base::RunLoop().RunUntilIdle(); |
462 | 464 |
463 EXPECT_CALL(*mock_renderer_, SetPlaybackRate(0.0)).Times(1); | 465 EXPECT_CALL(*mock_renderer_, SetPlaybackRate(0.0)).Times(1); |
464 mojo_renderer_->SetPlaybackRate(0.0); | 466 mojo_renderer_->SetPlaybackRate(0.0); |
465 Flush(); | 467 Flush(); |
466 } | 468 } |
467 | 469 |
468 } // namespace media | 470 } // namespace media |
OLD | NEW |