#include <tuple>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "content/browser/media/media_browsertest.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/shell/browser/shell.h"
#include "media/base/media.h"
#include "media/base/media_switches.h"
#include "media/base/test_data_util.h"
#include "media/cdm/clear_key_cdm_common.h"
#include "media/media_buildflags.h"
#include "media/mojo/buildflags.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#include "media/base/android/media_codec_util.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
#endif
#if BUILDFLAG(ENABLE_MOJO_CDM) && !BUILDFLAG(ENABLE_LIBRARY_CDMS)
#define SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL
#endif
namespace content {
const char16_t kEmeKeyError[] = …;
const char kEmeNotSupportedError[] = …;
const char16_t kEmeNotSupportedError16[] = …;
const char kDefaultEmePlayer[] = …;
const char kDefaultMseOnlyEmePlayer[] = …;
enum class SrcType { … };
enum class ConfigChangeType { … };
class EncryptedMediaTest
: public MediaBrowserTest,
public testing::WithParamInterface<std::tuple<const char*, SrcType>> { … };
Combine;
Values;
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
#if defined(SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL)
INSTANTIATE_TEST_SUITE_P(SRC_ExternalClearKey,
EncryptedMediaTest,
Combine(Values(media::kExternalClearKeyKeySystem),
Values(SrcType::SRC)));
INSTANTIATE_TEST_SUITE_P(MSE_ExternalClearKey,
EncryptedMediaTest,
Combine(Values(media::kExternalClearKeyKeySystem),
Values(SrcType::MSE)));
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_Playback_VideoAudio_WebM …
#else
#define MAYBE_Playback_VideoAudio_WebM …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, MAYBE_Playback_VideoAudio_WebM) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
DISABLED_Playback_VideoOnly_WebM_Fullsample) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM_Subsample) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_Playback_VideoAudio_WebM_Opus …
#else
#define MAYBE_Playback_VideoAudio_WebM_Opus …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
MAYBE_Playback_VideoAudio_WebM_Opus) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM_Opus) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_Playback_VideoClearAudio_WebM_Opus …
#else
#define MAYBE_Playback_VideoClearAudio_WebM_Opus …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
MAYBE_Playback_VideoClearAudio_WebM_Opus) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4_FLAC) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4_OPUS) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9) { … }
#if !BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_MAC) || (BUILDFLAG(IS_FUCHSIA) && defined(ARCH_CPU_ARM_FAMILY))
#define MAYBE_Playback_VideoOnly_WebM_VP9Profile2 …
#else
#define MAYBE_Playback_VideoOnly_WebM_VP9Profile2 …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
MAYBE_Playback_VideoOnly_WebM_VP9Profile2) { … }
#if BUILDFLAG(IS_MAC) || (BUILDFLAG(IS_FUCHSIA) && defined(ARCH_CPU_ARM_FAMILY))
#define MAYBE_Playback_VideoOnly_MP4_VP9Profile2 …
#else
#define MAYBE_Playback_VideoOnly_MP4_VP9Profile2 …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
MAYBE_Playback_VideoOnly_MP4_VP9Profile2) { … }
#endif
#if BUILDFLAG(ENABLE_AV1_DECODER)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM_AV1) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_Playback_VideoOnly_WebM_AV1_10bit …
#else
#define MAYBE_Playback_VideoOnly_WebM_AV1_10bit …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
MAYBE_Playback_VideoOnly_WebM_AV1_10bit) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_AV1) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_AV1_10bit) { … }
#endif
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_ConfigChangeVideo_ClearToClear …
#else
#define MAYBE_ConfigChangeVideo_ClearToClear …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
MAYBE_ConfigChangeVideo_ClearToClear) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_ConfigChangeVideo_ClearToEncrypted …
#else
#define MAYBE_ConfigChangeVideo_ClearToEncrypted …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
MAYBE_ConfigChangeVideo_ClearToEncrypted) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo_EncryptedToClear) { … }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
ConfigChangeVideo_EncryptedToEncrypted) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_FrameSizeChangeVideo …
#else
#define MAYBE_FrameSizeChangeVideo …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, MAYBE_FrameSizeChangeVideo) { … }
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Encryption_CENC) {
RunMultipleFileTest("bear-640x360-v_frag-cenc.mp4",
"bear-640x360-a_frag-cenc.mp4", media::kEndedTitle);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Encryption_CBC1) {
RunMultipleFileTest("bear-640x360-v_frag-cbc1.mp4", std::string(),
media::kErrorTitle);
}
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_Playback_Encryption_CENS …
#else
#define MAYBE_Playback_Encryption_CENS …
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, MAYBE_Playback_Encryption_CENS) {
RunMultipleFileTest("bear-640x360-v_frag-cens.mp4", std::string(),
media::kErrorTitle);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Encryption_CBCS) {
RunMultipleFileTest("bear-640x360-v_frag-cbcs.mp4",
"bear-640x360-a_frag-cbcs.mp4", media::kEndedTitle);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
Playback_Encryption_CBCS_Video_CENC_Audio) {
RunMultipleFileTest("bear-640x360-v_frag-cbcs.mp4",
"bear-640x360-a_frag-cenc.mp4", media::kEndedTitle);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
Playback_Encryption_CENC_Video_CBCS_Audio) {
RunMultipleFileTest("bear-640x360-v_frag-cenc.mp4",
"bear-640x360-a_frag-cbcs.mp4", media::kEndedTitle);
}
#endif
IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { … }
}