Chromium Code Reviews| 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 // TODO(sandersd): Refactor to remove recomputed codec arrays, and generally | 5 // TODO(sandersd): Refactor to remove recomputed codec arrays, and generally |
| 6 // shorten and improve coverage. | 6 // shorten and improve coverage. |
| 7 // - http://crbug.com/417444 | 7 // - http://crbug.com/417444 |
| 8 // - http://crbug.com/457438 | 8 // - http://crbug.com/457438 |
| 9 // TODO(sandersd): Add tests to cover codec vectors with empty items. | 9 // TODO(sandersd): Add tests to cover codec vectors with empty items. |
| 10 // http://crbug.com/417461 | 10 // http://crbug.com/417461 |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "media/base/eme_constants.h" | 16 #include "media/base/eme_constants.h" |
| 17 #include "media/base/key_system_info.h" | 17 #include "media/base/key_system_info.h" |
| 18 #include "media/base/key_systems.h" | 18 #include "media/base/key_systems.h" |
| 19 #include "media/base/media_client.h" | 19 #include "media/base/media_client.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 namespace media { | 22 namespace media { |
| 23 | 23 |
| 24 // These are the (fake) key systems that are registered for these tests. | 24 // These are the (fake) key systems that are registered for these tests. |
| 25 // kUsesAes uses the AesDecryptor like Clear Key. | 25 // kUsesAes uses the AesDecryptor like Clear Key. |
| 26 // kExternal uses an external CDM, such as Pepper-based or Android platform CDM. | 26 // kExternal uses an external CDM, such as Pepper-based or Android platform CDM. |
| 27 const char kUsesAes[] = "x-org.example.clear"; | 27 const char kUsesAes[] = "x-org.example.clear"; |
| 28 const char kUsesAesParent[] = "x-org.example"; // Not registered. | |
| 29 const char kUseAesNameForUMA[] = "UseAes"; | 28 const char kUseAesNameForUMA[] = "UseAes"; |
| 30 const char kExternal[] = "x-com.example.test"; | 29 const char kExternal[] = "x-com.example.test"; |
| 31 const char kExternalParent[] = "x-com.example"; | |
| 32 const char kExternalNameForUMA[] = "External"; | 30 const char kExternalNameForUMA[] = "External"; |
| 33 | 31 |
| 34 const char kClearKey[] = "org.w3.clearkey"; | 32 const char kClearKey[] = "org.w3.clearkey"; |
| 35 const char kExternalClearKey[] = "org.chromium.externalclearkey"; | 33 const char kExternalClearKey[] = "org.chromium.externalclearkey"; |
| 36 | 34 |
| 37 const char kAudioWebM[] = "audio/webm"; | 35 const char kAudioWebM[] = "audio/webm"; |
| 38 const char kVideoWebM[] = "video/webm"; | 36 const char kVideoWebM[] = "video/webm"; |
| 39 const char kAudioFoo[] = "audio/foo"; | 37 const char kAudioFoo[] = "audio/foo"; |
| 40 const char kVideoFoo[] = "video/foo"; | 38 const char kVideoFoo[] = "video/foo"; |
| 41 | 39 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 ext.key_system = kExternal; | 199 ext.key_system = kExternal; |
| 202 ext.supported_codecs = EME_CODEC_WEBM_ALL; | 200 ext.supported_codecs = EME_CODEC_WEBM_ALL; |
| 203 ext.supported_codecs |= TEST_CODEC_FOO_ALL; | 201 ext.supported_codecs |= TEST_CODEC_FOO_ALL; |
| 204 ext.supported_init_data_types = kInitDataTypeMaskWebM; | 202 ext.supported_init_data_types = kInitDataTypeMaskWebM; |
| 205 ext.max_audio_robustness = EmeRobustness::EMPTY; | 203 ext.max_audio_robustness = EmeRobustness::EMPTY; |
| 206 ext.max_video_robustness = EmeRobustness::EMPTY; | 204 ext.max_video_robustness = EmeRobustness::EMPTY; |
| 207 ext.persistent_license_support = EmeSessionTypeSupport::SUPPORTED; | 205 ext.persistent_license_support = EmeSessionTypeSupport::SUPPORTED; |
| 208 ext.persistent_release_message_support = EmeSessionTypeSupport::NOT_SUPPORTED; | 206 ext.persistent_release_message_support = EmeSessionTypeSupport::NOT_SUPPORTED; |
| 209 ext.persistent_state_support = EmeFeatureSupport::ALWAYS_ENABLED; | 207 ext.persistent_state_support = EmeFeatureSupport::ALWAYS_ENABLED; |
| 210 ext.distinctive_identifier_support = EmeFeatureSupport::ALWAYS_ENABLED; | 208 ext.distinctive_identifier_support = EmeFeatureSupport::ALWAYS_ENABLED; |
| 211 ext.parent_key_system = kExternalParent; | |
| 212 #if defined(ENABLE_PEPPER_CDMS) | 209 #if defined(ENABLE_PEPPER_CDMS) |
| 213 ext.pepper_type = "application/x-ppapi-external-cdm"; | 210 ext.pepper_type = "application/x-ppapi-external-cdm"; |
| 214 #endif // defined(ENABLE_PEPPER_CDMS) | 211 #endif // defined(ENABLE_PEPPER_CDMS) |
| 215 key_systems->push_back(ext); | 212 key_systems->push_back(ext); |
| 216 } | 213 } |
| 217 | 214 |
| 218 class PotentiallySupportedNamesTestMediaClient : public TestMediaClient { | 215 class PotentiallySupportedNamesTestMediaClient : public TestMediaClient { |
| 219 void AddSupportedKeySystems( | 216 void AddSupportedKeySystems( |
| 220 std::vector<KeySystemInfo>* key_systems_info) final; | 217 std::vector<KeySystemInfo>* key_systems_info) final; |
| 221 }; | 218 }; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 454 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 458 kAudioWebM, vp9_codec(), kUsesAes)); | 455 kAudioWebM, vp9_codec(), kUsesAes)); |
| 459 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 456 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 460 kAudioWebM, vp9_and_vorbis_codecs(), kUsesAes)); | 457 kAudioWebM, vp9_and_vorbis_codecs(), kUsesAes)); |
| 461 | 458 |
| 462 // Non-Webm codec. | 459 // Non-Webm codec. |
| 463 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( | 460 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 464 kAudioWebM, fooaudio_codec(), kUsesAes)); | 461 kAudioWebM, fooaudio_codec(), kUsesAes)); |
| 465 } | 462 } |
| 466 | 463 |
| 467 // No parent is registered for UsesAes. | |
| 468 TEST_F(KeySystemsTest, Parent_NoParentRegistered) { | |
| 469 EXPECT_FALSE(IsSupportedKeySystem(kUsesAesParent)); | |
| 470 | |
| 471 // The parent is not supported for most things. | |
| 472 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kUsesAesParent)); | |
| 473 EXPECT_FALSE(CanUseAesDecryptor(kUsesAesParent)); | |
| 474 | |
| 475 #if defined(ENABLE_PEPPER_CDMS) | |
| 476 std::string type; | |
| 477 EXPECT_DEBUG_DEATH(type = GetPepperType(kUsesAesParent), | |
| 478 "x-org.example is not a known concrete system"); | |
| 479 EXPECT_TRUE(type.empty()); | |
| 480 #endif | |
| 481 } | |
| 482 | |
| 483 TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) { | 464 TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) { |
| 484 // Case sensitive. | 465 // Case sensitive. |
| 485 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.ClEaR")); | 466 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.ClEaR")); |
| 486 | 467 |
| 487 // TLDs are not allowed. | 468 // TLDs are not allowed. |
| 488 EXPECT_FALSE(IsSupportedKeySystem("org.")); | 469 EXPECT_FALSE(IsSupportedKeySystem("org.")); |
| 489 EXPECT_FALSE(IsSupportedKeySystem("com")); | 470 EXPECT_FALSE(IsSupportedKeySystem("com")); |
| 490 | 471 |
| 491 // Extra period. | 472 // Extra period. |
| 492 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.")); | 473 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.")); |
| 493 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.")); | 474 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.")); |
|
jrummell
2016/02/25 19:28:07
Should we add a test that parents ("x-org.example"
ddorwin
2016/02/25 20:43:30
Done.
| |
| 494 | 475 |
| 495 // Incomplete. | 476 // Incomplete. |
| 496 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clea")); | 477 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clea")); |
| 497 | 478 |
| 498 // Extra character. | 479 // Extra character. |
| 499 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clearz")); | 480 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clearz")); |
| 500 | 481 |
| 501 // There are no child key systems for UsesAes. | 482 // There are no child key systems for UsesAes. |
| 502 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.foo")); | 483 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.foo")); |
| 503 } | 484 } |
| 504 | 485 |
| 505 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { | 486 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { |
| 506 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 487 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 507 std::string(), no_codecs(), kUsesAes)); | 488 std::string(), no_codecs(), kUsesAes)); |
| 508 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 509 std::string(), no_codecs(), kUsesAesParent)); | |
| 510 | 489 |
| 511 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(std::string(), no_codecs(), | 490 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(std::string(), no_codecs(), |
| 512 "x-org.example.foo")); | 491 "x-org.example.foo")); |
| 513 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 492 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 514 std::string(), no_codecs(), "x-org.example.clear.foo")); | 493 std::string(), no_codecs(), "x-org.example.clear.foo")); |
| 515 } | 494 } |
| 516 | 495 |
| 517 // Tests the second registered container type. | 496 // Tests the second registered container type. |
| 518 // TODO(ddorwin): Combined with TypesContainer1 in a future CL. | 497 // TODO(ddorwin): Combined with TypesContainer1 in a future CL. |
| 519 TEST_F(KeySystemsTest, | 498 TEST_F(KeySystemsTest, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); | 551 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); |
| 573 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 552 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 574 kVideoWebM, no_codecs(), kExternal)); | 553 kVideoWebM, no_codecs(), kExternal)); |
| 575 | 554 |
| 576 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); | 555 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); |
| 577 #if defined(ENABLE_PEPPER_CDMS) | 556 #if defined(ENABLE_PEPPER_CDMS) |
| 578 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); | 557 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); |
| 579 #endif // defined(ENABLE_PEPPER_CDMS) | 558 #endif // defined(ENABLE_PEPPER_CDMS) |
| 580 } | 559 } |
| 581 | 560 |
| 582 TEST_F(KeySystemsTest, Parent_ParentRegistered) { | |
| 583 // Unprefixed has no parent key system support. | |
| 584 EXPECT_FALSE(IsSupportedKeySystem(kExternalParent)); | |
| 585 | |
| 586 // The parent is not supported for most things. | |
| 587 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kExternalParent)); | |
| 588 EXPECT_FALSE(CanUseAesDecryptor(kExternalParent)); | |
| 589 | |
| 590 #if defined(ENABLE_PEPPER_CDMS) | |
| 591 std::string type; | |
| 592 EXPECT_DEBUG_DEATH(type = GetPepperType(kExternalParent), | |
| 593 "x-com.example is not a known concrete system"); | |
| 594 EXPECT_TRUE(type.empty()); | |
| 595 #endif | |
| 596 } | |
| 597 | |
| 598 TEST_F( | 561 TEST_F( |
| 599 KeySystemsTest, | 562 KeySystemsTest, |
| 600 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { | 563 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { |
| 601 // Valid video types. | 564 // Valid video types. |
| 602 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 565 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 603 kVideoWebM, no_codecs(), kExternal)); | 566 kVideoWebM, no_codecs(), kExternal)); |
| 604 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 567 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 605 kVideoWebM, vp8_codec(), kExternal)); | 568 kVideoWebM, vp8_codec(), kExternal)); |
| 606 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 569 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 607 kVideoWebM, vp80_codec(), kExternal)); | 570 kVideoWebM, vp80_codec(), kExternal)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); | 715 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); |
| 753 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); | 716 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); |
| 754 | 717 |
| 755 EXPECT_FALSE(IsSupportedKeySystem("x-")); | 718 EXPECT_FALSE(IsSupportedKeySystem("x-")); |
| 756 EXPECT_TRUE(IsSupportedKeySystem("x-something")); | 719 EXPECT_TRUE(IsSupportedKeySystem("x-something")); |
| 757 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); | 720 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); |
| 758 EXPECT_FALSE(IsSupportedKeySystem("x-other")); | 721 EXPECT_FALSE(IsSupportedKeySystem("x-other")); |
| 759 } | 722 } |
| 760 | 723 |
| 761 } // namespace media | 724 } // namespace media |
| OLD | NEW |