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

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: Created 7 years 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 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 kDecryptOnlyExternalClearKeyKeySystem[] =
ddorwin 2013/11/21 04:10:58 Start with a common prefix? kExternalClearKeyKeySy
xhwang 2013/11/22 01:47:36 Done.
38 "org.chromium.externalclearkey.decryptonly";
38 39
39 // Supported media types. 40 // Supported media types.
40 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; 41 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
41 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; 42 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
42 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; 43 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
43 #if defined(USE_PROPRIETARY_CODECS) 44 #if defined(USE_PROPRIETARY_CODECS)
44 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; 45 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\"";
45 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; 46 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\"";
46 #endif // defined(USE_PROPRIETARY_CODECS) 47 #endif // defined(USE_PROPRIETARY_CODECS)
47 48
(...skipping 16 matching lines...) Expand all
64 } 65 }
65 #endif // defined(OS_ANDROID) 66 #endif // defined(OS_ANDROID)
66 return true; 67 return true;
67 } 68 }
68 69
69 // Base class for encrypted media tests. 70 // Base class for encrypted media tests.
70 class EncryptedMediaTestBase : public MediaBrowserTest { 71 class EncryptedMediaTestBase : public MediaBrowserTest {
71 public: 72 public:
72 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} 73 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {}
73 74
74 bool IsExternalClearKey(const char* key_system) { 75 bool IsExternalClearKey(const std::string& key_system) {
75 return (strcmp(key_system, kExternalClearKeyKeySystem) == 0); 76 return key_system == kExternalClearKeyKeySystem ||
77 key_system == kDecryptOnlyExternalClearKeyKeySystem;
ddorwin 2013/11/21 04:10:58 Just check if the first length of kExternalClearKe
xhwang 2013/11/22 01:47:36 Done. This is not super accurate. The correct way
ddorwin 2013/11/22 04:28:59 Yeah, I know. Agreed. You could add: && (key_syste
xhwang 2013/11/22 07:44:26 Done.
76 } 78 }
77 79
78 #if defined(WIDEVINE_CDM_AVAILABLE) 80 #if defined(WIDEVINE_CDM_AVAILABLE)
79 bool IsWidevine(const char* key_system) { 81 bool IsWidevine(const std::string& key_system) {
80 return (strcmp(key_system, kWidevineKeySystem) == 0); 82 return key_system == kWidevineKeySystem;
81 } 83 }
82 #endif // defined(WIDEVINE_CDM_AVAILABLE) 84 #endif // defined(WIDEVINE_CDM_AVAILABLE)
83 85
84 void RunEncryptedMediaTest(const char* html_page, 86 void RunEncryptedMediaTest(const char* html_page,
85 const char* media_file, 87 const char* media_file,
86 const char* media_type, 88 const char* media_type,
87 const char* key_system, 89 const char* key_system,
88 SrcType src_type, 90 SrcType src_type,
89 const char* expectation) { 91 const char* expectation) {
90 if (src_type == MSE && !IsMSESupported()) { 92 if (src_type == MSE && !IsMSESupported()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 command_line->AppendSwitch( 144 command_line->AppendSwitch(
143 switches::kDisableGestureRequirementForMediaPlayback); 145 switches::kDisableGestureRequirementForMediaPlayback);
144 #endif // defined(OS_ANDROID) 146 #endif // defined(OS_ANDROID)
145 } 147 }
146 148
147 void SetUpCommandLineForKeySystem(const char* key_system, 149 void SetUpCommandLineForKeySystem(const char* key_system,
148 CommandLine* command_line) { 150 CommandLine* command_line) {
149 #if defined(ENABLE_PEPPER_CDMS) 151 #if defined(ENABLE_PEPPER_CDMS)
150 if (IsExternalClearKey(key_system)) { 152 if (IsExternalClearKey(key_system)) {
151 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, 153 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName,
152 kExternalClearKeyKeySystem); 154 key_system);
ddorwin 2013/11/21 04:10:58 fits?
xhwang 2013/11/22 01:47:36 Done.
153 } 155 }
154 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 156 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
155 else if (IsWidevine(key_system)) { 157 else if (IsWidevine(key_system)) {
156 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, 158 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName,
157 kWidevineKeySystem); 159 kWidevineKeySystem);
ddorwin 2013/11/21 04:10:58 change here too?
xhwang 2013/11/22 01:47:36 Done.
158 } 160 }
159 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 161 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
160 #endif // defined(ENABLE_PEPPER_CDMS) 162 #endif // defined(ENABLE_PEPPER_CDMS)
161 } 163 }
162 164
163 private: 165 private:
164 #if defined(ENABLE_PEPPER_CDMS) 166 #if defined(ENABLE_PEPPER_CDMS)
165 void RegisterPepperCdm(CommandLine* command_line, 167 void RegisterPepperCdm(CommandLine* command_line,
166 const std::string& adapter_name, 168 const std::string& adapter_name,
167 const std::string& key_system) { 169 const std::string& key_system) {
(...skipping 12 matching lines...) Expand all
180 pepper_plugin.append(ASCIIToWide(GetPepperType(key_system))); 182 pepper_plugin.append(ASCIIToWide(GetPepperType(key_system)));
181 #else 183 #else
182 pepper_plugin.append(GetPepperType(key_system)); 184 pepper_plugin.append(GetPepperType(key_system));
183 #endif 185 #endif
184 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, 186 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
185 pepper_plugin); 187 pepper_plugin);
186 } 188 }
187 189
188 // Adapted from key_systems.cc. 190 // Adapted from key_systems.cc.
189 std::string GetPepperType(const std::string& key_system) { 191 std::string GetPepperType(const std::string& key_system) {
190 if (key_system == kExternalClearKeyKeySystem) 192 if (IsExternalClearKey(key_system))
191 return kClearKeyCdmPluginMimeType; 193 return kClearKeyCdmPluginMimeType;
192 #if defined(WIDEVINE_CDM_AVAILABLE) 194 #if defined(WIDEVINE_CDM_AVAILABLE)
193 if (key_system == kWidevineKeySystem) 195 if (IsWidevine(key_system))
194 return kWidevineCdmPluginMimeType; 196 return kWidevineCdmPluginMimeType;
195 #endif // WIDEVINE_CDM_AVAILABLE 197 #endif // WIDEVINE_CDM_AVAILABLE
196 198
197 NOTREACHED(); 199 NOTREACHED();
198 return ""; 200 return "";
199 } 201 }
200 #endif // defined(ENABLE_PEPPER_CDMS) 202 #endif // defined(ENABLE_PEPPER_CDMS)
201 203
202 bool is_pepper_cdm_registered_; 204 bool is_pepper_cdm_registered_;
203 }; 205 };
204 206
205 #if defined(ENABLE_PEPPER_CDMS) 207 #if defined(ENABLE_PEPPER_CDMS)
206 // Tests encrypted media playback using ExternalClearKey key system. 208 // Tests encrypted media playback using ExternalClearKey key system in
209 // decrypt-and-decode mode.
207 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { 210 class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
208 protected: 211 protected:
209 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 212 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
210 EncryptedMediaTestBase::SetUpCommandLine(command_line); 213 EncryptedMediaTestBase::SetUpCommandLine(command_line);
211 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); 214 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
212 } 215 }
213 }; 216 };
214 217
215 #if defined(WIDEVINE_CDM_AVAILABLE) 218 #if defined(WIDEVINE_CDM_AVAILABLE)
216 // Tests encrypted media playback using Widevine key system. 219 // Tests encrypted media playback using Widevine key system.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 296
294 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, 297 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
295 Combine(Values(kClearKeyKeySystem), Values(MSE))); 298 Combine(Values(kClearKeyKeySystem), Values(MSE)));
296 299
297 // External Clear Key is currently only used on platforms that use Pepper CDMs. 300 // External Clear Key is currently only used on platforms that use Pepper CDMs.
298 #if defined(ENABLE_PEPPER_CDMS) 301 #if defined(ENABLE_PEPPER_CDMS)
299 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest, 302 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest,
300 Combine(Values(kExternalClearKeyKeySystem), Values(SRC))); 303 Combine(Values(kExternalClearKeyKeySystem), Values(SRC)));
301 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest, 304 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest,
302 Combine(Values(kExternalClearKeyKeySystem), Values(MSE))); 305 Combine(Values(kExternalClearKeyKeySystem), Values(MSE)));
306 INSTANTIATE_TEST_CASE_P(SRC_DecryptOnlyExternalClearKey, EncryptedMediaTest,
ddorwin 2013/11/21 04:10:58 This is going to add a lot of test time (in additi
xhwang 2013/11/22 01:47:36 The decrypt only path is orthogonal to SRC/MSE. Dr
307 Combine(Values(kDecryptOnlyExternalClearKeyKeySystem), Values(SRC)));
308 INSTANTIATE_TEST_CASE_P(MSE_DecryptOnlyExternalClearKey, EncryptedMediaTest,
309 Combine(Values(kDecryptOnlyExternalClearKeyKeySystem), Values(MSE)));
303 #endif // defined(ENABLE_PEPPER_CDMS) 310 #endif // defined(ENABLE_PEPPER_CDMS)
304 311
305 #if defined(WIDEVINE_CDM_AVAILABLE) 312 #if defined(WIDEVINE_CDM_AVAILABLE)
306 // This test doesn't fully test playback with Widevine. So we only run Widevine 313 // 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 314 // 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. 315 // with MSE and we cannot run this test with SRC.
309 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest, 316 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest,
310 Combine(Values(kWidevineKeySystem), Values(MSE))); 317 Combine(Values(kWidevineKeySystem), Values(MSE)));
311 #endif // defined(WIDEVINE_CDM_AVAILABLE) 318 #endif // defined(WIDEVINE_CDM_AVAILABLE)
312 319
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 kEmeNotSupportedError); 381 kEmeNotSupportedError);
375 } 382 }
376 #endif // defined(WIDEVINE_CDM_AVAILABLE) 383 #endif // defined(WIDEVINE_CDM_AVAILABLE)
377 384
378 #if defined(ENABLE_PEPPER_CDMS) 385 #if defined(ENABLE_PEPPER_CDMS)
379 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, 386 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest,
380 ExternalClearKeyInitializeCDMFail) { 387 ExternalClearKeyInitializeCDMFail) {
381 RunEncryptedMediaTest("encrypted_media_player.html", 388 RunEncryptedMediaTest("encrypted_media_player.html",
382 "bear-a-enc_a.webm", 389 "bear-a-enc_a.webm",
383 kWebMAudioOnly, 390 kWebMAudioOnly,
384 "org.chromium.externalclearkey.initializefail", 391 "org.chromium.externalclearkey.initializefail",
ddorwin 2013/11/21 04:10:58 Move this up with all other known "modes".
xhwang 2013/11/22 01:47:36 Done.
385 SRC, 392 SRC,
386 kEmeKeyError); 393 kEmeKeyError);
387 } 394 }
388 #endif // defined(ENABLE_PEPPER_CDMS) 395 #endif // defined(ENABLE_PEPPER_CDMS)
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/media/chrome_key_systems.cc » ('j') | chrome/renderer/media/chrome_key_systems.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698