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

Unified Diff: webkit/media/crypto/key_systems_unittest.cc

Issue 11474037: Several updates to canPlayType() results for EME (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/media/crypto/key_systems.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/crypto/key_systems_unittest.cc
diff --git a/webkit/media/crypto/key_systems_unittest.cc b/webkit/media/crypto/key_systems_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9eaddc0e336ef5ba519996b5067957275f36c5d0
--- /dev/null
+++ b/webkit/media/crypto/key_systems_unittest.cc
@@ -0,0 +1,658 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/media/crypto/key_systems.h"
+
xhwang 2012/12/07 22:35:39 include vector and string
ddorwin 2012/12/08 00:29:07 Done.
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
+
+#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+
+using WebKit::WebString;
+
+#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
+#define EXPECT_PROPRIETARY EXPECT_TRUE
+#else
+#define EXPECT_PROPRIETARY EXPECT_FALSE
+#endif
+
+#if defined(WIDEVINE_CDM_AVAILABLE)
+#define EXPECT_WV EXPECT_TRUE
+#else
+#define EXPECT_WV EXPECT_FALSE
+#endif
+
+#if defined(WIDEVINE_CDM_AVAILABLE) && \
+ defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+#define EXPECT_WVISO EXPECT_TRUE
+#else
+#define EXPECT_WVISO EXPECT_FALSE
+#endif
+
+namespace webkit_media {
+
+class KeySystemsTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ vp8_codec.push_back("vp8");
+ vp80_codec.push_back("vp8.0");
+
+ vorbis_codec.push_back("vorbis");
+
+ vp8_and_vorbis_codecs.push_back("vp8");
+ vp8_and_vorbis_codecs.push_back("vorbis");
+
+ avc1_codec.push_back("avc1");
+
+ aac_codec.push_back("mp4a");
+
+ avc1_and_aac_codecs.push_back("avc1");
+ avc1_and_aac_codecs.push_back("mp4a");
+
+ unknown_codec.push_back("foo");
+
+ mixed_codecs.push_back("vorbis");
+ mixed_codecs.push_back("avc1");
+ }
+
+ protected:
+ const char* const kClearKey = "webkit-org.w3.clearkey";
+ const char* const kExternalClearKey = "org.chromium.externalclearkey";
+ const char* const kWidevineAlpha = "com.widevine.alpha";
+
+ const std::vector<std::string> no_codecs;
xhwang 2012/12/07 22:35:39 nit: s/no_codecs/no_codecs_ ? same question for al
ddorwin 2012/12/08 00:29:07 Done. Made them private and added accessors to pre
+
+ std::vector<std::string> vp8_codec;
+ std::vector<std::string> vp80_codec;
+ std::vector<std::string> vorbis_codec;
+ std::vector<std::string> vp8_and_vorbis_codecs;
+
+ std::vector<std::string> avc1_codec;
+ std::vector<std::string> aac_codec;
+ std::vector<std::string> avc1_and_aac_codecs;
+
+ std::vector<std::string> unknown_codec;
+
+ std::vector<std::string> mixed_codecs;
+
+};
+
+TEST_F(KeySystemsTest, ClearKey_Basic) {
+ EXPECT_TRUE(IsSupportedKeySystem(WebString::fromUTF8(kClearKey)));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), kClearKey));
+
+ // Not yet out from behind the vendor prefix.
+ EXPECT_FALSE(IsSupportedKeySystem("org.w3.clearkey"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "org.w3.clearkey"));
+
+ EXPECT_STREQ("ClearKey", KeySystemNameForUMA(std::string(kClearKey)).c_str());
+ EXPECT_STREQ("ClearKey",
+ KeySystemNameForUMA(WebString::fromUTF8(kClearKey)).c_str());
+
+ EXPECT_TRUE(CanUseAesDecryptor(kClearKey));
+ EXPECT_TRUE(GetPluginType(kClearKey).empty()); // Does not use plugin.
+}
+
+TEST_F(KeySystemsTest, ClearKey_Parent) {
+ const char* const kClearKeyParent = "webkit-org.w3";
+
+ // The parent should be supported but is not. See http://crbug.com/164303.
+ EXPECT_FALSE(IsSupportedKeySystem(WebString::fromUTF8(kClearKeyParent)));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), kClearKeyParent));
xhwang 2012/12/07 22:35:39 can we use no_codecs for std::vector<std::string>(
ddorwin 2012/12/08 00:29:07 Done.
+
+ // The parent is not supported for most things.
+ EXPECT_STREQ("Unknown",
+ KeySystemNameForUMA(std::string(kClearKeyParent)).c_str());
+ EXPECT_STREQ("Unknown",
+ KeySystemNameForUMA(WebString::fromUTF8(kClearKeyParent)).c_str());
+ EXPECT_FALSE(CanUseAesDecryptor(kClearKeyParent));
+ EXPECT_TRUE(GetPluginType(kClearKeyParent).empty());
+}
+
+TEST_F(KeySystemsTest, ClearKey_IsSupportedKeySystem_InvalidVariants) {
+ // Case sensitive.
+ EXPECT_FALSE(IsSupportedKeySystem("webkit-org.w3.ClEaRkEy"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "webkit-org.w3.ClEaRkEy"));
+
+ // TLDs are not allowed.
+ EXPECT_FALSE(IsSupportedKeySystem("webkit-org."));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "webkit-org."));
+ EXPECT_FALSE(IsSupportedKeySystem("webkit-org"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "webkit-org"));
+ EXPECT_FALSE(IsSupportedKeySystem("org."));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "org."));
+ EXPECT_FALSE(IsSupportedKeySystem("org"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "org"));
+
+ // Extra period.
+ EXPECT_FALSE(IsSupportedKeySystem("webkit-org.w3."));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "webkit-org.w3."));
+
+ // Incomplete.
+ EXPECT_FALSE(IsSupportedKeySystem("webkit-org.w3.clearke"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "webkit-org.w3.clearke"));
+
+ // Extra character.
+ EXPECT_FALSE(IsSupportedKeySystem("webkit-org.w3.clearkeyz"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "webkit-org.w3.clearkeyz"));
+
+ // There are no child key systems for Clear Key.
+ EXPECT_FALSE(IsSupportedKeySystem("webkit-org.w3.clearkey.foo"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "webkit-org.w3.clearkey.foo"));
+}
+
+TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_NoType) {
+ // These two should be true. See http://crbug.com/164303.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), kClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "webkit-org.w3"));
+
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "webkit-org.w3.foo"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "webkit-org.w3.clearkey.foo"));
+}
+
+TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_WebM) {
+ // 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"));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp8_codec, kClearKey));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp80_codec, kClearKey));
+ // These two should be true. See http://crbug.com/123421.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp8_and_vorbis_codecs, kClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vorbis_codec, kClearKey));
+
+ // Non-Webm codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", avc1_codec, kClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", unknown_codec, kClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", mixed_codecs, kClearKey));
+
+ // Valid audio types.
+ // Should be true. See http://crbug.com/123421.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", no_codecs, kClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vorbis_codec, kClearKey));
+
+ // Non-audio codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vp8_codec, kClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vp8_and_vorbis_codecs, kClearKey));
+
+ // Non-Webm codec.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", aac_codec, kClearKey));
+}
+
+TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_ClearKey_MP4) {
+ std::vector<std::string> avc1_extended_codec;
+ avc1_extended_codec.push_back("avc1.4D400C");
+ std::vector<std::string> avc1_dot_codec;
+ avc1_dot_codec.push_back("avc1.");
+ std::vector<std::string> avc2_codec;
+ avc2_codec.push_back("avc2");
+
+ // 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));
+ // These two should be true. See http://crbug.com/123421.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_and_aac_codecs, kClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", aac_codec, kClearKey));
+
+ // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl.
+ // They should really pass canPlayType().
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_extended_codec, kClearKey));
+
+ // 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.
+ // Should be true. See http://crbug.com/123421.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", no_codecs, kClearKey));
+ EXPECT_FALSE(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_TRUE(IsSupportedKeySystem(WebString::fromUTF8(kExternalClearKey)));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), kExternalClearKey));
+
+ // External Clear Key does not have a UMA name because it is for testing.
+ EXPECT_STREQ(
+ "Unknown",
+ KeySystemNameForUMA(std::string(kExternalClearKey)).c_str());
+ EXPECT_STREQ(
+ "Unknown",
+ KeySystemNameForUMA(WebString::fromUTF8(kExternalClearKey)).c_str());
+
+ EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKey));
+ EXPECT_STREQ("application/x-ppapi-clearkey-cdm",
+ GetPluginType(kExternalClearKey).c_str());
+}
+
+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(
+ IsSupportedKeySystem(WebString::fromUTF8(kExternalClearKeyParent)));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), kExternalClearKeyParent));
+
+ // The parent is not supported for most things.
+ EXPECT_STREQ(
+ "Unknown",
+ KeySystemNameForUMA(std::string(kExternalClearKeyParent)).c_str());
+ EXPECT_STREQ("Unknown",
+ KeySystemNameForUMA(
+ WebString::fromUTF8(kExternalClearKeyParent)).c_str());
+ EXPECT_FALSE(CanUseAesDecryptor(kExternalClearKeyParent));
+ EXPECT_TRUE(GetPluginType(kExternalClearKeyParent).empty());
+}
+
+TEST_F(KeySystemsTest, ExternalClearKey_IsSupportedKeySystem_InvalidVariants) {
+ // Case sensitive.
+ EXPECT_FALSE(IsSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(),
+ "org.chromium.ExTeRnAlClEaRkEy"));
+
+ // TLDs are not allowed.
+ EXPECT_FALSE(IsSupportedKeySystem("org."));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "org."));
+ EXPECT_FALSE(IsSupportedKeySystem("org"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "org"));
+
+ // Extra period.
+ EXPECT_FALSE(IsSupportedKeySystem("org.chromium."));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "org.chromium."));
+
+ // Incomplete.
+ EXPECT_FALSE(IsSupportedKeySystem("org.chromium.externalclearke"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(),
+ "org.chromium.externalclearke"));
+
+ // Extra character.
+ EXPECT_FALSE(IsSupportedKeySystem("org.chromium.externalclearkeyz"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(),
+ "org.chromium.externalclearkeyz"));
+
+ // There are no child key systems for Clear Key.
+ EXPECT_FALSE(IsSupportedKeySystem("org.chromium.externalclearkey.foo"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(),
+ "org.chromium.externalclearkey.foo"));
+}
+
+TEST_F(KeySystemsTest,
+ IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_NoType) {
+ // These two should be true. See http://crbug.com/164303.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "org.chromium"));
+
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "org.chromium.foo"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "org.chromium.externalclearkey.foo"));
+}
+
+TEST_F(KeySystemsTest,
+ IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_WebM) {
+ // Valid video types.
+ EXPECT_TRUE(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_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp8_codec, kExternalClearKey));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp80_codec, kExternalClearKey));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp8_and_vorbis_codecs, kExternalClearKey));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vorbis_codec, kExternalClearKey));
+
+ // Non-Webm codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", avc1_codec, kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", unknown_codec, kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", mixed_codecs, kExternalClearKey));
+
+ // Valid audio types.
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", no_codecs, kExternalClearKey));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vorbis_codec, kExternalClearKey));
+
+ // Non-audio codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vp8_codec, kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vp8_and_vorbis_codecs, kExternalClearKey));
+
+ // Non-Webm codec.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", aac_codec, kExternalClearKey));
+}
+
+TEST_F(KeySystemsTest,
+ IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_MP4) {
+ std::vector<std::string> avc1_extended_codec;
+ avc1_extended_codec.push_back("avc1.4D400C");
+ std::vector<std::string> avc1_dot_codec;
+ avc1_dot_codec.push_back("avc1.");
+ std::vector<std::string> avc2_codec;
+ avc2_codec.push_back("avc2");
+
+ // Valid video types.
+ EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", no_codecs, kExternalClearKey));
+ // The parent should be supported but is not. See http://crbug.com/164303.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", no_codecs, "org.chromium"));
+ EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_codec, kExternalClearKey));
+ EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_and_aac_codecs, kExternalClearKey));
+ EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", aac_codec, kExternalClearKey));
+
+ // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl.
+ // They should really pass canPlayType().
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_extended_codec, kExternalClearKey));
+
+ // Invalid codec format.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_dot_codec, kExternalClearKey));
+
+ // Non-MP4 codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc2_codec, kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", vp8_codec, kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", unknown_codec, kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", mixed_codecs, kExternalClearKey));
+
+ // Valid audio types.
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", no_codecs, kExternalClearKey));
+ EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", aac_codec, kExternalClearKey));
+
+ // Non-audio codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", avc1_codec, kExternalClearKey));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", avc1_and_aac_codecs, kExternalClearKey));
+
+ // Non-MP4 codec.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", vorbis_codec, kExternalClearKey));
+}
+
+//
+// Widevine
+//
+
+TEST_F(KeySystemsTest, Widevine_Basic) {
+ EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha)));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), kWidevineAlpha));
+
+#if defined(WIDEVINE_CDM_AVAILABLE)
+ const char* const kWidevineUmaName = "Widevine";
+#else
+ const char* const kWidevineUmaName = "Unknown";
+#endif
+ EXPECT_STREQ(
+ kWidevineUmaName,
+ KeySystemNameForUMA(std::string(kWidevineAlpha)).c_str());
+ EXPECT_STREQ(
+ kWidevineUmaName,
+ KeySystemNameForUMA(WebString::fromUTF8(kWidevineAlpha)).c_str());
+
+ EXPECT_FALSE(CanUseAesDecryptor(kWidevineAlpha));
+#if defined(WIDEVINE_CDM_AVAILABLE)
+ EXPECT_STREQ("application/x-ppapi-widevine-cdm",
+ GetPluginType(kWidevineAlpha).c_str());
+#else
+ EXPECT_TRUE(GetPluginType(kWidevineAlpha).empty());
+#endif
+}
+
+TEST_F(KeySystemsTest, Widevine_Parent) {
+ const char* const kWidevineParent = "com.widevine";
+
+ EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineParent)));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), kWidevineParent));
+
+ // The parent is not supported for most things.
+ EXPECT_STREQ("Unknown",
+ KeySystemNameForUMA(std::string(kWidevineParent)).c_str());
+ EXPECT_STREQ("Unknown",
+ KeySystemNameForUMA(WebString::fromUTF8(kWidevineParent)).c_str());
+ EXPECT_FALSE(CanUseAesDecryptor(kWidevineParent));
+ EXPECT_TRUE(GetPluginType(kWidevineParent).empty());
+}
+
+TEST_F(KeySystemsTest, Widevine_IsSupportedKeySystem_InvalidVariants) {
+ // Case sensitive.
+ EXPECT_FALSE(IsSupportedKeySystem("com.widevine.AlPhA"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "com.widevine.AlPhA"));
+
+ // TLDs are not allowed.
+ EXPECT_FALSE(IsSupportedKeySystem("com."));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "com."));
+ EXPECT_FALSE(IsSupportedKeySystem("com"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "com"));
+
+ // Extra period.
+ EXPECT_FALSE(IsSupportedKeySystem("com.widevine."));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "com.widevine."));
+
+ // Incomplete.
+ EXPECT_FALSE(IsSupportedKeySystem("com.widevine.alph"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "com.widevine.alph"));
+
+ // Extra character.
+ EXPECT_FALSE(IsSupportedKeySystem("com.widevine.alphab"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "com.widevine.alphab"));
+
+ // There are no child key systems for Widevine Alpha.
+ EXPECT_FALSE(IsSupportedKeySystem("com.widevine.alpha.foo"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", std::vector<std::string>(), "com.widevine.alpha.foo"));
+}
+
+TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_NoType) {
+ // These two should be true. See http://crbug.com/164303.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "com.widevine.alpha"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "com.widevine"));
+
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "com.widevine.foo"));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "", std::vector<std::string>(), "com.widevine.alpha.foo"));
+}
+
+TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) {
+ // Valid video types.
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", no_codecs, kWidevineAlpha));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", no_codecs, "com.widevine"));
+ 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));
+
+ // Non-Webm codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", avc1_codec, kWidevineAlpha));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", unknown_codec, kWidevineAlpha));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", mixed_codecs, kWidevineAlpha));
+
+ // Valid audio types.
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", no_codecs, kWidevineAlpha));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vorbis_codec, kWidevineAlpha));
+
+ // Non-audio codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vp8_codec, kWidevineAlpha));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vp8_and_vorbis_codecs, kWidevineAlpha));
+
+ // Non-Webm codec.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", aac_codec, kWidevineAlpha));
+}
+
+TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) {
+ std::vector<std::string> avc1_extended_codec;
+ avc1_extended_codec.push_back("avc1.4D400C");
+ std::vector<std::string> avc1_dot_codec;
+ avc1_dot_codec.push_back("avc1.");
+ std::vector<std::string> avc2_codec;
+ avc2_codec.push_back("avc2");
+
+
+ // Valid video types.
+ EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", no_codecs, kWidevineAlpha));
+ EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", no_codecs, "com.widevine"));
+ EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_codec, kWidevineAlpha));
+ EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_and_aac_codecs, kWidevineAlpha));
+ EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", aac_codec, kWidevineAlpha));
+
+ // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl.
+ // They should really pass canPlayType().
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_extended_codec, kWidevineAlpha));
+
+ // Invalid codec format.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_dot_codec, kWidevineAlpha));
+
+ // Non-MP4 codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc2_codec, kWidevineAlpha));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", vp8_codec, kWidevineAlpha));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", unknown_codec, kWidevineAlpha));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", mixed_codecs, kWidevineAlpha));
+
+ // Valid audio types.
+ EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", no_codecs, kWidevineAlpha));
+ EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", aac_codec, kWidevineAlpha));
+
+ // Non-audio codecs.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", avc1_codec, kWidevineAlpha));
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", avc1_and_aac_codecs, kWidevineAlpha));
+
+ // Non-MP4 codec.
+ EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", vorbis_codec, kWidevineAlpha));
+}
+
+} // namespace webkit_media
« no previous file with comments | « webkit/media/crypto/key_systems.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698