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 #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/renderer/media/crypto/key_systems.h" | 11 #include "content/renderer/media/crypto/key_systems.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 13 | 14 |
| 14 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 15 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 15 | 16 |
| 16 // Death tests are not always available, including on Android. | 17 // Death tests are not always available, including on Android. |
| 17 // EXPECT_DEBUG_DEATH_PORTABLE executes tests correctly except in the case that | 18 // EXPECT_DEBUG_DEATH_PORTABLE executes tests correctly except in the case that |
| 18 // death tests are not available and NDEBUG is not defined. | 19 // death tests are not available and NDEBUG is not defined. |
| 19 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 20 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
| 20 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ | 21 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ |
| 21 EXPECT_DEBUG_DEATH(statement, regex) | 22 EXPECT_DEBUG_DEATH(statement, regex) |
| 22 #else | 23 #else |
| 23 #if defined(NDEBUG) | 24 #if defined(NDEBUG) |
| 24 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ | 25 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ |
| 25 do { statement; } while (false) | 26 do { statement; } while (false) |
| 26 #else | 27 #else |
| 27 #include "base/logging.h" | 28 #include "base/logging.h" |
| 28 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ | 29 #define EXPECT_DEBUG_DEATH_PORTABLE(statement, regex) \ |
| 29 LOG(WARNING) << "Death tests are not supported on this platform.\n" \ | 30 LOG(WARNING) << "Death tests are not supported on this platform.\n" \ |
| 30 << "Statement '" #statement "' cannot be verified."; | 31 << "Statement '" #statement "' cannot be verified."; |
| 31 #endif // defined(NDEBUG) | 32 #endif // defined(NDEBUG) |
| 32 #endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 33 #endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
| 33 | 34 |
| 34 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | |
| 35 defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 36 #include <gnu/libc-version.h> | |
| 37 #endif | |
| 38 | |
| 39 using WebKit::WebString; | 35 using WebKit::WebString; |
| 40 | 36 |
| 41 #if defined(USE_PROPRIETARY_CODECS) | 37 static const char* const kClear = "org.example.clear"; |
| 42 #define EXPECT_PROPRIETARY EXPECT_TRUE | 38 static const char* const kClearParent = "org.example"; // Not registered. |
| 43 #else | 39 static const char* const kTest = "com.example.test"; |
| 44 #define EXPECT_PROPRIETARY EXPECT_FALSE | 40 static const char* const kTestParent = "com.example"; |
|
xhwang
2013/09/11 20:38:55
It'll be nice to have better comment and naming. E
ddorwin
2013/09/12 22:35:40
Done. I tried to clarify these things.
| |
| 45 #endif | |
| 46 | 41 |
| 47 // Expectations for External Clear Key. | |
| 48 #if defined(ENABLE_PEPPER_CDMS) | |
| 49 #define EXPECT_ECK EXPECT_TRUE | |
| 50 #define EXPECT_ECKPROPRIETARY EXPECT_PROPRIETARY | |
| 51 #else | |
| 52 #define EXPECT_ECK EXPECT_FALSE | |
| 53 #define EXPECT_ECKPROPRIETARY EXPECT_FALSE | |
| 54 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 55 | 42 |
| 56 // Expectations for Widevine. | 43 static const char* const kClearKey = "webkit-org.w3.clearkey"; |
| 57 #if defined(WIDEVINE_CDM_AVAILABLE) | 44 static const char* const kExternalClearKey = "org.chromium.externalclearkey"; |
|
xhwang
2013/09/11 20:38:55
use "static const char Foo[]" to be consistent wit
ddorwin
2013/09/12 22:35:40
Done.
| |
| 58 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 59 // TODO(ddorwin): Remove after bots switch to Precise. | |
| 60 #define EXPECT_WV(a) \ | |
| 61 EXPECT_EQ((std::string(gnu_get_libc_version()) != "2.11.1"), (a)) | |
| 62 #else | |
| 63 // See http://crbug.com/237627. | |
| 64 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
| 65 #define EXPECT_WV EXPECT_FALSE | |
| 66 #else | |
| 67 #define EXPECT_WV EXPECT_TRUE | |
| 68 #endif // defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
| 69 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 70 | 45 |
| 71 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 46 static const char kAudioWebM[] = "audio/webm"; |
| 72 #define EXPECT_WVCENC EXPECT_TRUE | 47 static const char kVideoWebM[] = "video/webm"; |
| 48 static const char kVorbis[] = "vorbis"; | |
| 49 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; | |
| 73 | 50 |
| 74 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | 51 static const char kAudioFoo[] = "audio/foo"; |
| 75 #define EXPECT_WVAVC1 EXPECT_TRUE | 52 static const char kVideoFoo[] = "video/foo"; |
| 76 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | 53 static const char kFooAudioCodecs[] = "baraudio"; |
|
xhwang
2013/09/11 20:38:55
kBarAudioCodecs?
ddorwin
2013/09/12 22:35:40
It's the codecs for the Foo container. It makes mo
| |
| 77 #define EXPECT_WVAVC1AAC EXPECT_TRUE | 54 static const char kFooVideoCodecs[] = "baraudio,barvideo"; |
|
xhwang
2013/09/11 20:38:55
ditto
ddorwin
2013/09/12 22:35:40
Same
| |
| 78 #else | |
| 79 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
| 80 #endif // defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | |
| 81 #else // !defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | |
| 82 #define EXPECT_WVAVC1 EXPECT_FALSE | |
| 83 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
| 84 #endif // defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | |
| 85 | |
| 86 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | |
| 87 #define EXPECT_WVAAC EXPECT_TRUE | |
| 88 #else | |
| 89 #define EXPECT_WVAAC EXPECT_FALSE | |
| 90 #endif | |
| 91 | |
| 92 #else // !defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
| 93 #define EXPECT_WVCENC EXPECT_FALSE | |
| 94 #define EXPECT_WVAVC1 EXPECT_FALSE | |
| 95 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
| 96 #define EXPECT_WVAAC EXPECT_FALSE | |
| 97 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
| 98 | |
| 99 #else // !defined(WIDEVINE_CDM_AVAILABLE) | |
| 100 #define EXPECT_WV EXPECT_FALSE | |
| 101 #define EXPECT_WVCENC EXPECT_FALSE | |
| 102 #define EXPECT_WVAVC1 EXPECT_FALSE | |
| 103 #define EXPECT_WVAVC1AAC EXPECT_FALSE | |
| 104 #define EXPECT_WVAAC EXPECT_FALSE | |
| 105 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
| 106 | 55 |
| 107 namespace content { | 56 namespace content { |
| 108 | 57 |
| 109 static const char* const kClearKey = "webkit-org.w3.clearkey"; | 58 class TestContentRendererClient : public ContentRendererClient { |
| 110 static const char* const kExternalClearKey = "org.chromium.externalclearkey"; | 59 virtual void AddKeySystems( |
| 111 static const char* const kWidevine = "com.widevine"; | 60 std::vector<content::KeySystemInfo>* key_systems) OVERRIDE; |
| 112 static const char* const kWidevineAlpha = "com.widevine.alpha"; | 61 }; |
| 62 | |
| 63 void TestContentRendererClient::AddKeySystems( | |
| 64 std::vector<content::KeySystemInfo>* key_systems) { | |
| 65 #if defined(OS_ANDROID) | |
| 66 static const uint8 kTestUuid[16] = { | |
| 67 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, | |
| 68 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }; | |
| 69 #endif | |
| 70 | |
| 71 KeySystemInfo clear(kClear); | |
| 72 | |
| 73 clear.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); | |
| 74 clear.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); | |
| 75 | |
| 76 clear.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); | |
| 77 clear.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); | |
| 78 | |
| 79 clear.use_aes_decryptor = true; | |
| 80 | |
| 81 key_systems->push_back(clear); | |
| 82 | |
| 83 KeySystemInfo test(kTest); | |
| 84 | |
| 85 test.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); | |
| 86 test.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); | |
| 87 | |
| 88 test.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); | |
| 89 test.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); | |
| 90 | |
| 91 test.parent_key_system = kTestParent; | |
| 92 | |
| 93 #if defined(ENABLE_PEPPER_CDMS) | |
| 94 test.pepper_type = "application/x-ppapi-test-cdm"; | |
| 95 #elif defined(OS_ANDROID) | |
| 96 test.uuid.assign(kTestUuid, kTestUuid + arraysize(kTestUuid)); | |
| 97 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 98 | |
| 99 key_systems->push_back(test); | |
| 100 } | |
| 113 | 101 |
| 114 class KeySystemsTest : public testing::Test { | 102 class KeySystemsTest : public testing::Test { |
| 115 protected: | 103 protected: |
| 116 KeySystemsTest() { | 104 KeySystemsTest() { |
| 117 vp8_codec_.push_back("vp8"); | 105 vp8_codec_.push_back("vp8"); |
| 118 | 106 |
| 119 vp80_codec_.push_back("vp8.0"); | 107 vp80_codec_.push_back("vp8.0"); |
| 120 | 108 |
| 121 vorbis_codec_.push_back("vorbis"); | 109 vorbis_codec_.push_back("vorbis"); |
| 122 | 110 |
| 123 vp8_and_vorbis_codecs_.push_back("vp8"); | 111 vp8_and_vorbis_codecs_.push_back("vp8"); |
| 124 vp8_and_vorbis_codecs_.push_back("vorbis"); | 112 vp8_and_vorbis_codecs_.push_back("vorbis"); |
| 125 | 113 |
| 126 avc1_codec_.push_back("avc1"); | 114 barvideo_codec_.push_back("barvideo"); |
| 127 | 115 |
| 128 avc1_extended_codec_.push_back("avc1.4D400C"); | 116 barvideo_extended_codec_.push_back("barvideo.4D400C"); |
| 129 | 117 |
| 130 avc1_dot_codec_.push_back("avc1."); | 118 barvideo_dot_codec_.push_back("barvideo."); |
| 131 | 119 |
| 132 avc2_codec_.push_back("avc2"); | 120 baraudio_codec_.push_back("baraudio"); |
|
xhwang
2013/09/11 20:38:55
When should we use baraudio_codec_ and when should
ddorwin
2013/09/12 22:35:40
kFooAudioCodecs is the codecs supported by that co
| |
| 133 | 121 |
| 134 aac_codec_.push_back("mp4a"); | 122 barvideo_and_baraudio_codecs_.push_back("barvideo"); |
| 123 barvideo_and_baraudio_codecs_.push_back("baraudio"); | |
| 135 | 124 |
| 136 avc1_and_aac_codecs_.push_back("avc1"); | 125 unknown_codec_.push_back("unknown"); |
| 137 avc1_and_aac_codecs_.push_back("mp4a"); | |
| 138 | |
| 139 unknown_codec_.push_back("foo"); | |
| 140 | 126 |
| 141 mixed_codecs_.push_back("vorbis"); | 127 mixed_codecs_.push_back("vorbis"); |
| 142 mixed_codecs_.push_back("avc1"); | 128 mixed_codecs_.push_back("barvideo"); |
| 143 | 129 |
| 144 SetRendererClientForTesting(&content_renderer_client_); | 130 SetRendererClientForTesting(&content_renderer_client_); |
| 145 } | 131 } |
| 146 | 132 |
| 147 typedef std::vector<std::string> CodecVector; | 133 typedef std::vector<std::string> CodecVector; |
| 148 | 134 |
| 149 const CodecVector& no_codecs() const { return no_codecs_; } | 135 const CodecVector& no_codecs() const { return no_codecs_; } |
| 150 | 136 |
| 151 const CodecVector& vp8_codec() const { return vp8_codec_; } | 137 const CodecVector& vp8_codec() const { return vp8_codec_; } |
| 152 const CodecVector& vp80_codec() const { return vp80_codec_; } | 138 const CodecVector& vp80_codec() const { return vp80_codec_; } |
| 153 const CodecVector& vorbis_codec() const { return vorbis_codec_; } | 139 const CodecVector& vorbis_codec() const { return vorbis_codec_; } |
| 154 const CodecVector& vp8_and_vorbis_codecs() const { | 140 const CodecVector& vp8_and_vorbis_codecs() const { |
| 155 return vp8_and_vorbis_codecs_; | 141 return vp8_and_vorbis_codecs_; |
| 156 } | 142 } |
| 157 | 143 |
| 158 const CodecVector& avc1_codec() const { return avc1_codec_; } | 144 const CodecVector& barvideo_codec() const { return barvideo_codec_; } |
| 159 const CodecVector& avc1_extended_codec() const { | 145 const CodecVector& barvideo_extended_codec() const { |
| 160 return avc1_extended_codec_; | 146 return barvideo_extended_codec_; |
| 161 } | 147 } |
| 162 const CodecVector& avc1_dot_codec() const { return avc1_dot_codec_; } | 148 const CodecVector& barvideo_dot_codec() const { return barvideo_dot_codec_; } |
| 163 const CodecVector& avc2_codec() const { return avc2_codec_; } | 149 const CodecVector& baraudio_codec() const { return baraudio_codec_; } |
| 164 const CodecVector& aac_codec() const { return aac_codec_; } | 150 const CodecVector& barvideo_and_baraudio_codecs() const { |
| 165 const CodecVector& avc1_and_aac_codecs() const { | 151 return barvideo_and_baraudio_codecs_; |
| 166 return avc1_and_aac_codecs_; | |
| 167 } | 152 } |
| 168 | 153 |
| 169 const CodecVector& unknown_codec() const { return unknown_codec_; } | 154 const CodecVector& unknown_codec() const { return unknown_codec_; } |
| 170 | 155 |
| 171 const CodecVector& mixed_codecs() const { return mixed_codecs_; } | 156 const CodecVector& mixed_codecs() const { return mixed_codecs_; } |
| 172 | 157 |
| 173 private: | 158 private: |
| 174 const CodecVector no_codecs_; | 159 const CodecVector no_codecs_; |
| 175 | 160 |
| 176 CodecVector vp8_codec_; | 161 CodecVector vp8_codec_; |
| 177 CodecVector vp80_codec_; | 162 CodecVector vp80_codec_; |
| 178 CodecVector vorbis_codec_; | 163 CodecVector vorbis_codec_; |
| 179 CodecVector vp8_and_vorbis_codecs_; | 164 CodecVector vp8_and_vorbis_codecs_; |
| 180 | 165 |
| 181 CodecVector avc1_codec_; | 166 CodecVector barvideo_codec_; |
| 182 CodecVector avc1_extended_codec_; | 167 CodecVector barvideo_extended_codec_; |
| 183 CodecVector avc1_dot_codec_; | 168 CodecVector barvideo_dot_codec_; |
| 184 CodecVector avc2_codec_; | 169 CodecVector baraudio_codec_; |
| 185 CodecVector aac_codec_; | 170 CodecVector barvideo_and_baraudio_codecs_; |
| 186 CodecVector avc1_and_aac_codecs_; | |
| 187 | 171 |
| 188 CodecVector unknown_codec_; | 172 CodecVector unknown_codec_; |
| 189 | 173 |
| 190 CodecVector mixed_codecs_; | 174 CodecVector mixed_codecs_; |
| 191 | 175 |
| 192 ContentRendererClient content_renderer_client_; | 176 TestContentRendererClient content_renderer_client_; |
| 193 }; | 177 }; |
| 194 | 178 |
| 195 TEST_F(KeySystemsTest, ClearKey_Basic) { | 179 // TODO(ddorwin): Consider moving GetUUID() into these tests or moving |
| 196 EXPECT_TRUE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKey))); | 180 // GetPepperType() calls out to their own test. |
| 197 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 181 |
| 198 "video/webm", no_codecs(), kClearKey)); | 182 TEST_F(KeySystemsTest, ClearKeyNotRegistered) { |
| 183 // Not registered in content. | |
| 184 EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKey))); | |
| 185 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 186 kVideoWebM, no_codecs(), kClearKey)); | |
| 187 | |
| 188 EXPECT_STREQ("ClearKey", | |
| 189 KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str()); | |
|
xhwang
2013/09/11 20:38:55
This pattern is used in a lot of times, worth wrap
ddorwin
2013/09/12 22:35:40
I want to keep the comparison here for failure rea
| |
| 199 | 190 |
| 200 // Not yet out from behind the vendor prefix. | 191 // Not yet out from behind the vendor prefix. |
| 201 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.w3.clearkey")); | 192 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.w3.clearkey")); |
|
xhwang
2013/09/11 20:38:55
I see both
IsConcreteSupportedKeySystem("org.w3.
ddorwin
2013/09/12 22:35:40
The difference was unprefixed vs. prefixed. I've n
| |
| 202 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 193 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 203 "video/webm", no_codecs(), "org.w3.clearkey")); | 194 kVideoWebM, no_codecs(), "org.w3.clearkey")); |
| 204 | 195 EXPECT_STREQ( |
| 205 EXPECT_STREQ("ClearKey", | 196 "Unknown", |
| 206 KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str()); | 197 KeySystemNameForUMA(WebString::fromUTF8("org.w3.clearkey")).c_str()); |
| 207 | 198 |
|
xhwang
2013/09/11 20:38:55
drop empty line.
ddorwin
2013/09/12 22:35:40
Done.
| |
| 208 EXPECT_TRUE(CanUseAesDecryptor(kClearKey)); | 199 } |
| 200 | |
| 201 TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) { | |
| 202 static const char* const kUnrecognized = "org.example.unrecognized"; | |
| 203 | |
| 204 EXPECT_FALSE( | |
| 205 IsConcreteSupportedKeySystem(WebString::fromUTF8(kUnrecognized))); | |
| 206 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 207 kVideoWebM, no_codecs(), kUnrecognized)); | |
| 208 | |
| 209 EXPECT_STREQ( | |
| 210 "Unknown", | |
| 211 KeySystemNameForUMA(WebString::fromUTF8(kUnrecognized)).c_str()); | |
| 212 | |
| 213 bool can_use = false; | |
| 214 EXPECT_DEBUG_DEATH(can_use = CanUseAesDecryptor(kUnrecognized), | |
| 215 "org.example.unrecognized is not a known concrete system"); | |
| 216 EXPECT_FALSE(can_use); | |
| 217 | |
| 209 #if defined(ENABLE_PEPPER_CDMS) | 218 #if defined(ENABLE_PEPPER_CDMS) |
| 210 std::string type; | 219 std::string type; |
| 211 EXPECT_DEBUG_DEATH(type = GetPepperType(kClearKey), | 220 EXPECT_DEBUG_DEATH(type = GetPepperType(kUnrecognized), |
| 212 "webkit-org.w3.clearkey is not Pepper-based"); | 221 "org.example.unrecognized is not a known concrete system"); |
| 213 EXPECT_TRUE(type.empty()); | 222 EXPECT_TRUE(type.empty()); |
| 214 #endif | 223 #endif |
| 215 } | 224 } |
| 216 | 225 |
| 217 TEST_F(KeySystemsTest, ClearKey_Parent) { | 226 TEST_F(KeySystemsTest, Basic_UsesAesDecryptor) { |
| 218 const char* const kClearKeyParent = "webkit-org.w3"; | 227 EXPECT_TRUE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClear))); |
| 219 | 228 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 220 // The parent should be supported but is not. See http://crbug.com/164303. | 229 kVideoWebM, no_codecs(), kClear)); |
| 221 EXPECT_FALSE( | 230 |
| 222 IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKeyParent))); | 231 // No UMA value for this test key system. |
| 223 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 232 EXPECT_STREQ("Unknown", |
| 224 "video/webm", no_codecs(), kClearKeyParent)); | 233 KeySystemNameForUMA(WebString::fromUTF8(kClear)).c_str()); |
| 234 | |
| 235 EXPECT_TRUE(CanUseAesDecryptor(kClear)); | |
| 236 #if defined(ENABLE_PEPPER_CDMS) | |
| 237 std::string type; | |
| 238 EXPECT_DEBUG_DEATH(type = GetPepperType(kClear), | |
| 239 "org.example.clear is not Pepper-based"); | |
| 240 EXPECT_TRUE(type.empty()); | |
| 241 #endif | |
| 242 } | |
| 243 | |
| 244 TEST_F(KeySystemsTest, | |
| 245 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) { | |
| 246 // Valid video types. | |
| 247 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 248 kVideoWebM, vp8_codec(), kClear)); | |
| 249 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 250 kVideoWebM, vp80_codec(), kClear)); | |
| 251 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 252 kVideoWebM, vp8_and_vorbis_codecs(), kClear)); | |
| 253 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 254 kVideoWebM, vorbis_codec(), kClear)); | |
| 255 | |
| 256 // Non-Webm codecs. | |
| 257 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 258 kVideoWebM, barvideo_codec(), kClear)); | |
| 259 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 260 kVideoWebM, unknown_codec(), kClear)); | |
| 261 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 262 kVideoWebM, mixed_codecs(), kClear)); | |
| 263 | |
| 264 // Valid audio types. | |
| 265 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 266 kAudioWebM, no_codecs(), kClear)); | |
| 267 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 268 kAudioWebM, vorbis_codec(), kClear)); | |
| 269 | |
| 270 // Non-audio codecs. | |
| 271 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 272 kAudioWebM, vp8_codec(), kClear)); | |
| 273 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 274 kAudioWebM, vp8_and_vorbis_codecs(), kClear)); | |
| 275 | |
| 276 // Non-Webm codec. | |
| 277 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 278 kAudioWebM, baraudio_codec(), kClear)); | |
| 279 } | |
| 280 | |
| 281 // No parent is registered for Clear. | |
| 282 TEST_F(KeySystemsTest, Parent_NoParentRegistered) { | |
| 283 EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearParent))); | |
| 284 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 285 kVideoWebM, no_codecs(), kClearParent)); | |
| 225 | 286 |
| 226 // The parent is not supported for most things. | 287 // The parent is not supported for most things. |
| 227 EXPECT_STREQ("Unknown", | 288 EXPECT_STREQ( |
| 228 KeySystemNameForUMA(WebString::fromUTF8(kClearKeyParent)).c_str()); | 289 "Unknown", |
| 290 KeySystemNameForUMA(WebString::fromUTF8(kClearParent)).c_str()); | |
| 229 bool result = false; | 291 bool result = false; |
| 230 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kClearKeyParent), | 292 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kClearParent), |
| 231 "webkit-org.w3 is not a known concrete system"); | 293 "org.example is not a known concrete system"); |
|
xhwang
2013/09/11 20:38:55
nit: is there a way to use kClearParent in the log
ddorwin
2013/09/12 22:35:40
I think it would require #defining the constant so
| |
| 232 EXPECT_FALSE(result); | 294 EXPECT_FALSE(result); |
| 233 #if defined(ENABLE_PEPPER_CDMS) | 295 #if defined(ENABLE_PEPPER_CDMS) |
| 234 std::string type; | 296 std::string type; |
| 235 EXPECT_DEBUG_DEATH(type = GetPepperType(kClearKeyParent), | 297 EXPECT_DEBUG_DEATH(type = GetPepperType(kClearParent), |
| 236 "webkit-org.w3 is not a known concrete system"); | 298 "org.example is not a known concrete system"); |
| 237 EXPECT_TRUE(type.empty()); | 299 EXPECT_TRUE(type.empty()); |
| 238 #endif | 300 #endif |
| 239 } | 301 } |
| 240 | 302 |
| 241 TEST_F(KeySystemsTest, ClearKey_IsSupportedKeySystem_InvalidVariants) { | 303 TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) { |
| 242 // Case sensitive. | 304 // Case sensitive. |
| 243 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.ClEaRkEy")); | 305 EXPECT_FALSE( |
| 244 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 306 IsConcreteSupportedKeySystem(WebString::fromUTF8("org.example.ClEaR"))); |
| 245 "video/webm", no_codecs(), "webkit-org.w3.ClEaRkEy")); | 307 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 308 kVideoWebM, no_codecs(), "org.example.ClEaR")); | |
| 246 | 309 |
| 247 // TLDs are not allowed. | 310 // TLDs are not allowed. |
| 248 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.")); | |
| 249 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 250 "video/webm", no_codecs(), "webkit-org.")); | |
| 251 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org")); | |
| 252 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 253 "video/webm", no_codecs(), "webkit-org")); | |
| 254 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); | 311 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); |
| 255 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 312 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 256 "video/webm", no_codecs(), "org.")); | 313 kVideoWebM, no_codecs(), "org.")); |
| 257 EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); | 314 EXPECT_FALSE(IsConcreteSupportedKeySystem("com")); |
| 258 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 315 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 259 "video/webm", no_codecs(), "org")); | 316 kVideoWebM, no_codecs(), "com")); |
| 260 | 317 |
| 261 // Extra period. | 318 // Extra period. |
| 262 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.")); | 319 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.")); |
| 263 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 320 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 264 "video/webm", no_codecs(), "webkit-org.w3.")); | 321 kVideoWebM, no_codecs(), "org.example.")); |
| 265 | 322 |
| 266 // Incomplete. | 323 // Incomplete. |
| 267 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearke")); | 324 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clea")); |
| 268 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 325 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 269 "video/webm", no_codecs(), "webkit-org.w3.clearke")); | 326 kVideoWebM, no_codecs(), "org.example.clea")); |
| 270 | 327 |
| 271 // Extra character. | 328 // Extra character. |
| 272 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkeyz")); | 329 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clearz")); |
| 273 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 330 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 274 "video/webm", no_codecs(), "webkit-org.w3.clearkeyz")); | 331 kVideoWebM, no_codecs(), "org.example.clearz")); |
| 275 | 332 |
| 276 // There are no child key systems for Clear Key. | 333 // There are no child key systems for Clear Key. |
| 277 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkey.foo")); | 334 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clear.foo")); |
| 278 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 335 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 279 "video/webm", no_codecs(), "webkit-org.w3.clearkey.foo")); | 336 kVideoWebM, no_codecs(), "org.example.clear.foo")); |
| 280 } | 337 } |
| 281 | 338 |
| 282 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_NoType) { | 339 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { |
| 283 // These two should be true. See http://crbug.com/164303. | 340 // These two should be true. See http://crbug.com/164303. |
| 284 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 341 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 285 std::string(), no_codecs(), kClearKey)); | 342 std::string(), no_codecs(), kClear)); |
| 286 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 343 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 287 std::string(), no_codecs(), "webkit-org.w3")); | 344 std::string(), no_codecs(), kClearParent)); |
| 288 | 345 |
| 289 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 346 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 290 std::string(), no_codecs(), "webkit-org.w3.foo")); | 347 std::string(), no_codecs(), "org.example.foo")); |
| 291 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 348 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 292 std::string(), no_codecs(), "webkit-org.w3.clearkey.foo")); | 349 std::string(), no_codecs(), "org.example.clear.foo")); |
| 293 } | 350 } |
| 294 | 351 |
| 295 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_WebM) { | 352 // Tests the second registered container type. |
| 353 // TODO(ddorwin): Combined with TypesContainer1 in a future CL. | |
| 354 TEST_F(KeySystemsTest, | |
| 355 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer2) { | |
| 296 // Valid video types. | 356 // Valid video types. |
| 297 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 357 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 298 "video/webm", no_codecs(), kClearKey)); | 358 kVideoFoo, no_codecs(), kClear)); |
| 299 // The parent should be supported but is not. See http://crbug.com/164303. | 359 // The parent should be supported but is not. See http://crbug.com/164303. |
| 300 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 360 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 301 "video/webm", no_codecs(), "webkit-org.w3")); | 361 kVideoFoo, no_codecs(), kClearParent)); |
| 302 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 362 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 303 "video/webm", vp8_codec(), kClearKey)); | 363 kVideoFoo, barvideo_codec(), kClear)); |
| 304 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 364 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 305 "video/webm", vp80_codec(), kClearKey)); | 365 kVideoFoo, barvideo_and_baraudio_codecs(), kClear)); |
| 306 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 366 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 307 "video/webm", vp8_and_vorbis_codecs(), kClearKey)); | 367 kVideoFoo, baraudio_codec(), kClear)); |
| 308 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 309 "video/webm", vorbis_codec(), kClearKey)); | |
| 310 | |
| 311 // Non-Webm codecs. | |
| 312 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 313 "video/webm", avc1_codec(), kClearKey)); | |
| 314 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 315 "video/webm", unknown_codec(), kClearKey)); | |
| 316 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 317 "video/webm", mixed_codecs(), kClearKey)); | |
| 318 | |
| 319 // Valid audio types. | |
| 320 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 321 "audio/webm", no_codecs(), kClearKey)); | |
| 322 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 323 "audio/webm", vorbis_codec(), kClearKey)); | |
| 324 | |
| 325 // Non-audio codecs. | |
| 326 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 327 "audio/webm", vp8_codec(), kClearKey)); | |
| 328 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 329 "audio/webm", vp8_and_vorbis_codecs(), kClearKey)); | |
| 330 | |
| 331 // Non-Webm codec. | |
| 332 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 333 "audio/webm", aac_codec(), kClearKey)); | |
| 334 } | |
| 335 | |
| 336 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_MP4) { | |
| 337 // Valid video types. | |
| 338 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
| 339 "video/mp4", no_codecs(), kClearKey)); | |
| 340 // The parent should be supported but is not. See http://crbug.com/164303. | |
| 341 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 342 "video/mp4", no_codecs(), "webkit-org.w3")); | |
| 343 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
| 344 "video/mp4", avc1_codec(), kClearKey)); | |
| 345 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
| 346 "video/mp4", avc1_and_aac_codecs(), kClearKey)); | |
| 347 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | |
| 348 "video/mp4", aac_codec(), kClearKey)); | |
| 349 | 368 |
| 350 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | 369 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
| 351 // They should really pass canPlayType(). | 370 // They should really pass canPlayType(). |
| 352 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 371 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 353 "video/mp4", avc1_extended_codec(), kClearKey)); | 372 kVideoFoo, barvideo_extended_codec(), kClear)); |
| 354 | 373 |
| 355 // Invalid codec format. | 374 // Invalid codec format. |
| 356 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 375 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 357 "video/mp4", avc1_dot_codec(), kClearKey)); | 376 kVideoFoo, barvideo_dot_codec(), kClear)); |
| 358 | 377 |
| 359 // Non-MP4 codecs. | 378 // Non-container2 codec. |
| 360 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 379 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 361 "video/mp4", avc2_codec(), kClearKey)); | 380 kVideoFoo, vp8_codec(), kClear)); |
| 362 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 381 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 363 "video/mp4", vp8_codec(), kClearKey)); | 382 kVideoFoo, unknown_codec(), kClear)); |
| 364 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 383 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 365 "video/mp4", unknown_codec(), kClearKey)); | 384 kVideoFoo, mixed_codecs(), kClear)); |
| 366 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 367 "video/mp4", mixed_codecs(), kClearKey)); | |
| 368 | 385 |
| 369 // Valid audio types. | 386 // Valid audio types. |
| 370 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 387 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 371 "audio/mp4", no_codecs(), kClearKey)); | 388 kAudioFoo, no_codecs(), kClear)); |
| 372 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 389 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 373 "audio/mp4", aac_codec(), kClearKey)); | 390 kAudioFoo, baraudio_codec(), kClear)); |
| 374 | 391 |
| 375 // Non-audio codecs. | 392 // Non-audio codecs. |
| 376 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 393 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 377 "audio/mp4", avc1_codec(), kClearKey)); | 394 kAudioFoo, barvideo_codec(), kClear)); |
| 378 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 395 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 379 "audio/mp4", avc1_and_aac_codecs(), kClearKey)); | 396 kAudioFoo, barvideo_and_baraudio_codecs(), kClear)); |
| 380 | 397 |
| 381 // Non-MP4 codec. | 398 // Non-container2 codec. |
| 382 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 399 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 383 "audio/mp4", vorbis_codec(), kClearKey)); | 400 kAudioFoo, vorbis_codec(), kClear)); |
| 384 } | 401 } |
| 385 | 402 |
| 386 // | 403 // |
| 387 // External Clear Key | 404 // Non-AesDecryptor-based key system. |
| 388 // | 405 // |
| 389 | 406 |
| 390 TEST_F(KeySystemsTest, ExternalClearKey_Basic) { | 407 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { |
| 391 EXPECT_ECK( | 408 EXPECT_TRUE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kTest))); |
| 392 IsConcreteSupportedKeySystem(WebString::fromUTF8(kExternalClearKey))); | 409 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 393 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 410 kVideoWebM, no_codecs(), kTest)); |
| 394 "video/webm", no_codecs(), kExternalClearKey)); | 411 |
| 395 | 412 EXPECT_FALSE(CanUseAesDecryptor(kTest)); |
| 396 // External Clear Key does not have a UMA name because it is for testing. | |
| 397 EXPECT_STREQ( | |
| 398 "Unknown", | |
| 399 KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str()); | |
| 400 | |
| 401 #if defined(ENABLE_PEPPER_CDMS) | 413 #if defined(ENABLE_PEPPER_CDMS) |
| 402 EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKey)); | 414 EXPECT_STREQ("application/x-ppapi-test-cdm", |
| 403 EXPECT_STREQ("application/x-ppapi-clearkey-cdm", | 415 GetPepperType(kTest).c_str()); |
| 404 GetPepperType(kExternalClearKey).c_str()); | 416 #endif // defined(ENABLE_PEPPER_CDMS) |
| 405 #else | 417 |
| 418 } | |
| 419 | |
| 420 TEST_F(KeySystemsTest, Parent_ParentRegistered) { | |
| 421 // The parent system is not a concrete system but is supported. | |
| 422 EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kTestParent))); | |
| 423 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 424 kVideoWebM, no_codecs(), kTestParent)); | |
| 425 | |
| 426 // The parent is not supported for most things. | |
| 427 EXPECT_STREQ( | |
| 428 "Unknown", | |
| 429 KeySystemNameForUMA(WebString::fromUTF8(kTestParent)).c_str()); | |
| 406 bool result = false; | 430 bool result = false; |
| 407 EXPECT_DEBUG_DEATH_PORTABLE( | 431 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kTestParent), |
| 408 result = CanUseAesDecryptor(kExternalClearKey), | 432 "com.example is not a known concrete system"); |
| 409 "org.chromium.externalclearkey is not a known concrete system"); | |
| 410 EXPECT_FALSE(result); | |
| 411 #endif | |
| 412 } | |
| 413 | |
| 414 TEST_F(KeySystemsTest, ExternalClearKey_Parent) { | |
| 415 const char* const kExternalClearKeyParent = "org.chromium"; | |
| 416 | |
| 417 // The parent should be supported but is not. See http://crbug.com/164303. | |
| 418 EXPECT_FALSE(IsConcreteSupportedKeySystem( | |
| 419 WebString::fromUTF8(kExternalClearKeyParent))); | |
| 420 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 421 "video/webm", no_codecs(), kExternalClearKeyParent)); | |
| 422 | |
| 423 // The parent is not supported for most things. | |
| 424 EXPECT_STREQ("Unknown", | |
| 425 KeySystemNameForUMA( | |
| 426 WebString::fromUTF8(kExternalClearKeyParent)).c_str()); | |
| 427 bool result = false; | |
| 428 EXPECT_DEBUG_DEATH_PORTABLE( | |
| 429 result = CanUseAesDecryptor(kExternalClearKeyParent), | |
| 430 "org.chromium is not a known concrete system"); | |
| 431 EXPECT_FALSE(result); | 433 EXPECT_FALSE(result); |
| 432 #if defined(ENABLE_PEPPER_CDMS) | 434 #if defined(ENABLE_PEPPER_CDMS) |
| 433 std::string type; | 435 std::string type; |
| 434 EXPECT_DEBUG_DEATH(type = GetPepperType(kExternalClearKeyParent), | 436 EXPECT_DEBUG_DEATH(type = GetPepperType(kTestParent), |
| 435 "org.chromium is not a known concrete system"); | 437 "com.example is not a known concrete system"); |
| 436 EXPECT_TRUE(type.empty()); | 438 EXPECT_TRUE(type.empty()); |
| 437 #endif | 439 #endif |
| 438 } | 440 } |
| 439 | 441 |
| 440 TEST_F(KeySystemsTest, ExternalClearKey_IsSupportedKeySystem_InvalidVariants) { | 442 TEST_F( |
| 441 // Case sensitive. | 443 KeySystemsTest, |
| 442 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy")); | 444 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { |
| 443 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 444 "video/webm", no_codecs(), | |
| 445 "org.chromium.ExTeRnAlClEaRkEy")); | |
| 446 | |
| 447 // TLDs are not allowed. | |
| 448 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); | |
| 449 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 450 "video/webm", no_codecs(), "org.")); | |
| 451 EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); | |
| 452 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 453 "video/webm", no_codecs(), "org")); | |
| 454 | |
| 455 // Extra period. | |
| 456 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.")); | |
| 457 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 458 "video/webm", no_codecs(), "org.chromium.")); | |
| 459 | |
| 460 // Incomplete. | |
| 461 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearke")); | |
| 462 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 463 "video/webm", no_codecs(), | |
| 464 "org.chromium.externalclearke")); | |
| 465 | |
| 466 // Extra character. | |
| 467 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearkeyz")); | |
| 468 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 469 "video/webm", no_codecs(), | |
| 470 "org.chromium.externalclearkeyz")); | |
| 471 | |
| 472 // There are no child key systems for Clear Key. | |
| 473 EXPECT_FALSE( | |
| 474 IsConcreteSupportedKeySystem("org.chromium.externalclearkey.foo")); | |
| 475 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 476 "video/webm", no_codecs(), | |
| 477 "org.chromium.externalclearkey.foo")); | |
| 478 } | |
| 479 | |
| 480 TEST_F(KeySystemsTest, | |
| 481 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_NoType) { | |
| 482 // These two should be true. See http://crbug.com/164303. | |
| 483 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 484 std::string(), no_codecs(), kExternalClearKey)); | |
| 485 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 486 std::string(), no_codecs(), "org.chromium")); | |
| 487 | |
| 488 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 489 std::string(), no_codecs(), "org.chromium.foo")); | |
| 490 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 491 std::string(), no_codecs(), "org.chromium.externalclearkey.foo")); | |
| 492 } | |
| 493 | |
| 494 TEST_F(KeySystemsTest, | |
| 495 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_WebM) { | |
| 496 // Valid video types. | 445 // Valid video types. |
| 497 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 446 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 498 "video/webm", no_codecs(), kExternalClearKey)); | 447 kVideoWebM, no_codecs(), kTest)); |
| 499 // The parent should be supported but is not. See http://crbug.com/164303. | 448 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 500 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 449 kVideoWebM, vp8_codec(), kTest)); |
| 501 "video/webm", no_codecs(), "org.chromium")); | 450 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 502 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 451 kVideoWebM, vp80_codec(), kTest)); |
| 503 "video/webm", vp8_codec(), kExternalClearKey)); | 452 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 504 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 453 kVideoWebM, vp8_and_vorbis_codecs(), kTest)); |
| 505 "video/webm", vp80_codec(), kExternalClearKey)); | 454 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 506 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 455 kVideoWebM, vorbis_codec(), kTest)); |
| 507 "video/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); | 456 |
| 508 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 457 // Valid video types - parent key system. |
| 509 "video/webm", vorbis_codec(), kExternalClearKey)); | 458 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 459 kVideoWebM, no_codecs(), kTestParent)); | |
| 460 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 461 kVideoWebM, vp8_codec(), kTestParent)); | |
| 462 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 463 kVideoWebM, vp80_codec(), kTestParent)); | |
| 464 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 465 kVideoWebM, vp8_and_vorbis_codecs(), kTestParent)); | |
| 466 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 467 kVideoWebM, vorbis_codec(), kTestParent)); | |
| 510 | 468 |
| 511 // Non-Webm codecs. | 469 // Non-Webm codecs. |
| 512 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 470 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 513 "video/webm", avc1_codec(), kExternalClearKey)); | 471 kVideoWebM, barvideo_codec(), kTest)); |
| 514 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 472 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 515 "video/webm", unknown_codec(), kExternalClearKey)); | 473 kVideoWebM, unknown_codec(), kTest)); |
| 516 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 474 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 517 "video/webm", mixed_codecs(), kExternalClearKey)); | 475 kVideoWebM, mixed_codecs(), kTest)); |
| 518 | 476 |
| 519 // Valid audio types. | 477 // Valid audio types. |
| 520 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 478 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 521 "audio/webm", no_codecs(), kExternalClearKey)); | 479 kAudioWebM, no_codecs(), kTest)); |
| 522 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( | 480 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 523 "audio/webm", vorbis_codec(), kExternalClearKey)); | 481 kAudioWebM, vorbis_codec(), kTest)); |
| 482 | |
| 483 // Valid audio types - parent key system. | |
| 484 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 485 kAudioWebM, no_codecs(), kTestParent)); | |
| 486 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 487 kAudioWebM, vorbis_codec(), kTestParent)); | |
| 524 | 488 |
| 525 // Non-audio codecs. | 489 // Non-audio codecs. |
| 526 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 490 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 527 "audio/webm", vp8_codec(), kExternalClearKey)); | 491 kAudioWebM, vp8_codec(), kTest)); |
| 528 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 492 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 529 "audio/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); | 493 kAudioWebM, vp8_and_vorbis_codecs(), kTest)); |
| 530 | 494 |
| 531 // Non-Webm codec. | 495 // Non-Webm codec. |
| 532 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 496 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 533 "audio/webm", aac_codec(), kExternalClearKey)); | 497 kAudioWebM, baraudio_codec(), kTest)); |
| 534 } | 498 } |
| 535 | 499 |
| 536 TEST_F(KeySystemsTest, | 500 TEST_F( |
| 537 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_MP4) { | 501 KeySystemsTest, |
| 502 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { | |
| 538 // Valid video types. | 503 // Valid video types. |
| 539 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 504 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 540 "video/mp4", no_codecs(), kExternalClearKey)); | 505 kVideoFoo, no_codecs(), kTest)); |
| 541 // The parent should be supported but is not. See http://crbug.com/164303. | 506 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 542 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 507 kVideoFoo, barvideo_codec(), kTest)); |
| 543 "video/mp4", no_codecs(), "org.chromium")); | 508 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 544 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 509 kVideoFoo, barvideo_and_baraudio_codecs(), kTest)); |
| 545 "video/mp4", avc1_codec(), kExternalClearKey)); | 510 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 546 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 511 kVideoFoo, baraudio_codec(), kTest)); |
| 547 "video/mp4", avc1_and_aac_codecs(), kExternalClearKey)); | 512 |
| 548 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 513 // Valid video types - parent key system. |
| 549 "video/mp4", aac_codec(), kExternalClearKey)); | 514 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 515 kVideoFoo, no_codecs(), kTestParent)); | |
| 516 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 517 kVideoFoo, barvideo_codec(), kTestParent)); | |
| 518 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 519 kVideoFoo, barvideo_and_baraudio_codecs(), kTestParent)); | |
| 520 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 521 kVideoFoo, baraudio_codec(), kTestParent)); | |
| 550 | 522 |
| 551 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | 523 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
| 552 // They should really pass canPlayType(). | 524 // They should really pass canPlayType(). |
| 553 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 525 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 554 "video/mp4", avc1_extended_codec(), kExternalClearKey)); | 526 kVideoFoo, barvideo_extended_codec(), kTest)); |
| 555 | 527 |
| 556 // Invalid codec format. | 528 // Invalid codec format. |
| 557 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 529 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 558 "video/mp4", avc1_dot_codec(), kExternalClearKey)); | 530 kVideoFoo, barvideo_dot_codec(), kTest)); |
| 559 | 531 |
| 560 // Non-MP4 codecs. | 532 // Non-container2 codecs. |
| 561 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 533 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 562 "video/mp4", avc2_codec(), kExternalClearKey)); | 534 kVideoFoo, vp8_codec(), kTest)); |
| 563 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 535 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 564 "video/mp4", vp8_codec(), kExternalClearKey)); | 536 kVideoFoo, unknown_codec(), kTest)); |
| 565 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 537 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 566 "video/mp4", unknown_codec(), kExternalClearKey)); | 538 kVideoFoo, mixed_codecs(), kTest)); |
| 567 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 568 "video/mp4", mixed_codecs(), kExternalClearKey)); | |
| 569 | 539 |
| 570 // Valid audio types. | 540 // Valid audio types. |
| 571 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 541 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 572 "audio/mp4", no_codecs(), kExternalClearKey)); | 542 kAudioFoo, no_codecs(), kTest)); |
| 573 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( | 543 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 574 "audio/mp4", aac_codec(), kExternalClearKey)); | 544 kAudioFoo, baraudio_codec(), kTest)); |
| 545 | |
| 546 // Valid audio types - parent key system. | |
| 547 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 548 kAudioFoo, no_codecs(), kTestParent)); | |
| 549 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 550 kAudioFoo, baraudio_codec(), kTestParent)); | |
| 575 | 551 |
| 576 // Non-audio codecs. | 552 // Non-audio codecs. |
| 577 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 553 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 578 "audio/mp4", avc1_codec(), kExternalClearKey)); | 554 kAudioFoo, barvideo_codec(), kTest)); |
| 579 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 555 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 580 "audio/mp4", avc1_and_aac_codecs(), kExternalClearKey)); | 556 kAudioFoo, barvideo_and_baraudio_codecs(), kTest)); |
| 581 | 557 |
| 582 // Non-MP4 codec. | 558 // Non-container2 codec. |
| 583 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 559 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 584 "audio/mp4", vorbis_codec(), kExternalClearKey)); | 560 kAudioFoo, vorbis_codec(), kTest)); |
| 585 } | |
| 586 | |
| 587 // | |
| 588 // Widevine | |
| 589 // | |
| 590 | |
| 591 TEST_F(KeySystemsTest, Widevine_Basic) { | |
| 592 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | |
| 593 defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
| 594 EXPECT_TRUE( | |
| 595 IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha))); | |
| 596 #else | |
| 597 EXPECT_WV(IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha))); | |
| 598 #endif | |
| 599 | |
| 600 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 601 "video/webm", no_codecs(), kWidevineAlpha)); | |
| 602 | |
| 603 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 604 const char* const kWidevineUmaName = "Widevine"; | |
| 605 #else | |
| 606 const char* const kWidevineUmaName = "Unknown"; | |
| 607 #endif | |
| 608 EXPECT_STREQ( | |
| 609 kWidevineUmaName, | |
| 610 KeySystemNameForUMA(WebString::fromUTF8(kWidevineAlpha)).c_str()); | |
| 611 | |
| 612 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 613 EXPECT_FALSE(CanUseAesDecryptor(kWidevineAlpha)); | |
| 614 #else | |
| 615 bool result = false; | |
| 616 EXPECT_DEBUG_DEATH_PORTABLE( | |
| 617 result = CanUseAesDecryptor(kWidevineAlpha), | |
| 618 "com.widevine.alpha is not a known concrete system"); | |
| 619 EXPECT_FALSE(result); | |
| 620 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
| 621 | |
| 622 #if defined(ENABLE_PEPPER_CDMS) | |
| 623 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 624 EXPECT_STREQ("application/x-ppapi-widevine-cdm", | |
| 625 GetPepperType(kWidevineAlpha).c_str()); | |
| 626 #else | |
| 627 std::string type; | |
| 628 EXPECT_DEBUG_DEATH(type = GetPepperType(kWidevineAlpha), | |
| 629 "com.widevine.alpha is not a known concrete system"); | |
| 630 EXPECT_TRUE(type.empty()); | |
| 631 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
| 632 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 633 | |
| 634 } | |
| 635 | |
| 636 TEST_F(KeySystemsTest, Widevine_Parent) { | |
| 637 // The parent system is not a concrete system but is supported. | |
| 638 EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevine))); | |
| 639 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 640 "video/webm", no_codecs(), kWidevine)); | |
| 641 | |
| 642 // The parent is not supported for most things. | |
| 643 EXPECT_STREQ("Unknown", | |
| 644 KeySystemNameForUMA(WebString::fromUTF8(kWidevine)).c_str()); | |
| 645 bool result = false; | |
| 646 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kWidevine), | |
| 647 "com.widevine is not a known concrete system"); | |
| 648 EXPECT_FALSE(result); | |
| 649 #if defined(ENABLE_PEPPER_CDMS) | |
| 650 std::string type; | |
| 651 EXPECT_DEBUG_DEATH(type = GetPepperType(kWidevine), | |
| 652 "com.widevine is not a known concrete system"); | |
| 653 EXPECT_TRUE(type.empty()); | |
| 654 #endif | |
| 655 } | |
| 656 | |
| 657 TEST_F(KeySystemsTest, Widevine_IsSupportedKeySystem_InvalidVariants) { | |
| 658 // Case sensitive. | |
| 659 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.AlPhA")); | |
| 660 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 661 "video/webm", no_codecs(), "com.widevine.AlPhA")); | |
| 662 | |
| 663 // TLDs are not allowed. | |
| 664 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.")); | |
| 665 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 666 "video/webm", no_codecs(), "com.")); | |
| 667 EXPECT_FALSE(IsConcreteSupportedKeySystem("com")); | |
| 668 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 669 "video/webm", no_codecs(), "com")); | |
| 670 | |
| 671 // Extra period. | |
| 672 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.")); | |
| 673 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 674 "video/webm", no_codecs(), "com.widevine.")); | |
| 675 | |
| 676 // Incomplete. | |
| 677 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alph")); | |
| 678 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 679 "video/webm", no_codecs(), "com.widevine.alph")); | |
| 680 | |
| 681 // Extra character. | |
| 682 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alphab")); | |
| 683 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 684 "video/webm", no_codecs(), "com.widevine.alphab")); | |
| 685 | |
| 686 // There are no child key systems for Widevine Alpha. | |
| 687 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alpha.foo")); | |
| 688 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 689 "video/webm", no_codecs(), "com.widevine.alpha.foo")); | |
| 690 } | |
| 691 | |
| 692 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_NoType) { | |
| 693 // These two should be true. See http://crbug.com/164303. | |
| 694 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 695 std::string(), no_codecs(), kWidevineAlpha)); | |
| 696 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 697 std::string(), no_codecs(), kWidevine)); | |
| 698 | |
| 699 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 700 std::string(), no_codecs(), "com.widevine.foo")); | |
| 701 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 702 std::string(), no_codecs(), "com.widevine.alpha.foo")); | |
| 703 } | |
| 704 | |
| 705 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) { | |
| 706 // Valid video types. | |
| 707 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 708 "video/webm", no_codecs(), kWidevineAlpha)); | |
| 709 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 710 "video/webm", vp8_codec(), kWidevineAlpha)); | |
| 711 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 712 "video/webm", vp80_codec(), kWidevineAlpha)); | |
| 713 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 714 "video/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); | |
| 715 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 716 "video/webm", vorbis_codec(), kWidevineAlpha)); | |
| 717 | |
| 718 // Valid video types - parent key system. | |
| 719 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 720 "video/webm", no_codecs(), kWidevine)); | |
| 721 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 722 "video/webm", vp8_codec(), kWidevine)); | |
| 723 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 724 "video/webm", vp80_codec(), kWidevine)); | |
| 725 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 726 "video/webm", vp8_and_vorbis_codecs(), kWidevine)); | |
| 727 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 728 "video/webm", vorbis_codec(), kWidevine)); | |
| 729 | |
| 730 // Non-Webm codecs. | |
| 731 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 732 "video/webm", avc1_codec(), kWidevineAlpha)); | |
| 733 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 734 "video/webm", unknown_codec(), kWidevineAlpha)); | |
| 735 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 736 "video/webm", mixed_codecs(), kWidevineAlpha)); | |
| 737 | |
| 738 // Valid audio types. | |
| 739 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 740 "audio/webm", no_codecs(), kWidevineAlpha)); | |
| 741 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 742 "audio/webm", vorbis_codec(), kWidevineAlpha)); | |
| 743 | |
| 744 // Valid audio types - parent key system. | |
| 745 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 746 "audio/webm", no_codecs(), kWidevine)); | |
| 747 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( | |
| 748 "audio/webm", vorbis_codec(), kWidevine)); | |
| 749 | |
| 750 // Non-audio codecs. | |
| 751 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 752 "audio/webm", vp8_codec(), kWidevineAlpha)); | |
| 753 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 754 "audio/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); | |
| 755 | |
| 756 // Non-Webm codec. | |
| 757 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 758 "audio/webm", aac_codec(), kWidevineAlpha)); | |
| 759 } | |
| 760 | |
| 761 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) { | |
| 762 // Valid video types. | |
| 763 EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( | |
| 764 "video/mp4", no_codecs(), kWidevineAlpha)); | |
| 765 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( | |
| 766 "video/mp4", avc1_codec(), kWidevineAlpha)); | |
| 767 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
| 768 "video/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); | |
| 769 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
| 770 "video/mp4", aac_codec(), kWidevineAlpha)); | |
| 771 | |
| 772 // Valid video types - parent key system. | |
| 773 EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( | |
| 774 "video/mp4", no_codecs(), kWidevine)); | |
| 775 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( | |
| 776 "video/mp4", avc1_codec(), kWidevine)); | |
| 777 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
| 778 "video/mp4", avc1_and_aac_codecs(), kWidevine)); | |
| 779 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( | |
| 780 "video/mp4", aac_codec(), kWidevine)); | |
| 781 | |
| 782 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | |
| 783 // They should really pass canPlayType(). | |
| 784 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 785 "video/mp4", avc1_extended_codec(), kWidevineAlpha)); | |
| 786 | |
| 787 // Invalid codec format. | |
| 788 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 789 "video/mp4", avc1_dot_codec(), kWidevineAlpha)); | |
| 790 | |
| 791 // Non-MP4 codecs. | |
| 792 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 793 "video/mp4", avc2_codec(), kWidevineAlpha)); | |
| 794 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 795 "video/mp4", vp8_codec(), kWidevineAlpha)); | |
| 796 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 797 "video/mp4", unknown_codec(), kWidevineAlpha)); | |
| 798 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 799 "video/mp4", mixed_codecs(), kWidevineAlpha)); | |
| 800 | |
| 801 // Valid audio types. | |
| 802 EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( | |
| 803 "audio/mp4", no_codecs(), kWidevineAlpha)); | |
| 804 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( | |
| 805 "audio/mp4", aac_codec(), kWidevineAlpha)); | |
| 806 | |
| 807 // Valid audio types - parent key system. | |
| 808 EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( | |
| 809 "audio/mp4", no_codecs(), kWidevine)); | |
| 810 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( | |
| 811 "audio/mp4", aac_codec(), kWidevine)); | |
| 812 | |
| 813 // Non-audio codecs. | |
| 814 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 815 "audio/mp4", avc1_codec(), kWidevineAlpha)); | |
| 816 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 817 "audio/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); | |
| 818 | |
| 819 // Non-MP4 codec. | |
| 820 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 821 "audio/mp4", vorbis_codec(), kWidevineAlpha)); | |
| 822 } | 561 } |
| 823 | 562 |
| 824 #if defined(OS_ANDROID) | 563 #if defined(OS_ANDROID) |
| 825 TEST_F(KeySystemsTest, GetUUID_Widevine) { | 564 TEST_F(KeySystemsTest, GetUUID_RegisteredExternalDecryptor) { |
| 826 #if defined(WIDEVINE_CDM_AVAILABLE) | 565 std::vector<uint8> uuid = GetUUID(kTest); |
| 827 std::vector<uint8> uuid = GetUUID(kWidevineAlpha); | |
| 828 EXPECT_EQ(16u, uuid.size()); | 566 EXPECT_EQ(16u, uuid.size()); |
| 829 EXPECT_EQ(0xED, uuid[15]); | 567 EXPECT_EQ(0xef, uuid[15]); |
| 830 #else | 568 } |
| 831 std::vector<uint8> uuid; | 569 |
| 832 EXPECT_DEBUG_DEATH_PORTABLE( | 570 TEST_F(KeySystemsTest, GetUUID_RegisteredAesDecryptor) { |
| 833 uuid = GetUUID(kWidevineAlpha), | 571 EXPECT_TRUE(GetUUID(kClear).empty()); |
| 834 "com.widevine.alpha is not a known concrete system"); | |
| 835 EXPECT_TRUE(uuid.empty()); | |
| 836 #endif | |
| 837 } | 572 } |
| 838 | 573 |
| 839 TEST_F(KeySystemsTest, GetUUID_Unrecognized) { | 574 TEST_F(KeySystemsTest, GetUUID_Unrecognized) { |
| 840 std::vector<uint8> uuid; | 575 std::vector<uint8> uuid; |
| 841 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(kWidevine), | 576 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(kTestParent), |
| 842 "com.widevine is not a known concrete system"); | 577 "com.example is not a known concrete system"); |
| 843 EXPECT_TRUE(uuid.empty()); | 578 EXPECT_TRUE(uuid.empty()); |
| 844 | 579 |
| 845 EXPECT_TRUE(GetUUID(kClearKey).empty()); | |
| 846 | |
| 847 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(""), " is not a concrete system"); | 580 EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(""), " is not a concrete system"); |
| 848 EXPECT_TRUE(uuid.empty()); | 581 EXPECT_TRUE(uuid.empty()); |
| 849 } | 582 } |
| 850 #endif // defined(OS_ANDROID) | 583 #endif // defined(OS_ANDROID) |
| 851 | 584 |
| 585 TEST_F(KeySystemsTest, KeySystemNameForUMA) { | |
| 586 EXPECT_STREQ("ClearKey", | |
| 587 KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str()); | |
| 588 // Unprefixed is not yet supported. | |
| 589 EXPECT_STREQ( | |
| 590 "Unknown", | |
| 591 KeySystemNameForUMA(WebString::fromUTF8("org.w3.clearkey")).c_str()); | |
| 592 | |
| 593 // External Clear Key never has a UMA name. | |
| 594 EXPECT_STREQ( | |
| 595 "Unknown", | |
| 596 KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str()); | |
| 597 | |
| 598 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 599 const char* const kTestWidevineUmaName = "Widevine"; | |
| 600 #else | |
| 601 const char* const kTestWidevineUmaName = "Unknown"; | |
| 602 #endif | |
| 603 EXPECT_STREQ( | |
| 604 kTestWidevineUmaName, | |
| 605 KeySystemNameForUMA(WebString::fromUTF8("com.widevine.alpha")).c_str()); | |
| 606 } | |
| 607 | |
| 852 } // namespace content | 608 } // namespace content |
| OLD | NEW |