#include "content/browser/media/media_browsertest.h"
#include <memory>
#include <string_view>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/gpu_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.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/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/shell/common/shell_switches.h"
#include "media/audio/audio_features.h"
#include "media/base/media_switches.h"
#include "media/base/supported_types.h"
#include "media/base/test_data_util.h"
#include "media/media_buildflags.h"
#include "media/mojo/services/gpu_mojo_media_client_test_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/url_util.h"
#if BUILDFLAG(IS_ANDROID) && !BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
#define REQUIRE_ACCELERATION_ON_ANDROID …
#else
#define REQUIRE_ACCELERATION_ON_ANDROID() …
#endif
namespace content {
#if BUILDFLAG(IS_ANDROID)
const char16_t kClean[] = u"CLEAN";
#endif
void MediaBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { … }
void MediaBrowserTest::RunMediaTestPage(const std::string& html_page,
const base::StringPairs& query_params,
const std::string& expected_title,
bool http) { … }
std::string MediaBrowserTest::RunTest(const GURL& gurl,
const std::string& expected_title) { … }
void MediaBrowserTest::CleanupTest() { … }
std::string MediaBrowserTest::EncodeErrorMessage(
const std::string& original_message) { … }
void MediaBrowserTest::AddTitlesToAwait(content::TitleWatcher* title_watcher) { … }
void MediaBrowserTest::PreRunTestOnMainThread() { … }
class MediaTest : public testing::WithParamInterface<bool>,
public MediaBrowserTest { … };
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWebm) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWebm_FileProtocol) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearOpusWebm) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearOpusMp4) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearOpusOgg) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearOpusOgg_FileProtocol) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearSilentWebm) { … }
#if !BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_FUCHSIA) && defined(ARCH_CPU_ARM64)
#define MAYBE_VideoBearHighBitDepthVP9 …
#else
#define MAYBE_VideoBearHighBitDepthVP9 …
#endif
IN_PROC_BROWSER_TEST_P(MediaTest, MAYBE_VideoBearHighBitDepthVP9) { … }
#if BUILDFLAG(IS_FUCHSIA) && defined(ARCH_CPU_ARM64)
#define MAYBE_VideoBear12DepthVP9 …
#else
#define MAYBE_VideoBear12DepthVP9 …
#endif
IN_PROC_BROWSER_TEST_P(MediaTest, MAYBE_VideoBear12DepthVP9) { … }
#endif
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4Vp9) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearFlacMp4) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearFlac192kHzMp4) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS16be) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS24be) { … }
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
#if BUILDFLAG(ENABLE_HLS_DEMUXER)
IN_PROC_BROWSER_TEST_P(MediaTest, HLSSingleFileBear) {
REQUIRE_ACCELERATION_ON_ANDROID();
PlayVideo("bear-1280x720-hls-clear-mpl.m3u8");
}
IN_PROC_BROWSER_TEST_P(MediaTest, HLSMultivariantBitrateBear) {
REQUIRE_ACCELERATION_ON_ANDROID();
PlayVideo("hls/multi-bitrate-multivariant-bear/playlist.m3u8");
}
#endif
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4) {
REQUIRE_ACCELERATION_ON_ANDROID();
PlayVideo("bear.mp4");
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearSilentMp4) {
REQUIRE_ACCELERATION_ON_ANDROID();
PlayVideo("bear_silent.mp4");
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearRotated0) {
REQUIRE_ACCELERATION_ON_ANDROID();
RunVideoSizeTest("bear_rotate_0.mp4", 1280, 720);
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearRotated90) {
REQUIRE_ACCELERATION_ON_ANDROID();
RunVideoSizeTest("bear_rotate_90.mp4", 720, 1280);
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearRotated180) {
REQUIRE_ACCELERATION_ON_ANDROID();
RunVideoSizeTest("bear_rotate_180.mp4", 1280, 720);
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearRotated270) {
REQUIRE_ACCELERATION_ON_ANDROID();
RunVideoSizeTest("bear_rotate_270.mp4", 720, 1280);
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBear3gpAacH264) {
REQUIRE_ACCELERATION_ON_ANDROID();
PlayVideo("bear_h264_aac.3gp");
}
#if BUILDFLAG(ENABLE_HEVC_PARSER_AND_HW_DECODER)
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4Hevc8bit422) {
MaybePlayVideo("hev1.4.10.L93.9d.8",
"bear-1280x720-hevc-8bit-422-no-audio.mp4");
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4Hevc8bit444) {
MaybePlayVideo("hev1.4.10.L93.9e.8",
"bear-1280x720-hevc-8bit-444-no-audio.mp4");
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4Hevc10bit422) {
MaybePlayVideo("hev1.4.10.L93.9d.8",
"bear-1280x720-hevc-10bit-422-no-audio.mp4");
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4Hevc10bit444) {
MaybePlayVideo("hev1.4.10.L93.9c.8",
"bear-1280x720-hevc-10bit-444-no-audio.mp4");
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4Hevc8bit) {
REQUIRE_ACCELERATION_ON_ANDROID();
MaybePlayVideo("hev1.1.6.L93.90", "bear-1280x720-hevc-no-audio.mp4");
}
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMp4Hevc10bit) {
REQUIRE_ACCELERATION_ON_ANDROID();
MaybePlayVideo("hev1.2.4.L93.90", "bear-1280x720-hevc-10bit-no-audio.mp4");
}
#endif
#if BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearHighBitDepthMp4) {
PlayVideo("bear-320x180-hi10p.mp4");
}
#endif
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID)
#define MAYBE_LoadManyVideos …
#else
#define MAYBE_LoadManyVideos …
#endif
IN_PROC_BROWSER_TEST_P(MediaTest, MAYBE_LoadManyVideos) {
if (is_accelerated())
return;
base::StringPairs query_params;
RunMediaTestPage("load_many_videos.html", query_params, media::kEndedTitle,
true);
}
#endif
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearFlac) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioBearFlacOgg) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavAlaw) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavMulaw) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavPcm) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavPcm3kHz) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavPcm192kHz) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoTulipWebm) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoEbu3213Primary) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoErrorMissingResource) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoErrorEmptySrcAttribute) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, VideoErrorNoSupportedStreams) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, Navigate) { … }
IN_PROC_BROWSER_TEST_P(MediaTest, AudioOnly_XHE_AAC_MP4) { … }
INSTANTIATE_TEST_SUITE_P(…);
}