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

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

Issue 2804373002: Eliminate Connector::Connect(), Connection, etc. (Closed)
Patch Set: . Created 3 years, 8 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
« no previous file with comments | « media/mojo/services/media_service.cc ('k') | services/catalog/catalog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 public: 70 public:
71 MediaServiceTest() 71 MediaServiceTest()
72 : ServiceTest("media_service_unittests"), 72 : ServiceTest("media_service_unittests"),
73 renderer_client_binding_(&renderer_client_), 73 renderer_client_binding_(&renderer_client_),
74 video_stream_(DemuxerStream::VIDEO) {} 74 video_stream_(DemuxerStream::VIDEO) {}
75 ~MediaServiceTest() override {} 75 ~MediaServiceTest() override {}
76 76
77 void SetUp() override { 77 void SetUp() override {
78 ServiceTest::SetUp(); 78 ServiceTest::SetUp();
79 79
80 connection_ = connector()->Connect("media");
81 media::mojom::MediaServicePtr media_service; 80 media::mojom::MediaServicePtr media_service;
82 connection_->GetInterface(&media_service); 81 connector()->BindInterface("media", &media_service);
83 82
84 auto registry = 83 auto registry =
85 base::MakeUnique<service_manager::InterfaceRegistry>(std::string()); 84 base::MakeUnique<service_manager::InterfaceRegistry>(std::string());
86 service_manager::mojom::InterfaceProviderPtr interfaces; 85 service_manager::mojom::InterfaceProviderPtr interfaces;
87 registry->Bind(MakeRequest(&interfaces), service_manager::Identity(), 86 registry->Bind(MakeRequest(&interfaces), service_manager::Identity(),
88 service_manager::InterfaceProviderSpec(), 87 service_manager::InterfaceProviderSpec(),
89 service_manager::Identity(), 88 service_manager::Identity(),
90 service_manager::InterfaceProviderSpec()); 89 service_manager::InterfaceProviderSpec());
91 90
92 media_service->CreateInterfaceFactory( 91 media_service->CreateInterfaceFactory(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 streams.push_back(std::move(video_stream_proxy)); 140 streams.push_back(std::move(video_stream_proxy));
142 renderer_->Initialize(std::move(client_ptr_info), std::move(streams), 141 renderer_->Initialize(std::move(client_ptr_info), std::move(streams),
143 base::nullopt, base::nullopt, 142 base::nullopt, base::nullopt,
144 base::Bind(&MediaServiceTest::OnRendererInitialized, 143 base::Bind(&MediaServiceTest::OnRendererInitialized,
145 base::Unretained(this))); 144 base::Unretained(this)));
146 } 145 }
147 146
148 MOCK_METHOD0(ConnectionClosed, void()); 147 MOCK_METHOD0(ConnectionClosed, void());
149 148
150 protected: 149 protected:
151 std::unique_ptr<service_manager::Connection> connection_;
152 std::unique_ptr<base::RunLoop> run_loop_; 150 std::unique_ptr<base::RunLoop> run_loop_;
153 151
154 mojom::InterfaceFactoryPtr interface_factory_; 152 mojom::InterfaceFactoryPtr interface_factory_;
155 mojom::ContentDecryptionModulePtr cdm_; 153 mojom::ContentDecryptionModulePtr cdm_;
156 mojom::RendererPtr renderer_; 154 mojom::RendererPtr renderer_;
157 155
158 StrictMock<MockRendererClient> renderer_client_; 156 StrictMock<MockRendererClient> renderer_client_;
159 mojo::AssociatedBinding<mojom::RendererClient> renderer_client_binding_; 157 mojo::AssociatedBinding<mojom::RendererClient> renderer_client_binding_;
160 158
161 StrictMock<MockDemuxerStream> video_stream_; 159 StrictMock<MockDemuxerStream> video_stream_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 run_loop_->Run(); 193 run_loop_->Run();
196 } 194 }
197 195
198 TEST_F(MediaServiceTest, InitializeRenderer_InvalidConfig) { 196 TEST_F(MediaServiceTest, InitializeRenderer_InvalidConfig) {
199 InitializeRenderer(TestVideoConfig::Invalid(), false); 197 InitializeRenderer(TestVideoConfig::Invalid(), false);
200 run_loop_->Run(); 198 run_loop_->Run();
201 } 199 }
202 #endif // defined(ENABLE_MOJO_RENDERER) 200 #endif // defined(ENABLE_MOJO_RENDERER)
203 201
204 TEST_F(MediaServiceTest, Lifetime) { 202 TEST_F(MediaServiceTest, Lifetime) {
205 connection_->SetConnectionLostClosure( 203 // The lifetime of the media service is controlled by the number of
204 // live InterfaceFactory impls, not MediaService impls, so this pipe should
205 // be closed when the last InterfaceFactory is destroyed.
206 media::mojom::MediaServicePtr media_service;
207 connector()->BindInterface("media", &media_service);
208 media_service.set_connection_error_handler(
206 base::Bind(&MediaServiceTest::ConnectionClosed, base::Unretained(this))); 209 base::Bind(&MediaServiceTest::ConnectionClosed, base::Unretained(this)));
207 210
208 // Disconnecting CDM and Renderer services doesn't terminate the app. 211 // Disconnecting CDM and Renderer services doesn't terminate the app.
209 cdm_.reset(); 212 cdm_.reset();
210 renderer_.reset(); 213 renderer_.reset();
211 214
212 // Disconnecting InterfaceFactory service should terminate the app, which will 215 // Disconnecting InterfaceFactory service should terminate the app, which will
213 // close the connection. 216 // close the connection.
214 EXPECT_CALL(*this, ConnectionClosed()) 217 EXPECT_CALL(*this, ConnectionClosed())
215 .Times(Exactly(1)) 218 .Times(Exactly(1))
216 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); 219 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit));
217 interface_factory_.reset(); 220 interface_factory_.reset();
218 221
219 run_loop_->Run(); 222 run_loop_->Run();
220 } 223 }
221 224
222 } // namespace media 225 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/media_service.cc ('k') | services/catalog/catalog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698