Permission messages: Add a bunch of missing combinations/suppressions.
[chromium-blink-merge.git] / content / browser / media / media_source_browsertest.cc
blobdb819a1cccc6ba6589c182ccd2a7756e8d22e956
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 #if defined(USE_PROPRIETARY_CODECS) && !defined(OS_ANDROID)
14 const char kAAC_ADTS_AudioOnly[] = "audio/aac";
15 #endif
16 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
17 #if !defined(OS_ANDROID)
18 const char kWebMOpusAudioOnly[] = "audio/webm; codecs=\"opus\"";
19 #endif
20 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
21 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
23 #if defined(USE_PROPRIETARY_CODECS) && defined(ENABLE_MPEG2TS_STREAM_PARSER)
24 const char kMp2tAudioVideo[] = "video/mp2t; codecs=\"mp4a.40.2, avc1.42E01E\"";
25 #endif
27 namespace content {
29 // MSE is available on all desktop platforms and on Android 4.1 and later.
30 static bool IsMSESupported() {
31 #if defined(OS_ANDROID)
32 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
33 VLOG(0) << "MSE is only supported in Android 4.1 and later.";
34 return false;
36 #endif // defined(OS_ANDROID)
37 return true;
40 class MediaSourceTest : public content::MediaBrowserTest {
41 public:
42 void TestSimplePlayback(const std::string& media_file,
43 const std::string& media_type,
44 const std::string& expectation) {
45 if (!IsMSESupported()) {
46 VLOG(0) << "Skipping test - MSE not supported.";
47 return;
50 base::StringPairs query_params;
51 query_params.push_back(std::make_pair("mediaFile", media_file));
52 query_params.push_back(std::make_pair("mediaType", media_type));
53 RunMediaTestPage("media_source_player.html", query_params, expectation,
54 false);
57 #if defined(OS_ANDROID)
58 void SetUpCommandLine(base::CommandLine* command_line) override {
59 command_line->AppendSwitch(
60 switches::kDisableGestureRequirementForMediaPlayback);
62 #endif
65 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoAudio_WebM) {
66 TestSimplePlayback("bear-320x240.webm", kWebMAudioVideo, kEnded);
69 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoOnly_WebM) {
70 TestSimplePlayback("bear-320x240-video-only.webm", kWebMVideoOnly, kEnded);
73 #if defined(USE_PROPRIETARY_CODECS) && !defined(OS_ANDROID)
74 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_AAC_ADTS) {
75 TestSimplePlayback("sfx.adts", kAAC_ADTS_AudioOnly, kEnded);
77 #endif
79 // Opus is not supported in Android as of now.
80 #if !defined(OS_ANDROID)
81 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_Opus_WebM) {
82 TestSimplePlayback("bear-opus.webm", kWebMOpusAudioOnly, kEnded);
84 #endif
86 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_WebM) {
87 TestSimplePlayback("bear-320x240-audio-only.webm", kWebMAudioOnly, kEnded);
90 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_Type_Error) {
91 TestSimplePlayback("bear-320x240-video-only.webm", kWebMAudioOnly, kError);
94 // Flaky test crbug.com/246308
95 // Test changed to skip checks resulting in flakiness. Proper fix still needed.
96 IN_PROC_BROWSER_TEST_F(MediaSourceTest, ConfigChangeVideo) {
97 if (!IsMSESupported()) {
98 VLOG(0) << "Skipping test - MSE not supported.";
99 return;
101 RunMediaTestPage("mse_config_change.html", base::StringPairs(), kEnded, true);
104 #if defined(USE_PROPRIETARY_CODECS)
105 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_Video_MP4_Audio_WEBM) {
106 if (!IsMSESupported()) {
107 VLOG(0) << "Skipping test - MSE not supported.";
108 return;
110 base::StringPairs query_params;
111 query_params.push_back(std::make_pair("videoFormat", "CLEAR_MP4"));
112 query_params.push_back(std::make_pair("audioFormat", "CLEAR_WEBM"));
113 RunMediaTestPage("mse_different_containers.html", query_params, kEnded, true);
116 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_Video_WEBM_Audio_MP4) {
117 if (!IsMSESupported()) {
118 VLOG(0) << "Skipping test - MSE not supported.";
119 return;
121 base::StringPairs query_params;
122 query_params.push_back(std::make_pair("videoFormat", "CLEAR_WEBM"));
123 query_params.push_back(std::make_pair("audioFormat", "CLEAR_MP4"));
124 RunMediaTestPage("mse_different_containers.html", query_params, kEnded, true);
126 #endif
128 #if defined(USE_PROPRIETARY_CODECS) && defined(ENABLE_MPEG2TS_STREAM_PARSER)
129 IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioVideo_Mp2t) {
130 TestSimplePlayback("bear-1280x720.ts", kMp2tAudioVideo, kEnded);
132 #endif
133 } // namespace content