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

Unified Diff: content/renderer/media/crypto/key_systems_unittest.cc

Issue 246033002: Store SupportedCodecs in KeySystemInfo and KeySystems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 88c999963ed6603c3b8185cf8edfb677ba545a16..729bce34b61b19e3259f1b638172299262d7a60e 100644
--- a/content/renderer/media/crypto/key_systems_unittest.cc
+++ b/content/renderer/media/crypto/key_systems_unittest.cc
@@ -33,6 +33,8 @@
#endif // defined(NDEBUG)
#endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID)
+namespace content {
+
using blink::WebString;
// These are the (fake) key systems that are registered for these tests.
@@ -49,16 +51,44 @@ const char kExternalClearKey[] = "org.chromium.externalclearkey";
const char kAudioWebM[] = "audio/webm";
const char kVideoWebM[] = "video/webm";
-const char kVorbis[] = "vorbis";
-const char kVP8[] = "vp8";
-const char kVP80[] = "vp8.0";
-
const char kAudioFoo[] = "audio/foo";
const char kVideoFoo[] = "video/foo";
-const char kFooAudioCodec[] = "fooaudio";
-const char kFooVideoCodec[] = "foovideo";
-namespace content {
+// Pick some arbitrary bit fields as long as they are not in conflict with the
+// real ones.
+enum TestCodecMask {
+ FOO_AUDIO = 1 << 10, // An audio codec for foo container.
+ FOO_AUDIO_CODECS = FOO_AUDIO,
+ FOO_VIDEO = 1 << 11, // A video codec for foo container.
+ FOO_VIDEO_CODECS = FOO_VIDEO,
+ FOO_ALL_CODECS = FOO_AUDIO_CODECS | FOO_VIDEO_CODECS
+};
+
+COMPILE_ASSERT((FOO_ALL_CODECS & ALL_CODECS) == NO_CODECS,
+ test_codec_masks_should_only_use_invalid_codec_masks);
+
+// Adds test container and codec masks.
+// This function must be called after SetContentClient() is called.
+// More details: AddXxxMask() will create KeySystems if it hasn't been created.
+// During KeySystems's construction GetContentClient() will be used to add key
+// systems. In test code, the content client is set by SetContentClient().
+// Therefore, SetContentClient() must be called before this function to avoid
+// access violation.
+static void AddContainerAndCodecMasksForTest() {
+ // Since KeySystems is a singleton. Make sure we only add test container and
+ // codec masks once per process.
+ static bool is_test_masks_added = false;
+
+ if (is_test_masks_added)
+ return;
+
+ AddContainerMask("audio/foo", FOO_AUDIO_CODECS);
+ AddContainerMask("video/foo", FOO_ALL_CODECS);
+ AddCodecMask("fooaudio", FOO_AUDIO);
+ AddCodecMask("foovideo", FOO_VIDEO);
+
+ is_test_masks_added = true;
+}
class TestContentRendererClient : public ContentRendererClient {
virtual void AddKeySystems(
@@ -68,35 +98,18 @@ class TestContentRendererClient : public ContentRendererClient {
void TestContentRendererClient::AddKeySystems(
std::vector<content::KeySystemInfo>* key_systems) {
KeySystemInfo aes(kUsesAes);
-
- aes.supported_types[kAudioWebM].insert(kVorbis);
- aes.supported_types[kVideoWebM] = aes.supported_types[kAudioWebM];
- aes.supported_types[kVideoWebM].insert(kVP8);
- aes.supported_types[kVideoWebM].insert(kVP80);
- aes.supported_types[kAudioFoo].insert(kFooAudioCodec);
- aes.supported_types[kVideoFoo] = aes.supported_types[kAudioFoo];
- aes.supported_types[kVideoFoo].insert(kFooVideoCodec);
-
+ aes.supported_codecs = WEBM_ALL_CODECS;
+ aes.supported_codecs |= FOO_ALL_CODECS;
aes.use_aes_decryptor = true;
-
key_systems->push_back(aes);
KeySystemInfo ext(kExternal);
-
- ext.supported_types[kAudioWebM].insert(kVorbis);
- ext.supported_types[kVideoWebM] = ext.supported_types[kAudioWebM];
- ext.supported_types[kVideoWebM].insert(kVP8);
- ext.supported_types[kVideoWebM].insert(kVP80);
- ext.supported_types[kAudioFoo].insert(kFooAudioCodec);
- ext.supported_types[kVideoFoo] = ext.supported_types[kAudioFoo];
- ext.supported_types[kVideoFoo].insert(kFooVideoCodec);
-
+ ext.supported_codecs = WEBM_ALL_CODECS;
+ ext.supported_codecs |= FOO_ALL_CODECS;
ext.parent_key_system = kExternalParent;
-
#if defined(ENABLE_PEPPER_CDMS)
ext.pepper_type = "application/x-ppapi-external-cdm";
#endif // defined(ENABLE_PEPPER_CDMS)
-
key_systems->push_back(ext);
}
@@ -139,6 +152,10 @@ class KeySystemsTest : public testing::Test {
SetRendererClientForTesting(&content_renderer_client_);
}
+ virtual void SetUp() OVERRIDE {
+ AddContainerAndCodecMasksForTest();
+ }
+
virtual ~KeySystemsTest() {
// Clear the use of content_client_, which was set in SetUp().
SetContentClient(NULL);
« content/renderer/media/crypto/key_systems.cc ('K') | « content/renderer/media/crypto/key_systems.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698