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

Side by Side Diff: media/mojo/services/media_mojo_unittest.cc

Issue 2358413002: media: Use associated interface for mojo RendererClient (Closed)
Patch Set: more test update Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "media/base/cdm_config.h" 14 #include "media/base/cdm_config.h"
15 #include "media/base/mock_filters.h" 15 #include "media/base/mock_filters.h"
16 #include "media/base/test_helpers.h" 16 #include "media/base/test_helpers.h"
17 #include "media/mojo/clients/mojo_demuxer_stream_impl.h" 17 #include "media/mojo/clients/mojo_demuxer_stream_impl.h"
18 #include "media/mojo/common/media_type_converters.h" 18 #include "media/mojo/common/media_type_converters.h"
19 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 19 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
20 #include "media/mojo/interfaces/decryptor.mojom.h" 20 #include "media/mojo/interfaces/decryptor.mojom.h"
21 #include "media/mojo/interfaces/renderer.mojom.h" 21 #include "media/mojo/interfaces/renderer.mojom.h"
22 #include "media/mojo/interfaces/service_factory.mojom.h" 22 #include "media/mojo/interfaces/service_factory.mojom.h"
23 #include "mojo/public/cpp/bindings/associated_binding.h"
23 #include "services/shell/public/cpp/service_test.h" 24 #include "services/shell/public/cpp/service_test.h"
24 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
25 26
26 using testing::Exactly; 27 using testing::Exactly;
27 using testing::Invoke; 28 using testing::Invoke;
28 using testing::InvokeWithoutArgs; 29 using testing::InvokeWithoutArgs;
29 using testing::StrictMock; 30 using testing::StrictMock;
30 31
31 namespace media { 32 namespace media {
32 namespace { 33 namespace {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void InitializeRenderer(const VideoDecoderConfig& video_config, 110 void InitializeRenderer(const VideoDecoderConfig& video_config,
110 bool expected_result) { 111 bool expected_result) {
111 service_factory_->CreateRenderer(std::string(), mojo::GetProxy(&renderer_)); 112 service_factory_->CreateRenderer(std::string(), mojo::GetProxy(&renderer_));
112 113
113 video_stream_.set_video_decoder_config(video_config); 114 video_stream_.set_video_decoder_config(video_config);
114 115
115 mojom::DemuxerStreamPtr video_stream_proxy; 116 mojom::DemuxerStreamPtr video_stream_proxy;
116 mojo_video_stream_.reset(new MojoDemuxerStreamImpl( 117 mojo_video_stream_.reset(new MojoDemuxerStreamImpl(
117 &video_stream_, GetProxy(&video_stream_proxy))); 118 &video_stream_, GetProxy(&video_stream_proxy)));
118 119
120 mojom::RendererClientAssociatedPtrInfo client_ptr_info;
121 renderer_client_binding_.Bind(&client_ptr_info,
122 renderer_.associated_group());
123
119 EXPECT_CALL(*this, OnRendererInitialized(expected_result)) 124 EXPECT_CALL(*this, OnRendererInitialized(expected_result))
120 .Times(Exactly(1)) 125 .Times(Exactly(1))
121 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); 126 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit));
122 renderer_->Initialize(renderer_client_binding_.CreateInterfacePtrAndBind(), 127 renderer_->Initialize(std::move(client_ptr_info), nullptr,
123 nullptr, std::move(video_stream_proxy), base::nullopt, 128 std::move(video_stream_proxy), base::nullopt,
124 base::Bind(&MediaServiceTest::OnRendererInitialized, 129 base::Bind(&MediaServiceTest::OnRendererInitialized,
125 base::Unretained(this))); 130 base::Unretained(this)));
126 } 131 }
127 132
128 MOCK_METHOD0(ConnectionClosed, void()); 133 MOCK_METHOD0(ConnectionClosed, void());
129 134
130 protected: 135 protected:
131 std::unique_ptr<base::RunLoop> run_loop_; 136 std::unique_ptr<base::RunLoop> run_loop_;
132 137
133 mojom::ServiceFactoryPtr service_factory_; 138 mojom::ServiceFactoryPtr service_factory_;
134 mojom::ContentDecryptionModulePtr cdm_; 139 mojom::ContentDecryptionModulePtr cdm_;
135 mojom::RendererPtr renderer_; 140 mojom::RendererPtr renderer_;
136 141
137 StrictMock<MockRendererClient> renderer_client_; 142 StrictMock<MockRendererClient> renderer_client_;
138 mojo::Binding<mojom::RendererClient> renderer_client_binding_; 143 mojo::AssociatedBinding<mojom::RendererClient> renderer_client_binding_;
139 144
140 StrictMock<MockDemuxerStream> video_stream_; 145 StrictMock<MockDemuxerStream> video_stream_;
141 std::unique_ptr<MojoDemuxerStreamImpl> mojo_video_stream_; 146 std::unique_ptr<MojoDemuxerStreamImpl> mojo_video_stream_;
142 147
143 private: 148 private:
144 std::unique_ptr<shell::Connection> connection_; 149 std::unique_ptr<shell::Connection> connection_;
145 150
146 DISALLOW_COPY_AND_ASSIGN(MediaServiceTest); 151 DISALLOW_COPY_AND_ASSIGN(MediaServiceTest);
147 }; 152 };
148 153
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // close the connection. 196 // close the connection.
192 EXPECT_CALL(*this, ConnectionClosed()) 197 EXPECT_CALL(*this, ConnectionClosed())
193 .Times(Exactly(1)) 198 .Times(Exactly(1))
194 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); 199 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit));
195 service_factory_.reset(); 200 service_factory_.reset();
196 201
197 run_loop_->Run(); 202 run_loop_->Run();
198 } 203 }
199 204
200 } // namespace media 205 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698