| 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..c5e05cf298660bc0e126e1c3ee897285b6e197cc 100644
|
| --- a/content/renderer/media/crypto/key_systems_unittest.cc
|
| +++ b/content/renderer/media/crypto/key_systems_unittest.cc
|
| @@ -49,17 +49,45 @@ 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";
|
| +
|
| +enum TestCodecMask {
|
| + FOO_AUDIO_CODEC = 1 << 10,
|
| + FOO_AUDIO = FOO_AUDIO_CODEC,
|
| + FOO_VIDEO_CODEC = 1 << 11,
|
| + FOO_VIDEO = FOO_VIDEO_CODEC,
|
| + FOO_CODECS = FOO_AUDIO | FOO_VIDEO
|
| +};
|
| +
|
| +COMPILE_ASSERT((FOO_CODECS & media::ALL_CODECS) == media::NO_CODECS,
|
| + "Test codec masks should only use invalid codec masks.");
|
|
|
| namespace content {
|
|
|
| +// 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);
|
| + AddContainerMask("video/foo", FOO_CODECS);
|
| + AddCodecMask("fooaudio", FOO_AUDIO_CODEC);
|
| + AddCodecMask("foovideo", FOO_VIDEO_CODEC);
|
| +
|
| + is_test_masks_added = true;
|
| +}
|
| +
|
| class TestContentRendererClient : public ContentRendererClient {
|
| virtual void AddKeySystems(
|
| std::vector<content::KeySystemInfo>* key_systems) OVERRIDE;
|
| @@ -68,35 +96,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 = media::WEBM_CODECS;
|
| + aes.supported_codecs |= FOO_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 = media::WEBM_CODECS;
|
| + ext.supported_codecs |= FOO_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 +150,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);
|
|
|