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

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

Issue 1200323003: media: Quit MojoMediaApplication when no service is bound. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 5 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 | « no previous file | media/mojo/services/mojo_cdm_service.h » ('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/mock_filters.h" 10 #include "media/base/mock_filters.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 : media_renderer_client_binding_(&media_renderer_client_), 50 : media_renderer_client_binding_(&media_renderer_client_),
51 video_demuxer_stream_(DemuxerStream::VIDEO) {} 51 video_demuxer_stream_(DemuxerStream::VIDEO) {}
52 ~MediaAppTest() override {} 52 ~MediaAppTest() override {}
53 53
54 void SetUp() override { 54 void SetUp() override {
55 ApplicationTestBase::SetUp(); 55 ApplicationTestBase::SetUp();
56 56
57 mojo::URLRequestPtr request = mojo::URLRequest::New(); 57 mojo::URLRequestPtr request = mojo::URLRequest::New();
58 request->url = "mojo:media"; 58 request->url = "mojo:media";
59 mojo::ApplicationConnection* connection = 59 mojo::ApplicationConnection* connection =
60 application_impl()->ConnectToApplication(request.Pass()); 60 application_impl()->ConnectToApplication(
61 request.Pass(),
62 base::Bind(&MediaAppTest::OnAppTerminated, base::Unretained(this)));
61 63
62 connection->ConnectToService(&cdm_); 64 connection->ConnectToService(&cdm_);
63 connection->ConnectToService(&media_renderer_); 65 connection->ConnectToService(&media_renderer_);
64 66
65 run_loop_.reset(new base::RunLoop()); 67 run_loop_.reset(new base::RunLoop());
66 } 68 }
67 69
68 // MOCK_METHOD* doesn't support move only types. Work around this by having 70 // MOCK_METHOD* doesn't support move only types. Work around this by having
69 // an extra method. 71 // an extra method.
70 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result)); 72 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result));
(...skipping 22 matching lines...) Expand all
93 media_renderer_client_binding_.Bind(GetProxy(&client_ptr)); 95 media_renderer_client_binding_.Bind(GetProxy(&client_ptr));
94 96
95 EXPECT_CALL(*this, OnRendererInitialized()) 97 EXPECT_CALL(*this, OnRendererInitialized())
96 .Times(Exactly(1)) 98 .Times(Exactly(1))
97 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); 99 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit));
98 media_renderer_->Initialize(client_ptr.Pass(), nullptr, video_stream.Pass(), 100 media_renderer_->Initialize(client_ptr.Pass(), nullptr, video_stream.Pass(),
99 base::Bind(&MediaAppTest::OnRendererInitialized, 101 base::Bind(&MediaAppTest::OnRendererInitialized,
100 base::Unretained(this))); 102 base::Unretained(this)));
101 } 103 }
102 104
105 MOCK_METHOD0(OnAppTerminated, void());
106
103 protected: 107 protected:
104 scoped_ptr<base::RunLoop> run_loop_; 108 scoped_ptr<base::RunLoop> run_loop_;
105 109
106 mojo::ContentDecryptionModulePtr cdm_; 110 mojo::ContentDecryptionModulePtr cdm_;
107 mojo::MediaRendererPtr media_renderer_; 111 mojo::MediaRendererPtr media_renderer_;
108 112
109 StrictMock<MockMediaRendererClient> media_renderer_client_; 113 StrictMock<MockMediaRendererClient> media_renderer_client_;
110 mojo::Binding<mojo::MediaRendererClient> media_renderer_client_binding_; 114 mojo::Binding<mojo::MediaRendererClient> media_renderer_client_binding_;
111 115
112 StrictMock<MockDemuxerStream> video_demuxer_stream_; 116 StrictMock<MockDemuxerStream> video_demuxer_stream_;
(...skipping 21 matching lines...) Expand all
134 InitializeRenderer(TestVideoConfig::Normal()); 138 InitializeRenderer(TestVideoConfig::Normal());
135 run_loop_->Run(); 139 run_loop_->Run();
136 } 140 }
137 141
138 TEST_F(MediaAppTest, InitializeRenderer_InvalidConfig) { 142 TEST_F(MediaAppTest, InitializeRenderer_InvalidConfig) {
139 EXPECT_CALL(media_renderer_client_, OnError()); 143 EXPECT_CALL(media_renderer_client_, OnError());
140 InitializeRenderer(TestVideoConfig::Invalid()); 144 InitializeRenderer(TestVideoConfig::Invalid());
141 run_loop_->Run(); 145 run_loop_->Run();
142 } 146 }
143 147
148 TEST_F(MediaAppTest, Lifetime) {
149 // Disconnect one service doesn't terminate the app.
150 cdm_.reset();
151
152 // Disconnect all services should terminate the app.
153 EXPECT_CALL(*this, OnAppTerminated())
154 .Times(Exactly(1))
155 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit));
156 media_renderer_.reset();
157
158 run_loop_->Run();
159 }
160
144 } // namespace media 161 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/mojo/services/mojo_cdm_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698