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 25 matching lines...) Expand all Loading... | |
49 // EME-specific test results and errors. | 52 // EME-specific test results and errors. |
50 const char kEmeGkrException[] = "GENERATE_KEY_REQUEST_EXCEPTION"; | 53 const char kEmeGkrException[] = "GENERATE_KEY_REQUEST_EXCEPTION"; |
51 const char kEmeKeyError[] = "KEYERROR"; | 54 const char kEmeKeyError[] = "KEYERROR"; |
52 | 55 |
53 // The type of video src used to load media. | 56 // The type of video src used to load media. |
54 enum SrcType { | 57 enum SrcType { |
55 SRC, | 58 SRC, |
56 MSE | 59 MSE |
57 }; | 60 }; |
58 | 61 |
62 // MSE is available on all desktop platforms and on Android 4.1 and later. | |
63 static bool IsMSESupported() { | |
64 #if defined(OS_ANDROID) | |
65 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { | |
66 LOG(INFO) << "MSE is only supported in JellyBean and later."; | |
ddorwin
2013/10/17 00:59:56
You have more room to add a space and even 4.1. :)
| |
67 return false; | |
68 } | |
69 #endif // defined(OS_ANDROID) | |
70 return true; | |
71 } | |
72 | |
59 // Tests encrypted media playback with a combination of parameters: | 73 // Tests encrypted media playback with a combination of parameters: |
60 // - char*: Key system name. | 74 // - char*: Key system name. |
61 // - bool: True to load media using MSE, otherwise use src. | 75 // - bool: True to load media using MSE, otherwise use src. |
62 class EncryptedMediaTest : public MediaBrowserTest, | 76 class EncryptedMediaTest : public MediaBrowserTest, |
63 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > { | 77 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > { |
64 public: | 78 public: |
65 // Can only be used in parameterized (*_P) tests. | 79 // Can only be used in parameterized (*_P) tests. |
66 const char* CurrentKeySystem() { | 80 const char* CurrentKeySystem() { |
67 return std::tr1::get<0>(GetParam()); | 81 return std::tr1::get<0>(GetParam()); |
68 } | 82 } |
(...skipping 20 matching lines...) Expand all Loading... | |
89 LOG(INFO) << "FrameSizeChange test cannot run with Widevine."; | 103 LOG(INFO) << "FrameSizeChange test cannot run with Widevine."; |
90 return; | 104 return; |
91 } | 105 } |
92 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 106 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
93 RunEncryptedMediaTest("encrypted_frame_size_change.html", | 107 RunEncryptedMediaTest("encrypted_frame_size_change.html", |
94 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, | 108 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, |
95 CurrentKeySystem(), CurrentSourceType(), kEnded); | 109 CurrentKeySystem(), CurrentSourceType(), kEnded); |
96 } | 110 } |
97 | 111 |
98 void TestConfigChange() { | 112 void TestConfigChange() { |
113 if (CurrentSourceType() != MSE || !IsMSESupported()) { | |
114 LOG(INFO) << "Skipping test - config change test requires MSE."; | |
115 return; | |
116 } | |
117 | |
99 #if defined(WIDEVINE_CDM_AVAILABLE) | 118 #if defined(WIDEVINE_CDM_AVAILABLE) |
100 if (IsWidevine(CurrentKeySystem())) { | 119 if (IsWidevine(CurrentKeySystem())) { |
101 LOG(INFO) << "ConfigChange test cannot run with Widevine."; | 120 LOG(INFO) << "ConfigChange test cannot run with Widevine."; |
102 return; | 121 return; |
103 } | 122 } |
104 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 123 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
124 | |
105 std::vector<StringPair> query_params; | 125 std::vector<StringPair> query_params; |
106 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); | 126 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); |
107 query_params.push_back(std::make_pair("runencrypted", "1")); | 127 query_params.push_back(std::make_pair("runencrypted", "1")); |
108 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); | 128 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); |
109 } | 129 } |
110 | 130 |
111 void RunEncryptedMediaTest(const char* html_page, | 131 void RunEncryptedMediaTest(const char* html_page, |
112 const char* media_file, | 132 const char* media_file, |
113 const char* media_type, | 133 const char* media_type, |
114 const char* key_system, | 134 const char* key_system, |
115 SrcType src_type, | 135 SrcType src_type, |
116 const char* expectation) { | 136 const char* expectation) { |
137 if (src_type == MSE && !IsMSESupported()) { | |
138 LOG(INFO) << "Skipping test - MSE not supported."; | |
139 return; | |
140 } | |
141 | |
117 std::vector<StringPair> query_params; | 142 std::vector<StringPair> query_params; |
118 query_params.push_back(std::make_pair("mediafile", media_file)); | 143 query_params.push_back(std::make_pair("mediafile", media_file)); |
119 query_params.push_back(std::make_pair("mediatype", media_type)); | 144 query_params.push_back(std::make_pair("mediatype", media_type)); |
120 query_params.push_back(std::make_pair("keysystem", key_system)); | 145 query_params.push_back(std::make_pair("keysystem", key_system)); |
121 if (src_type == MSE) | 146 if (src_type == MSE) |
122 query_params.push_back(std::make_pair("usemse", "1")); | 147 query_params.push_back(std::make_pair("usemse", "1")); |
123 RunMediaTestPage(html_page, &query_params, expectation, true); | 148 RunMediaTestPage(html_page, &query_params, expectation, true); |
124 } | 149 } |
125 | 150 |
126 void RunSimpleEncryptedMediaTest(const char* media_file, | 151 void RunSimpleEncryptedMediaTest(const char* media_file, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 if (key_system == kWidevineKeySystem) | 244 if (key_system == kWidevineKeySystem) |
220 return kWidevineCdmPluginMimeType; | 245 return kWidevineCdmPluginMimeType; |
221 #endif // WIDEVINE_CDM_AVAILABLE | 246 #endif // WIDEVINE_CDM_AVAILABLE |
222 | 247 |
223 NOTREACHED(); | 248 NOTREACHED(); |
224 return ""; | 249 return ""; |
225 } | 250 } |
226 #endif // defined(ENABLE_PEPPER_CDMS) | 251 #endif // defined(ENABLE_PEPPER_CDMS) |
227 }; | 252 }; |
228 | 253 |
229 INSTANTIATE_TEST_CASE_P(ClearKey, EncryptedMediaTest, | 254 using Combine; |
230 ::testing::Combine( | 255 using Values; |
231 ::testing::Values(kClearKeyKeySystem), ::testing::Values(SRC, MSE))); | 256 |
257 #if !defined(OS_ANDROID) | |
258 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, | |
259 Combine(Values(kClearKeyKeySystem), Values(SRC))); | |
260 #endif // !defined(OS_ANDROID) | |
261 | |
262 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, | |
263 Combine(Values(kClearKeyKeySystem), Values(MSE))); | |
232 | 264 |
233 // External Clear Key is currently only used on platforms that use Pepper CDMs. | 265 // External Clear Key is currently only used on platforms that use Pepper CDMs. |
234 #if defined(ENABLE_PEPPER_CDMS) | 266 #if defined(ENABLE_PEPPER_CDMS) |
235 INSTANTIATE_TEST_CASE_P(ExternalClearKey, EncryptedMediaTest, | 267 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest, |
236 ::testing::Combine( | 268 Combine(Values(kExternalClearKeyKeySystem), Values(SRC))); |
237 ::testing::Values(kExternalClearKeyKeySystem), | 269 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest, |
238 ::testing::Values(SRC, MSE))); | 270 Combine(Values(kExternalClearKeyKeySystem), Values(MSE))); |
271 #endif // defined(ENABLE_PEPPER_CDMS) | |
239 | 272 |
240 #if defined(WIDEVINE_CDM_AVAILABLE) | 273 #if defined(WIDEVINE_CDM_AVAILABLE) |
241 // This test doesn't fully test playback with Widevine. So we only run Widevine | 274 // This test doesn't fully test playback with Widevine. So we only run Widevine |
242 // test with MSE (no SRC) to reduce test time. | 275 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works |
243 INSTANTIATE_TEST_CASE_P(Widevine, EncryptedMediaTest, | 276 // with MSE and we cannot run this test with SRC. |
244 ::testing::Combine( | 277 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest, |
245 ::testing::Values(kWidevineKeySystem), ::testing::Values(MSE))); | 278 Combine(Values(kWidevineKeySystem), Values(MSE))); |
246 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 279 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
247 #endif // defined(ENABLE_PEPPER_CDMS) | |
248 | 280 |
249 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 281 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
250 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); | 282 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); |
251 } | 283 } |
252 | 284 |
253 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { | 285 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
254 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); | 286 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); |
255 } | 287 } |
256 | 288 |
257 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { | 289 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 } | 331 } |
300 #endif // defined(USE_PROPRIETARY_CODECS) | 332 #endif // defined(USE_PROPRIETARY_CODECS) |
301 | 333 |
302 #if defined(WIDEVINE_CDM_AVAILABLE) | 334 #if defined(WIDEVINE_CDM_AVAILABLE) |
303 // The parent key system cannot be used in generateKeyRequest. | 335 // The parent key system cannot be used in generateKeyRequest. |
304 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, WVParentThrowsException) { | 336 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, WVParentThrowsException) { |
305 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm", | 337 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm", |
306 kWebMAudioOnly, "com.widevine", SRC, kEmeGkrException); | 338 kWebMAudioOnly, "com.widevine", SRC, kEmeGkrException); |
307 } | 339 } |
308 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 340 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
OLD | NEW |