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

Side by Side Diff: content/renderer/media/crypto/key_systems_unittest.cc

Issue 185993004: Encrypted Media: Confine UUID code to MediaDrmBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 9 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 | Annotate | Revision Log
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 #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/public/renderer/key_system_info.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 namespace content { 60 namespace content {
61 61
62 class TestContentRendererClient : public ContentRendererClient { 62 class TestContentRendererClient : public ContentRendererClient {
63 virtual void AddKeySystems( 63 virtual void AddKeySystems(
64 std::vector<content::KeySystemInfo>* key_systems) OVERRIDE; 64 std::vector<content::KeySystemInfo>* key_systems) OVERRIDE;
65 }; 65 };
66 66
67 void TestContentRendererClient::AddKeySystems( 67 void TestContentRendererClient::AddKeySystems(
68 std::vector<content::KeySystemInfo>* key_systems) { 68 std::vector<content::KeySystemInfo>* key_systems) {
69 #if defined(OS_ANDROID)
70 static const uint8 kExternalUuid[16] = {
71 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
72 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
73 #endif
74
75 KeySystemInfo aes(kUsesAes); 69 KeySystemInfo aes(kUsesAes);
76 70
77 aes.supported_types.push_back(std::make_pair(kAudioWebM, kWebMAudioCodecs)); 71 aes.supported_types.push_back(std::make_pair(kAudioWebM, kWebMAudioCodecs));
78 aes.supported_types.push_back(std::make_pair(kVideoWebM, kWebMVideoCodecs)); 72 aes.supported_types.push_back(std::make_pair(kVideoWebM, kWebMVideoCodecs));
79 73
80 aes.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); 74 aes.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs));
81 aes.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); 75 aes.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs));
82 76
83 aes.use_aes_decryptor = true; 77 aes.use_aes_decryptor = true;
84 78
85 key_systems->push_back(aes); 79 key_systems->push_back(aes);
86 80
87 KeySystemInfo ext(kExternal); 81 KeySystemInfo ext(kExternal);
88 82
89 ext.supported_types.push_back(std::make_pair(kAudioWebM, kWebMAudioCodecs)); 83 ext.supported_types.push_back(std::make_pair(kAudioWebM, kWebMAudioCodecs));
90 ext.supported_types.push_back(std::make_pair(kVideoWebM, kWebMVideoCodecs)); 84 ext.supported_types.push_back(std::make_pair(kVideoWebM, kWebMVideoCodecs));
91 85
92 ext.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); 86 ext.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs));
93 ext.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); 87 ext.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs));
94 88
95 ext.parent_key_system = kExternalParent; 89 ext.parent_key_system = kExternalParent;
96 90
97 #if defined(ENABLE_PEPPER_CDMS) 91 #if defined(ENABLE_PEPPER_CDMS)
98 ext.pepper_type = "application/x-ppapi-external-cdm"; 92 ext.pepper_type = "application/x-ppapi-external-cdm";
99 #elif defined(OS_ANDROID)
100 ext.uuid.assign(kExternalUuid, kExternalUuid + arraysize(kExternalUuid));
101 #endif // defined(ENABLE_PEPPER_CDMS) 93 #endif // defined(ENABLE_PEPPER_CDMS)
102 94
103 key_systems->push_back(ext); 95 key_systems->push_back(ext);
104 } 96 }
105 97
106 class KeySystemsTest : public testing::Test { 98 class KeySystemsTest : public testing::Test {
107 protected: 99 protected:
108 KeySystemsTest() { 100 KeySystemsTest() {
109 vp8_codec_.push_back("vp8"); 101 vp8_codec_.push_back("vp8");
110 102
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 CodecVector foovideo_and_fooaudio_codecs_; 179 CodecVector foovideo_and_fooaudio_codecs_;
188 180
189 CodecVector unknown_codec_; 181 CodecVector unknown_codec_;
190 182
191 CodecVector mixed_codecs_; 183 CodecVector mixed_codecs_;
192 184
193 TestContentClient test_content_client_; 185 TestContentClient test_content_client_;
194 TestContentRendererClient content_renderer_client_; 186 TestContentRendererClient content_renderer_client_;
195 }; 187 };
196 188
197 // TODO(ddorwin): Consider moving GetUUID() into these tests or moving 189 // TODO(ddorwin): Consider moving GetPepperType() calls out to their own test.
198 // GetPepperType() calls out to their own test.
199 190
200 TEST_F(KeySystemsTest, EmptyKeySystem) { 191 TEST_F(KeySystemsTest, EmptyKeySystem) {
201 EXPECT_FALSE(IsConcreteSupportedKeySystem(std::string())); 192 EXPECT_FALSE(IsConcreteSupportedKeySystem(std::string()));
202 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 193 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
203 kVideoWebM, no_codecs(), std::string())); 194 kVideoWebM, no_codecs(), std::string()));
204 EXPECT_EQ("Unknown", KeySystemNameForUMA(std::string())); 195 EXPECT_EQ("Unknown", KeySystemNameForUMA(std::string()));
205 } 196 }
206 197
207 // Clear Key is the only key system registered in content. 198 // Clear Key is the only key system registered in content.
208 TEST_F(KeySystemsTest, ClearKey) { 199 TEST_F(KeySystemsTest, ClearKey) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 556 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
566 kAudioFoo, foovideo_codec(), kExternal)); 557 kAudioFoo, foovideo_codec(), kExternal));
567 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 558 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
568 kAudioFoo, foovideo_and_fooaudio_codecs(), kExternal)); 559 kAudioFoo, foovideo_and_fooaudio_codecs(), kExternal));
569 560
570 // Non-container2 codec. 561 // Non-container2 codec.
571 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 562 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
572 kAudioFoo, vorbis_codec(), kExternal)); 563 kAudioFoo, vorbis_codec(), kExternal));
573 } 564 }
574 565
575 #if defined(OS_ANDROID)
576 TEST_F(KeySystemsTest, GetUUID_RegisteredExternalDecryptor) {
577 std::vector<uint8> uuid = GetUUID(kExternal);
578 EXPECT_EQ(16u, uuid.size());
579 EXPECT_EQ(0xef, uuid[15]);
580 }
581
582 TEST_F(KeySystemsTest, GetUUID_RegisteredAesDecryptor) {
583 EXPECT_TRUE(GetUUID(kUsesAes).empty());
584 }
585
586 TEST_F(KeySystemsTest, GetUUID_Unrecognized) {
587 std::vector<uint8> uuid;
588 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(kExternalParent),
589 "com.example is not a known concrete system");
590 EXPECT_TRUE(uuid.empty());
591
592 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(""), " is not a concrete system");
593 EXPECT_TRUE(uuid.empty());
594 }
595 #endif // defined(OS_ANDROID)
596
597 TEST_F(KeySystemsTest, KeySystemNameForUMA) { 566 TEST_F(KeySystemsTest, KeySystemNameForUMA) {
598 EXPECT_EQ("ClearKey", KeySystemNameForUMA(kClearKey)); 567 EXPECT_EQ("ClearKey", KeySystemNameForUMA(kClearKey));
599 // Prefixed is not supported internally. 568 // Prefixed is not supported internally.
600 EXPECT_EQ("Unknown", KeySystemNameForUMA(kPrefixedClearKey)); 569 EXPECT_EQ("Unknown", KeySystemNameForUMA(kPrefixedClearKey));
601 570
602 // External Clear Key never has a UMA name. 571 // External Clear Key never has a UMA name.
603 EXPECT_EQ("Unknown", KeySystemNameForUMA(kExternalClearKey)); 572 EXPECT_EQ("Unknown", KeySystemNameForUMA(kExternalClearKey));
604 573
605 #if defined(WIDEVINE_CDM_AVAILABLE) 574 #if defined(WIDEVINE_CDM_AVAILABLE)
606 const char* const kTestWidevineUmaName = "Widevine"; 575 const char* const kTestWidevineUmaName = "Widevine";
607 #else 576 #else
608 const char* const kTestWidevineUmaName = "Unknown"; 577 const char* const kTestWidevineUmaName = "Unknown";
609 #endif 578 #endif
610 EXPECT_EQ(kTestWidevineUmaName, KeySystemNameForUMA("com.widevine.alpha")); 579 EXPECT_EQ(kTestWidevineUmaName, KeySystemNameForUMA("com.widevine.alpha"));
611 } 580 }
612 581
613 } // namespace content 582 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698