Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: media/base/key_systems_unittest.cc

Issue 1732423002: EME: Remove the concept of a parent key system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ks
Patch Set: Add test per review. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/key_systems.cc ('k') | media/cdm/key_system_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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."));
474
475 // Prefix.
493 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.")); 476 EXPECT_FALSE(IsSupportedKeySystem("x-org.example."));
477 EXPECT_FALSE(IsSupportedKeySystem("x-org.example"));
494 478
495 // Incomplete. 479 // Incomplete.
496 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clea")); 480 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clea"));
497 481
498 // Extra character. 482 // Extra character.
499 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clearz")); 483 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clearz"));
500 484
501 // There are no child key systems for UsesAes. 485 // There are no child key systems for UsesAes.
502 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.foo")); 486 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.foo"));
503 } 487 }
504 488
505 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { 489 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) {
506 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 490 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
507 std::string(), no_codecs(), kUsesAes)); 491 std::string(), no_codecs(), kUsesAes));
508 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
509 std::string(), no_codecs(), kUsesAesParent));
510 492
511 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(std::string(), no_codecs(), 493 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(std::string(), no_codecs(),
512 "x-org.example.foo")); 494 "x-org.example.foo"));
513 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 495 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
514 std::string(), no_codecs(), "x-org.example.clear.foo")); 496 std::string(), no_codecs(), "x-org.example.clear.foo"));
515 } 497 }
516 498
517 // Tests the second registered container type. 499 // Tests the second registered container type.
518 // TODO(ddorwin): Combined with TypesContainer1 in a future CL. 500 // TODO(ddorwin): Combined with TypesContainer1 in a future CL.
519 TEST_F(KeySystemsTest, 501 TEST_F(KeySystemsTest,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); 554 EXPECT_TRUE(IsSupportedKeySystem(kExternal));
573 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 555 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
574 kVideoWebM, no_codecs(), kExternal)); 556 kVideoWebM, no_codecs(), kExternal));
575 557
576 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); 558 EXPECT_FALSE(CanUseAesDecryptor(kExternal));
577 #if defined(ENABLE_PEPPER_CDMS) 559 #if defined(ENABLE_PEPPER_CDMS)
578 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); 560 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal));
579 #endif // defined(ENABLE_PEPPER_CDMS) 561 #endif // defined(ENABLE_PEPPER_CDMS)
580 } 562 }
581 563
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( 564 TEST_F(
599 KeySystemsTest, 565 KeySystemsTest,
600 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { 566 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) {
601 // Valid video types. 567 // Valid video types.
602 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 568 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
603 kVideoWebM, no_codecs(), kExternal)); 569 kVideoWebM, no_codecs(), kExternal));
604 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 570 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
605 kVideoWebM, vp8_codec(), kExternal)); 571 kVideoWebM, vp8_codec(), kExternal));
606 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 572 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
607 kVideoWebM, vp80_codec(), kExternal)); 573 kVideoWebM, vp80_codec(), kExternal));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); 718 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else"));
753 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); 719 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other"));
754 720
755 EXPECT_FALSE(IsSupportedKeySystem("x-")); 721 EXPECT_FALSE(IsSupportedKeySystem("x-"));
756 EXPECT_TRUE(IsSupportedKeySystem("x-something")); 722 EXPECT_TRUE(IsSupportedKeySystem("x-something"));
757 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); 723 EXPECT_FALSE(IsSupportedKeySystem("x-something.else"));
758 EXPECT_FALSE(IsSupportedKeySystem("x-other")); 724 EXPECT_FALSE(IsSupportedKeySystem("x-other"));
759 } 725 }
760 726
761 } // namespace media 727 } // namespace media
OLDNEW
« no previous file with comments | « media/base/key_systems.cc ('k') | media/cdm/key_system_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698