Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: media/mojo/clients/mojo_renderer_unittest.cc

Issue 2491043003: MediaResource refactoring to support multiple streams (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 std::vector<DemuxerStream*> empty;
81 EXPECT_CALL(demuxer_, GetStreams()).WillRepeatedly(Return(empty));
81 82
82 EXPECT_CALL(*mock_renderer_, GetMediaTime()) 83 EXPECT_CALL(*mock_renderer_, GetMediaTime())
83 .WillRepeatedly(Return(base::TimeDelta())); 84 .WillRepeatedly(Return(base::TimeDelta()));
84 } 85 }
85 86
86 virtual ~MojoRendererTest() {} 87 virtual ~MojoRendererTest() {}
87 88
88 void Destroy() { 89 void Destroy() {
89 mojo_renderer_.reset(); 90 mojo_renderer_.reset();
90 base::RunLoop().RunUntilIdle(); 91 base::RunLoop().RunUntilIdle();
91 } 92 }
92 93
93 // Completion callbacks. 94 // Completion callbacks.
94 MOCK_METHOD1(OnInitialized, void(PipelineStatus)); 95 MOCK_METHOD1(OnInitialized, void(PipelineStatus));
95 MOCK_METHOD0(OnFlushed, void()); 96 MOCK_METHOD0(OnFlushed, void());
96 MOCK_METHOD1(OnCdmAttached, void(bool)); 97 MOCK_METHOD1(OnCdmAttached, void(bool));
97 MOCK_METHOD1(OnSurfaceRequestToken, void(const base::UnguessableToken&)); 98 MOCK_METHOD1(OnSurfaceRequestToken, void(const base::UnguessableToken&));
98 99
99 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream( 100 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream(
100 DemuxerStream::Type type) { 101 DemuxerStream::Type type) {
101 std::unique_ptr<StrictMock<MockDemuxerStream>> stream( 102 std::unique_ptr<StrictMock<MockDemuxerStream>> stream(
102 new StrictMock<MockDemuxerStream>(type)); 103 new StrictMock<MockDemuxerStream>(type));
103 return stream; 104 return stream;
104 } 105 }
105 106
106 void CreateAudioStream() { 107 void CreateAudioStream() {
107 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 108 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
108 EXPECT_CALL(demuxer_, GetStream(DemuxerStream::AUDIO)) 109 std::vector<DemuxerStream*> streams;
109 .WillRepeatedly(Return(audio_stream_.get())); 110 streams.push_back(audio_stream_.get());
111 if (video_stream_)
112 streams.push_back(video_stream_.get());
113 EXPECT_CALL(demuxer_, GetStreams()).WillRepeatedly(Return(streams));
xhwang 2017/02/01 18:26:04 It's odd that CreateAudioStream() needs to worry a
servolk 2017/02/01 22:29:17 Done.
110 } 114 }
111 115
112 void CreateVideoStream(bool is_encrypted = false) { 116 void CreateVideoStream(bool is_encrypted = false) {
113 video_stream_ = CreateStream(DemuxerStream::VIDEO); 117 video_stream_ = CreateStream(DemuxerStream::VIDEO);
114 video_stream_->set_video_decoder_config( 118 video_stream_->set_video_decoder_config(
115 is_encrypted ? TestVideoConfig::NormalEncrypted() 119 is_encrypted ? TestVideoConfig::NormalEncrypted()
116 : TestVideoConfig::Normal()); 120 : TestVideoConfig::Normal());
117 EXPECT_CALL(demuxer_, GetStream(DemuxerStream::VIDEO)) 121 std::vector<DemuxerStream*> streams;
118 .WillRepeatedly(Return(video_stream_.get())); 122 if (audio_stream_)
xhwang 2017/02/01 18:26:04 ditto
servolk 2017/02/01 22:29:17 Done.
123 streams.push_back(audio_stream_.get());
124 streams.push_back(video_stream_.get());
125 EXPECT_CALL(demuxer_, GetStreams()).WillRepeatedly(Return(streams));
119 } 126 }
120 127
121 void InitializeAndExpect(PipelineStatus status) { 128 void InitializeAndExpect(PipelineStatus status) {
122 DVLOG(1) << __func__ << ": " << status; 129 DVLOG(1) << __func__ << ": " << status;
123 EXPECT_CALL(*this, OnInitialized(status)); 130 EXPECT_CALL(*this, OnInitialized(status));
124 mojo_renderer_->Initialize( 131 mojo_renderer_->Initialize(
125 &demuxer_, &renderer_client_, 132 &demuxer_, &renderer_client_,
126 base::Bind(&MojoRendererTest::OnInitialized, base::Unretained(this))); 133 base::Bind(&MojoRendererTest::OnInitialized, base::Unretained(this)));
127 base::RunLoop().RunUntilIdle(); 134 base::RunLoop().RunUntilIdle();
128 } 135 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 Play(); 466 Play();
460 remote_renderer_client_->OnError(PIPELINE_ERROR_DECODE); 467 remote_renderer_client_->OnError(PIPELINE_ERROR_DECODE);
461 base::RunLoop().RunUntilIdle(); 468 base::RunLoop().RunUntilIdle();
462 469
463 EXPECT_CALL(*mock_renderer_, SetPlaybackRate(0.0)).Times(1); 470 EXPECT_CALL(*mock_renderer_, SetPlaybackRate(0.0)).Times(1);
464 mojo_renderer_->SetPlaybackRate(0.0); 471 mojo_renderer_->SetPlaybackRate(0.0);
465 Flush(); 472 Flush();
466 } 473 }
467 474
468 } // namespace media 475 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698