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

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

Issue 1254383016: ApplicationConnection lifetime management changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 4 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 | « mandoline/ui/browser/desktop/desktop_ui.cc ('k') | mojo/application/public/cpp/BUILD.gn » ('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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "media/base/cdm_config.h" 10 #include "media/base/cdm_config.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 MediaAppTest() 52 MediaAppTest()
53 : renderer_client_binding_(&renderer_client_), 53 : renderer_client_binding_(&renderer_client_),
54 video_demuxer_stream_(DemuxerStream::VIDEO) {} 54 video_demuxer_stream_(DemuxerStream::VIDEO) {}
55 ~MediaAppTest() override {} 55 ~MediaAppTest() override {}
56 56
57 void SetUp() override { 57 void SetUp() override {
58 ApplicationTestBase::SetUp(); 58 ApplicationTestBase::SetUp();
59 59
60 mojo::URLRequestPtr request = mojo::URLRequest::New(); 60 mojo::URLRequestPtr request = mojo::URLRequest::New();
61 request->url = "mojo:media"; 61 request->url = "mojo:media";
62 mojo::ApplicationConnection* connection = 62 connection_ = application_impl()->ConnectToApplication(request.Pass());
63 application_impl()->ConnectToApplication(request.Pass()); 63 connection_->SetRemoteServiceProviderConnectionErrorHandler(
64 connection->SetRemoteServiceProviderConnectionErrorHandler(
65 base::Bind(&MediaAppTest::ConnectionClosed, base::Unretained(this))); 64 base::Bind(&MediaAppTest::ConnectionClosed, base::Unretained(this)));
66 65
67 connection->ConnectToService(&service_factory_); 66 connection_->ConnectToService(&service_factory_);
68 service_factory_->CreateCdm(mojo::GetProxy(&cdm_)); 67 service_factory_->CreateCdm(mojo::GetProxy(&cdm_));
69 service_factory_->CreateRenderer(mojo::GetProxy(&renderer_)); 68 service_factory_->CreateRenderer(mojo::GetProxy(&renderer_));
70 69
71 run_loop_.reset(new base::RunLoop()); 70 run_loop_.reset(new base::RunLoop());
72 } 71 }
73 72
74 // MOCK_METHOD* doesn't support move only types. Work around this by having 73 // MOCK_METHOD* doesn't support move only types. Work around this by having
75 // an extra method. 74 // an extra method.
76 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result)); 75 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result));
77 void OnCdmInitialized(interfaces::CdmPromiseResultPtr result) { 76 void OnCdmInitialized(interfaces::CdmPromiseResultPtr result) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 interfaces::ServiceFactoryPtr service_factory_; 114 interfaces::ServiceFactoryPtr service_factory_;
116 interfaces::ContentDecryptionModulePtr cdm_; 115 interfaces::ContentDecryptionModulePtr cdm_;
117 interfaces::RendererPtr renderer_; 116 interfaces::RendererPtr renderer_;
118 117
119 StrictMock<MockRendererClient> renderer_client_; 118 StrictMock<MockRendererClient> renderer_client_;
120 mojo::Binding<interfaces::RendererClient> renderer_client_binding_; 119 mojo::Binding<interfaces::RendererClient> renderer_client_binding_;
121 120
122 StrictMock<MockDemuxerStream> video_demuxer_stream_; 121 StrictMock<MockDemuxerStream> video_demuxer_stream_;
123 122
124 private: 123 private:
124 scoped_ptr<mojo::ApplicationConnection> connection_;
125
125 DISALLOW_COPY_AND_ASSIGN(MediaAppTest); 126 DISALLOW_COPY_AND_ASSIGN(MediaAppTest);
126 }; 127 };
127 128
128 } // namespace 129 } // namespace
129 130
130 // Note: base::RunLoop::RunUntilIdle() does not work well in these tests because 131 // Note: base::RunLoop::RunUntilIdle() does not work well in these tests because
131 // even when the loop is idle, we may still have pending events in the pipe. 132 // even when the loop is idle, we may still have pending events in the pipe.
132 133
133 TEST_F(MediaAppTest, InitializeCdm_Success) { 134 TEST_F(MediaAppTest, InitializeCdm_Success) {
134 InitializeCdm(kClearKey, true); 135 InitializeCdm(kClearKey, true);
(...skipping 24 matching lines...) Expand all
159 // close the connection. 160 // close the connection.
160 EXPECT_CALL(*this, ConnectionClosed()) 161 EXPECT_CALL(*this, ConnectionClosed())
161 .Times(Exactly(1)) 162 .Times(Exactly(1))
162 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); 163 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit));
163 service_factory_.reset(); 164 service_factory_.reset();
164 165
165 run_loop_->Run(); 166 run_loop_->Run();
166 } 167 }
167 168
168 } // namespace media 169 } // namespace media
OLDNEW
« no previous file with comments | « mandoline/ui/browser/desktop/desktop_ui.cc ('k') | mojo/application/public/cpp/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698