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

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

Issue 79903002: Add decrypt-only external clear key browser tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/renderer/media/chrome_key_systems.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 15 matching lines...) Expand all
26 "clearkeycdmadapter.dll"; 26 "clearkeycdmadapter.dll";
27 #elif defined(OS_POSIX) 27 #elif defined(OS_POSIX)
28 "libclearkeycdmadapter.so"; 28 "libclearkeycdmadapter.so";
29 #endif 29 #endif
30 30
31 const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; 31 const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm";
32 #endif // defined(ENABLE_PEPPER_CDMS) 32 #endif // defined(ENABLE_PEPPER_CDMS)
33 33
34 // Available key systems. 34 // Available key systems.
35 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; 35 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
36 const char kExternalClearKeyKeySystem[] = 36 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
37 "org.chromium.externalclearkey"; 37 const char kExternalClearKeyDecryptOnlyKeySystem[] =
38 "org.chromium.externalclearkey.decryptonly";
39 const char kExternalClearKeyInitializeFailKeySystem[] =
40 "org.chromium.externalclearkey.initializefail";
38 41
39 // Supported media types. 42 // Supported media types.
40 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; 43 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
41 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; 44 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
42 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; 45 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
43 #if defined(USE_PROPRIETARY_CODECS) 46 #if defined(USE_PROPRIETARY_CODECS)
44 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; 47 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\"";
45 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; 48 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\"";
46 #endif // defined(USE_PROPRIETARY_CODECS) 49 #endif // defined(USE_PROPRIETARY_CODECS)
47 50
(...skipping 11 matching lines...) Expand all
59 static bool IsMSESupported() { 62 static bool IsMSESupported() {
60 #if defined(OS_ANDROID) 63 #if defined(OS_ANDROID)
61 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { 64 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
62 LOG(INFO) << "MSE is only supported in Android 4.1 and later."; 65 LOG(INFO) << "MSE is only supported in Android 4.1 and later.";
63 return false; 66 return false;
64 } 67 }
65 #endif // defined(OS_ANDROID) 68 #endif // defined(OS_ANDROID)
66 return true; 69 return true;
67 } 70 }
68 71
72 static bool IsParentKeySystemOf(const std::string& parent_key_system,
73 const std::string& key_system) {
74 std::string prefix = parent_key_system + '.';
75 return key_system.substr(0, prefix.size()) == prefix;
76 }
77
69 // Base class for encrypted media tests. 78 // Base class for encrypted media tests.
70 class EncryptedMediaTestBase : public MediaBrowserTest { 79 class EncryptedMediaTestBase : public MediaBrowserTest {
71 public: 80 public:
72 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} 81 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {}
73 82
74 bool IsExternalClearKey(const char* key_system) { 83 bool IsExternalClearKey(const std::string& key_system) {
75 return (strcmp(key_system, kExternalClearKeyKeySystem) == 0); 84 return key_system == kExternalClearKeyKeySystem ||
85 IsParentKeySystemOf(kExternalClearKeyKeySystem, key_system);
76 } 86 }
77 87
78 #if defined(WIDEVINE_CDM_AVAILABLE) 88 #if defined(WIDEVINE_CDM_AVAILABLE)
79 bool IsWidevine(const char* key_system) { 89 bool IsWidevine(const std::string& key_system) {
80 return (strcmp(key_system, kWidevineKeySystem) == 0); 90 return key_system == kWidevineKeySystem;
81 } 91 }
82 #endif // defined(WIDEVINE_CDM_AVAILABLE) 92 #endif // defined(WIDEVINE_CDM_AVAILABLE)
83 93
84 void RunEncryptedMediaTest(const char* html_page, 94 void RunEncryptedMediaTest(const char* html_page,
85 const char* media_file, 95 const char* media_file,
86 const char* media_type, 96 const char* media_type,
87 const char* key_system, 97 const char* key_system,
88 SrcType src_type, 98 SrcType src_type,
89 const char* expectation) { 99 const char* expectation) {
90 if (src_type == MSE && !IsMSESupported()) { 100 if (src_type == MSE && !IsMSESupported()) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #if defined(OS_ANDROID) 151 #if defined(OS_ANDROID)
142 command_line->AppendSwitch( 152 command_line->AppendSwitch(
143 switches::kDisableGestureRequirementForMediaPlayback); 153 switches::kDisableGestureRequirementForMediaPlayback);
144 #endif // defined(OS_ANDROID) 154 #endif // defined(OS_ANDROID)
145 } 155 }
146 156
147 void SetUpCommandLineForKeySystem(const char* key_system, 157 void SetUpCommandLineForKeySystem(const char* key_system,
148 CommandLine* command_line) { 158 CommandLine* command_line) {
149 #if defined(ENABLE_PEPPER_CDMS) 159 #if defined(ENABLE_PEPPER_CDMS)
150 if (IsExternalClearKey(key_system)) { 160 if (IsExternalClearKey(key_system)) {
151 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, 161 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system);
152 kExternalClearKeyKeySystem);
153 } 162 }
154 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 163 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
155 else if (IsWidevine(key_system)) { 164 else if (IsWidevine(key_system)) {
156 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, 165 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system);
157 kWidevineKeySystem);
158 } 166 }
159 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 167 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
160 #endif // defined(ENABLE_PEPPER_CDMS) 168 #endif // defined(ENABLE_PEPPER_CDMS)
161 } 169 }
162 170
163 private: 171 private:
164 #if defined(ENABLE_PEPPER_CDMS) 172 #if defined(ENABLE_PEPPER_CDMS)
165 void RegisterPepperCdm(CommandLine* command_line, 173 void RegisterPepperCdm(CommandLine* command_line,
166 const std::string& adapter_name, 174 const std::string& adapter_name,
167 const std::string& key_system) { 175 const std::string& key_system) {
(...skipping 12 matching lines...) Expand all
180 pepper_plugin.append(ASCIIToWide(GetPepperType(key_system))); 188 pepper_plugin.append(ASCIIToWide(GetPepperType(key_system)));
181 #else 189 #else
182 pepper_plugin.append(GetPepperType(key_system)); 190 pepper_plugin.append(GetPepperType(key_system));
183 #endif 191 #endif
184 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, 192 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
185 pepper_plugin); 193 pepper_plugin);
186 } 194 }
187 195
188 // Adapted from key_systems.cc. 196 // Adapted from key_systems.cc.
189 std::string GetPepperType(const std::string& key_system) { 197 std::string GetPepperType(const std::string& key_system) {
190 if (key_system == kExternalClearKeyKeySystem) 198 if (IsExternalClearKey(key_system))
191 return kClearKeyCdmPluginMimeType; 199 return kClearKeyCdmPluginMimeType;
192 #if defined(WIDEVINE_CDM_AVAILABLE) 200 #if defined(WIDEVINE_CDM_AVAILABLE)
193 if (key_system == kWidevineKeySystem) 201 if (IsWidevine(key_system))
194 return kWidevineCdmPluginMimeType; 202 return kWidevineCdmPluginMimeType;
195 #endif // WIDEVINE_CDM_AVAILABLE 203 #endif // WIDEVINE_CDM_AVAILABLE
196 204
197 NOTREACHED(); 205 NOTREACHED();
198 return ""; 206 return "";
199 } 207 }
200 #endif // defined(ENABLE_PEPPER_CDMS) 208 #endif // defined(ENABLE_PEPPER_CDMS)
201 209
202 bool is_pepper_cdm_registered_; 210 bool is_pepper_cdm_registered_;
203 }; 211 };
204 212
205 #if defined(ENABLE_PEPPER_CDMS) 213 #if defined(ENABLE_PEPPER_CDMS)
206 // Tests encrypted media playback using ExternalClearKey key system. 214 // Tests encrypted media playback using ExternalClearKey key system in
215 // decrypt-and-decode mode.
207 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { 216 class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
208 protected: 217 protected:
209 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 218 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
210 EncryptedMediaTestBase::SetUpCommandLine(command_line); 219 EncryptedMediaTestBase::SetUpCommandLine(command_line);
211 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); 220 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
212 } 221 }
213 }; 222 };
214 223
215 #if defined(WIDEVINE_CDM_AVAILABLE) 224 #if defined(WIDEVINE_CDM_AVAILABLE)
216 // Tests encrypted media playback using Widevine key system. 225 // Tests encrypted media playback using Widevine key system.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 302
294 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, 303 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
295 Combine(Values(kClearKeyKeySystem), Values(MSE))); 304 Combine(Values(kClearKeyKeySystem), Values(MSE)));
296 305
297 // External Clear Key is currently only used on platforms that use Pepper CDMs. 306 // External Clear Key is currently only used on platforms that use Pepper CDMs.
298 #if defined(ENABLE_PEPPER_CDMS) 307 #if defined(ENABLE_PEPPER_CDMS)
299 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest, 308 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest,
300 Combine(Values(kExternalClearKeyKeySystem), Values(SRC))); 309 Combine(Values(kExternalClearKeyKeySystem), Values(SRC)));
301 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest, 310 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest,
302 Combine(Values(kExternalClearKeyKeySystem), Values(MSE))); 311 Combine(Values(kExternalClearKeyKeySystem), Values(MSE)));
312 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
313 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, EncryptedMediaTest,
314 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), Values(MSE)));
303 #endif // defined(ENABLE_PEPPER_CDMS) 315 #endif // defined(ENABLE_PEPPER_CDMS)
304 316
305 #if defined(WIDEVINE_CDM_AVAILABLE) 317 #if defined(WIDEVINE_CDM_AVAILABLE)
306 // This test doesn't fully test playback with Widevine. So we only run Widevine 318 // This test doesn't fully test playback with Widevine. So we only run Widevine
307 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works 319 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works
308 // with MSE and we cannot run this test with SRC. 320 // with MSE and we cannot run this test with SRC.
309 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest, 321 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest,
310 Combine(Values(kWidevineKeySystem), Values(MSE))); 322 Combine(Values(kWidevineKeySystem), Values(MSE)));
311 #endif // defined(WIDEVINE_CDM_AVAILABLE) 323 #endif // defined(WIDEVINE_CDM_AVAILABLE)
312 324
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 kEmeNotSupportedError); 386 kEmeNotSupportedError);
375 } 387 }
376 #endif // defined(WIDEVINE_CDM_AVAILABLE) 388 #endif // defined(WIDEVINE_CDM_AVAILABLE)
377 389
378 #if defined(ENABLE_PEPPER_CDMS) 390 #if defined(ENABLE_PEPPER_CDMS)
379 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, 391 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest,
380 ExternalClearKeyInitializeCDMFail) { 392 ExternalClearKeyInitializeCDMFail) {
381 RunEncryptedMediaTest("encrypted_media_player.html", 393 RunEncryptedMediaTest("encrypted_media_player.html",
382 "bear-a-enc_a.webm", 394 "bear-a-enc_a.webm",
383 kWebMAudioOnly, 395 kWebMAudioOnly,
384 "org.chromium.externalclearkey.initializefail", 396 kExternalClearKeyInitializeFailKeySystem,
385 SRC, 397 SRC,
386 kEmeKeyError); 398 kEmeKeyError);
387 } 399 }
388 #endif // defined(ENABLE_PEPPER_CDMS) 400 #endif // defined(ENABLE_PEPPER_CDMS)
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/media/chrome_key_systems.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698