| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |