Index: content/renderer/media/crypto/key_systems_unittest.cc |
diff --git a/content/renderer/media/crypto/key_systems_unittest.cc b/content/renderer/media/crypto/key_systems_unittest.cc |
index aef3fc5b279c60d9b753d3b77debb8774733923a..82e83589635325f037f821a4ebb9a875619b3758 100644 |
--- a/content/renderer/media/crypto/key_systems_unittest.cc |
+++ b/content/renderer/media/crypto/key_systems_unittest.cc |
@@ -7,6 +7,7 @@ |
#include "content/public/common/content_client.h" |
#include "content/public/renderer/content_renderer_client.h" |
+#include "content/public/renderer/key_system_info.h" |
#include "content/renderer/media/crypto/key_systems.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/WebKit/public/platform/WebString.h" |
@@ -31,85 +32,72 @@ |
#endif // defined(NDEBUG) |
#endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
-#if defined(WIDEVINE_CDM_AVAILABLE) && \ |
- defined(OS_LINUX) && !defined(OS_CHROMEOS) |
-#include <gnu/libc-version.h> |
-#endif |
- |
using WebKit::WebString; |
-#if defined(USE_PROPRIETARY_CODECS) |
-#define EXPECT_PROPRIETARY EXPECT_TRUE |
-#else |
-#define EXPECT_PROPRIETARY EXPECT_FALSE |
-#endif |
+static const char* const kClear = "org.example.clear"; |
+static const char* const kClearParent = "org.example"; // Not registered. |
+static const char* const kTest = "com.example.test"; |
+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.
|
-// Expectations for External Clear Key. |
-#if defined(ENABLE_PEPPER_CDMS) |
-#define EXPECT_ECK EXPECT_TRUE |
-#define EXPECT_ECKPROPRIETARY EXPECT_PROPRIETARY |
-#else |
-#define EXPECT_ECK EXPECT_FALSE |
-#define EXPECT_ECKPROPRIETARY EXPECT_FALSE |
-#endif // defined(ENABLE_PEPPER_CDMS) |
-// Expectations for Widevine. |
-#if defined(WIDEVINE_CDM_AVAILABLE) |
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
-// TODO(ddorwin): Remove after bots switch to Precise. |
-#define EXPECT_WV(a) \ |
- EXPECT_EQ((std::string(gnu_get_libc_version()) != "2.11.1"), (a)) |
-#else |
-// See http://crbug.com/237627. |
-#if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) |
-#define EXPECT_WV EXPECT_FALSE |
-#else |
-#define EXPECT_WV EXPECT_TRUE |
-#endif // defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) |
-#endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
+static const char* const kClearKey = "webkit-org.w3.clearkey"; |
+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.
|
-#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
-#define EXPECT_WVCENC EXPECT_TRUE |
+static const char kAudioWebM[] = "audio/webm"; |
+static const char kVideoWebM[] = "video/webm"; |
+static const char kVorbis[] = "vorbis"; |
+static const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; |
-#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
-#define EXPECT_WVAVC1 EXPECT_TRUE |
-#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
-#define EXPECT_WVAVC1AAC EXPECT_TRUE |
-#else |
-#define EXPECT_WVAVC1AAC EXPECT_FALSE |
-#endif // defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
-#else // !defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
-#define EXPECT_WVAVC1 EXPECT_FALSE |
-#define EXPECT_WVAVC1AAC EXPECT_FALSE |
-#endif // defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
- |
-#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
-#define EXPECT_WVAAC EXPECT_TRUE |
-#else |
-#define EXPECT_WVAAC EXPECT_FALSE |
+static const char kAudioFoo[] = "audio/foo"; |
+static const char kVideoFoo[] = "video/foo"; |
+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
|
+static const char kFooVideoCodecs[] = "baraudio,barvideo"; |
xhwang
2013/09/11 20:38:55
ditto
ddorwin
2013/09/12 22:35:40
Same
|
+ |
+namespace content { |
+ |
+class TestContentRendererClient : public ContentRendererClient { |
+ virtual void AddKeySystems( |
+ std::vector<content::KeySystemInfo>* key_systems) OVERRIDE; |
+}; |
+ |
+void TestContentRendererClient::AddKeySystems( |
+ std::vector<content::KeySystemInfo>* key_systems) { |
+#if defined(OS_ANDROID) |
+ static const uint8 kTestUuid[16] = { |
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, |
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }; |
#endif |
-#else // !defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
-#define EXPECT_WVCENC EXPECT_FALSE |
-#define EXPECT_WVAVC1 EXPECT_FALSE |
-#define EXPECT_WVAVC1AAC EXPECT_FALSE |
-#define EXPECT_WVAAC EXPECT_FALSE |
-#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
- |
-#else // !defined(WIDEVINE_CDM_AVAILABLE) |
-#define EXPECT_WV EXPECT_FALSE |
-#define EXPECT_WVCENC EXPECT_FALSE |
-#define EXPECT_WVAVC1 EXPECT_FALSE |
-#define EXPECT_WVAVC1AAC EXPECT_FALSE |
-#define EXPECT_WVAAC EXPECT_FALSE |
-#endif // defined(WIDEVINE_CDM_AVAILABLE) |
+ KeySystemInfo clear(kClear); |
-namespace content { |
+ clear.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
+ clear.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
-static const char* const kClearKey = "webkit-org.w3.clearkey"; |
-static const char* const kExternalClearKey = "org.chromium.externalclearkey"; |
-static const char* const kWidevine = "com.widevine"; |
-static const char* const kWidevineAlpha = "com.widevine.alpha"; |
+ clear.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); |
+ clear.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); |
+ |
+ clear.use_aes_decryptor = true; |
+ |
+ key_systems->push_back(clear); |
+ |
+ KeySystemInfo test(kTest); |
+ |
+ test.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
+ test.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
+ |
+ test.supported_types.push_back(std::make_pair(kAudioFoo, kFooAudioCodecs)); |
+ test.supported_types.push_back(std::make_pair(kVideoFoo, kFooVideoCodecs)); |
+ |
+ test.parent_key_system = kTestParent; |
+ |
+#if defined(ENABLE_PEPPER_CDMS) |
+ test.pepper_type = "application/x-ppapi-test-cdm"; |
+#elif defined(OS_ANDROID) |
+ test.uuid.assign(kTestUuid, kTestUuid + arraysize(kTestUuid)); |
+#endif // defined(ENABLE_PEPPER_CDMS) |
+ |
+ key_systems->push_back(test); |
+} |
class KeySystemsTest : public testing::Test { |
protected: |
@@ -123,23 +111,21 @@ class KeySystemsTest : public testing::Test { |
vp8_and_vorbis_codecs_.push_back("vp8"); |
vp8_and_vorbis_codecs_.push_back("vorbis"); |
- avc1_codec_.push_back("avc1"); |
+ barvideo_codec_.push_back("barvideo"); |
- avc1_extended_codec_.push_back("avc1.4D400C"); |
+ barvideo_extended_codec_.push_back("barvideo.4D400C"); |
- avc1_dot_codec_.push_back("avc1."); |
+ barvideo_dot_codec_.push_back("barvideo."); |
- avc2_codec_.push_back("avc2"); |
+ 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
|
- aac_codec_.push_back("mp4a"); |
+ barvideo_and_baraudio_codecs_.push_back("barvideo"); |
+ barvideo_and_baraudio_codecs_.push_back("baraudio"); |
- avc1_and_aac_codecs_.push_back("avc1"); |
- avc1_and_aac_codecs_.push_back("mp4a"); |
- |
- unknown_codec_.push_back("foo"); |
+ unknown_codec_.push_back("unknown"); |
mixed_codecs_.push_back("vorbis"); |
- mixed_codecs_.push_back("avc1"); |
+ mixed_codecs_.push_back("barvideo"); |
SetRendererClientForTesting(&content_renderer_client_); |
} |
@@ -155,15 +141,14 @@ class KeySystemsTest : public testing::Test { |
return vp8_and_vorbis_codecs_; |
} |
- const CodecVector& avc1_codec() const { return avc1_codec_; } |
- const CodecVector& avc1_extended_codec() const { |
- return avc1_extended_codec_; |
+ const CodecVector& barvideo_codec() const { return barvideo_codec_; } |
+ const CodecVector& barvideo_extended_codec() const { |
+ return barvideo_extended_codec_; |
} |
- const CodecVector& avc1_dot_codec() const { return avc1_dot_codec_; } |
- const CodecVector& avc2_codec() const { return avc2_codec_; } |
- const CodecVector& aac_codec() const { return aac_codec_; } |
- const CodecVector& avc1_and_aac_codecs() const { |
- return avc1_and_aac_codecs_; |
+ const CodecVector& barvideo_dot_codec() const { return barvideo_dot_codec_; } |
+ const CodecVector& baraudio_codec() const { return baraudio_codec_; } |
+ const CodecVector& barvideo_and_baraudio_codecs() const { |
+ return barvideo_and_baraudio_codecs_; |
} |
const CodecVector& unknown_codec() const { return unknown_codec_; } |
@@ -178,675 +163,446 @@ class KeySystemsTest : public testing::Test { |
CodecVector vorbis_codec_; |
CodecVector vp8_and_vorbis_codecs_; |
- CodecVector avc1_codec_; |
- CodecVector avc1_extended_codec_; |
- CodecVector avc1_dot_codec_; |
- CodecVector avc2_codec_; |
- CodecVector aac_codec_; |
- CodecVector avc1_and_aac_codecs_; |
+ CodecVector barvideo_codec_; |
+ CodecVector barvideo_extended_codec_; |
+ CodecVector barvideo_dot_codec_; |
+ CodecVector baraudio_codec_; |
+ CodecVector barvideo_and_baraudio_codecs_; |
CodecVector unknown_codec_; |
CodecVector mixed_codecs_; |
- ContentRendererClient content_renderer_client_; |
+ TestContentRendererClient content_renderer_client_; |
}; |
-TEST_F(KeySystemsTest, ClearKey_Basic) { |
- EXPECT_TRUE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKey))); |
- EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kClearKey)); |
+// TODO(ddorwin): Consider moving GetUUID() into these tests or moving |
+// GetPepperType() calls out to their own test. |
- // Not yet out from behind the vendor prefix. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org.w3.clearkey")); |
+TEST_F(KeySystemsTest, ClearKeyNotRegistered) { |
+ // Not registered in content. |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKey))); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "org.w3.clearkey")); |
+ kVideoWebM, no_codecs(), kClearKey)); |
EXPECT_STREQ("ClearKey", |
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
|
- EXPECT_TRUE(CanUseAesDecryptor(kClearKey)); |
-#if defined(ENABLE_PEPPER_CDMS) |
- std::string type; |
- EXPECT_DEBUG_DEATH(type = GetPepperType(kClearKey), |
- "webkit-org.w3.clearkey is not Pepper-based"); |
- EXPECT_TRUE(type.empty()); |
-#endif |
+ // Not yet out from behind the vendor prefix. |
+ 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
|
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, no_codecs(), "org.w3.clearkey")); |
+ EXPECT_STREQ( |
+ "Unknown", |
+ KeySystemNameForUMA(WebString::fromUTF8("org.w3.clearkey")).c_str()); |
+ |
xhwang
2013/09/11 20:38:55
drop empty line.
ddorwin
2013/09/12 22:35:40
Done.
|
} |
-TEST_F(KeySystemsTest, ClearKey_Parent) { |
- const char* const kClearKeyParent = "webkit-org.w3"; |
+TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) { |
+ static const char* const kUnrecognized = "org.example.unrecognized"; |
- // The parent should be supported but is not. See http://crbug.com/164303. |
EXPECT_FALSE( |
- IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearKeyParent))); |
+ IsConcreteSupportedKeySystem(WebString::fromUTF8(kUnrecognized))); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kClearKeyParent)); |
+ kVideoWebM, no_codecs(), kUnrecognized)); |
+ |
+ EXPECT_STREQ( |
+ "Unknown", |
+ KeySystemNameForUMA(WebString::fromUTF8(kUnrecognized)).c_str()); |
+ |
+ bool can_use = false; |
+ EXPECT_DEBUG_DEATH(can_use = CanUseAesDecryptor(kUnrecognized), |
+ "org.example.unrecognized is not a known concrete system"); |
+ EXPECT_FALSE(can_use); |
- // The parent is not supported for most things. |
- EXPECT_STREQ("Unknown", |
- KeySystemNameForUMA(WebString::fromUTF8(kClearKeyParent)).c_str()); |
- bool result = false; |
- EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kClearKeyParent), |
- "webkit-org.w3 is not a known concrete system"); |
- EXPECT_FALSE(result); |
#if defined(ENABLE_PEPPER_CDMS) |
std::string type; |
- EXPECT_DEBUG_DEATH(type = GetPepperType(kClearKeyParent), |
- "webkit-org.w3 is not a known concrete system"); |
+ EXPECT_DEBUG_DEATH(type = GetPepperType(kUnrecognized), |
+ "org.example.unrecognized is not a known concrete system"); |
EXPECT_TRUE(type.empty()); |
#endif |
} |
-TEST_F(KeySystemsTest, ClearKey_IsSupportedKeySystem_InvalidVariants) { |
- // Case sensitive. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.ClEaRkEy")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org.w3.ClEaRkEy")); |
- |
- // TLDs are not allowed. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org.")); |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org")); |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "org.")); |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "org")); |
- |
- // Extra period. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org.w3.")); |
- |
- // Incomplete. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearke")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org.w3.clearke")); |
- |
- // Extra character. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkeyz")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org.w3.clearkeyz")); |
- |
- // There are no child key systems for Clear Key. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkey.foo")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org.w3.clearkey.foo")); |
-} |
+TEST_F(KeySystemsTest, Basic_UsesAesDecryptor) { |
+ EXPECT_TRUE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClear))); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, no_codecs(), kClear)); |
-TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_NoType) { |
- // These two should be true. See http://crbug.com/164303. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), kClearKey)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "webkit-org.w3")); |
+ // No UMA value for this test key system. |
+ EXPECT_STREQ("Unknown", |
+ KeySystemNameForUMA(WebString::fromUTF8(kClear)).c_str()); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "webkit-org.w3.foo")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "webkit-org.w3.clearkey.foo")); |
+ EXPECT_TRUE(CanUseAesDecryptor(kClear)); |
+#if defined(ENABLE_PEPPER_CDMS) |
+ std::string type; |
+ EXPECT_DEBUG_DEATH(type = GetPepperType(kClear), |
+ "org.example.clear is not Pepper-based"); |
+ EXPECT_TRUE(type.empty()); |
+#endif |
} |
-TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_WebM) { |
+TEST_F(KeySystemsTest, |
+ IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) { |
// Valid video types. |
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kClearKey)); |
- // The parent should be supported but is not. See http://crbug.com/164303. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "webkit-org.w3")); |
+ kVideoWebM, vp8_codec(), kClear)); |
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_codec(), kClearKey)); |
+ kVideoWebM, vp80_codec(), kClear)); |
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp80_codec(), kClearKey)); |
+ kVideoWebM, vp8_and_vorbis_codecs(), kClear)); |
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_and_vorbis_codecs(), kClearKey)); |
- EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vorbis_codec(), kClearKey)); |
+ kVideoWebM, vorbis_codec(), kClear)); |
// Non-Webm codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", avc1_codec(), kClearKey)); |
+ kVideoWebM, barvideo_codec(), kClear)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", unknown_codec(), kClearKey)); |
+ kVideoWebM, unknown_codec(), kClear)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", mixed_codecs(), kClearKey)); |
+ kVideoWebM, mixed_codecs(), kClear)); |
// Valid audio types. |
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", no_codecs(), kClearKey)); |
+ kAudioWebM, no_codecs(), kClear)); |
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vorbis_codec(), kClearKey)); |
+ kAudioWebM, vorbis_codec(), kClear)); |
// Non-audio codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vp8_codec(), kClearKey)); |
+ kAudioWebM, vp8_codec(), kClear)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vp8_and_vorbis_codecs(), kClearKey)); |
+ kAudioWebM, vp8_and_vorbis_codecs(), kClear)); |
// Non-Webm codec. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", aac_codec(), kClearKey)); |
+ kAudioWebM, baraudio_codec(), kClear)); |
} |
-TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_MP4) { |
- // Valid video types. |
- EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", no_codecs(), kClearKey)); |
- // The parent should be supported but is not. See http://crbug.com/164303. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", no_codecs(), "webkit-org.w3")); |
- EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_codec(), kClearKey)); |
- EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_and_aac_codecs(), kClearKey)); |
- EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", aac_codec(), kClearKey)); |
- |
- // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
- // They should really pass canPlayType(). |
+// No parent is registered for Clear. |
+TEST_F(KeySystemsTest, Parent_NoParentRegistered) { |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kClearParent))); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_extended_codec(), kClearKey)); |
+ kVideoWebM, no_codecs(), kClearParent)); |
- // Invalid codec format. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_dot_codec(), kClearKey)); |
- |
- // Non-MP4 codecs. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc2_codec(), kClearKey)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", vp8_codec(), kClearKey)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", unknown_codec(), kClearKey)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", mixed_codecs(), kClearKey)); |
- |
- // Valid audio types. |
- EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", no_codecs(), kClearKey)); |
- EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", aac_codec(), kClearKey)); |
- |
- // Non-audio codecs. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", avc1_codec(), kClearKey)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", avc1_and_aac_codecs(), kClearKey)); |
- |
- // Non-MP4 codec. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", vorbis_codec(), kClearKey)); |
-} |
- |
-// |
-// External Clear Key |
-// |
- |
-TEST_F(KeySystemsTest, ExternalClearKey_Basic) { |
- EXPECT_ECK( |
- IsConcreteSupportedKeySystem(WebString::fromUTF8(kExternalClearKey))); |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kExternalClearKey)); |
- |
- // External Clear Key does not have a UMA name because it is for testing. |
+ // The parent is not supported for most things. |
EXPECT_STREQ( |
"Unknown", |
- KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str()); |
- |
-#if defined(ENABLE_PEPPER_CDMS) |
- EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKey)); |
- EXPECT_STREQ("application/x-ppapi-clearkey-cdm", |
- GetPepperType(kExternalClearKey).c_str()); |
-#else |
- bool result = false; |
- EXPECT_DEBUG_DEATH_PORTABLE( |
- result = CanUseAesDecryptor(kExternalClearKey), |
- "org.chromium.externalclearkey is not a known concrete system"); |
- EXPECT_FALSE(result); |
-#endif |
-} |
- |
-TEST_F(KeySystemsTest, ExternalClearKey_Parent) { |
- const char* const kExternalClearKeyParent = "org.chromium"; |
- |
- // The parent should be supported but is not. See http://crbug.com/164303. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem( |
- WebString::fromUTF8(kExternalClearKeyParent))); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kExternalClearKeyParent)); |
- |
- // The parent is not supported for most things. |
- EXPECT_STREQ("Unknown", |
- KeySystemNameForUMA( |
- WebString::fromUTF8(kExternalClearKeyParent)).c_str()); |
+ KeySystemNameForUMA(WebString::fromUTF8(kClearParent)).c_str()); |
bool result = false; |
- EXPECT_DEBUG_DEATH_PORTABLE( |
- result = CanUseAesDecryptor(kExternalClearKeyParent), |
- "org.chromium is not a known concrete system"); |
+ EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kClearParent), |
+ "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
|
EXPECT_FALSE(result); |
#if defined(ENABLE_PEPPER_CDMS) |
std::string type; |
- EXPECT_DEBUG_DEATH(type = GetPepperType(kExternalClearKeyParent), |
- "org.chromium is not a known concrete system"); |
+ EXPECT_DEBUG_DEATH(type = GetPepperType(kClearParent), |
+ "org.example is not a known concrete system"); |
EXPECT_TRUE(type.empty()); |
#endif |
} |
-TEST_F(KeySystemsTest, ExternalClearKey_IsSupportedKeySystem_InvalidVariants) { |
+TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) { |
// Case sensitive. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy")); |
+ EXPECT_FALSE( |
+ IsConcreteSupportedKeySystem(WebString::fromUTF8("org.example.ClEaR"))); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), |
- "org.chromium.ExTeRnAlClEaRkEy")); |
+ kVideoWebM, no_codecs(), "org.example.ClEaR")); |
// TLDs are not allowed. |
EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "org.")); |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); |
+ kVideoWebM, no_codecs(), "org.")); |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem("com")); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "org")); |
+ kVideoWebM, no_codecs(), "com")); |
// Extra period. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.")); |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.")); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "org.chromium.")); |
+ kVideoWebM, no_codecs(), "org.example.")); |
// Incomplete. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearke")); |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clea")); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), |
- "org.chromium.externalclearke")); |
+ kVideoWebM, no_codecs(), "org.example.clea")); |
// Extra character. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearkeyz")); |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clearz")); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), |
- "org.chromium.externalclearkeyz")); |
+ kVideoWebM, no_codecs(), "org.example.clearz")); |
// There are no child key systems for Clear Key. |
- EXPECT_FALSE( |
- IsConcreteSupportedKeySystem("org.chromium.externalclearkey.foo")); |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem("org.example.clear.foo")); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), |
- "org.chromium.externalclearkey.foo")); |
+ kVideoWebM, no_codecs(), "org.example.clear.foo")); |
} |
-TEST_F(KeySystemsTest, |
- IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_NoType) { |
+TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { |
// These two should be true. See http://crbug.com/164303. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), kExternalClearKey)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "org.chromium")); |
- |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "org.chromium.foo")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "org.chromium.externalclearkey.foo")); |
-} |
- |
-TEST_F(KeySystemsTest, |
- IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_WebM) { |
- // Valid video types. |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kExternalClearKey)); |
- // The parent should be supported but is not. See http://crbug.com/164303. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "org.chromium")); |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_codec(), kExternalClearKey)); |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp80_codec(), kExternalClearKey)); |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vorbis_codec(), kExternalClearKey)); |
- |
- // Non-Webm codecs. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", avc1_codec(), kExternalClearKey)); |
+ std::string(), no_codecs(), kClear)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", unknown_codec(), kExternalClearKey)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", mixed_codecs(), kExternalClearKey)); |
+ std::string(), no_codecs(), kClearParent)); |
- // Valid audio types. |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", no_codecs(), kExternalClearKey)); |
- EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vorbis_codec(), kExternalClearKey)); |
- |
- // Non-audio codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vp8_codec(), kExternalClearKey)); |
+ std::string(), no_codecs(), "org.example.foo")); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); |
- |
- // Non-Webm codec. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", aac_codec(), kExternalClearKey)); |
+ std::string(), no_codecs(), "org.example.clear.foo")); |
} |
+// Tests the second registered container type. |
+// TODO(ddorwin): Combined with TypesContainer1 in a future CL. |
TEST_F(KeySystemsTest, |
- IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_MP4) { |
+ IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer2) { |
// Valid video types. |
- EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", no_codecs(), kExternalClearKey)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, no_codecs(), kClear)); |
// The parent should be supported but is not. See http://crbug.com/164303. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", no_codecs(), "org.chromium")); |
- EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_codec(), kExternalClearKey)); |
- EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_and_aac_codecs(), kExternalClearKey)); |
- EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", aac_codec(), kExternalClearKey)); |
+ kVideoFoo, no_codecs(), kClearParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, barvideo_codec(), kClear)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, barvideo_and_baraudio_codecs(), kClear)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, baraudio_codec(), kClear)); |
// Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
// They should really pass canPlayType(). |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_extended_codec(), kExternalClearKey)); |
+ kVideoFoo, barvideo_extended_codec(), kClear)); |
// Invalid codec format. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_dot_codec(), kExternalClearKey)); |
+ kVideoFoo, barvideo_dot_codec(), kClear)); |
- // Non-MP4 codecs. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc2_codec(), kExternalClearKey)); |
+ // Non-container2 codec. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", vp8_codec(), kExternalClearKey)); |
+ kVideoFoo, vp8_codec(), kClear)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", unknown_codec(), kExternalClearKey)); |
+ kVideoFoo, unknown_codec(), kClear)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", mixed_codecs(), kExternalClearKey)); |
+ kVideoFoo, mixed_codecs(), kClear)); |
// Valid audio types. |
- EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", no_codecs(), kExternalClearKey)); |
- EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", aac_codec(), kExternalClearKey)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioFoo, no_codecs(), kClear)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioFoo, baraudio_codec(), kClear)); |
// Non-audio codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", avc1_codec(), kExternalClearKey)); |
+ kAudioFoo, barvideo_codec(), kClear)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", avc1_and_aac_codecs(), kExternalClearKey)); |
+ kAudioFoo, barvideo_and_baraudio_codecs(), kClear)); |
- // Non-MP4 codec. |
+ // Non-container2 codec. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", vorbis_codec(), kExternalClearKey)); |
+ kAudioFoo, vorbis_codec(), kClear)); |
} |
// |
-// Widevine |
+// Non-AesDecryptor-based key system. |
// |
-TEST_F(KeySystemsTest, Widevine_Basic) { |
-#if defined(WIDEVINE_CDM_AVAILABLE) && \ |
- defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) |
- EXPECT_TRUE( |
- IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha))); |
-#else |
- EXPECT_WV(IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha))); |
-#endif |
- |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kWidevineAlpha)); |
- |
-#if defined(WIDEVINE_CDM_AVAILABLE) |
- const char* const kWidevineUmaName = "Widevine"; |
-#else |
- const char* const kWidevineUmaName = "Unknown"; |
-#endif |
- EXPECT_STREQ( |
- kWidevineUmaName, |
- KeySystemNameForUMA(WebString::fromUTF8(kWidevineAlpha)).c_str()); |
- |
-#if defined(WIDEVINE_CDM_AVAILABLE) |
- EXPECT_FALSE(CanUseAesDecryptor(kWidevineAlpha)); |
-#else |
- bool result = false; |
- EXPECT_DEBUG_DEATH_PORTABLE( |
- result = CanUseAesDecryptor(kWidevineAlpha), |
- "com.widevine.alpha is not a known concrete system"); |
- EXPECT_FALSE(result); |
-#endif // defined(WIDEVINE_CDM_AVAILABLE) |
+TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { |
+ EXPECT_TRUE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kTest))); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, no_codecs(), kTest)); |
+ EXPECT_FALSE(CanUseAesDecryptor(kTest)); |
#if defined(ENABLE_PEPPER_CDMS) |
-#if defined(WIDEVINE_CDM_AVAILABLE) |
- EXPECT_STREQ("application/x-ppapi-widevine-cdm", |
- GetPepperType(kWidevineAlpha).c_str()); |
-#else |
- std::string type; |
- EXPECT_DEBUG_DEATH(type = GetPepperType(kWidevineAlpha), |
- "com.widevine.alpha is not a known concrete system"); |
- EXPECT_TRUE(type.empty()); |
-#endif // defined(WIDEVINE_CDM_AVAILABLE) |
+ EXPECT_STREQ("application/x-ppapi-test-cdm", |
+ GetPepperType(kTest).c_str()); |
#endif // defined(ENABLE_PEPPER_CDMS) |
} |
-TEST_F(KeySystemsTest, Widevine_Parent) { |
+TEST_F(KeySystemsTest, Parent_ParentRegistered) { |
// The parent system is not a concrete system but is supported. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kWidevine))); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kWidevine)); |
+ EXPECT_FALSE(IsConcreteSupportedKeySystem(WebString::fromUTF8(kTestParent))); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, no_codecs(), kTestParent)); |
// The parent is not supported for most things. |
- EXPECT_STREQ("Unknown", |
- KeySystemNameForUMA(WebString::fromUTF8(kWidevine)).c_str()); |
+ EXPECT_STREQ( |
+ "Unknown", |
+ KeySystemNameForUMA(WebString::fromUTF8(kTestParent)).c_str()); |
bool result = false; |
- EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kWidevine), |
- "com.widevine is not a known concrete system"); |
+ EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kTestParent), |
+ "com.example is not a known concrete system"); |
EXPECT_FALSE(result); |
#if defined(ENABLE_PEPPER_CDMS) |
std::string type; |
- EXPECT_DEBUG_DEATH(type = GetPepperType(kWidevine), |
- "com.widevine is not a known concrete system"); |
+ EXPECT_DEBUG_DEATH(type = GetPepperType(kTestParent), |
+ "com.example is not a known concrete system"); |
EXPECT_TRUE(type.empty()); |
#endif |
} |
-TEST_F(KeySystemsTest, Widevine_IsSupportedKeySystem_InvalidVariants) { |
- // Case sensitive. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.AlPhA")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "com.widevine.AlPhA")); |
- |
- // TLDs are not allowed. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("com.")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "com.")); |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("com")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "com")); |
- |
- // Extra period. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "com.widevine.")); |
- |
- // Incomplete. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alph")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "com.widevine.alph")); |
- |
- // Extra character. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alphab")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "com.widevine.alphab")); |
- |
- // There are no child key systems for Widevine Alpha. |
- EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alpha.foo")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), "com.widevine.alpha.foo")); |
-} |
- |
-TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_NoType) { |
- // These two should be true. See http://crbug.com/164303. |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), kWidevineAlpha)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), kWidevine)); |
- |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "com.widevine.foo")); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- std::string(), no_codecs(), "com.widevine.alpha.foo")); |
-} |
- |
-TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) { |
+TEST_F( |
+ KeySystemsTest, |
+ IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { |
// Valid video types. |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kWidevineAlpha)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_codec(), kWidevineAlpha)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp80_codec(), kWidevineAlpha)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vorbis_codec(), kWidevineAlpha)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, no_codecs(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vp8_codec(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vp80_codec(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vp8_and_vorbis_codecs(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vorbis_codec(), kTest)); |
// Valid video types - parent key system. |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", no_codecs(), kWidevine)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_codec(), kWidevine)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp80_codec(), kWidevine)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vp8_and_vorbis_codecs(), kWidevine)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", vorbis_codec(), kWidevine)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, no_codecs(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vp8_codec(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vp80_codec(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vp8_and_vorbis_codecs(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoWebM, vorbis_codec(), kTestParent)); |
// Non-Webm codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", avc1_codec(), kWidevineAlpha)); |
+ kVideoWebM, barvideo_codec(), kTest)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", unknown_codec(), kWidevineAlpha)); |
+ kVideoWebM, unknown_codec(), kTest)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/webm", mixed_codecs(), kWidevineAlpha)); |
+ kVideoWebM, mixed_codecs(), kTest)); |
// Valid audio types. |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", no_codecs(), kWidevineAlpha)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vorbis_codec(), kWidevineAlpha)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioWebM, no_codecs(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioWebM, vorbis_codec(), kTest)); |
// Valid audio types - parent key system. |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", no_codecs(), kWidevine)); |
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vorbis_codec(), kWidevine)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioWebM, no_codecs(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioWebM, vorbis_codec(), kTestParent)); |
// Non-audio codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vp8_codec(), kWidevineAlpha)); |
+ kAudioWebM, vp8_codec(), kTest)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); |
+ kAudioWebM, vp8_and_vorbis_codecs(), kTest)); |
// Non-Webm codec. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/webm", aac_codec(), kWidevineAlpha)); |
+ kAudioWebM, baraudio_codec(), kTest)); |
} |
-TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) { |
+TEST_F( |
+ KeySystemsTest, |
+ IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { |
// Valid video types. |
- EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", no_codecs(), kWidevineAlpha)); |
- EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_codec(), kWidevineAlpha)); |
- EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); |
- EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", aac_codec(), kWidevineAlpha)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, no_codecs(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, barvideo_codec(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, barvideo_and_baraudio_codecs(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, baraudio_codec(), kTest)); |
// Valid video types - parent key system. |
- EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", no_codecs(), kWidevine)); |
- EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_codec(), kWidevine)); |
- EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_and_aac_codecs(), kWidevine)); |
- EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", aac_codec(), kWidevine)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, no_codecs(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, barvideo_codec(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, barvideo_and_baraudio_codecs(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kVideoFoo, baraudio_codec(), kTestParent)); |
// Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
// They should really pass canPlayType(). |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_extended_codec(), kWidevineAlpha)); |
+ kVideoFoo, barvideo_extended_codec(), kTest)); |
// Invalid codec format. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc1_dot_codec(), kWidevineAlpha)); |
+ kVideoFoo, barvideo_dot_codec(), kTest)); |
- // Non-MP4 codecs. |
+ // Non-container2 codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", avc2_codec(), kWidevineAlpha)); |
+ kVideoFoo, vp8_codec(), kTest)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", vp8_codec(), kWidevineAlpha)); |
+ kVideoFoo, unknown_codec(), kTest)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", unknown_codec(), kWidevineAlpha)); |
- EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "video/mp4", mixed_codecs(), kWidevineAlpha)); |
+ kVideoFoo, mixed_codecs(), kTest)); |
// Valid audio types. |
- EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", no_codecs(), kWidevineAlpha)); |
- EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", aac_codec(), kWidevineAlpha)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioFoo, no_codecs(), kTest)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioFoo, baraudio_codec(), kTest)); |
// Valid audio types - parent key system. |
- EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", no_codecs(), kWidevine)); |
- EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", aac_codec(), kWidevine)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioFoo, no_codecs(), kTestParent)); |
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
+ kAudioFoo, baraudio_codec(), kTestParent)); |
// Non-audio codecs. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", avc1_codec(), kWidevineAlpha)); |
+ kAudioFoo, barvideo_codec(), kTest)); |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); |
+ kAudioFoo, barvideo_and_baraudio_codecs(), kTest)); |
- // Non-MP4 codec. |
+ // Non-container2 codec. |
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
- "audio/mp4", vorbis_codec(), kWidevineAlpha)); |
+ kAudioFoo, vorbis_codec(), kTest)); |
} |
#if defined(OS_ANDROID) |
-TEST_F(KeySystemsTest, GetUUID_Widevine) { |
-#if defined(WIDEVINE_CDM_AVAILABLE) |
- std::vector<uint8> uuid = GetUUID(kWidevineAlpha); |
+TEST_F(KeySystemsTest, GetUUID_RegisteredExternalDecryptor) { |
+ std::vector<uint8> uuid = GetUUID(kTest); |
EXPECT_EQ(16u, uuid.size()); |
- EXPECT_EQ(0xED, uuid[15]); |
-#else |
- std::vector<uint8> uuid; |
- EXPECT_DEBUG_DEATH_PORTABLE( |
- uuid = GetUUID(kWidevineAlpha), |
- "com.widevine.alpha is not a known concrete system"); |
- EXPECT_TRUE(uuid.empty()); |
-#endif |
+ EXPECT_EQ(0xef, uuid[15]); |
+} |
+ |
+TEST_F(KeySystemsTest, GetUUID_RegisteredAesDecryptor) { |
+ EXPECT_TRUE(GetUUID(kClear).empty()); |
} |
TEST_F(KeySystemsTest, GetUUID_Unrecognized) { |
std::vector<uint8> uuid; |
- EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(kWidevine), |
- "com.widevine is not a known concrete system"); |
+ EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(kTestParent), |
+ "com.example is not a known concrete system"); |
EXPECT_TRUE(uuid.empty()); |
- EXPECT_TRUE(GetUUID(kClearKey).empty()); |
- |
EXPECT_DEBUG_DEATH_PORTABLE(uuid = GetUUID(""), " is not a concrete system"); |
EXPECT_TRUE(uuid.empty()); |
} |
#endif // defined(OS_ANDROID) |
+TEST_F(KeySystemsTest, KeySystemNameForUMA) { |
+ EXPECT_STREQ("ClearKey", |
+ KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str()); |
+ // Unprefixed is not yet supported. |
+ EXPECT_STREQ( |
+ "Unknown", |
+ KeySystemNameForUMA(WebString::fromUTF8("org.w3.clearkey")).c_str()); |
+ |
+ // External Clear Key never has a UMA name. |
+ EXPECT_STREQ( |
+ "Unknown", |
+ KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str()); |
+ |
+#if defined(WIDEVINE_CDM_AVAILABLE) |
+ const char* const kTestWidevineUmaName = "Widevine"; |
+#else |
+ const char* const kTestWidevineUmaName = "Unknown"; |
+#endif |
+ EXPECT_STREQ( |
+ kTestWidevineUmaName, |
+ KeySystemNameForUMA(WebString::fromUTF8("com.widevine.alpha")).c_str()); |
+} |
+ |
} // namespace content |