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 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
15 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
19 // MSE is available on all desktop platforms and on Android 4.1 and later.
20 static bool IsMSESupported() {
21 #if defined(OS_ANDROID)
22 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
23 LOG(INFO) << "MSE is only supported in Android 4.1 and later.";
26 #endif // defined(OS_ANDROID)
30 class MediaSourceTest : public content::MediaBrowserTest {
32 void TestSimplePlayback(const char* media_file, const char* media_type,
33 const char* expectation) {
34 if (!IsMSESupported()) {
35 LOG(INFO) << "Skipping test - MSE not supported.";
39 std::vector<StringPair> query_params;
40 query_params.push_back(std::make_pair("mediafile", media_file));
41 query_params.push_back(std::make_pair("mediatype", media_type));
42 RunMediaTestPage("media_source_player.html", &query_params, expectation,
46 #if defined(OS_ANDROID)
47 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
48 command_line->AppendSwitch(
49 switches::kDisableGestureRequirementForMediaPlayback);
54 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoAudio_WebM) {
55 TestSimplePlayback("bear-320x240.webm", kWebMAudioVideo, kEnded);
58 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoOnly_WebM) {
59 TestSimplePlayback("bear-320x240-video-only.webm", kWebMVideoOnly, kEnded);
62 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_WebM) {
63 TestSimplePlayback("bear-320x240-audio-only.webm", kWebMAudioOnly, kEnded);
66 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_Type_Error) {
67 TestSimplePlayback("bear-320x240-video-only.webm", kWebMAudioOnly, kError);
70 // Flaky test crbug.com/246308
71 // Test changed to skip checks resulting in flakiness. Proper fix still needed.
72 IN_PROC_BROWSER_TEST_F(MediaSourceTest, ConfigChangeVideo) {
73 if (!IsMSESupported()) {
74 LOG(INFO) << "Skipping test - MSE not supported.";
77 RunMediaTestPage("mse_config_change.html", NULL, kEnded, true);
80 } // namespace content