OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "content/public/common/content_client.h" | 8 #include "content/public/common/content_client.h" |
9 #include "content/public/renderer/content_renderer_client.h" | 9 #include "content/public/renderer/content_renderer_client.h" |
| 10 #include "content/public/renderer/key_system_info.h" |
10 #include "content/renderer/media/crypto/key_systems.h" | 11 #include "content/renderer/media/crypto/key_systems.h" |
11 #include "content/test/test_content_client.h" | 12 #include "content/test/test_content_client.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
14 | 15 |
15 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 16 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
16 | 17 |
17 // Death tests are not always available, including on Android. | 18 // Death tests are not always available, including on Android. |
18 // EXPECT_DEBUG_DEATH_PORTABLE executes tests correctly except in the case that | 19 // EXPECT_DEBUG_DEATH_PORTABLE executes tests correctly except in the case that |
19 // death tests are not available and NDEBUG is not defined. | 20 // death tests are not available and NDEBUG is not defined. |
20 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 21 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
21 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ | 22 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ |
22 EXPECT_DEBUG_DEATH(statement, regex) | 23 EXPECT_DEBUG_DEATH(statement, regex) |
23 #else | 24 #else |
24 #if defined(NDEBUG) | 25 #if defined(NDEBUG) |
25 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ | 26 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ |
26 do { statement; } while (false) | 27 do { statement; } while (false) |
27 #else | 28 #else |
28 #include "base/logging.h" | 29 #include "base/logging.h" |
29 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ | 30 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ |
30 LOG(WARNING) << "Death tests are not supported on this platform.\n" \ | 31 LOG(WARNING) << "Death tests are not supported on this platform.\n" \ |
31 << "Statement '" #statement "' cannot be verified."; | 32 << "Statement '" #statement "' cannot be verified."; |
32 #endif // defined(NDEBUG) | 33 #endif // defined(NDEBUG) |
33 #endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 34 #endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
34 | 35 |
35 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | |
36 defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
37 #include <gnu/libc-version.h> | |
38 #endif | |
39 | |
40 using WebKit::WebString; | 36 using WebKit::WebString; |
41 | 37 |
42 #if defined(USE_PROPRIETARY_CODECS) | 38 // These are the (fake) key systems that are registered for these tests. |
43 #define EXPECT_PROPRIETARY EXPECT_TRUE | 39 // kUsesAes uses the AesDecryptor like Clear Key. |
44 #else | 40 // kExternal uses an external CDM, such as Pepper-based or Android platform CDM. |
45 #define EXPECT_PROPRIETARY EXPECT_FALSE | 41 static const char kUsesAes[] = "org.example.clear"; |
46 #endif | 42 static const char kUsesAesParent[] = "org.example"; // Not registered. |
| 43 static const char kExternal[] = "com.example.test"; |
| 44 static const char kExternalParent[] = "com.example"; |
47 | 45 |
48 // Expectations for External Clear Key. | 46 static const char kPrefixedClearKey[] = "webkit-org.w3.clearkey"; |
49 #if defined(ENABLE_PEPPER_CDMS) | 47 static const char kUnprefixedClearKey[] = "org.w3.clearkey"; |
50 #define EXPECT_ECK EXPECT_TRUE | 48 static const char kExternalClearKey[] = "org.chromium.externalclearkey"; |
51 #define EXPECT_ECKPROPRIETARY EXPECT_PROPRIETARY | |
52 #else | |
53 #define EXPECT_ECK EXPECT_FALSE | |
54 #define EXPECT_ECKPROPRIETARY EXPECT_FALSE | |
55 #endif // defined(ENABLE_PEPPER_CDMS) | |
56 | 49 |
57 // Expectations for Widevine. | 50 static const char kAudioWebM[] = "audio/webm"; |
58 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | 51 static const char kVideoWebM[] = "video/webm"; |
59 !defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) // See http://crbug.com/237627 | 52 static const char kWebMAudioCodecs[] = "vorbis"; |
60 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 53 static const char kWebMVideoCodecs[] = "vorbis,vp8,vp8.0"; |
61 // TODO(ddorwin): Remove after bots switch to Precise. | |
62 #define EXPECT_WV(a) \ | |
63 EXPECT_EQ((std::string(gnu_get_libc_version()) != "2.11.1"), (a)) | |
64 #else | |
65 #define EXPECT_WV EXPECT_TRUE | |
66 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
67 | 54 |
68 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 55 static const char kAudioFoo[] = "audio/foo"; |
69 | 56 static const char kVideoFoo[] = "video/foo"; |
70 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | 57 static const char kFooAudioCodecs[] = "fooaudio"; |
71 #define EXPECT_WVAVC1 EXPECT_TRUE | 58 static const char kFooVideoCodecs[] = "fooaudio,foovideo"; |
72 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | |
73 #define EXPECT_WVAVC1AAC EXPECT_TRUE | |
74 #else | |
75 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
76 #endif // defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | |
77 #else // !defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | |
78 #define EXPECT_WVAVC1 EXPECT_FALSE | |
79 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
80 #endif // defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | |
81 | |
82 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | |
83 #define EXPECT_WVAAC EXPECT_TRUE | |
84 #else | |
85 #define EXPECT_WVAAC EXPECT_FALSE | |
86 #endif | |
87 | |
88 #else // !defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
89 #define EXPECT_WVAVC1 EXPECT_FALSE | |
90 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
91 #define EXPECT_WVAAC EXPECT_FALSE | |
92 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
93 | |
94 #else // defined(WIDEVINE_CDM_AVAILABLE) && | |
95 // !defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
96 #define EXPECT_WV EXPECT_FALSE | |
97 #define EXPECT_WVAVC1 EXPECT_FALSE | |
98 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
99 #define EXPECT_WVAAC EXPECT_FALSE | |
100 #endif // defined(WIDEVINE_CDM_AVAILABLE) && | |
101 // !defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
102 | 59 |
103 namespace content { | 60 namespace content { |
104 | 61 |
105 static const char* const kClearKey = "webkit-org.w3.clearkey"; | 62 // Helper functions that handle the WebString conversion to simplify tests. |
106 static const char* const kExternalClearKey = "org.chromium.externalclearkey"; | 63 static std::string KeySystemNameForUMAUTF8(const std::string& key_system) { |
107 static const char* const kWidevine = "com.widevine"; | 64 return KeySystemNameForUMA(WebString::fromUTF8(key_system)); |
108 static const char* const kWidevineAlpha = "com.widevine.alpha"; | 65 } |
| 66 |
| 67 static bool IsConcreteSupportedKeySystemUTF8(const std::string& key_system) { |
| 68 return IsConcreteSupportedKeySystem(WebString::fromUTF8(key_system)); |
| 69 } |
| 70 |
| 71 class TestContentRendererClient : public ContentRendererClient { |
| 72 virtual void AddKeySystems( |
| 73 std::vector<content::KeySystemInfo>* key_systems) OVERRIDE; |
| 74 }; |
| 75 |
| 76 void TestContentRendererClient::AddKeySystems( |
| 77 std::vector<content::KeySystemInfo>* key_systems) { |
| 78 #if defined(OS_ANDROID) |
| 79 static const uint8 kExternalUuid[16] = { |
| 80 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, |
| 81 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }; |
| 82 #endif |
| 83 |
| 84 KeySystemInfo aes(kUsesAes); |
| 85 |
| 86 aes.supported_types.push_back(std::make_pair(kAudioWebM, kWebMAudioCodecs)); |
| 87 aes.supported_types.push_back(std::make_pair(kVideoWebM, kWebMVideoCodecs)); |
| 88 |
| 89 aes.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); |
| 90 aes.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); |
| 91 |
| 92 aes.use_aes_decryptor = true; |
| 93 |
| 94 key_systems->push_back(aes); |
| 95 |
| 96 KeySystemInfo ext(kExternal); |
| 97 |
| 98 ext.supported_types.push_back(std::make_pair(kAudioWebM, kWebMAudioCodecs)); |
| 99 ext.supported_types.push_back(std::make_pair(kVideoWebM, kWebMVideoCodecs)); |
| 100 |
| 101 ext.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); |
| 102 ext.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); |
| 103 |
| 104 ext.parent_key_system = kExternalParent; |
| 105 |
| 106 #if defined(ENABLE_PEPPER_CDMS) |
| 107 ext.pepper_type = "application/x-ppapi-external-cdm"; |
| 108 #elif defined(OS_ANDROID) |
| 109 ext.uuid.assign(kExternalUuid, kExternalUuid + arraysize(kExternalUuid)); |
| 110 #endif // defined(ENABLE_PEPPER_CDMS) |
| 111 |
| 112 key_systems->push_back(ext); |
| 113 } |
109 | 114 |
110 class KeySystemsTest : public testing::Test { | 115 class KeySystemsTest : public testing::Test { |
111 protected: | 116 protected: |
112 KeySystemsTest() { | 117 KeySystemsTest() { |
113 vp8_codec_.push_back("vp8"); | 118 vp8_codec_.push_back("vp8"); |
114 | 119 |
115 vp80_codec_.push_back("vp8.0"); | 120 vp80_codec_.push_back("vp8.0"); |
116 | 121 |
117 vorbis_codec_.push_back("vorbis"); | 122 vorbis_codec_.push_back("vorbis"); |
118 | 123 |
119 vp8_and_vorbis_codecs_.push_back("vp8"); | 124 vp8_and_vorbis_codecs_.push_back("vp8"); |
120 vp8_and_vorbis_codecs_.push_back("vorbis"); | 125 vp8_and_vorbis_codecs_.push_back("vorbis"); |
121 | 126 |
122 avc1_codec_.push_back("avc1"); | 127 foovideo_codec_.push_back("foovideo"); |
123 | 128 |
124 avc1_extended_codec_.push_back("avc1.4D400C"); | 129 foovideo_extended_codec_.push_back("foovideo.4D400C"); |
125 | 130 |
126 avc1_dot_codec_.push_back("avc1."); | 131 foovideo_dot_codec_.push_back("foovideo."); |
127 | 132 |
128 avc2_codec_.push_back("avc2"); | 133 fooaudio_codec_.push_back("fooaudio"); |
129 | 134 |
130 aac_codec_.push_back("mp4a"); | 135 foovideo_and_fooaudio_codecs_.push_back("foovideo"); |
| 136 foovideo_and_fooaudio_codecs_.push_back("fooaudio"); |
131 | 137 |
132 avc1_and_aac_codecs_.push_back("avc1"); | 138 unknown_codec_.push_back("unknown"); |
133 avc1_and_aac_codecs_.push_back("mp4a"); | |
134 | |
135 unknown_codec_.push_back("foo"); | |
136 | 139 |
137 mixed_codecs_.push_back("vorbis"); | 140 mixed_codecs_.push_back("vorbis"); |
138 mixed_codecs_.push_back("avc1"); | 141 mixed_codecs_.push_back("foovideo"); |
139 | 142 |
140 // KeySystems requires a valid ContentRendererClient and thus ContentClient. | 143 // KeySystems requires a valid ContentRendererClient and thus ContentClient. |
141 // The TestContentClient is not available inside Death Tests on some | 144 // The TestContentClient is not available inside Death Tests on some |
142 // platforms (see below). Therefore, always provide a TestContentClient. | 145 // platforms (see below). Therefore, always provide a TestContentClient. |
143 // Explanation: When Death Tests fork, there is a valid ContentClient. | 146 // Explanation: When Death Tests fork, there is a valid ContentClient. |
144 // However, when they launch a new process instead of forking, the global | 147 // However, when they launch a new process instead of forking, the global |
145 // variable is not copied and for some reason TestContentClientInitializer | 148 // variable is not copied and for some reason TestContentClientInitializer |
146 // does not get created to set the global variable in the new process. | 149 // does not get created to set the global variable in the new process. |
147 SetContentClient(&test_content_client_); | 150 SetContentClient(&test_content_client_); |
148 SetRendererClientForTesting(&content_renderer_client_); | 151 SetRendererClientForTesting(&content_renderer_client_); |
149 } | 152 } |
150 | 153 |
151 virtual ~KeySystemsTest() { | 154 virtual ~KeySystemsTest() { |
152 // Clear the use of content_client_, which was set in SetUp(). | 155 // Clear the use of content_client_, which was set in SetUp(). |
153 SetContentClient(NULL); | 156 SetContentClient(NULL); |
154 } | 157 } |
155 | 158 |
156 typedef std::vector<std::string> CodecVector; | 159 typedef std::vector<std::string> CodecVector; |
157 | 160 |
158 const CodecVector& no_codecs() const { return no_codecs_; } | 161 const CodecVector& no_codecs() const { return no_codecs_; } |
159 | 162 |
160 const CodecVector& vp8_codec() const { return vp8_codec_; } | 163 const CodecVector& vp8_codec() const { return vp8_codec_; } |
161 const CodecVector& vp80_codec() const { return vp80_codec_; } | 164 const CodecVector& vp80_codec() const { return vp80_codec_; } |
162 const CodecVector& vorbis_codec() const { return vorbis_codec_; } | 165 const CodecVector& vorbis_codec() const { return vorbis_codec_; } |
163 const CodecVector& vp8_and_vorbis_codecs() const { | 166 const CodecVector& vp8_and_vorbis_codecs() const { |
164 return vp8_and_vorbis_codecs_; | 167 return vp8_and_vorbis_codecs_; |
165 } | 168 } |
166 | 169 |
167 const CodecVector& avc1_codec() const { return avc1_codec_; } | 170 const CodecVector& foovideo_codec() const { return foovideo_codec_; } |
168 const CodecVector& avc1_extended_codec() const { | 171 const CodecVector& foovideo_extended_codec() const { |
169 return avc1_extended_codec_; | 172 return foovideo_extended_codec_; |
170 } | 173 } |
171 const CodecVector& avc1_dot_codec() const { return avc1_dot_codec_; } | 174 const CodecVector& foovideo_dot_codec() const { return foovideo_dot_codec_; } |
172 const CodecVector& avc2_codec() const { return avc2_codec_; } | 175 const CodecVector& fooaudio_codec() const { return fooaudio_codec_; } |
173 const CodecVector& aac_codec() const { return aac_codec_; } | 176 const CodecVector& foovideo_and_fooaudio_codecs() const { |
174 const CodecVector& avc1_and_aac_codecs() const { | 177 return foovideo_and_fooaudio_codecs_; |
175 return avc1_and_aac_codecs_; | |
176 } | 178 } |
177 | 179 |
178 const CodecVector& unknown_codec() const { return unknown_codec_; } | 180 const CodecVector& unknown_codec() const { return unknown_codec_; } |
179 | 181 |
180 const CodecVector& mixed_codecs() const { return mixed_codecs_; } | 182 const CodecVector& mixed_codecs() const { return mixed_codecs_; } |
181 | 183 |
182 private: | 184 private: |
183 const CodecVector no_codecs_; | 185 const CodecVector no_codecs_; |
184 | 186 |
185 CodecVector vp8_codec_; | 187 CodecVector vp8_codec_; |
186 CodecVector vp80_codec_; | 188 CodecVector vp80_codec_; |
187 CodecVector vorbis_codec_; | 189 CodecVector vorbis_codec_; |
188 CodecVector vp8_and_vorbis_codecs_; | 190 CodecVector vp8_and_vorbis_codecs_; |
189 | 191 |
190 CodecVector avc1_codec_; | 192 CodecVector foovideo_codec_; |
191 CodecVector avc1_extended_codec_; | 193 CodecVector foovideo_extended_codec_; |
192 CodecVector avc1_dot_codec_; | 194 CodecVector foovideo_dot_codec_; |
193 CodecVector avc2_codec_; | 195 CodecVector fooaudio_codec_; |
194 CodecVector aac_codec_; | 196 CodecVector foovideo_and_fooaudio_codecs_; |
195 CodecVector avc1_and_aac_codecs_; | |
196 | 197 |
197 CodecVector unknown_codec_; | 198 CodecVector unknown_codec_; |
198 | 199 |
199 CodecVector mixed_codecs_; | 200 CodecVector mixed_codecs_; |
200 | 201 |
201 TestContentClient test_content_client_; | 202 TestContentClient test_content_client_; |
202 ContentRendererClient content_renderer_client_; | 203 TestContentRendererClient content_renderer_client_; |
203 }; | 204 }; |
204 | 205 |
205 TEST_F(KeySystemsTest, ClearKey_Basic) { | 206 // TODO(ddorwin): Consider moving GetUUID() into these tests or moving |
206 EXPECT_TRUE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKey))); | 207 // GetPepperType() calls out to their own test. |
207 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 208 |
208 "video/webm", no_codecs(), kClearKey)); | 209 TEST_F(KeySystemsTest, ClearKeyNotRegistered) { |
| 210 // Not registered in content. |
| 211 EXPECT_FALSE(IsConcreteSupportedKeySystemUTF8(kPrefixedClearKey)); |
| 212 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 213 kVideoWebM, no_codecs(), kPrefixedClearKey)); |
| 214 |
| 215 EXPECT_EQ("ClearKey", KeySystemNameForUMAUTF8(kPrefixedClearKey)); |
209 | 216 |
210 // Not yet out from behind the vendor prefix. | 217 // Not yet out from behind the vendor prefix. |
211 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.w3.clearkey")); | 218 EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey)); |
212 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 219 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
213 "video/webm", no_codecs(), "org.w3.clearkey")); | 220 kVideoWebM, no_codecs(), kUnprefixedClearKey)); |
214 | 221 EXPECT_EQ("Unknown", KeySystemNameForUMAUTF8(kUnprefixedClearKey)); |
215 EXPECT_STREQ("ClearKey", | 222 } |
216 KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str()); | 223 |
217 | 224 // The key system is not registered and therefore is unrecognized. |
218 EXPECT_TRUE(CanUseAesDecryptor(kClearKey)); | 225 TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) { |
| 226 static const char* const kUnrecognized = "org.example.unrecognized"; |
| 227 |
| 228 EXPECT_FALSE(IsConcreteSupportedKeySystemUTF8(kUnrecognized)); |
| 229 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 230 kVideoWebM, no_codecs(), kUnrecognized)); |
| 231 |
| 232 EXPECT_EQ("Unknown", KeySystemNameForUMAUTF8(kUnrecognized)); |
| 233 |
| 234 bool can_use = false; |
| 235 EXPECT_DEBUG_DEATH_PORTABLE( |
| 236 can_use = CanUseAesDecryptor(kUnrecognized), |
| 237 "org.example.unrecognized is not a known concrete system"); |
| 238 EXPECT_FALSE(can_use); |
| 239 |
219 #if defined(ENABLE_PEPPER_CDMS) | 240 #if defined(ENABLE_PEPPER_CDMS) |
220 std::string type; | 241 std::string type; |
221 EXPECT_DEBUG_DEATH(type = GetPepperType(kClearKey), | 242 EXPECT_DEBUG_DEATH(type = GetPepperType(kUnrecognized), |
222 "webkit-org.w3.clearkey is not Pepper-based"); | 243 "org.example.unrecognized is not a known concrete system"); |
223 EXPECT_TRUE(type.empty()); | 244 EXPECT_TRUE(type.empty()); |
224 #endif | 245 #endif |
225 } | 246 } |
226 | 247 |
227 TEST_F(KeySystemsTest, ClearKey_Parent) { | 248 TEST_F(KeySystemsTest, Basic_UsesAesDecryptor) { |
228 const char* const kClearKeyParent = "webkit-org.w3"; | 249 EXPECT_TRUE(IsConcreteSupportedKeySystemUTF8(kUsesAes)); |
229 | 250 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
230 // The parent should be supported but is not. See http://crbug.com/164303. | 251 kVideoWebM, no_codecs(), kUsesAes)); |
231 EXPECT_FALSE( | 252 |
232 IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKeyParent))); | 253 // No UMA value for this test key system. |
233 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 254 EXPECT_EQ("Unknown", KeySystemNameForUMAUTF8(kUsesAes)); |
234 "video/webm", no_codecs(), kClearKeyParent)); | 255 |
| 256 EXPECT_TRUE(CanUseAesDecryptor(kUsesAes)); |
| 257 #if defined(ENABLE_PEPPER_CDMS) |
| 258 std::string type; |
| 259 EXPECT_DEBUG_DEATH(type = GetPepperType(kUsesAes), |
| 260 "org.example.clear is not Pepper-based"); |
| 261 EXPECT_TRUE(type.empty()); |
| 262 #endif |
| 263 } |
| 264 |
| 265 TEST_F(KeySystemsTest, |
| 266 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) { |
| 267 // Valid video types. |
| 268 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 269 kVideoWebM, vp8_codec(), kUsesAes)); |
| 270 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 271 kVideoWebM, vp80_codec(), kUsesAes)); |
| 272 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 273 kVideoWebM, vp8_and_vorbis_codecs(), kUsesAes)); |
| 274 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 275 kVideoWebM, vorbis_codec(), kUsesAes)); |
| 276 |
| 277 // Non-Webm codecs. |
| 278 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 279 kVideoWebM, foovideo_codec(), kUsesAes)); |
| 280 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 281 kVideoWebM, unknown_codec(), kUsesAes)); |
| 282 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 283 kVideoWebM, mixed_codecs(), kUsesAes)); |
| 284 |
| 285 // Valid audio types. |
| 286 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 287 kAudioWebM, no_codecs(), kUsesAes)); |
| 288 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 289 kAudioWebM, vorbis_codec(), kUsesAes)); |
| 290 |
| 291 // Non-audio codecs. |
| 292 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 293 kAudioWebM, vp8_codec(), kUsesAes)); |
| 294 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 295 kAudioWebM, vp8_and_vorbis_codecs(), kUsesAes)); |
| 296 |
| 297 // Non-Webm codec. |
| 298 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 299 kAudioWebM, fooaudio_codec(), kUsesAes)); |
| 300 } |
| 301 |
| 302 // No parent is registered for Clear. |
| 303 TEST_F(KeySystemsTest, Parent_NoParentRegistered) { |
| 304 EXPECT_FALSE(IsConcreteSupportedKeySystemUTF8(kUsesAesParent)); |
| 305 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 306 kVideoWebM, no_codecs(), kUsesAesParent)); |
235 | 307 |
236 // The parent is not supported for most things. | 308 // The parent is not supported for most things. |
237 EXPECT_STREQ("Unknown", | 309 EXPECT_EQ("Unknown", KeySystemNameForUMAUTF8(kUsesAesParent)); |
238 KeySystemNameForUMA(WebString::fromUTF8(kClearKeyParent)).c_str()); | |
239 bool result = false; | 310 bool result = false; |
240 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kClearKeyParent), | 311 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kUsesAesParent), |
241 "webkit-org.w3 is not a known concrete system"); | 312 "org.example is not a known concrete system"); |
242 EXPECT_FALSE(result); | 313 EXPECT_FALSE(result); |
243 #if defined(ENABLE_PEPPER_CDMS) | 314 #if defined(ENABLE_PEPPER_CDMS) |
244 std::string type; | 315 std::string type; |
245 EXPECT_DEBUG_DEATH(type = GetPepperType(kClearKeyParent), | 316 EXPECT_DEBUG_DEATH(type = GetPepperType(kUsesAesParent), |
246 "webkit-org.w3 is not a known concrete system"); | 317 "org.example is not a known concrete system"); |
247 EXPECT_TRUE(type.empty()); | 318 EXPECT_TRUE(type.empty()); |
248 #endif | 319 #endif |
249 } | 320 } |
250 | 321 |
251 TEST_F(KeySystemsTest, ClearKey_IsSupportedKeySystem_InvalidVariants) { | 322 TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) { |
252 // Case sensitive. | 323 // Case sensitive. |
253 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.ClEaRkEy")); | 324 EXPECT_FALSE(IsConcreteSupportedKeySystemUTF8("org.example.ClEaR")); |
254 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 325 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
255 "video/webm", no_codecs(), "webkit-org.w3.ClEaRkEy")); | 326 kVideoWebM, no_codecs(), "org.example.ClEaR")); |
256 | 327 |
257 // TLDs are not allowed. | 328 // TLDs are not allowed. |
258 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.")); | |
259 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
260 "video/webm", no_codecs(), "webkit-org.")); | |
261 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org")); | |
262 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
263 "video/webm", no_codecs(), "webkit-org")); | |
264 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); | 329 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); |
265 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 330 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
266 "video/webm", no_codecs(), "org.")); | 331 kVideoWebM, no_codecs(), "org.")); |
267 EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); | 332 EXPECT_FALSE(IsConcreteSupportedKeySystem("com")); |
268 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 333 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
269 "video/webm", no_codecs(), "org")); | 334 kVideoWebM, no_codecs(), "com")); |
270 | 335 |
271 // Extra period. | 336 // Extra period. |
272 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.")); | 337 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.")); |
273 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 338 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
274 "video/webm", no_codecs(), "webkit-org.w3.")); | 339 kVideoWebM, no_codecs(), "org.example.")); |
275 | 340 |
276 // Incomplete. | 341 // Incomplete. |
277 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearke")); | 342 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clea")); |
278 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 343 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
279 "video/webm", no_codecs(), "webkit-org.w3.clearke")); | 344 kVideoWebM, no_codecs(), "org.example.clea")); |
280 | 345 |
281 // Extra character. | 346 // Extra character. |
282 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkeyz")); | 347 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clearz")); |
283 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 348 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
284 "video/webm", no_codecs(), "webkit-org.w3.clearkeyz")); | 349 kVideoWebM, no_codecs(), "org.example.clearz")); |
285 | 350 |
286 // There are no child key systems for Clear Key. | 351 // There are no child key systems for Clear Key. |
287 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkey.foo")); | 352 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clear.foo")); |
288 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 353 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
289 "video/webm", no_codecs(), "webkit-org.w3.clearkey.foo")); | 354 kVideoWebM, no_codecs(), "org.example.clear.foo")); |
290 } | 355 } |
291 | 356 |
292 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_NoType) { | 357 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { |
293 // These two should be true. See http://crbug.com/164303. | 358 // These two should be true. See http://crbug.com/164303. |
294 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 359 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
295 std::string(), no_codecs(), kClearKey)); | 360 std::string(), no_codecs(), kUsesAes)); |
296 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 361 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
297 std::string(), no_codecs(), "webkit-org.w3")); | 362 std::string(), no_codecs(), kUsesAesParent)); |
298 | 363 |
299 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 364 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
300 std::string(), no_codecs(), "webkit-org.w3.foo")); | 365 std::string(), no_codecs(), "org.example.foo")); |
301 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 366 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
302 std::string(), no_codecs(), "webkit-org.w3.clearkey.foo")); | 367 std::string(), no_codecs(), "org.example.clear.foo")); |
303 } | 368 } |
304 | 369 |
305 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_WebM) { | 370 // Tests the second registered container type. |
| 371 // TODO(ddorwin): Combined with TypesContainer1 in a future CL. |
| 372 TEST_F(KeySystemsTest, |
| 373 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer2) { |
306 // Valid video types. | 374 // Valid video types. |
307 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 375 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
308 "video/webm", no_codecs(), kClearKey)); | 376 kVideoFoo, no_codecs(), kUsesAes)); |
309 // The parent should be supported but is not. See http://crbug.com/164303. | 377 // The parent should be supported but is not. See http://crbug.com/164303. |
310 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 378 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
311 "video/webm", no_codecs(), "webkit-org.w3")); | 379 kVideoFoo, no_codecs(), kUsesAesParent)); |
312 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 380 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
313 "video/webm", vp8_codec(), kClearKey)); | 381 kVideoFoo, foovideo_codec(), kUsesAes)); |
314 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 382 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
315 "video/webm", vp80_codec(), kClearKey)); | 383 kVideoFoo, foovideo_and_fooaudio_codecs(), kUsesAes)); |
316 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 384 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
317 "video/webm", vp8_and_vorbis_codecs(), kClearKey)); | 385 kVideoFoo, fooaudio_codec(), kUsesAes)); |
318 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
319 "video/webm", vorbis_codec(), kClearKey)); | |
320 | |
321 // Non-Webm codecs. | |
322 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
323 "video/webm", avc1_codec(), kClearKey)); | |
324 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
325 "video/webm", unknown_codec(), kClearKey)); | |
326 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
327 "video/webm", mixed_codecs(), kClearKey)); | |
328 | |
329 // Valid audio types. | |
330 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
331 "audio/webm", no_codecs(), kClearKey)); | |
332 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
333 "audio/webm", vorbis_codec(), kClearKey)); | |
334 | |
335 // Non-audio codecs. | |
336 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
337 "audio/webm", vp8_codec(), kClearKey)); | |
338 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
339 "audio/webm", vp8_and_vorbis_codecs(), kClearKey)); | |
340 | |
341 // Non-Webm codec. | |
342 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
343 "audio/webm", aac_codec(), kClearKey)); | |
344 } | |
345 | |
346 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_MP4) { | |
347 // Valid video types. | |
348 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
349 "video/mp4", no_codecs(), kClearKey)); | |
350 // The parent should be supported but is not. See http://crbug.com/164303. | |
351 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
352 "video/mp4", no_codecs(), "webkit-org.w3")); | |
353 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
354 "video/mp4", avc1_codec(), kClearKey)); | |
355 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
356 "video/mp4", avc1_and_aac_codecs(), kClearKey)); | |
357 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
358 "video/mp4", aac_codec(), kClearKey)); | |
359 | 386 |
360 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | 387 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
361 // They should really pass canPlayType(). | 388 // They should really pass canPlayType(). |
362 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 389 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
363 "video/mp4", avc1_extended_codec(), kClearKey)); | 390 kVideoFoo, foovideo_extended_codec(), kUsesAes)); |
364 | 391 |
365 // Invalid codec format. | 392 // Invalid codec format. |
366 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 393 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
367 "video/mp4", avc1_dot_codec(), kClearKey)); | 394 kVideoFoo, foovideo_dot_codec(), kUsesAes)); |
368 | 395 |
369 // Non-MP4 codecs. | 396 // Non-container2 codec. |
370 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 397 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
371 "video/mp4", avc2_codec(), kClearKey)); | 398 kVideoFoo, vp8_codec(), kUsesAes)); |
372 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 399 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
373 "video/mp4", vp8_codec(), kClearKey)); | 400 kVideoFoo, unknown_codec(), kUsesAes)); |
374 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 401 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
375 "video/mp4", unknown_codec(), kClearKey)); | 402 kVideoFoo, mixed_codecs(), kUsesAes)); |
376 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
377 "video/mp4", mixed_codecs(), kClearKey)); | |
378 | 403 |
379 // Valid audio types. | 404 // Valid audio types. |
380 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 405 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
381 "audio/mp4", no_codecs(), kClearKey)); | 406 kAudioFoo, no_codecs(), kUsesAes)); |
382 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 407 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
383 "audio/mp4", aac_codec(), kClearKey)); | 408 kAudioFoo, fooaudio_codec(), kUsesAes)); |
384 | 409 |
385 // Non-audio codecs. | 410 // Non-audio codecs. |
386 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 411 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
387 "audio/mp4", avc1_codec(), kClearKey)); | 412 kAudioFoo, foovideo_codec(), kUsesAes)); |
388 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 413 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
389 "audio/mp4", avc1_and_aac_codecs(), kClearKey)); | 414 kAudioFoo, foovideo_and_fooaudio_codecs(), kUsesAes)); |
390 | 415 |
391 // Non-MP4 codec. | 416 // Non-container2 codec. |
392 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 417 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
393 "audio/mp4", vorbis_codec(), kClearKey)); | 418 kAudioFoo, vorbis_codec(), kUsesAes)); |
394 } | 419 } |
395 | 420 |
396 // | 421 // |
397 // External Clear Key | 422 // Non-AesDecryptor-based key system. |
398 // | 423 // |
399 | 424 |
400 TEST_F(KeySystemsTest, ExternalClearKey_Basic) { | 425 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { |
401 EXPECT_ECK( | 426 EXPECT_TRUE(IsConcreteSupportedKeySystemUTF8(kExternal)); |
402 IsConcreteSupportedKeySystem(WebString::fromUTF8(kExternalClearKey))); | 427 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
403 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 428 kVideoWebM, no_codecs(), kExternal)); |
404 "video/webm", no_codecs(), kExternalClearKey)); | 429 |
405 | 430 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); |
406 // External Clear Key does not have a UMA name because it is for testing. | |
407 EXPECT_STREQ( | |
408 "Unknown", | |
409 KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str()); | |
410 | |
411 #if defined(ENABLE_PEPPER_CDMS) | 431 #if defined(ENABLE_PEPPER_CDMS) |
412 EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKey)); | 432 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); |
413 EXPECT_STREQ("application/x-ppapi-clearkey-cdm", | 433 #endif // defined(ENABLE_PEPPER_CDMS) |
414 GetPepperType(kExternalClearKey).c_str()); | 434 |
415 #else | 435 } |
| 436 |
| 437 TEST_F(KeySystemsTest, Parent_ParentRegistered) { |
| 438 // The parent system is not a concrete system but is supported. |
| 439 EXPECT_FALSE(IsConcreteSupportedKeySystemUTF8(kExternalParent)); |
| 440 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 441 kVideoWebM, no_codecs(), kExternalParent)); |
| 442 |
| 443 // The parent is not supported for most things. |
| 444 EXPECT_EQ("Unknown", KeySystemNameForUMAUTF8(kExternalParent)); |
416 bool result = false; | 445 bool result = false; |
417 EXPECT_DEBUG_DEATH_PORTABLE( | 446 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kExternalParent), |
418 result = CanUseAesDecryptor(kExternalClearKey), | 447 "com.example is not a known concrete system"); |
419 "org.chromium.externalclearkey is not a known concrete system"); | |
420 EXPECT_FALSE(result); | |
421 #endif | |
422 } | |
423 | |
424 TEST_F(KeySystemsTest, ExternalClearKey_Parent) { | |
425 const char* const kExternalClearKeyParent = "org.chromium"; | |
426 | |
427 // The parent should be supported but is not. See http://crbug.com/164303. | |
428 EXPECT_FALSE(IsConcreteSupportedKeySystem( | |
429 WebString::fromUTF8(kExternalClearKeyParent))); | |
430 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
431 "video/webm", no_codecs(), kExternalClearKeyParent)); | |
432 | |
433 // The parent is not supported for most things. | |
434 EXPECT_STREQ("Unknown", | |
435 KeySystemNameForUMA( | |
436 WebString::fromUTF8(kExternalClearKeyParent)).c_str()); | |
437 bool result = false; | |
438 EXPECT_DEBUG_DEATH_PORTABLE( | |
439 result = CanUseAesDecryptor(kExternalClearKeyParent), | |
440 "org.chromium is not a known concrete system"); | |
441 EXPECT_FALSE(result); | 448 EXPECT_FALSE(result); |
442 #if defined(ENABLE_PEPPER_CDMS) | 449 #if defined(ENABLE_PEPPER_CDMS) |
443 std::string type; | 450 std::string type; |
444 EXPECT_DEBUG_DEATH(type = GetPepperType(kExternalClearKeyParent), | 451 EXPECT_DEBUG_DEATH(type = GetPepperType(kExternalParent), |
445 "org.chromium is not a known concrete system"); | 452 "com.example is not a known concrete system"); |
446 EXPECT_TRUE(type.empty()); | 453 EXPECT_TRUE(type.empty()); |
447 #endif | 454 #endif |
448 } | 455 } |
449 | 456 |
450 TEST_F(KeySystemsTest, ExternalClearKey_IsSupportedKeySystem_InvalidVariants) { | 457 TEST_F( |
451 // Case sensitive. | 458 KeySystemsTest, |
452 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy")); | 459 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { |
453 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
454 "video/webm", no_codecs(), | |
455 "org.chromium.ExTeRnAlClEaRkEy")); | |
456 | |
457 // TLDs are not allowed. | |
458 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); | |
459 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
460 "video/webm", no_codecs(), "org.")); | |
461 EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); | |
462 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
463 "video/webm", no_codecs(), "org")); | |
464 | |
465 // Extra period. | |
466 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.")); | |
467 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
468 "video/webm", no_codecs(), "org.chromium.")); | |
469 | |
470 // Incomplete. | |
471 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearke")); | |
472 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
473 "video/webm", no_codecs(), | |
474 "org.chromium.externalclearke")); | |
475 | |
476 // Extra character. | |
477 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearkeyz")); | |
478 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
479 "video/webm", no_codecs(), | |
480 "org.chromium.externalclearkeyz")); | |
481 | |
482 // There are no child key systems for Clear Key. | |
483 EXPECT_FALSE( | |
484 IsConcreteSupportedKeySystem("org.chromium.externalclearkey.foo")); | |
485 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
486 "video/webm", no_codecs(), | |
487 "org.chromium.externalclearkey.foo")); | |
488 } | |
489 | |
490 TEST_F(KeySystemsTest, | |
491 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_NoType) { | |
492 // These two should be true. See http://crbug.com/164303. | |
493 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
494 std::string(), no_codecs(), kExternalClearKey)); | |
495 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
496 std::string(), no_codecs(), "org.chromium")); | |
497 | |
498 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
499 std::string(), no_codecs(), "org.chromium.foo")); | |
500 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
501 std::string(), no_codecs(), "org.chromium.externalclearkey.foo")); | |
502 } | |
503 | |
504 TEST_F(KeySystemsTest, | |
505 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_WebM) { | |
506 // Valid video types. | 460 // Valid video types. |
507 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 461 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
508 "video/webm", no_codecs(), kExternalClearKey)); | 462 kVideoWebM, no_codecs(), kExternal)); |
509 // The parent should be supported but is not. See http://crbug.com/164303. | 463 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
510 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 464 kVideoWebM, vp8_codec(), kExternal)); |
511 "video/webm", no_codecs(), "org.chromium")); | 465 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
512 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 466 kVideoWebM, vp80_codec(), kExternal)); |
513 "video/webm", vp8_codec(), kExternalClearKey)); | 467 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
514 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 468 kVideoWebM, vp8_and_vorbis_codecs(), kExternal)); |
515 "video/webm", vp80_codec(), kExternalClearKey)); | 469 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
516 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 470 kVideoWebM, vorbis_codec(), kExternal)); |
517 "video/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); | 471 |
518 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 472 // Valid video types - parent key system. |
519 "video/webm", vorbis_codec(), kExternalClearKey)); | 473 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 474 kVideoWebM, no_codecs(), kExternalParent)); |
| 475 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 476 kVideoWebM, vp8_codec(), kExternalParent)); |
| 477 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 478 kVideoWebM, vp80_codec(), kExternalParent)); |
| 479 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 480 kVideoWebM, vp8_and_vorbis_codecs(), kExternalParent)); |
| 481 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 482 kVideoWebM, vorbis_codec(), kExternalParent)); |
520 | 483 |
521 // Non-Webm codecs. | 484 // Non-Webm codecs. |
522 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 485 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
523 "video/webm", avc1_codec(), kExternalClearKey)); | 486 kVideoWebM, foovideo_codec(), kExternal)); |
524 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 487 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
525 "video/webm", unknown_codec(), kExternalClearKey)); | 488 kVideoWebM, unknown_codec(), kExternal)); |
526 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 489 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
527 "video/webm", mixed_codecs(), kExternalClearKey)); | 490 kVideoWebM, mixed_codecs(), kExternal)); |
528 | 491 |
529 // Valid audio types. | 492 // Valid audio types. |
530 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 493 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
531 "audio/webm", no_codecs(), kExternalClearKey)); | 494 kAudioWebM, no_codecs(), kExternal)); |
532 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 495 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
533 "audio/webm", vorbis_codec(), kExternalClearKey)); | 496 kAudioWebM, vorbis_codec(), kExternal)); |
| 497 |
| 498 // Valid audio types - parent key system. |
| 499 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 500 kAudioWebM, no_codecs(), kExternalParent)); |
| 501 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 502 kAudioWebM, vorbis_codec(), kExternalParent)); |
534 | 503 |
535 // Non-audio codecs. | 504 // Non-audio codecs. |
536 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 505 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
537 "audio/webm", vp8_codec(), kExternalClearKey)); | 506 kAudioWebM, vp8_codec(), kExternal)); |
538 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 507 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
539 "audio/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); | 508 kAudioWebM, vp8_and_vorbis_codecs(), kExternal)); |
540 | 509 |
541 // Non-Webm codec. | 510 // Non-Webm codec. |
542 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 511 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
543 "audio/webm", aac_codec(), kExternalClearKey)); | 512 kAudioWebM, fooaudio_codec(), kExternal)); |
544 } | 513 } |
545 | 514 |
546 TEST_F(KeySystemsTest, | 515 TEST_F( |
547 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_MP4) { | 516 KeySystemsTest, |
| 517 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { |
548 // Valid video types. | 518 // Valid video types. |
549 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 519 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
550 "video/mp4", no_codecs(), kExternalClearKey)); | 520 kVideoFoo, no_codecs(), kExternal)); |
551 // The parent should be supported but is not. See http://crbug.com/164303. | 521 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
552 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 522 kVideoFoo, foovideo_codec(), kExternal)); |
553 "video/mp4", no_codecs(), "org.chromium")); | 523 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
554 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 524 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternal)); |
555 "video/mp4", avc1_codec(), kExternalClearKey)); | 525 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
556 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 526 kVideoFoo, fooaudio_codec(), kExternal)); |
557 "video/mp4", avc1_and_aac_codecs(), kExternalClearKey)); | 527 |
558 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 528 // Valid video types - parent key system. |
559 "video/mp4", aac_codec(), kExternalClearKey)); | 529 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 530 kVideoFoo, no_codecs(), kExternalParent)); |
| 531 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 532 kVideoFoo, foovideo_codec(), kExternalParent)); |
| 533 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 534 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternalParent)); |
| 535 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 536 kVideoFoo, fooaudio_codec(), kExternalParent)); |
560 | 537 |
561 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | 538 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
562 // They should really pass canPlayType(). | 539 // They should really pass canPlayType(). |
563 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 540 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
564 "video/mp4", avc1_extended_codec(), kExternalClearKey)); | 541 kVideoFoo, foovideo_extended_codec(), kExternal)); |
565 | 542 |
566 // Invalid codec format. | 543 // Invalid codec format. |
567 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 544 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
568 "video/mp4", avc1_dot_codec(), kExternalClearKey)); | 545 kVideoFoo, foovideo_dot_codec(), kExternal)); |
569 | 546 |
570 // Non-MP4 codecs. | 547 // Non-container2 codecs. |
571 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 548 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
572 "video/mp4", avc2_codec(), kExternalClearKey)); | 549 kVideoFoo, vp8_codec(), kExternal)); |
573 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 550 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
574 "video/mp4", vp8_codec(), kExternalClearKey)); | 551 kVideoFoo, unknown_codec(), kExternal)); |
575 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 552 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
576 "video/mp4", unknown_codec(), kExternalClearKey)); | 553 kVideoFoo, mixed_codecs(), kExternal)); |
577 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
578 "video/mp4", mixed_codecs(), kExternalClearKey)); | |
579 | 554 |
580 // Valid audio types. | 555 // Valid audio types. |
581 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 556 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
582 "audio/mp4", no_codecs(), kExternalClearKey)); | 557 kAudioFoo, no_codecs(), kExternal)); |
583 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 558 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
584 "audio/mp4", aac_codec(), kExternalClearKey)); | 559 kAudioFoo, fooaudio_codec(), kExternal)); |
| 560 |
| 561 // Valid audio types - parent key system. |
| 562 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 563 kAudioFoo, no_codecs(), kExternalParent)); |
| 564 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 565 kAudioFoo, fooaudio_codec(), kExternalParent)); |
585 | 566 |
586 // Non-audio codecs. | 567 // Non-audio codecs. |
587 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 568 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
588 "audio/mp4", avc1_codec(), kExternalClearKey)); | 569 kAudioFoo, foovideo_codec(), kExternal)); |
589 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 570 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
590 "audio/mp4", avc1_and_aac_codecs(), kExternalClearKey)); | 571 kAudioFoo, foovideo_and_fooaudio_codecs(), kExternal)); |
591 | 572 |
592 // Non-MP4 codec. | 573 // Non-container2 codec. |
593 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 574 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
594 "audio/mp4", vorbis_codec(), kExternalClearKey)); | 575 kAudioFoo, vorbis_codec(), kExternal)); |
595 } | |
596 | |
597 // | |
598 // Widevine | |
599 // | |
600 | |
601 TEST_F(KeySystemsTest, Widevine_Basic) { | |
602 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | |
603 defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
604 EXPECT_TRUE( | |
605 IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha))); | |
606 #else | |
607 EXPECT_WV(IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha))); | |
608 #endif | |
609 | |
610 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
611 "video/webm", no_codecs(), kWidevineAlpha)); | |
612 | |
613 #if defined(WIDEVINE_CDM_AVAILABLE) | |
614 const char* const kWidevineUmaName = "Widevine"; | |
615 #else | |
616 const char* const kWidevineUmaName = "Unknown"; | |
617 #endif | |
618 EXPECT_STREQ( | |
619 kWidevineUmaName, | |
620 KeySystemNameForUMA(WebString::fromUTF8(kWidevineAlpha)).c_str()); | |
621 | |
622 #if defined(WIDEVINE_CDM_AVAILABLE) | |
623 EXPECT_FALSE(CanUseAesDecryptor(kWidevineAlpha)); | |
624 #else | |
625 bool result = false; | |
626 EXPECT_DEBUG_DEATH_PORTABLE( | |
627 result = CanUseAesDecryptor(kWidevineAlpha), | |
628 "com.widevine.alpha is not a known concrete system"); | |
629 EXPECT_FALSE(result); | |
630 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
631 | |
632 #if defined(ENABLE_PEPPER_CDMS) | |
633 #if defined(WIDEVINE_CDM_AVAILABLE) | |
634 EXPECT_STREQ("application/x-ppapi-widevine-cdm", | |
635 GetPepperType(kWidevineAlpha).c_str()); | |
636 #else | |
637 std::string type; | |
638 EXPECT_DEBUG_DEATH(type = GetPepperType(kWidevineAlpha), | |
639 "com.widevine.alpha is not a known concrete system"); | |
640 EXPECT_TRUE(type.empty()); | |
641 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
642 #endif // defined(ENABLE_PEPPER_CDMS) | |
643 | |
644 } | |
645 | |
646 TEST_F(KeySystemsTest, Widevine_Parent) { | |
647 // The parent system is not a concrete system but is supported. | |
648 EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevine))); | |
649 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
650 "video/webm", no_codecs(), kWidevine)); | |
651 | |
652 // The parent is not supported for most things. | |
653 EXPECT_STREQ("Unknown", | |
654 KeySystemNameForUMA(WebString::fromUTF8(kWidevine)).c_str()); | |
655 bool result = false; | |
656 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kWidevine), | |
657 "com.widevine is not a known concrete system"); | |
658 EXPECT_FALSE(result); | |
659 #if defined(ENABLE_PEPPER_CDMS) | |
660 std::string type; | |
661 EXPECT_DEBUG_DEATH(type = GetPepperType(kWidevine), | |
662 "com.widevine is not a known concrete system"); | |
663 EXPECT_TRUE(type.empty()); | |
664 #endif | |
665 } | |
666 | |
667 TEST_F(KeySystemsTest, Widevine_IsSupportedKeySystem_InvalidVariants) { | |
668 // Case sensitive. | |
669 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.AlPhA")); | |
670 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
671 "video/webm", no_codecs(), "com.widevine.AlPhA")); | |
672 | |
673 // TLDs are not allowed. | |
674 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.")); | |
675 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
676 "video/webm", no_codecs(), "com.")); | |
677 EXPECT_FALSE(IsConcreteSupportedKeySystem("com")); | |
678 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
679 "video/webm", no_codecs(), "com")); | |
680 | |
681 // Extra period. | |
682 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.")); | |
683 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
684 "video/webm", no_codecs(), "com.widevine.")); | |
685 | |
686 // Incomplete. | |
687 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alph")); | |
688 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
689 "video/webm", no_codecs(), "com.widevine.alph")); | |
690 | |
691 // Extra character. | |
692 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alphab")); | |
693 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
694 "video/webm", no_codecs(), "com.widevine.alphab")); | |
695 | |
696 // There are no child key systems for Widevine Alpha. | |
697 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alpha.foo")); | |
698 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
699 "video/webm", no_codecs(), "com.widevine.alpha.foo")); | |
700 } | |
701 | |
702 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_NoType) { | |
703 // These two should be true. See http://crbug.com/164303. | |
704 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
705 std::string(), no_codecs(), kWidevineAlpha)); | |
706 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
707 std::string(), no_codecs(), kWidevine)); | |
708 | |
709 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
710 std::string(), no_codecs(), "com.widevine.foo")); | |
711 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
712 std::string(), no_codecs(), "com.widevine.alpha.foo")); | |
713 } | |
714 | |
715 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) { | |
716 // Valid video types. | |
717 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
718 "video/webm", no_codecs(), kWidevineAlpha)); | |
719 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
720 "video/webm", vp8_codec(), kWidevineAlpha)); | |
721 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
722 "video/webm", vp80_codec(), kWidevineAlpha)); | |
723 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
724 "video/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); | |
725 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
726 "video/webm", vorbis_codec(), kWidevineAlpha)); | |
727 | |
728 // Valid video types - parent key system. | |
729 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
730 "video/webm", no_codecs(), kWidevine)); | |
731 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
732 "video/webm", vp8_codec(), kWidevine)); | |
733 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
734 "video/webm", vp80_codec(), kWidevine)); | |
735 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
736 "video/webm", vp8_and_vorbis_codecs(), kWidevine)); | |
737 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
738 "video/webm", vorbis_codec(), kWidevine)); | |
739 | |
740 // Non-Webm codecs. | |
741 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
742 "video/webm", avc1_codec(), kWidevineAlpha)); | |
743 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
744 "video/webm", unknown_codec(), kWidevineAlpha)); | |
745 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
746 "video/webm", mixed_codecs(), kWidevineAlpha)); | |
747 | |
748 // Valid audio types. | |
749 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
750 "audio/webm", no_codecs(), kWidevineAlpha)); | |
751 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
752 "audio/webm", vorbis_codec(), kWidevineAlpha)); | |
753 | |
754 // Valid audio types - parent key system. | |
755 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
756 "audio/webm", no_codecs(), kWidevine)); | |
757 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
758 "audio/webm", vorbis_codec(), kWidevine)); | |
759 | |
760 // Non-audio codecs. | |
761 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
762 "audio/webm", vp8_codec(), kWidevineAlpha)); | |
763 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
764 "audio/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); | |
765 | |
766 // Non-Webm codec. | |
767 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
768 "audio/webm", aac_codec(), kWidevineAlpha)); | |
769 } | |
770 | |
771 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) { | |
772 // Valid video types. | |
773 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( | |
774 "video/mp4", no_codecs(), kWidevineAlpha)); | |
775 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( | |
776 "video/mp4", avc1_codec(), kWidevineAlpha)); | |
777 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
778 "video/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); | |
779 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
780 "video/mp4", aac_codec(), kWidevineAlpha)); | |
781 | |
782 // Valid video types - parent key system. | |
783 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( | |
784 "video/mp4", no_codecs(), kWidevine)); | |
785 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( | |
786 "video/mp4", avc1_codec(), kWidevine)); | |
787 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
788 "video/mp4", avc1_and_aac_codecs(), kWidevine)); | |
789 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
790 "video/mp4", aac_codec(), kWidevine)); | |
791 | |
792 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | |
793 // They should really pass canPlayType(). | |
794 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
795 "video/mp4", avc1_extended_codec(), kWidevineAlpha)); | |
796 | |
797 // Invalid codec format. | |
798 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
799 "video/mp4", avc1_dot_codec(), kWidevineAlpha)); | |
800 | |
801 // Non-MP4 codecs. | |
802 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
803 "video/mp4", avc2_codec(), kWidevineAlpha)); | |
804 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
805 "video/mp4", vp8_codec(), kWidevineAlpha)); | |
806 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
807 "video/mp4", unknown_codec(), kWidevineAlpha)); | |
808 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
809 "video/mp4", mixed_codecs(), kWidevineAlpha)); | |
810 | |
811 // Valid audio types. | |
812 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( | |
813 "audio/mp4", no_codecs(), kWidevineAlpha)); | |
814 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( | |
815 "audio/mp4", aac_codec(), kWidevineAlpha)); | |
816 | |
817 // Valid audio types - parent key system. | |
818 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( | |
819 "audio/mp4", no_codecs(), kWidevine)); | |
820 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( | |
821 "audio/mp4", aac_codec(), kWidevine)); | |
822 | |
823 // Non-audio codecs. | |
824 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
825 "audio/mp4", avc1_codec(), kWidevineAlpha)); | |
826 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
827 "audio/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); | |
828 | |
829 // Non-MP4 codec. | |
830 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
831 "audio/mp4", vorbis_codec(), kWidevineAlpha)); | |
832 } | 576 } |
833 | 577 |
834 #if defined(OS_ANDROID) | 578 #if defined(OS_ANDROID) |
835 TEST_F(KeySystemsTest, GetUUID_Widevine) { | 579 TEST_F(KeySystemsTest, GetUUID_RegisteredExternalDecryptor) { |
836 #if defined(WIDEVINE_CDM_AVAILABLE) | 580 std::vector<uint8> uuid = GetUUID(kExternal); |
837 std::vector<uint8> uuid = GetUUID(kWidevineAlpha); | |
838 EXPECT_EQ(16u, uuid.size()); | 581 EXPECT_EQ(16u, uuid.size()); |
839 EXPECT_EQ(0xED, uuid[15]); | 582 EXPECT_EQ(0xef, uuid[15]); |
840 #else | 583 } |
841 std::vector<uint8> uuid; | 584 |
842 EXPECT_DEBUG_DEATH_PORTABLE( | 585 TEST_F(KeySystemsTest, GetUUID_RegisteredAesDecryptor) { |
843 uuid = GetUUID(kWidevineAlpha), | 586 EXPECT_TRUE(GetUUID(kUsesAes).empty()); |
844 "com.widevine.alpha is not a known concrete system"); | |
845 EXPECT_TRUE(uuid.empty()); | |
846 #endif | |
847 } | 587 } |
848 | 588 |
849 TEST_F(KeySystemsTest, GetUUID_Unrecognized) { | 589 TEST_F(KeySystemsTest, GetUUID_Unrecognized) { |
850 std::vector<uint8> uuid; | 590 std::vector<uint8> uuid; |
851 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(kWidevine), | 591 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(kExternalParent), |
852 "com.widevine is not a known concrete system"); | 592 "com.example is not a known concrete system"); |
853 EXPECT_TRUE(uuid.empty()); | 593 EXPECT_TRUE(uuid.empty()); |
854 | 594 |
855 EXPECT_TRUE(GetUUID(kClearKey).empty()); | |
856 | |
857 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(""), " is not a concrete system"); | 595 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(""), " is not a concrete system"); |
858 EXPECT_TRUE(uuid.empty()); | 596 EXPECT_TRUE(uuid.empty()); |
859 } | 597 } |
860 #endif // defined(OS_ANDROID) | 598 #endif // defined(OS_ANDROID) |
861 | 599 |
| 600 TEST_F(KeySystemsTest, KeySystemNameForUMA) { |
| 601 EXPECT_EQ("ClearKey", KeySystemNameForUMAUTF8(kPrefixedClearKey)); |
| 602 // Unprefixed is not yet supported. |
| 603 EXPECT_EQ("Unknown", KeySystemNameForUMAUTF8(kUnprefixedClearKey)); |
| 604 |
| 605 // External Clear Key never has a UMA name. |
| 606 EXPECT_EQ("Unknown", KeySystemNameForUMAUTF8(kExternalClearKey)); |
| 607 |
| 608 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 609 const char* const kTestWidevineUmaName = "Widevine"; |
| 610 #else |
| 611 const char* const kTestWidevineUmaName = "Unknown"; |
| 612 #endif |
| 613 EXPECT_EQ(kTestWidevineUmaName, |
| 614 KeySystemNameForUMAUTF8("com.widevine.alpha")); |
| 615 } |
| 616 |
862 } // namespace content | 617 } // namespace content |
OLD | NEW |