OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
10 #include "webkit/media/crypto/key_systems.h" | 10 #include "webkit/media/crypto/key_systems.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Not yet out from behind the vendor prefix. | 167 // Not yet out from behind the vendor prefix. |
168 EXPECT_FALSE(IsSupportedKeySystem("org.w3.clearkey")); | 168 EXPECT_FALSE(IsSupportedKeySystem("org.w3.clearkey")); |
169 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 169 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
170 "video/webm", no_codecs(), "org.w3.clearkey")); | 170 "video/webm", no_codecs(), "org.w3.clearkey")); |
171 | 171 |
172 EXPECT_STREQ("ClearKey", KeySystemNameForUMA(std::string(kClearKey)).c_str()); | 172 EXPECT_STREQ("ClearKey", KeySystemNameForUMA(std::string(kClearKey)).c_str()); |
173 EXPECT_STREQ("ClearKey", | 173 EXPECT_STREQ("ClearKey", |
174 KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str()); | 174 KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str()); |
175 | 175 |
176 EXPECT_TRUE(CanUseAesDecryptor(kClearKey)); | 176 EXPECT_TRUE(CanUseAesDecryptor(kClearKey)); |
177 EXPECT_TRUE(GetPluginType(kClearKey).empty()); // Does not use plugin. | 177 #if defined(ENABLE_PEPPER_CDMS) |
| 178 EXPECT_TRUE(GetPepperType(kClearKey).empty()); // Does not use Pepper. |
| 179 #endif |
178 } | 180 } |
179 | 181 |
180 TEST_F(KeySystemsTest, ClearKey_Parent) { | 182 TEST_F(KeySystemsTest, ClearKey_Parent) { |
181 const char* const kClearKeyParent = "webkit-org.w3"; | 183 const char* const kClearKeyParent = "webkit-org.w3"; |
182 | 184 |
183 // The parent should be supported but is not. See http://crbug.com/164303. | 185 // The parent should be supported but is not. See http://crbug.com/164303. |
184 EXPECT_FALSE(IsSupportedKeySystem(WebString::fromUTF8(kClearKeyParent))); | 186 EXPECT_FALSE(IsSupportedKeySystem(WebString::fromUTF8(kClearKeyParent))); |
185 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 187 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
186 "video/webm", no_codecs(), kClearKeyParent)); | 188 "video/webm", no_codecs(), kClearKeyParent)); |
187 | 189 |
188 // The parent is not supported for most things. | 190 // The parent is not supported for most things. |
189 EXPECT_STREQ("Unknown", | 191 EXPECT_STREQ("Unknown", |
190 KeySystemNameForUMA(std::string(kClearKeyParent)).c_str()); | 192 KeySystemNameForUMA(std::string(kClearKeyParent)).c_str()); |
191 EXPECT_STREQ("Unknown", | 193 EXPECT_STREQ("Unknown", |
192 KeySystemNameForUMA(WebString::fromUTF8(kClearKeyParent)).c_str()); | 194 KeySystemNameForUMA(WebString::fromUTF8(kClearKeyParent)).c_str()); |
193 EXPECT_FALSE(CanUseAesDecryptor(kClearKeyParent)); | 195 EXPECT_FALSE(CanUseAesDecryptor(kClearKeyParent)); |
194 EXPECT_TRUE(GetPluginType(kClearKeyParent).empty()); | 196 #if defined(ENABLE_PEPPER_CDMS) |
| 197 EXPECT_TRUE(GetPepperType(kClearKeyParent).empty()); |
| 198 #endif |
195 } | 199 } |
196 | 200 |
197 TEST_F(KeySystemsTest, ClearKey_IsSupportedKeySystem_InvalidVariants) { | 201 TEST_F(KeySystemsTest, ClearKey_IsSupportedKeySystem_InvalidVariants) { |
198 // Case sensitive. | 202 // Case sensitive. |
199 EXPECT_FALSE(IsSupportedKeySystem("webkit-org.w3.ClEaRkEy")); | 203 EXPECT_FALSE(IsSupportedKeySystem("webkit-org.w3.ClEaRkEy")); |
200 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 204 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
201 "video/webm", no_codecs(), "webkit-org.w3.ClEaRkEy")); | 205 "video/webm", no_codecs(), "webkit-org.w3.ClEaRkEy")); |
202 | 206 |
203 // TLDs are not allowed. | 207 // TLDs are not allowed. |
204 EXPECT_FALSE(IsSupportedKeySystem("webkit-org.")); | 208 EXPECT_FALSE(IsSupportedKeySystem("webkit-org.")); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 354 |
351 // External Clear Key does not have a UMA name because it is for testing. | 355 // External Clear Key does not have a UMA name because it is for testing. |
352 EXPECT_STREQ( | 356 EXPECT_STREQ( |
353 "Unknown", | 357 "Unknown", |
354 KeySystemNameForUMA(std::string(kExternalClearKey)).c_str()); | 358 KeySystemNameForUMA(std::string(kExternalClearKey)).c_str()); |
355 EXPECT_STREQ( | 359 EXPECT_STREQ( |
356 "Unknown", | 360 "Unknown", |
357 KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str()); | 361 KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str()); |
358 | 362 |
359 EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKey)); | 363 EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKey)); |
| 364 #if defined(ENABLE_PEPPER_CDMS) |
360 EXPECT_STREQ("application/x-ppapi-clearkey-cdm", | 365 EXPECT_STREQ("application/x-ppapi-clearkey-cdm", |
361 GetPluginType(kExternalClearKey).c_str()); | 366 GetPepperType(kExternalClearKey).c_str()); |
| 367 #endif |
362 } | 368 } |
363 | 369 |
364 TEST_F(KeySystemsTest, ExternalClearKey_Parent) { | 370 TEST_F(KeySystemsTest, ExternalClearKey_Parent) { |
365 const char* const kExternalClearKeyParent = "org.chromium"; | 371 const char* const kExternalClearKeyParent = "org.chromium"; |
366 | 372 |
367 // The parent should be supported but is not. See http://crbug.com/164303. | 373 // The parent should be supported but is not. See http://crbug.com/164303. |
368 EXPECT_FALSE( | 374 EXPECT_FALSE( |
369 IsSupportedKeySystem(WebString::fromUTF8(kExternalClearKeyParent))); | 375 IsSupportedKeySystem(WebString::fromUTF8(kExternalClearKeyParent))); |
370 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 376 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
371 "video/webm", no_codecs(), kExternalClearKeyParent)); | 377 "video/webm", no_codecs(), kExternalClearKeyParent)); |
372 | 378 |
373 // The parent is not supported for most things. | 379 // The parent is not supported for most things. |
374 EXPECT_STREQ( | 380 EXPECT_STREQ( |
375 "Unknown", | 381 "Unknown", |
376 KeySystemNameForUMA(std::string(kExternalClearKeyParent)).c_str()); | 382 KeySystemNameForUMA(std::string(kExternalClearKeyParent)).c_str()); |
377 EXPECT_STREQ("Unknown", | 383 EXPECT_STREQ("Unknown", |
378 KeySystemNameForUMA( | 384 KeySystemNameForUMA( |
379 WebString::fromUTF8(kExternalClearKeyParent)).c_str()); | 385 WebString::fromUTF8(kExternalClearKeyParent)).c_str()); |
380 EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKeyParent)); | 386 EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKeyParent)); |
381 EXPECT_TRUE(GetPluginType(kExternalClearKeyParent).empty()); | 387 #if defined(ENABLE_PEPPER_CDMS) |
| 388 EXPECT_TRUE(GetPepperType(kExternalClearKeyParent).empty()); |
| 389 #endif |
382 } | 390 } |
383 | 391 |
384 TEST_F(KeySystemsTest, ExternalClearKey_IsSupportedKeySystem_InvalidVariants) { | 392 TEST_F(KeySystemsTest, ExternalClearKey_IsSupportedKeySystem_InvalidVariants) { |
385 // Case sensitive. | 393 // Case sensitive. |
386 EXPECT_FALSE(IsSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy")); | 394 EXPECT_FALSE(IsSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy")); |
387 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 395 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
388 "video/webm", no_codecs(), | 396 "video/webm", no_codecs(), |
389 "org.chromium.ExTeRnAlClEaRkEy")); | 397 "org.chromium.ExTeRnAlClEaRkEy")); |
390 | 398 |
391 // TLDs are not allowed. | 399 // TLDs are not allowed. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 const char* const kWidevineUmaName = "Unknown"; | 550 const char* const kWidevineUmaName = "Unknown"; |
543 #endif | 551 #endif |
544 EXPECT_STREQ( | 552 EXPECT_STREQ( |
545 kWidevineUmaName, | 553 kWidevineUmaName, |
546 KeySystemNameForUMA(std::string(kWidevineAlpha)).c_str()); | 554 KeySystemNameForUMA(std::string(kWidevineAlpha)).c_str()); |
547 EXPECT_STREQ( | 555 EXPECT_STREQ( |
548 kWidevineUmaName, | 556 kWidevineUmaName, |
549 KeySystemNameForUMA(WebString::fromUTF8(kWidevineAlpha)).c_str()); | 557 KeySystemNameForUMA(WebString::fromUTF8(kWidevineAlpha)).c_str()); |
550 | 558 |
551 EXPECT_FALSE(CanUseAesDecryptor(kWidevineAlpha)); | 559 EXPECT_FALSE(CanUseAesDecryptor(kWidevineAlpha)); |
| 560 #if defined(ENABLE_PEPPER_CDMS) |
552 #if defined(WIDEVINE_CDM_AVAILABLE) | 561 #if defined(WIDEVINE_CDM_AVAILABLE) |
553 EXPECT_STREQ("application/x-ppapi-widevine-cdm", | 562 EXPECT_STREQ("application/x-ppapi-widevine-cdm", |
554 GetPluginType(kWidevineAlpha).c_str()); | 563 GetPepperType(kWidevineAlpha).c_str()); |
555 #else | 564 #else |
556 EXPECT_TRUE(GetPluginType(kWidevineAlpha).empty()); | 565 EXPECT_TRUE(GetPepperType(kWidevineAlpha).empty()); |
557 #endif | 566 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 567 #endif // defined(ENABLE_PEPPER_CDMS) |
| 568 |
558 } | 569 } |
559 | 570 |
560 TEST_F(KeySystemsTest, Widevine_Parent) { | 571 TEST_F(KeySystemsTest, Widevine_Parent) { |
561 const char* const kWidevineParent = kWidevine; | 572 const char* const kWidevineParent = kWidevine; |
562 | 573 |
563 EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineParent))); | 574 EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineParent))); |
564 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | 575 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
565 "video/webm", no_codecs(), kWidevineParent)); | 576 "video/webm", no_codecs(), kWidevineParent)); |
566 | 577 |
567 // The parent is not supported for most things. | 578 // The parent is not supported for most things. |
568 EXPECT_STREQ("Unknown", | 579 EXPECT_STREQ("Unknown", |
569 KeySystemNameForUMA(std::string(kWidevineParent)).c_str()); | 580 KeySystemNameForUMA(std::string(kWidevineParent)).c_str()); |
570 EXPECT_STREQ("Unknown", | 581 EXPECT_STREQ("Unknown", |
571 KeySystemNameForUMA(WebString::fromUTF8(kWidevineParent)).c_str()); | 582 KeySystemNameForUMA(WebString::fromUTF8(kWidevineParent)).c_str()); |
572 EXPECT_FALSE(CanUseAesDecryptor(kWidevineParent)); | 583 EXPECT_FALSE(CanUseAesDecryptor(kWidevineParent)); |
573 EXPECT_TRUE(GetPluginType(kWidevineParent).empty()); | 584 #if defined(ENABLE_PEPPER_CDMS) |
| 585 EXPECT_TRUE(GetPepperType(kWidevineParent).empty()); |
| 586 #endif |
574 } | 587 } |
575 | 588 |
576 TEST_F(KeySystemsTest, Widevine_IsSupportedKeySystem_InvalidVariants) { | 589 TEST_F(KeySystemsTest, Widevine_IsSupportedKeySystem_InvalidVariants) { |
577 // Case sensitive. | 590 // Case sensitive. |
578 EXPECT_FALSE(IsSupportedKeySystem("com.widevine.AlPhA")); | 591 EXPECT_FALSE(IsSupportedKeySystem("com.widevine.AlPhA")); |
579 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 592 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
580 "video/webm", no_codecs(), "com.widevine.AlPhA")); | 593 "video/webm", no_codecs(), "com.widevine.AlPhA")); |
581 | 594 |
582 // TLDs are not allowed. | 595 // TLDs are not allowed. |
583 EXPECT_FALSE(IsSupportedKeySystem("com.")); | 596 EXPECT_FALSE(IsSupportedKeySystem("com.")); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 "audio/mp4", avc1_codec(), kWidevineAlpha)); | 747 "audio/mp4", avc1_codec(), kWidevineAlpha)); |
735 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 748 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
736 "audio/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); | 749 "audio/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); |
737 | 750 |
738 // Non-MP4 codec. | 751 // Non-MP4 codec. |
739 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 752 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
740 "audio/mp4", vorbis_codec(), kWidevineAlpha)); | 753 "audio/mp4", vorbis_codec(), kWidevineAlpha)); |
741 } | 754 } |
742 | 755 |
743 } // namespace webkit_media | 756 } // namespace webkit_media |
OLD | NEW |