chromium/media/base/key_systems_unittest.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/base/key_systems.h"

#include <optional>
#include <string>
#include <vector>

#include "base/check.h"
#include "base/notreached.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "media/base/audio_parameters.h"
#include "media/base/decrypt_config.h"
#include "media/base/eme_constants.h"
#include "media/base/key_systems_impl.h"
#include "media/base/media.h"
#include "media/base/media_client.h"
#include "media/cdm/clear_key_cdm_common.h"
#include "media/media_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h"

namespace media {

namespace {

// These are the (fake) key systems that are registered for these tests.
// kUsesAes uses the AesDecryptor like Clear Key.
// kExternal uses an external CDM, such as library CDM or Android platform CDM.
const char kUsesAes[] =;
const char kExternal[] =;

const char kAudioWebM[] =;
const char kVideoWebM[] =;
const char kAudioFoo[] =;
const char kVideoFoo[] =;

const char kRobustnessSupported[] =;
const char kRobustnessSecureCodecsRequired[] =;
const char kRobustnessNotSupported[] =;

// Codecs only supported in FOO container. Pick some arbitrary bit fields as
// long as they are not in conflict with the real ones (static_asserted below).
// TODO(crbug.com/40521627): Remove container type (FOO) from codec enums.
enum TestCodec : uint32_t {};

static_assert;

// Base class to provide default implementations.
class TestKeySystemInfoBase : public KeySystemInfo {};

class AesKeySystemInfo : public TestKeySystemInfoBase {};

class ExternalKeySystemInfo : public TestKeySystemInfoBase {};

class TestMediaClient : public MediaClient {};

TestMediaClient::TestMediaClient() = default;
TestMediaClient::~TestMediaClient() = default;

std::unique_ptr<::media::KeySystemSupportRegistration>
TestMediaClient::GetSupportedKeySystems(GetSupportedKeySystemsCB cb) {}

bool TestMediaClient::IsSupportedAudioType(const AudioType& type) {}

bool TestMediaClient::IsSupportedVideoType(const VideoType& type) {}

bool TestMediaClient::IsSupportedBitstreamAudioCodec(AudioCodec codec) {}

ExternalMemoryAllocator* TestMediaClient::GetMediaAllocator() {}

void TestMediaClient::DisableExternalKeySystemSupport() {}

std::optional<AudioRendererAlgorithmParameters>
TestMediaClient::GetAudioRendererAlgorithmParameters(
    AudioParameters audio_parameters) {}

KeySystemInfos TestMediaClient::GetSupportedKeySystemsInternal() {}

}  // namespace

class KeySystemsTest : public testing::Test {};

TEST_F(KeySystemsTest, EmptyKeySystem) {}

// Clear Key is the only key system registered in content.
TEST_F(KeySystemsTest, ClearKey) {}

TEST_F(KeySystemsTest, ClearKeyWithInitDataType) {}

// The key system is not registered and therefore is unrecognized.
TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) {}

TEST_F(KeySystemsTest, Basic_UsesAesDecryptor) {}

TEST_F(KeySystemsTest,
       IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) {}

TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) {}

TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) {}

// Tests the second registered container type.
// TODO(ddorwin): Combined with TypesContainer1 in a future CL.
TEST_F(KeySystemsTest,
       IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer2) {}

TEST_F(KeySystemsTest,
       IsSupportedKeySystem_UsesAesDecryptor_EncryptionSchemes) {}

//
// Non-AesDecryptor-based key system.
//

TEST_F(KeySystemsTest, Basic_ExternalDecryptor) {}

TEST_F(
    KeySystemsTest,
    IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) {}

TEST_F(
    KeySystemsTest,
    IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) {}

TEST_F(KeySystemsTest,
       IsSupportedKeySystem_ExternalDecryptor_EncryptionSchemes) {}

TEST_F(KeySystemsTest, KeySystemNameForUMA) {}

TEST_F(KeySystemsTest, KeySystemsUpdate) {}

TEST_F(KeySystemsTest, GetContentTypeConfigRule) {}

TEST_F(KeySystemsTest, HardwareSecureCodecs) {}

}  // namespace media