Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / media / media_source_browsertest.cc
blob90d0c84219fdb5774774c2a29656e3e62833809b
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"
10 #endif
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\"";
16 #endif
17 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
18 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
20 namespace content {
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.";
27 return false;
29 #endif // defined(OS_ANDROID)
30 return true;
33 class MediaSourceTest : public content::MediaBrowserTest {
34 public:
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.";
40 return;
43 media::QueryParams 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 RunMediaTestPage("media_source_player.html", query_params, expectation,
47 true);
50 #if defined(OS_ANDROID)
51 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
52 command_line->AppendSwitch(
53 switches::kDisableGestureRequirementForMediaPlayback);
55 #endif
58 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoAudio_WebM) {
59 TestSimplePlayback("bear-320x240.webm", kWebMAudioVideo, kEnded);
62 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoOnly_WebM) {
63 TestSimplePlayback("bear-320x240-video-only.webm", kWebMVideoOnly, kEnded);
66 // Opus is not supported in Android as of now.
67 #if !defined(OS_ANDROID)
68 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_Opus_WebM) {
69 TestSimplePlayback("bear-opus.webm", kWebMOpusAudioOnly, kEnded);
71 #endif
73 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_WebM) {
74 TestSimplePlayback("bear-320x240-audio-only.webm", kWebMAudioOnly, kEnded);
77 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_Type_Error) {
78 TestSimplePlayback("bear-320x240-video-only.webm", kWebMAudioOnly, kError);
81 // Flaky test crbug.com/246308
82 // Test changed to skip checks resulting in flakiness. Proper fix still needed.
83 IN_PROC_BROWSER_TEST_F(MediaSourceTest, ConfigChangeVideo) {
84 if (!IsMSESupported()) {
85 VLOG(0) << "Skipping test - MSE not supported.";
86 return;
88 RunMediaTestPage("mse_config_change.html",
89 media::QueryParams(),
90 kEnded,
91 true);
94 } // namespace content