| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace media { | 31 namespace media { |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 #if defined(ENABLE_MOJO_CDM) | 34 #if defined(ENABLE_MOJO_CDM) |
| 35 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 35 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 36 const char kInvalidKeySystem[] = "invalid.key.system"; | 36 const char kInvalidKeySystem[] = "invalid.key.system"; |
| 37 #endif | 37 #endif |
| 38 const char kSecurityOrigin[] = "http://foo.com"; | 38 const char kSecurityOrigin[] = "http://foo.com"; |
| 39 | 39 |
| 40 class MockRendererClient : public interfaces::RendererClient { | 40 class MockRendererClient : public mojom::RendererClient { |
| 41 public: | 41 public: |
| 42 MockRendererClient(){}; | 42 MockRendererClient(){}; |
| 43 ~MockRendererClient() override{}; | 43 ~MockRendererClient() override{}; |
| 44 | 44 |
| 45 // interfaces::RendererClient implementation. | 45 // mojom::RendererClient implementation. |
| 46 MOCK_METHOD2(OnTimeUpdate, void(int64_t time_usec, int64_t max_time_usec)); | 46 MOCK_METHOD2(OnTimeUpdate, void(int64_t time_usec, int64_t max_time_usec)); |
| 47 MOCK_METHOD1(OnBufferingStateChange, void(interfaces::BufferingState state)); | 47 MOCK_METHOD1(OnBufferingStateChange, void(mojom::BufferingState state)); |
| 48 MOCK_METHOD0(OnEnded, void()); | 48 MOCK_METHOD0(OnEnded, void()); |
| 49 MOCK_METHOD0(OnError, void()); | 49 MOCK_METHOD0(OnError, void()); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(MockRendererClient); | 52 DISALLOW_COPY_AND_ASSIGN(MockRendererClient); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class MediaShellTest : public shell::test::ShellTest { | 55 class MediaShellTest : public shell::test::ShellTest { |
| 56 public: | 56 public: |
| 57 MediaShellTest() | 57 MediaShellTest() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 base::Bind(&MediaShellTest::ConnectionClosed, base::Unretained(this))); | 68 base::Bind(&MediaShellTest::ConnectionClosed, base::Unretained(this))); |
| 69 | 69 |
| 70 connection_->GetInterface(&service_factory_); | 70 connection_->GetInterface(&service_factory_); |
| 71 | 71 |
| 72 run_loop_.reset(new base::RunLoop()); | 72 run_loop_.reset(new base::RunLoop()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // MOCK_METHOD* doesn't support move only types. Work around this by having | 75 // MOCK_METHOD* doesn't support move only types. Work around this by having |
| 76 // an extra method. | 76 // an extra method. |
| 77 MOCK_METHOD2(OnCdmInitializedInternal, void(bool result, int cdm_id)); | 77 MOCK_METHOD2(OnCdmInitializedInternal, void(bool result, int cdm_id)); |
| 78 void OnCdmInitialized(interfaces::CdmPromiseResultPtr result, | 78 void OnCdmInitialized(mojom::CdmPromiseResultPtr result, |
| 79 int cdm_id, | 79 int cdm_id, |
| 80 interfaces::DecryptorPtr decryptor) { | 80 mojom::DecryptorPtr decryptor) { |
| 81 OnCdmInitializedInternal(result->success, cdm_id); | 81 OnCdmInitializedInternal(result->success, cdm_id); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void InitializeCdm(const std::string& key_system, | 84 void InitializeCdm(const std::string& key_system, |
| 85 bool expected_result, | 85 bool expected_result, |
| 86 int cdm_id) { | 86 int cdm_id) { |
| 87 service_factory_->CreateCdm(mojo::GetProxy(&cdm_)); | 87 service_factory_->CreateCdm(mojo::GetProxy(&cdm_)); |
| 88 | 88 |
| 89 EXPECT_CALL(*this, OnCdmInitializedInternal(expected_result, cdm_id)) | 89 EXPECT_CALL(*this, OnCdmInitializedInternal(expected_result, cdm_id)) |
| 90 .Times(Exactly(1)) | 90 .Times(Exactly(1)) |
| 91 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); | 91 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); |
| 92 cdm_->Initialize( | 92 cdm_->Initialize( |
| 93 key_system, kSecurityOrigin, interfaces::CdmConfig::From(CdmConfig()), | 93 key_system, kSecurityOrigin, mojom::CdmConfig::From(CdmConfig()), |
| 94 base::Bind(&MediaShellTest::OnCdmInitialized, base::Unretained(this))); | 94 base::Bind(&MediaShellTest::OnCdmInitialized, base::Unretained(this))); |
| 95 } | 95 } |
| 96 | 96 |
| 97 MOCK_METHOD1(OnRendererInitialized, void(bool)); | 97 MOCK_METHOD1(OnRendererInitialized, void(bool)); |
| 98 | 98 |
| 99 void InitializeRenderer(const VideoDecoderConfig& video_config, | 99 void InitializeRenderer(const VideoDecoderConfig& video_config, |
| 100 bool expected_result) { | 100 bool expected_result) { |
| 101 service_factory_->CreateRenderer(mojo::GetProxy(&renderer_)); | 101 service_factory_->CreateRenderer(mojo::GetProxy(&renderer_)); |
| 102 | 102 |
| 103 video_demuxer_stream_.set_video_decoder_config(video_config); | 103 video_demuxer_stream_.set_video_decoder_config(video_config); |
| 104 | 104 |
| 105 interfaces::DemuxerStreamPtr video_stream; | 105 mojom::DemuxerStreamPtr video_stream; |
| 106 new MojoDemuxerStreamImpl(&video_demuxer_stream_, GetProxy(&video_stream)); | 106 new MojoDemuxerStreamImpl(&video_demuxer_stream_, GetProxy(&video_stream)); |
| 107 | 107 |
| 108 EXPECT_CALL(*this, OnRendererInitialized(expected_result)) | 108 EXPECT_CALL(*this, OnRendererInitialized(expected_result)) |
| 109 .Times(Exactly(1)) | 109 .Times(Exactly(1)) |
| 110 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); | 110 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); |
| 111 renderer_->Initialize(renderer_client_binding_.CreateInterfacePtrAndBind(), | 111 renderer_->Initialize(renderer_client_binding_.CreateInterfacePtrAndBind(), |
| 112 nullptr, std::move(video_stream), | 112 nullptr, std::move(video_stream), |
| 113 base::Bind(&MediaShellTest::OnRendererInitialized, | 113 base::Bind(&MediaShellTest::OnRendererInitialized, |
| 114 base::Unretained(this))); | 114 base::Unretained(this))); |
| 115 } | 115 } |
| 116 | 116 |
| 117 MOCK_METHOD0(ConnectionClosed, void()); | 117 MOCK_METHOD0(ConnectionClosed, void()); |
| 118 | 118 |
| 119 protected: | 119 protected: |
| 120 std::unique_ptr<base::RunLoop> run_loop_; | 120 std::unique_ptr<base::RunLoop> run_loop_; |
| 121 | 121 |
| 122 interfaces::ServiceFactoryPtr service_factory_; | 122 mojom::ServiceFactoryPtr service_factory_; |
| 123 interfaces::ContentDecryptionModulePtr cdm_; | 123 mojom::ContentDecryptionModulePtr cdm_; |
| 124 interfaces::RendererPtr renderer_; | 124 mojom::RendererPtr renderer_; |
| 125 | 125 |
| 126 StrictMock<MockRendererClient> renderer_client_; | 126 StrictMock<MockRendererClient> renderer_client_; |
| 127 mojo::Binding<interfaces::RendererClient> renderer_client_binding_; | 127 mojo::Binding<mojom::RendererClient> renderer_client_binding_; |
| 128 | 128 |
| 129 StrictMock<MockDemuxerStream> video_demuxer_stream_; | 129 StrictMock<MockDemuxerStream> video_demuxer_stream_; |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 std::unique_ptr<shell::Connection> connection_; | 132 std::unique_ptr<shell::Connection> connection_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(MediaShellTest); | 134 DISALLOW_COPY_AND_ASSIGN(MediaShellTest); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace | 137 } // namespace |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // close the connection. | 179 // close the connection. |
| 180 EXPECT_CALL(*this, ConnectionClosed()) | 180 EXPECT_CALL(*this, ConnectionClosed()) |
| 181 .Times(Exactly(1)) | 181 .Times(Exactly(1)) |
| 182 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); | 182 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); |
| 183 service_factory_.reset(); | 183 service_factory_.reset(); |
| 184 | 184 |
| 185 run_loop_->Run(); | 185 run_loop_->Run(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace media | 188 } // namespace media |
| OLD | NEW |