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

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

Issue 1230313010: media: Add ServiceFactory mojo interface and implementation. (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 | « media/mojo/services/BUILD.gn ('k') | media/mojo/services/mojo_cdm_factory.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/cdm_config.h" 10 #include "media/base/cdm_config.h"
11 #include "media/base/mock_filters.h" 11 #include "media/base/mock_filters.h"
12 #include "media/base/test_helpers.h" 12 #include "media/base/test_helpers.h"
13 #include "media/cdm/key_system_names.h" 13 #include "media/cdm/key_system_names.h"
14 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 14 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
15 #include "media/mojo/interfaces/media_renderer.mojom.h" 15 #include "media/mojo/interfaces/media_renderer.mojom.h"
16 #include "media/mojo/interfaces/service_factory.mojom.h"
16 #include "media/mojo/services/media_type_converters.h" 17 #include "media/mojo/services/media_type_converters.h"
17 #include "media/mojo/services/mojo_demuxer_stream_impl.h" 18 #include "media/mojo/services/mojo_demuxer_stream_impl.h"
18 #include "mojo/application/public/cpp/application_connection.h" 19 #include "mojo/application/public/cpp/application_connection.h"
19 #include "mojo/application/public/cpp/application_impl.h" 20 #include "mojo/application/public/cpp/application_impl.h"
20 #include "mojo/application/public/cpp/application_test_base.h" 21 #include "mojo/application/public/cpp/application_test_base.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
22 23
23 using testing::Exactly; 24 using testing::Exactly;
24 using testing::Invoke; 25 using testing::Invoke;
25 using testing::InvokeWithoutArgs; 26 using testing::InvokeWithoutArgs;
(...skipping 28 matching lines...) Expand all
54 ~MediaAppTest() override {} 55 ~MediaAppTest() override {}
55 56
56 void SetUp() override { 57 void SetUp() override {
57 ApplicationTestBase::SetUp(); 58 ApplicationTestBase::SetUp();
58 59
59 mojo::URLRequestPtr request = mojo::URLRequest::New(); 60 mojo::URLRequestPtr request = mojo::URLRequest::New();
60 request->url = "mojo:media"; 61 request->url = "mojo:media";
61 mojo::ApplicationConnection* connection = 62 mojo::ApplicationConnection* connection =
62 application_impl()->ConnectToApplication(request.Pass()); 63 application_impl()->ConnectToApplication(request.Pass());
63 64
64 connection->ConnectToService(&cdm_); 65 connection->ConnectToService(&service_factory_);
65 connection->ConnectToService(&media_renderer_); 66 service_factory_->CreateCdm(mojo::GetProxy(&cdm_));
67 service_factory_->CreateRenderer(mojo::GetProxy(&media_renderer_));
66 68
67 run_loop_.reset(new base::RunLoop()); 69 run_loop_.reset(new base::RunLoop());
68 } 70 }
69 71
70 // MOCK_METHOD* doesn't support move only types. Work around this by having 72 // MOCK_METHOD* doesn't support move only types. Work around this by having
71 // an extra method. 73 // an extra method.
72 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result)); 74 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result));
73 void OnCdmInitialized(interfaces::CdmPromiseResultPtr result) { 75 void OnCdmInitialized(interfaces::CdmPromiseResultPtr result) {
74 OnCdmInitializedInternal(result->success); 76 OnCdmInitializedInternal(result->success);
75 } 77 }
(...skipping 23 matching lines...) Expand all
99 .Times(Exactly(1)) 101 .Times(Exactly(1))
100 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); 102 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit));
101 media_renderer_->Initialize(client_ptr.Pass(), nullptr, video_stream.Pass(), 103 media_renderer_->Initialize(client_ptr.Pass(), nullptr, video_stream.Pass(),
102 base::Bind(&MediaAppTest::OnRendererInitialized, 104 base::Bind(&MediaAppTest::OnRendererInitialized,
103 base::Unretained(this))); 105 base::Unretained(this)));
104 } 106 }
105 107
106 protected: 108 protected:
107 scoped_ptr<base::RunLoop> run_loop_; 109 scoped_ptr<base::RunLoop> run_loop_;
108 110
111 interfaces::ServiceFactoryPtr service_factory_;
109 interfaces::ContentDecryptionModulePtr cdm_; 112 interfaces::ContentDecryptionModulePtr cdm_;
110 interfaces::MediaRendererPtr media_renderer_; 113 interfaces::MediaRendererPtr media_renderer_;
111 114
112 StrictMock<MockMediaRendererClient> media_renderer_client_; 115 StrictMock<MockMediaRendererClient> media_renderer_client_;
113 mojo::Binding<interfaces::MediaRendererClient> media_renderer_client_binding_; 116 mojo::Binding<interfaces::MediaRendererClient> media_renderer_client_binding_;
114 117
115 StrictMock<MockDemuxerStream> video_demuxer_stream_; 118 StrictMock<MockDemuxerStream> video_demuxer_stream_;
116 119
117 private: 120 private:
118 DISALLOW_COPY_AND_ASSIGN(MediaAppTest); 121 DISALLOW_COPY_AND_ASSIGN(MediaAppTest);
(...skipping 18 matching lines...) Expand all
137 InitializeRenderer(TestVideoConfig::Normal(), true); 140 InitializeRenderer(TestVideoConfig::Normal(), true);
138 run_loop_->Run(); 141 run_loop_->Run();
139 } 142 }
140 143
141 TEST_F(MediaAppTest, InitializeRenderer_InvalidConfig) { 144 TEST_F(MediaAppTest, InitializeRenderer_InvalidConfig) {
142 InitializeRenderer(TestVideoConfig::Invalid(), false); 145 InitializeRenderer(TestVideoConfig::Invalid(), false);
143 run_loop_->Run(); 146 run_loop_->Run();
144 } 147 }
145 148
146 } // namespace media 149 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/BUILD.gn ('k') | media/mojo/services/mojo_cdm_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698