1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "content/browser/media/media_browsertest.h"
7 #include "content/public/common/content_switches.h"
8 #if defined(OS_ANDROID)
9 #include "base/android/build_info.h"
12 // Common media types.
13 const char kWebMAudioOnly
[] = "audio/webm; codecs=\"vorbis\"";
14 #if !defined(OS_ANDROID)
15 const char kWebMOpusAudioOnly
[] = "audio/webm; codecs=\"opus\"";
17 const char kWebMVideoOnly
[] = "video/webm; codecs=\"vp8\"";
18 const char kWebMAudioVideo
[] = "video/webm; codecs=\"vorbis, vp8\"";
22 // MSE is available on all desktop platforms and on Android 4.1 and later.
23 static bool IsMSESupported() {
24 #if defined(OS_ANDROID)
25 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
26 VLOG(0) << "MSE is only supported in Android 4.1 and later.";
29 #endif // defined(OS_ANDROID)
33 class MediaSourceTest
: public content::MediaBrowserTest
{
35 void TestSimplePlayback(const std::string
& media_file
,
36 const std::string
& media_type
,
37 const std::string
& expectation
) {
38 if (!IsMSESupported()) {
39 VLOG(0) << "Skipping test - MSE not supported.";
43 base::StringPairs query_params
;
44 query_params
.push_back(std::make_pair("mediaFile", media_file
));
45 query_params
.push_back(std::make_pair("mediaType", media_type
));
46 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
47 RunMediaTestPage("media_source_player.html", query_params
, expectation
,
51 #if defined(OS_ANDROID)
52 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
53 command_line
->AppendSwitch(
54 switches::kDisableGestureRequirementForMediaPlayback
);
59 IN_PROC_BROWSER_TEST_F(MediaSourceTest
, Playback_VideoAudio_WebM
) {
60 TestSimplePlayback("bear-320x240.webm", kWebMAudioVideo
, kEnded
);
63 IN_PROC_BROWSER_TEST_F(MediaSourceTest
, Playback_VideoOnly_WebM
) {
64 TestSimplePlayback("bear-320x240-video-only.webm", kWebMVideoOnly
, kEnded
);
67 // Opus is not supported in Android as of now.
68 #if !defined(OS_ANDROID)
69 IN_PROC_BROWSER_TEST_F(MediaSourceTest
, Playback_AudioOnly_Opus_WebM
) {
70 TestSimplePlayback("bear-opus.webm", kWebMOpusAudioOnly
, kEnded
);
74 IN_PROC_BROWSER_TEST_F(MediaSourceTest
, Playback_AudioOnly_WebM
) {
75 TestSimplePlayback("bear-320x240-audio-only.webm", kWebMAudioOnly
, kEnded
);
78 IN_PROC_BROWSER_TEST_F(MediaSourceTest
, Playback_Type_Error
) {
79 TestSimplePlayback("bear-320x240-video-only.webm", kWebMAudioOnly
, kError
);
82 // Flaky test crbug.com/246308
83 // Test changed to skip checks resulting in flakiness. Proper fix still needed.
84 IN_PROC_BROWSER_TEST_F(MediaSourceTest
, ConfigChangeVideo
) {
85 if (!IsMSESupported()) {
86 VLOG(0) << "Skipping test - MSE not supported.";
89 base::StringPairs query_params
;
90 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
91 RunMediaTestPage("mse_config_change.html", query_params
, kEnded
, true);
94 } // namespace content