OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/path_service.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
9 #include "chrome/browser/media/media_browsertest.h" | 9 #include "chrome/browser/media/media_browsertest.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
14 #if defined(OS_ANDROID) | |
15 #include "base/android/build_info.h" | |
16 #endif | |
14 | 17 |
15 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
16 | 19 |
17 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) | 20 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) |
18 #include <gnu/libc-version.h> | 21 #include <gnu/libc-version.h> |
19 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) | 22 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) |
20 | 23 |
21 #if defined(ENABLE_PEPPER_CDMS) | 24 #if defined(ENABLE_PEPPER_CDMS) |
22 // Platform-specific filename relative to the chrome executable. | 25 // Platform-specific filename relative to the chrome executable. |
23 const char kClearKeyCdmAdapterFileName[] = | 26 const char kClearKeyCdmAdapterFileName[] = |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 LOG(INFO) << "FrameSizeChange test cannot run with Widevine."; | 92 LOG(INFO) << "FrameSizeChange test cannot run with Widevine."; |
90 return; | 93 return; |
91 } | 94 } |
92 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 95 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
93 RunEncryptedMediaTest("encrypted_frame_size_change.html", | 96 RunEncryptedMediaTest("encrypted_frame_size_change.html", |
94 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, | 97 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, |
95 CurrentKeySystem(), CurrentSourceType(), kEnded); | 98 CurrentKeySystem(), CurrentSourceType(), kEnded); |
96 } | 99 } |
97 | 100 |
98 void TestConfigChange() { | 101 void TestConfigChange() { |
102 if (CurrentSourceType() != MSE) { | |
103 LOG(INFO) << "Skipping test - config change only applies to MSE."; | |
104 return; | |
105 } | |
106 | |
107 #if defined(OS_ANDROID) | |
108 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { | |
qinmin
2013/10/16 22:14:34
make this a static boolean function at the top of
xhwang
2013/10/17 00:46:19
Done.
| |
109 LOG(INFO) << "Skipping test - MSE only supported in JellyBean and later."; | |
ddorwin
2013/10/16 22:51:46
JB is two words. Maybe just say 4.1?
xhwang
2013/10/17 00:46:19
I tried 4.1 but in the context I need to use "Andr
| |
110 return; | |
111 } | |
112 #endif // defined(OS_ANDROID) | |
113 | |
99 #if defined(WIDEVINE_CDM_AVAILABLE) | 114 #if defined(WIDEVINE_CDM_AVAILABLE) |
100 if (IsWidevine(CurrentKeySystem())) { | 115 if (IsWidevine(CurrentKeySystem())) { |
101 LOG(INFO) << "ConfigChange test cannot run with Widevine."; | 116 LOG(INFO) << "ConfigChange test cannot run with Widevine."; |
102 return; | 117 return; |
103 } | 118 } |
104 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 119 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
120 | |
105 std::vector<StringPair> query_params; | 121 std::vector<StringPair> query_params; |
106 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); | 122 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); |
107 query_params.push_back(std::make_pair("runencrypted", "1")); | 123 query_params.push_back(std::make_pair("runencrypted", "1")); |
108 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); | 124 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); |
109 } | 125 } |
110 | 126 |
111 void RunEncryptedMediaTest(const char* html_page, | 127 void RunEncryptedMediaTest(const char* html_page, |
112 const char* media_file, | 128 const char* media_file, |
113 const char* media_type, | 129 const char* media_type, |
114 const char* key_system, | 130 const char* key_system, |
115 SrcType src_type, | 131 SrcType src_type, |
116 const char* expectation) { | 132 const char* expectation) { |
133 #if defined(OS_ANDROID) | |
134 DCHECK_EQ(src_type, MSE) << "EME only works with MSE on Android."; | |
135 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { | |
136 LOG(INFO) << "Skipping test - MSE only supported in JellyBean and later."; | |
137 return; | |
138 } | |
139 #endif // defined(OS_ANDROID) | |
140 | |
117 std::vector<StringPair> query_params; | 141 std::vector<StringPair> query_params; |
118 query_params.push_back(std::make_pair("mediafile", media_file)); | 142 query_params.push_back(std::make_pair("mediafile", media_file)); |
119 query_params.push_back(std::make_pair("mediatype", media_type)); | 143 query_params.push_back(std::make_pair("mediatype", media_type)); |
120 query_params.push_back(std::make_pair("keysystem", key_system)); | 144 query_params.push_back(std::make_pair("keysystem", key_system)); |
121 if (src_type == MSE) | 145 if (src_type == MSE) |
122 query_params.push_back(std::make_pair("usemse", "1")); | 146 query_params.push_back(std::make_pair("usemse", "1")); |
123 RunMediaTestPage(html_page, &query_params, expectation, true); | 147 RunMediaTestPage(html_page, &query_params, expectation, true); |
124 } | 148 } |
125 | 149 |
126 void RunSimpleEncryptedMediaTest(const char* media_file, | 150 void RunSimpleEncryptedMediaTest(const char* media_file, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 if (key_system == kWidevineKeySystem) | 243 if (key_system == kWidevineKeySystem) |
220 return kWidevineCdmPluginMimeType; | 244 return kWidevineCdmPluginMimeType; |
221 #endif // WIDEVINE_CDM_AVAILABLE | 245 #endif // WIDEVINE_CDM_AVAILABLE |
222 | 246 |
223 NOTREACHED(); | 247 NOTREACHED(); |
224 return ""; | 248 return ""; |
225 } | 249 } |
226 #endif // defined(ENABLE_PEPPER_CDMS) | 250 #endif // defined(ENABLE_PEPPER_CDMS) |
227 }; | 251 }; |
228 | 252 |
229 INSTANTIATE_TEST_CASE_P(ClearKey, EncryptedMediaTest, | 253 using Combine; |
230 ::testing::Combine( | 254 using Values; |
231 ::testing::Values(kClearKeyKeySystem), ::testing::Values(SRC, MSE))); | 255 |
256 #if !defined(OS_ANDROID) | |
257 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, | |
258 Combine(Values(kClearKeyKeySystem), Values(SRC))); | |
259 #endif // !defined(OS_ANDROID) | |
260 | |
261 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, | |
262 Combine(Values(kClearKeyKeySystem), Values(MSE))); | |
232 | 263 |
233 // External Clear Key is currently only used on platforms that use Pepper CDMs. | 264 // External Clear Key is currently only used on platforms that use Pepper CDMs. |
234 #if defined(ENABLE_PEPPER_CDMS) | 265 #if defined(ENABLE_PEPPER_CDMS) |
235 INSTANTIATE_TEST_CASE_P(ExternalClearKey, EncryptedMediaTest, | 266 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest, |
236 ::testing::Combine( | 267 Combine(Values(kExternalClearKeyKeySystem), Values(SRC))); |
237 ::testing::Values(kExternalClearKeyKeySystem), | 268 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest, |
238 ::testing::Values(SRC, MSE))); | 269 Combine(Values(kExternalClearKeyKeySystem), Values(MSE))); |
270 #endif // defined(ENABLE_PEPPER_CDMS) | |
239 | 271 |
240 #if defined(WIDEVINE_CDM_AVAILABLE) | 272 #if defined(WIDEVINE_CDM_AVAILABLE) |
241 // This test doesn't fully test playback with Widevine. So we only run Widevine | 273 // This test doesn't fully test playback with Widevine. So we only run Widevine |
242 // test with MSE (no SRC) to reduce test time. | 274 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works |
243 INSTANTIATE_TEST_CASE_P(Widevine, EncryptedMediaTest, | 275 // with MSE and we cannot run this test with SRC. |
244 ::testing::Combine( | 276 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest, |
245 ::testing::Values(kWidevineKeySystem), ::testing::Values(MSE))); | 277 Combine(Values(kWidevineKeySystem), Values(MSE))); |
246 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 278 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
247 #endif // defined(ENABLE_PEPPER_CDMS) | |
248 | 279 |
249 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 280 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
250 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); | 281 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); |
251 } | 282 } |
252 | 283 |
253 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { | 284 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
254 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); | 285 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); |
255 } | 286 } |
256 | 287 |
257 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { | 288 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 } | 330 } |
300 #endif // defined(USE_PROPRIETARY_CODECS) | 331 #endif // defined(USE_PROPRIETARY_CODECS) |
301 | 332 |
302 #if defined(WIDEVINE_CDM_AVAILABLE) | 333 #if defined(WIDEVINE_CDM_AVAILABLE) |
303 // The parent key system cannot be used in generateKeyRequest. | 334 // The parent key system cannot be used in generateKeyRequest. |
304 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, WVParentThrowsException) { | 335 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, WVParentThrowsException) { |
305 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm", | 336 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm", |
306 kWebMAudioOnly, "com.widevine", SRC, kEmeGkrException); | 337 kWebMAudioOnly, "com.widevine", SRC, kEmeGkrException); |
307 } | 338 } |
308 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 339 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
OLD | NEW |