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/mock_filters.h" | 11 #include "media/base/mock_filters.h" |
11 #include "media/base/test_helpers.h" | 12 #include "media/base/test_helpers.h" |
12 #include "media/cdm/key_system_names.h" | 13 #include "media/cdm/key_system_names.h" |
13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 14 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
14 #include "media/mojo/interfaces/media_renderer.mojom.h" | 15 #include "media/mojo/interfaces/media_renderer.mojom.h" |
| 16 #include "media/mojo/services/media_type_converters.h" |
15 #include "media/mojo/services/mojo_demuxer_stream_impl.h" | 17 #include "media/mojo/services/mojo_demuxer_stream_impl.h" |
16 #include "mojo/application/public/cpp/application_connection.h" | 18 #include "mojo/application/public/cpp/application_connection.h" |
17 #include "mojo/application/public/cpp/application_impl.h" | 19 #include "mojo/application/public/cpp/application_impl.h" |
18 #include "mojo/application/public/cpp/application_test_base.h" | 20 #include "mojo/application/public/cpp/application_test_base.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
20 | 22 |
21 using testing::Exactly; | 23 using testing::Exactly; |
22 using testing::Invoke; | 24 using testing::Invoke; |
23 using testing::InvokeWithoutArgs; | 25 using testing::InvokeWithoutArgs; |
24 using testing::StrictMock; | 26 using testing::StrictMock; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result)); | 72 MOCK_METHOD1(OnCdmInitializedInternal, void(bool result)); |
71 void OnCdmInitialized(mojo::CdmPromiseResultPtr result) { | 73 void OnCdmInitialized(mojo::CdmPromiseResultPtr result) { |
72 OnCdmInitializedInternal(result->success); | 74 OnCdmInitializedInternal(result->success); |
73 } | 75 } |
74 | 76 |
75 void InitializeCdm(const std::string& key_system, bool expected_result) { | 77 void InitializeCdm(const std::string& key_system, bool expected_result) { |
76 EXPECT_CALL(*this, OnCdmInitializedInternal(expected_result)) | 78 EXPECT_CALL(*this, OnCdmInitializedInternal(expected_result)) |
77 .Times(Exactly(1)) | 79 .Times(Exactly(1)) |
78 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); | 80 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); |
79 cdm_->Initialize( | 81 cdm_->Initialize( |
80 key_system, kSecurityOrigin, 1, | 82 key_system, kSecurityOrigin, mojo::CdmConfig::From(CdmConfig()), 1, |
81 base::Bind(&MediaAppTest::OnCdmInitialized, base::Unretained(this))); | 83 base::Bind(&MediaAppTest::OnCdmInitialized, base::Unretained(this))); |
82 } | 84 } |
83 | 85 |
84 MOCK_METHOD0(OnRendererInitialized, void()); | 86 MOCK_METHOD0(OnRendererInitialized, void()); |
85 | 87 |
86 void InitializeRenderer(const VideoDecoderConfig& video_config) { | 88 void InitializeRenderer(const VideoDecoderConfig& video_config) { |
87 video_demuxer_stream_.set_video_decoder_config(video_config); | 89 video_demuxer_stream_.set_video_decoder_config(video_config); |
88 | 90 |
89 mojo::DemuxerStreamPtr video_stream; | 91 mojo::DemuxerStreamPtr video_stream; |
90 new MojoDemuxerStreamImpl(&video_demuxer_stream_, GetProxy(&video_stream)); | 92 new MojoDemuxerStreamImpl(&video_demuxer_stream_, GetProxy(&video_stream)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 run_loop_->Run(); | 137 run_loop_->Run(); |
136 } | 138 } |
137 | 139 |
138 TEST_F(MediaAppTest, InitializeRenderer_InvalidConfig) { | 140 TEST_F(MediaAppTest, InitializeRenderer_InvalidConfig) { |
139 EXPECT_CALL(media_renderer_client_, OnError()); | 141 EXPECT_CALL(media_renderer_client_, OnError()); |
140 InitializeRenderer(TestVideoConfig::Invalid()); | 142 InitializeRenderer(TestVideoConfig::Invalid()); |
141 run_loop_->Run(); | 143 run_loop_->Run(); |
142 } | 144 } |
143 | 145 |
144 } // namespace media | 146 } // namespace media |
OLD | NEW |