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

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

Issue 1840173004: Flip unified media pipeline to default-on w/ disabled holdback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Comments. Fix UMA. Created 4 years, 8 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 | « content/browser/renderer_host/render_process_host_impl.cc ('k') | media/base/media.cc » ('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.h"
19 #include "media/base/media_client.h" 20 #include "media/base/media_client.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace media { 23 namespace media {
23 24
24 // These are the (fake) key systems that are registered for these tests. 25 // These are the (fake) key systems that are registered for these tests.
25 // kUsesAes uses the AesDecryptor like Clear Key. 26 // kUsesAes uses the AesDecryptor like Clear Key.
26 // kExternal uses an external CDM, such as Pepper-based or Android platform CDM. 27 // kExternal uses an external CDM, such as Pepper-based or Android platform CDM.
27 const char kUsesAes[] = "x-org.example.clear"; 28 const char kUsesAes[] = "x-org.example.clear";
28 const char kUseAesNameForUMA[] = "UseAes"; 29 const char kUseAesNameForUMA[] = "UseAes";
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return; 92 return;
92 93
93 AddCodecMask(EmeMediaType::AUDIO, "fooaudio", TEST_CODEC_FOO_AUDIO); 94 AddCodecMask(EmeMediaType::AUDIO, "fooaudio", TEST_CODEC_FOO_AUDIO);
94 AddCodecMask(EmeMediaType::VIDEO, "foovideo", TEST_CODEC_FOO_VIDEO); 95 AddCodecMask(EmeMediaType::VIDEO, "foovideo", TEST_CODEC_FOO_VIDEO);
95 AddMimeTypeCodecMask("audio/foo", TEST_CODEC_FOO_AUDIO_ALL); 96 AddMimeTypeCodecMask("audio/foo", TEST_CODEC_FOO_AUDIO_ALL);
96 AddMimeTypeCodecMask("video/foo", TEST_CODEC_FOO_VIDEO_ALL); 97 AddMimeTypeCodecMask("video/foo", TEST_CODEC_FOO_VIDEO_ALL);
97 98
98 is_test_masks_added = true; 99 is_test_masks_added = true;
99 } 100 }
100 101
102 static bool CanRunExternalKeySystemTests() {
103 #if defined(OS_ANDROID)
104 if (HasPlatformDecoderSupport())
105 return true;
106
107 EXPECT_FALSE(IsSupportedKeySystem(kExternal));
108 return false;
109 #else
110 return true;
111 #endif
112 }
113
101 class TestMediaClient : public MediaClient { 114 class TestMediaClient : public MediaClient {
102 public: 115 public:
103 TestMediaClient(); 116 TestMediaClient();
104 ~TestMediaClient() override; 117 ~TestMediaClient() override;
105 118
106 // MediaClient implementation. 119 // MediaClient implementation.
107 void AddKeySystemsInfoForUMA( 120 void AddKeySystemsInfoForUMA(
108 std::vector<KeySystemInfoForUMA>* key_systems_info_for_uma) final; 121 std::vector<KeySystemInfoForUMA>* key_systems_info_for_uma) final;
109 bool IsKeySystemsUpdateNeeded() final; 122 bool IsKeySystemsUpdateNeeded() final;
110 void AddSupportedKeySystems( 123 void AddSupportedKeySystems(
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 // Non-container2 codec. 556 // Non-container2 codec.
544 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( 557 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType(
545 kAudioFoo, vorbis_codec(), kUsesAes)); 558 kAudioFoo, vorbis_codec(), kUsesAes));
546 } 559 }
547 560
548 // 561 //
549 // Non-AesDecryptor-based key system. 562 // Non-AesDecryptor-based key system.
550 // 563 //
551 564
552 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { 565 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) {
566 if (!CanRunExternalKeySystemTests())
567 return;
568
553 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); 569 EXPECT_TRUE(IsSupportedKeySystem(kExternal));
554 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 570 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
555 kVideoWebM, no_codecs(), kExternal)); 571 kVideoWebM, no_codecs(), kExternal));
556 572
557 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); 573 EXPECT_FALSE(CanUseAesDecryptor(kExternal));
558 #if defined(ENABLE_PEPPER_CDMS) 574 #if defined(ENABLE_PEPPER_CDMS)
559 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); 575 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal));
560 #endif // defined(ENABLE_PEPPER_CDMS) 576 #endif // defined(ENABLE_PEPPER_CDMS)
561 } 577 }
562 578
563 TEST_F( 579 TEST_F(
564 KeySystemsTest, 580 KeySystemsTest,
565 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { 581 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) {
582 if (!CanRunExternalKeySystemTests())
583 return;
584
566 // Valid video types. 585 // Valid video types.
567 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 586 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
568 kVideoWebM, no_codecs(), kExternal)); 587 kVideoWebM, no_codecs(), kExternal));
569 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 588 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
570 kVideoWebM, vp8_codec(), kExternal)); 589 kVideoWebM, vp8_codec(), kExternal));
571 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 590 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
572 kVideoWebM, vp80_codec(), kExternal)); 591 kVideoWebM, vp80_codec(), kExternal));
573 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 592 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
574 kVideoWebM, vp9_codec(), kExternal)); 593 kVideoWebM, vp9_codec(), kExternal));
575 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 594 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 kAudioWebM, vp9_and_vorbis_codecs(), kExternal)); 627 kAudioWebM, vp9_and_vorbis_codecs(), kExternal));
609 628
610 // Non-Webm codec. 629 // Non-Webm codec.
611 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( 630 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType(
612 kAudioWebM, fooaudio_codec(), kExternal)); 631 kAudioWebM, fooaudio_codec(), kExternal));
613 } 632 }
614 633
615 TEST_F( 634 TEST_F(
616 KeySystemsTest, 635 KeySystemsTest,
617 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { 636 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) {
637 if (!CanRunExternalKeySystemTests())
638 return;
639
618 // Valid video types. 640 // Valid video types.
619 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 641 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
620 kVideoFoo, no_codecs(), kExternal)); 642 kVideoFoo, no_codecs(), kExternal));
621 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 643 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
622 kVideoFoo, foovideo_codec(), kExternal)); 644 kVideoFoo, foovideo_codec(), kExternal));
623 645
624 // Audio in a video container. 646 // Audio in a video container.
625 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 647 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
626 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternal)); 648 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternal));
627 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 649 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
(...skipping 30 matching lines...) Expand all
658 680
659 // Non-container2 codec. 681 // Non-container2 codec.
660 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( 682 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType(
661 kAudioFoo, vorbis_codec(), kExternal)); 683 kAudioFoo, vorbis_codec(), kExternal));
662 } 684 }
663 685
664 TEST_F(KeySystemsTest, KeySystemNameForUMA) { 686 TEST_F(KeySystemsTest, KeySystemNameForUMA) {
665 EXPECT_EQ("ClearKey", GetKeySystemNameForUMA(kClearKey)); 687 EXPECT_EQ("ClearKey", GetKeySystemNameForUMA(kClearKey));
666 688
667 // External Clear Key never has a UMA name. 689 // External Clear Key never has a UMA name.
668 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kExternalClearKey)); 690 if (CanRunExternalKeySystemTests())
691 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kExternalClearKey));
669 } 692 }
670 693
671 TEST_F(KeySystemsTest, KeySystemsUpdate) { 694 TEST_F(KeySystemsTest, KeySystemsUpdate) {
672 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); 695 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes));
673 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 696 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
674 kVideoWebM, no_codecs(), kUsesAes)); 697 kVideoWebM, no_codecs(), kUsesAes));
675 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); 698
676 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 699 if (CanRunExternalKeySystemTests()) {
677 kVideoWebM, no_codecs(), kExternal)); 700 EXPECT_TRUE(IsSupportedKeySystem(kExternal));
701 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(kVideoWebM, no_codecs(),
702 kExternal));
703 }
678 704
679 UpdateClientKeySystems(); 705 UpdateClientKeySystems();
680 706
681 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); 707 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes));
682 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 708 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
683 kVideoWebM, no_codecs(), kUsesAes)); 709 kVideoWebM, no_codecs(), kUsesAes));
684 EXPECT_FALSE(IsSupportedKeySystem(kExternal)); 710 if (CanRunExternalKeySystemTests())
711 EXPECT_FALSE(IsSupportedKeySystem(kExternal));
685 } 712 }
686 713
687 TEST_F(KeySystemsPotentiallySupportedNamesTest, PotentiallySupportedNames) { 714 TEST_F(KeySystemsPotentiallySupportedNamesTest, PotentiallySupportedNames) {
688 EXPECT_FALSE(IsSupportedKeySystem("org.w3")); 715 EXPECT_FALSE(IsSupportedKeySystem("org.w3"));
689 EXPECT_FALSE(IsSupportedKeySystem("org.w3.")); 716 EXPECT_FALSE(IsSupportedKeySystem("org.w3."));
690 EXPECT_FALSE(IsSupportedKeySystem("org.w3.clearke")); 717 EXPECT_FALSE(IsSupportedKeySystem("org.w3.clearke"));
691 EXPECT_TRUE(IsSupportedKeySystem("org.w3.clearkey")); 718 EXPECT_TRUE(IsSupportedKeySystem("org.w3.clearkey"));
692 EXPECT_FALSE(IsSupportedKeySystem("org.w3.clearkeys")); 719 EXPECT_FALSE(IsSupportedKeySystem("org.w3.clearkeys"));
693 720
694 EXPECT_FALSE(IsSupportedKeySystem("com.widevine")); 721 EXPECT_FALSE(IsSupportedKeySystem("com.widevine"));
(...skipping 22 matching lines...) Expand all
717 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); 744 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else"));
718 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); 745 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other"));
719 746
720 EXPECT_FALSE(IsSupportedKeySystem("x-")); 747 EXPECT_FALSE(IsSupportedKeySystem("x-"));
721 EXPECT_TRUE(IsSupportedKeySystem("x-something")); 748 EXPECT_TRUE(IsSupportedKeySystem("x-something"));
722 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); 749 EXPECT_FALSE(IsSupportedKeySystem("x-something.else"));
723 EXPECT_FALSE(IsSupportedKeySystem("x-other")); 750 EXPECT_FALSE(IsSupportedKeySystem("x-other"));
724 } 751 }
725 752
726 } // namespace media 753 } // namespace media
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | media/base/media.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698