OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/test/test_message_loop.h" | 11 #include "base/test/test_message_loop.h" |
12 #include "media/base/cdm_config.h" | 12 #include "media/base/cdm_config.h" |
| 13 #include "media/base/content_decryption_module.h" |
13 #include "media/base/mock_filters.h" | 14 #include "media/base/mock_filters.h" |
14 #include "media/cdm/default_cdm_factory.h" | 15 #include "media/cdm/default_cdm_factory.h" |
15 #include "media/mojo/clients/mojo_cdm.h" | 16 #include "media/mojo/clients/mojo_cdm.h" |
16 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 17 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
17 #include "media/mojo/services/mojo_cdm_service.h" | 18 #include "media/mojo/services/mojo_cdm_service.h" |
18 #include "media/mojo/services/mojo_cdm_service_context.h" | 19 #include "media/mojo/services/mojo_cdm_service_context.h" |
19 #include "mojo/public/cpp/bindings/interface_request.h" | 20 #include "mojo/public/cpp/bindings/interface_request.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 using ::testing::StrictMock; | 23 using ::testing::StrictMock; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 base::RunLoop().RunUntilIdle(); | 72 base::RunLoop().RunUntilIdle(); |
72 | 73 |
73 if (expected_result == SUCCESS) { | 74 if (expected_result == SUCCESS) { |
74 EXPECT_TRUE(mojo_cdm_); | 75 EXPECT_TRUE(mojo_cdm_); |
75 } else { | 76 } else { |
76 EXPECT_FALSE(mojo_cdm_); | 77 EXPECT_FALSE(mojo_cdm_); |
77 } | 78 } |
78 } | 79 } |
79 | 80 |
80 void OnCdmCreated(ExpectedResult expected_result, | 81 void OnCdmCreated(ExpectedResult expected_result, |
81 const scoped_refptr<MediaKeys>& cdm, | 82 const scoped_refptr<ContentDecryptionModule>& cdm, |
82 const std::string& error_message) { | 83 const std::string& error_message) { |
83 if (!cdm) { | 84 if (!cdm) { |
84 DVLOG(1) << error_message; | 85 DVLOG(1) << error_message; |
85 return; | 86 return; |
86 } | 87 } |
87 | 88 |
88 EXPECT_EQ(SUCCESS, expected_result); | 89 EXPECT_EQ(SUCCESS, expected_result); |
89 mojo_cdm_ = cdm; | 90 mojo_cdm_ = cdm; |
90 } | 91 } |
91 | 92 |
92 // Fixture members. | 93 // Fixture members. |
93 base::TestMessageLoop message_loop_; | 94 base::TestMessageLoop message_loop_; |
94 | 95 |
95 MojoCdmServiceContext mojo_cdm_service_context_; | 96 MojoCdmServiceContext mojo_cdm_service_context_; |
96 StrictMock<MockCdmClient> cdm_client_; | 97 StrictMock<MockCdmClient> cdm_client_; |
97 | 98 |
98 // TODO(jrummell): Use a MockCdmFactory to create a MockCdm here for more test | 99 // TODO(jrummell): Use a MockCdmFactory to create a MockCdm here for more test |
99 // coverage. | 100 // coverage. |
100 DefaultCdmFactory cdm_factory_; | 101 DefaultCdmFactory cdm_factory_; |
101 | 102 |
102 std::unique_ptr<MojoCdmService> mojo_cdm_service_; | 103 std::unique_ptr<MojoCdmService> mojo_cdm_service_; |
103 mojo::Binding<mojom::ContentDecryptionModule> cdm_binding_; | 104 mojo::Binding<mojom::ContentDecryptionModule> cdm_binding_; |
104 scoped_refptr<MediaKeys> mojo_cdm_; | 105 scoped_refptr<ContentDecryptionModule> mojo_cdm_; |
105 | 106 |
106 private: | 107 private: |
107 DISALLOW_COPY_AND_ASSIGN(MojoCdmTest); | 108 DISALLOW_COPY_AND_ASSIGN(MojoCdmTest); |
108 }; | 109 }; |
109 | 110 |
110 TEST_F(MojoCdmTest, Create_Success) { | 111 TEST_F(MojoCdmTest, Create_Success) { |
111 Initialize(SUCCESS); | 112 Initialize(SUCCESS); |
112 } | 113 } |
113 | 114 |
114 TEST_F(MojoCdmTest, Create_ConnectionError) { | 115 TEST_F(MojoCdmTest, Create_ConnectionError) { |
115 Initialize(CONNECTION_ERROR); | 116 Initialize(CONNECTION_ERROR); |
116 } | 117 } |
117 | 118 |
118 // TODO(xhwang): Add more test cases! | 119 // TODO(xhwang): Add more test cases! |
119 | 120 |
120 } // namespace media | 121 } // namespace media |
OLD | NEW |