Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: trunk/src/content/browser/media/encrypted_media_browsertest.cc

Issue 383063009: Revert 282795 "Have media content and chrome browser tests load ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h"
6 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
7 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
8 #include "content/browser/media/media_browsertest.h" 9 #include "content/browser/media/media_browsertest.h"
9 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
10 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/browser_test_utils.h"
11 #include "content/shell/browser/shell.h" 12 #include "content/shell/browser/shell.h"
12 #if defined(OS_ANDROID) 13 #if defined(OS_ANDROID)
13 #include "base/android/build_info.h" 14 #include "base/android/build_info.h"
14 #endif 15 #endif
15 16
16 // Available key systems. 17 // Available key systems.
17 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; 18 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
18 19
19 // Supported media types. 20 // Supported media types.
20 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; 21 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
21 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; 22 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
22 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; 23 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
23 24
24 // EME-specific test results and errors. 25 // EME-specific test results and errors.
25 const char kEmeKeyError[] = "KEYERROR"; 26 const char kEmeKeyError[] = "KEYERROR";
26 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; 27 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
27 28
28 const char kDefaultEmePlayer[] = "eme_player.html";
29
30 // The type of video src used to load media. 29 // The type of video src used to load media.
31 enum SrcType { 30 enum SrcType {
32 SRC, 31 SRC,
33 MSE 32 MSE
34 }; 33 };
35 34
36 namespace content { 35 namespace content {
37 36
38 // MSE is available on all desktop platforms and on Android 4.1 and later. 37 // MSE is available on all desktop platforms and on Android 4.1 and later.
39 static bool IsMSESupported() { 38 static bool IsMSESupported() {
40 #if defined(OS_ANDROID) 39 #if defined(OS_ANDROID)
41 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { 40 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
42 VLOG(0) << "MSE is only supported in Android 4.1 and later."; 41 VLOG(0) << "MSE is only supported in Android 4.1 and later.";
43 return false; 42 return false;
44 } 43 }
45 #endif // defined(OS_ANDROID) 44 #endif // defined(OS_ANDROID)
46 return true; 45 return true;
47 } 46 }
48 47
49 // Tests encrypted media playback with a combination of parameters: 48 // Tests encrypted media playback with a combination of parameters:
50 // - char*: Key system name. 49 // - char*: Key system name.
51 // - bool: True to load media using MSE, otherwise use src. 50 // - bool: True to load media using MSE, otherwise use src.
52 class EncryptedMediaTest : public content::MediaBrowserTest, 51 class EncryptedMediaTest : public content::MediaBrowserTest,
53 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > { 52 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > {
54 public: 53 public:
55 // Can only be used in parameterized (*_P) tests. 54 // Can only be used in parameterized (*_P) tests.
56 const std::string CurrentKeySystem() { 55 const char* CurrentKeySystem() {
57 return std::tr1::get<0>(GetParam()); 56 return std::tr1::get<0>(GetParam());
58 } 57 }
59 58
60 // Can only be used in parameterized (*_P) tests. 59 // Can only be used in parameterized (*_P) tests.
61 SrcType CurrentSourceType() { 60 SrcType CurrentSourceType() {
62 return std::tr1::get<1>(GetParam()); 61 return std::tr1::get<1>(GetParam());
63 } 62 }
64 63
65 void TestSimplePlayback(const std::string& encrypted_media, 64 void TestSimplePlayback(const char* encrypted_media, const char* media_type) {
66 const std::string& media_type) {
67 RunSimpleEncryptedMediaTest( 65 RunSimpleEncryptedMediaTest(
68 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType()); 66 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType());
69 } 67 }
70 68
71 void TestFrameSizeChange() { 69 void TestFrameSizeChange() {
72 RunEncryptedMediaTest("encrypted_frame_size_change.html", 70 RunEncryptedMediaTest("encrypted_frame_size_change.html",
73 "frame_size_change-av_enc-v.webm", kWebMAudioVideo, 71 "frame_size_change-av-enc-v.webm", kWebMAudioVideo,
74 CurrentKeySystem(), CurrentSourceType(), kEnded); 72 CurrentKeySystem(), CurrentSourceType(), kEnded);
75 } 73 }
76 74
77 void TestConfigChange() { 75 void TestConfigChange() {
78 if (CurrentSourceType() != MSE || !IsMSESupported()) { 76 if (CurrentSourceType() != MSE || !IsMSESupported()) {
79 VLOG(0) << "Skipping test - config change test requires MSE."; 77 VLOG(0) << "Skipping test - config change test requires MSE.";
80 return; 78 return;
81 } 79 }
82 80
83 media::QueryParams query_params; 81 std::vector<StringPair> query_params;
84 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); 82 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem()));
85 query_params.push_back(std::make_pair("runEncrypted", "1")); 83 query_params.push_back(std::make_pair("runencrypted", "1"));
86 RunMediaTestPage("mse_config_change.html", query_params, kEnded, true); 84 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true);
87 } 85 }
88 86
89 void RunEncryptedMediaTest(const std::string& html_page, 87 void RunEncryptedMediaTest(const char* html_page,
90 const std::string& media_file, 88 const char* media_file,
91 const std::string& media_type, 89 const char* media_type,
92 const std::string& key_system, 90 const char* key_system,
93 SrcType src_type, 91 SrcType src_type,
94 const std::string& expectation) { 92 const char* expectation) {
95 if (src_type == MSE && !IsMSESupported()) { 93 if (src_type == MSE && !IsMSESupported()) {
96 VLOG(0) << "Skipping test - MSE not supported."; 94 VLOG(0) << "Skipping test - MSE not supported.";
97 return; 95 return;
98 } 96 }
99 97
100 media::QueryParams query_params; 98 std::vector<StringPair> query_params;
101 query_params.push_back(std::make_pair("mediaFile", media_file)); 99 query_params.push_back(std::make_pair("mediafile", media_file));
102 query_params.push_back(std::make_pair("mediaType", media_type)); 100 query_params.push_back(std::make_pair("mediatype", media_type));
103 query_params.push_back(std::make_pair("keySystem", key_system)); 101 query_params.push_back(std::make_pair("keysystem", key_system));
104 if (src_type == MSE) 102 if (src_type == MSE)
105 query_params.push_back(std::make_pair("useMSE", "1")); 103 query_params.push_back(std::make_pair("usemse", "1"));
106 RunMediaTestPage(html_page, query_params, expectation, true); 104 RunMediaTestPage(html_page, &query_params, expectation, true);
107 } 105 }
108 106
109 void RunSimpleEncryptedMediaTest(const std::string& media_file, 107 void RunSimpleEncryptedMediaTest(const char* media_file,
110 const std::string& media_type, 108 const char* media_type,
111 const std::string& key_system, 109 const char* key_system,
112 SrcType src_type) { 110 SrcType src_type) {
113 RunEncryptedMediaTest(kDefaultEmePlayer, 111 RunEncryptedMediaTest("encrypted_media_player.html", media_file,
114 media_file, 112 media_type, key_system, src_type, kEnded);
115 media_type,
116 key_system,
117 src_type,
118 kEnded);
119 } 113 }
120 114
121 protected: 115 protected:
122 // We want to fail quickly when a test fails because an error is encountered. 116 // We want to fail quickly when a test fails because an error is encountered.
123 virtual void AddWaitForTitles(content::TitleWatcher* title_watcher) OVERRIDE { 117 virtual void AddWaitForTitles(content::TitleWatcher* title_watcher) OVERRIDE {
124 MediaBrowserTest::AddWaitForTitles(title_watcher); 118 MediaBrowserTest::AddWaitForTitles(title_watcher);
125 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); 119 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError));
126 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError)); 120 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError));
127 } 121 }
128 122
(...skipping 11 matching lines...) Expand all
140 #if !defined(OS_ANDROID) 134 #if !defined(OS_ANDROID)
141 // Encrypted media playback with SRC is not supported on Android. 135 // Encrypted media playback with SRC is not supported on Android.
142 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, 136 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest,
143 Combine(Values(kClearKeyKeySystem), Values(SRC))); 137 Combine(Values(kClearKeyKeySystem), Values(SRC)));
144 #endif // !defined(OS_ANDROID) 138 #endif // !defined(OS_ANDROID)
145 139
146 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, 140 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
147 Combine(Values(kClearKeyKeySystem), Values(MSE))); 141 Combine(Values(kClearKeyKeySystem), Values(MSE)));
148 142
149 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { 143 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
150 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly); 144 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly);
151 } 145 }
152 146
153 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { 147 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
154 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo); 148 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo);
155 } 149 }
156 150
157 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { 151 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
158 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo); 152 TestSimplePlayback("bear-320x240-av-enc_av.webm", kWebMAudioVideo);
159 } 153 }
160 154
161 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) { 155 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) {
162 TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly); 156 TestSimplePlayback("bear-320x240-v-enc_v.webm", kWebMVideoOnly);
163 } 157 }
164 158
165 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) { 159 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) {
166 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo); 160 TestSimplePlayback("bear-320x240-av-enc_v.webm", kWebMAudioVideo);
167 } 161 }
168 162
169 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { 163 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) {
170 TestConfigChange(); 164 TestConfigChange();
171 } 165 }
172 166
173 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) { 167 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) {
174 // Times out on Windows XP. http://crbug.com/171937 168 // Times out on Windows XP. http://crbug.com/171937
175 #if defined(OS_WIN) 169 #if defined(OS_WIN)
176 if (base::win::GetVersion() < base::win::VERSION_VISTA) 170 if (base::win::GetVersion() < base::win::VERSION_VISTA)
177 return; 171 return;
178 #endif 172 #endif
179 TestFrameSizeChange(); 173 TestFrameSizeChange();
180 } 174 }
181 175
182 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { 176 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) {
183 RunEncryptedMediaTest(kDefaultEmePlayer, 177 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm",
184 "bear-a_enc-a.webm", 178 kWebMAudioOnly, "com.example.foo", MSE,
185 kWebMAudioOnly,
186 "com.example.foo",
187 MSE,
188 kEmeNotSupportedError); 179 kEmeNotSupportedError);
189 } 180 }
190 181
191 } // namespace content 182 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698