| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "media/base/cdm_config.h" | 14 #include "media/base/cdm_config.h" |
| 15 #include "media/base/mock_filters.h" | 15 #include "media/base/mock_filters.h" |
| 16 #include "media/base/test_helpers.h" | 16 #include "media/base/test_helpers.h" |
| 17 #include "media/cdm/key_system_names.h" | |
| 18 #include "media/mojo/common/media_type_converters.h" | 17 #include "media/mojo/common/media_type_converters.h" |
| 19 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 18 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
| 20 #include "media/mojo/interfaces/decryptor.mojom.h" | 19 #include "media/mojo/interfaces/decryptor.mojom.h" |
| 21 #include "media/mojo/interfaces/renderer.mojom.h" | 20 #include "media/mojo/interfaces/renderer.mojom.h" |
| 22 #include "media/mojo/interfaces/service_factory.mojom.h" | 21 #include "media/mojo/interfaces/service_factory.mojom.h" |
| 23 #include "media/mojo/services/mojo_demuxer_stream_impl.h" | 22 #include "media/mojo/services/mojo_demuxer_stream_impl.h" |
| 24 #include "services/shell/public/cpp/application_test_base.h" | 23 #include "services/shell/public/cpp/application_test_base.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 26 | 25 |
| 27 using testing::Exactly; | 26 using testing::Exactly; |
| 28 using testing::Invoke; | 27 using testing::Invoke; |
| 29 using testing::InvokeWithoutArgs; | 28 using testing::InvokeWithoutArgs; |
| 30 using testing::StrictMock; | 29 using testing::StrictMock; |
| 31 | 30 |
| 32 namespace media { | 31 namespace media { |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 #if defined(ENABLE_MOJO_CDM) | 34 #if defined(ENABLE_MOJO_CDM) |
| 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 interfaces::RendererClient { |
| 41 public: | 41 public: |
| 42 MockRendererClient(){}; | 42 MockRendererClient(){}; |
| 43 ~MockRendererClient() override{}; | 43 ~MockRendererClient() override{}; |
| 44 | 44 |
| 45 // interfaces::RendererClient implementation. | 45 // interfaces::RendererClient implementation. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 DISALLOW_COPY_AND_ASSIGN(MediaAppTest); | 133 DISALLOW_COPY_AND_ASSIGN(MediaAppTest); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace | 136 } // namespace |
| 137 | 137 |
| 138 // Note: base::RunLoop::RunUntilIdle() does not work well in these tests because | 138 // Note: base::RunLoop::RunUntilIdle() does not work well in these tests because |
| 139 // even when the loop is idle, we may still have pending events in the pipe. | 139 // even when the loop is idle, we may still have pending events in the pipe. |
| 140 | 140 |
| 141 #if defined(ENABLE_MOJO_CDM) | 141 #if defined(ENABLE_MOJO_CDM) |
| 142 TEST_F(MediaAppTest, InitializeCdm_Success) { | 142 TEST_F(MediaAppTest, InitializeCdm_Success) { |
| 143 InitializeCdm(kClearKey, true, 1); | 143 InitializeCdm(kClearKeyKeySystem, true, 1); |
| 144 run_loop_->Run(); | 144 run_loop_->Run(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 TEST_F(MediaAppTest, InitializeCdm_InvalidKeySystem) { | 147 TEST_F(MediaAppTest, InitializeCdm_InvalidKeySystem) { |
| 148 InitializeCdm(kInvalidKeySystem, false, 0); | 148 InitializeCdm(kInvalidKeySystem, false, 0); |
| 149 run_loop_->Run(); | 149 run_loop_->Run(); |
| 150 } | 150 } |
| 151 #endif // defined(ENABLE_MOJO_CDM) | 151 #endif // defined(ENABLE_MOJO_CDM) |
| 152 | 152 |
| 153 #if defined(ENABLE_MOJO_RENDERER) | 153 #if defined(ENABLE_MOJO_RENDERER) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 178 // close the connection. | 178 // close the connection. |
| 179 EXPECT_CALL(*this, ConnectionClosed()) | 179 EXPECT_CALL(*this, ConnectionClosed()) |
| 180 .Times(Exactly(1)) | 180 .Times(Exactly(1)) |
| 181 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); | 181 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); |
| 182 service_factory_.reset(); | 182 service_factory_.reset(); |
| 183 | 183 |
| 184 run_loop_->Run(); | 184 run_loop_->Run(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace media | 187 } // namespace media |
| OLD | NEW |