Fixes for cr-settings-page-header
[chromium-blink-merge.git] / content / browser / media / media_source_browsertest.cc
blob191ff66045eb8e0bd23d7a903b880118f4ff5bcd
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 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,
48 true);
51 #if defined(OS_ANDROID)
52 void SetUpCommandLine(base::CommandLine* command_line) override {
53 command_line->AppendSwitch(
54 switches::kDisableGestureRequirementForMediaPlayback);
56 #endif
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);
72 #endif
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.";
87 return;
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