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

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

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

Powered by Google App Engine
This is Rietveld 408576698