Standardize usage of virtual/override/final in chrome/browser/media
[chromium-blink-merge.git] / chrome / browser / media / encrypted_media_browsertest.cc
blob15bfc130e14cb05aaea2dc32ad3db6f1d396ac28
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/path_service.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "base/win/windows_version.h"
10 #include "chrome/browser/media/media_browsertest.h"
11 #include "chrome/browser/media/test_license_server.h"
12 #include "chrome/browser/media/wv_test_license_server_config.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "content/public/test/browser_test_utils.h"
17 #include "testing/gtest/include/gtest/gtest-spi.h"
18 #if defined(OS_ANDROID)
19 #include "base/android/build_info.h"
20 #endif
22 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
24 #if defined(ENABLE_PEPPER_CDMS)
25 // Platform-specific filename relative to the chrome executable.
26 const char kClearKeyCdmAdapterFileName[] =
27 #if defined(OS_MACOSX)
28 "clearkeycdmadapter.plugin";
29 #elif defined(OS_WIN)
30 "clearkeycdmadapter.dll";
31 #elif defined(OS_POSIX)
32 "libclearkeycdmadapter.so";
33 #endif
35 const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm";
36 #endif // defined(ENABLE_PEPPER_CDMS)
38 // Available key systems.
39 const char kClearKeyKeySystem[] = "org.w3.clearkey";
40 const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey";
41 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
42 const char kExternalClearKeyDecryptOnlyKeySystem[] =
43 "org.chromium.externalclearkey.decryptonly";
44 const char kExternalClearKeyFileIOTestKeySystem[] =
45 "org.chromium.externalclearkey.fileiotest";
46 const char kExternalClearKeyInitializeFailKeySystem[] =
47 "org.chromium.externalclearkey.initializefail";
48 const char kExternalClearKeyCrashKeySystem[] =
49 "org.chromium.externalclearkey.crash";
51 // Supported media types.
52 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
53 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
54 const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\"";
55 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
56 #if defined(USE_PROPRIETARY_CODECS)
57 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\"";
58 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\"";
59 #endif // defined(USE_PROPRIETARY_CODECS)
61 // Sessions to load.
62 const char kNoSessionToLoad[] = "";
63 const char kLoadableSession[] = "LoadableSession";
64 const char kUnknownSession[] = "UnknownSession";
66 // EME-specific test results and errors.
67 const char kEmeKeyError[] = "KEY_ERROR";
68 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
69 const char kFileIOTestSuccess[] = "FILE_IO_TEST_SUCCESS";
71 const char kDefaultEmePlayer[] = "eme_player.html";
73 // The type of video src used to load media.
74 enum SrcType {
75 SRC,
76 MSE
79 // Whether to use prefixed or unprefixed EME.
80 enum EmeVersion {
81 PREFIXED,
82 UNPREFIXED
85 // MSE is available on all desktop platforms and on Android 4.1 and later.
86 static bool IsMSESupported() {
87 #if defined(OS_ANDROID)
88 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
89 VLOG(0) << "MSE is only supported in Android 4.1 and later.";
90 return false;
92 #endif // defined(OS_ANDROID)
93 return true;
96 static bool IsParentKeySystemOf(const std::string& parent_key_system,
97 const std::string& key_system) {
98 std::string prefix = parent_key_system + '.';
99 return key_system.substr(0, prefix.size()) == prefix;
102 // Base class for encrypted media tests.
103 class EncryptedMediaTestBase : public MediaBrowserTest {
104 public:
105 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {}
107 bool IsExternalClearKey(const std::string& key_system) {
108 return key_system == kExternalClearKeyKeySystem ||
109 IsParentKeySystemOf(kExternalClearKeyKeySystem, key_system);
112 #if defined(WIDEVINE_CDM_AVAILABLE)
113 bool IsWidevine(const std::string& key_system) {
114 return key_system == kWidevineKeySystem;
116 #endif // defined(WIDEVINE_CDM_AVAILABLE)
118 void RunEncryptedMediaTestPage(
119 const std::string& html_page,
120 const std::string& key_system,
121 base::StringPairs& query_params,
122 const std::string& expected_title) {
123 base::StringPairs new_query_params = query_params;
124 StartLicenseServerIfNeeded(key_system, &new_query_params);
125 RunMediaTestPage(html_page, new_query_params, expected_title, true);
128 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|.
129 // When |session_to_load| is not empty, the test will try to load
130 // |session_to_load| with stored keys, instead of creating a new session
131 // and trying to update it with licenses.
132 // When |force_invalid_response| is true, the test will provide invalid
133 // responses, which should trigger errors.
134 // TODO(xhwang): Find an easier way to pass multiple configuration test
135 // options.
136 void RunEncryptedMediaTest(const std::string& html_page,
137 const std::string& media_file,
138 const std::string& media_type,
139 const std::string& key_system,
140 SrcType src_type,
141 EmeVersion eme_version,
142 const std::string& session_to_load,
143 bool force_invalid_response,
144 const std::string& expected_title) {
145 if (src_type == MSE && !IsMSESupported()) {
146 VLOG(0) << "Skipping test - MSE not supported.";
147 return;
149 base::StringPairs query_params;
150 query_params.push_back(std::make_pair("mediaFile", media_file));
151 query_params.push_back(std::make_pair("mediaType", media_type));
152 query_params.push_back(std::make_pair("keySystem", key_system));
153 if (src_type == MSE)
154 query_params.push_back(std::make_pair("useMSE", "1"));
155 if (eme_version == PREFIXED)
156 query_params.push_back(std::make_pair("usePrefixedEME", "1"));
157 if (force_invalid_response)
158 query_params.push_back(std::make_pair("forceInvalidResponse", "1"));
159 if (!session_to_load.empty())
160 query_params.push_back(std::make_pair("sessionToLoad", session_to_load));
161 RunEncryptedMediaTestPage(html_page, key_system, query_params,
162 expected_title);
165 void RunSimpleEncryptedMediaTest(const std::string& media_file,
166 const std::string& media_type,
167 const std::string& key_system,
168 SrcType src_type,
169 EmeVersion eme_version) {
170 std::string expected_title = kEnded;
171 if (!IsPlayBackPossible(key_system))
172 expected_title = kEmeKeyError;
174 RunEncryptedMediaTest(kDefaultEmePlayer,
175 media_file,
176 media_type,
177 key_system,
178 src_type,
179 eme_version,
180 kNoSessionToLoad,
181 false,
182 expected_title);
183 // Check KeyMessage received for all key systems.
184 bool receivedKeyMessage = false;
185 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
186 browser()->tab_strip_model()->GetActiveWebContents(),
187 "window.domAutomationController.send("
188 "document.querySelector('video').receivedKeyMessage);",
189 &receivedKeyMessage));
190 EXPECT_TRUE(receivedKeyMessage);
193 // Starts a license server if available for the |key_system| and adds a
194 // 'licenseServerURL' query parameter to |query_params|.
195 void StartLicenseServerIfNeeded(const std::string& key_system,
196 base::StringPairs* query_params) {
197 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system);
198 if (!config)
199 return;
200 license_server_.reset(new TestLicenseServer(config.Pass()));
201 EXPECT_TRUE(license_server_->Start());
202 query_params->push_back(
203 std::make_pair("licenseServerURL", license_server_->GetServerURL()));
206 bool IsPlayBackPossible(const std::string& key_system) {
207 #if defined(WIDEVINE_CDM_AVAILABLE)
208 if (IsWidevine(key_system) && !GetServerConfig(key_system))
209 return false;
210 #endif // defined(WIDEVINE_CDM_AVAILABLE)
211 return true;
214 scoped_ptr<TestLicenseServerConfig> GetServerConfig(
215 const std::string& key_system) {
216 #if defined(WIDEVINE_CDM_AVAILABLE)
217 if (IsWidevine(key_system)) {
218 scoped_ptr<TestLicenseServerConfig> config =
219 scoped_ptr<TestLicenseServerConfig>(new WVTestLicenseServerConfig());
220 if (config->IsPlatformSupported())
221 return config.Pass();
223 #endif // defined(WIDEVINE_CDM_AVAILABLE)
224 return scoped_ptr<TestLicenseServerConfig>();
227 protected:
228 scoped_ptr<TestLicenseServer> license_server_;
230 // We want to fail quickly when a test fails because an error is encountered.
231 void AddWaitForTitles(content::TitleWatcher* title_watcher) override {
232 MediaBrowserTest::AddWaitForTitles(title_watcher);
233 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError));
234 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError));
237 void SetUpCommandLine(CommandLine* command_line) override {
238 #if defined(OS_ANDROID)
239 command_line->AppendSwitch(
240 switches::kDisableGestureRequirementForMediaPlayback);
241 #endif // defined(OS_ANDROID)
244 void SetUpCommandLineForKeySystem(const std::string& key_system,
245 CommandLine* command_line) {
246 if (GetServerConfig(key_system))
247 // Since the web and license servers listen on different ports, we need to
248 // disable web-security to send license requests to the license server.
249 // TODO(shadi): Add port forwarding to the test web server configuration.
250 command_line->AppendSwitch(switches::kDisableWebSecurity);
252 #if defined(ENABLE_PEPPER_CDMS)
253 if (IsExternalClearKey(key_system)) {
254 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system);
256 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
257 else if (IsWidevine(key_system)) {
258 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system);
260 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
261 #endif // defined(ENABLE_PEPPER_CDMS)
264 private:
265 #if defined(ENABLE_PEPPER_CDMS)
266 void RegisterPepperCdm(CommandLine* command_line,
267 const std::string& adapter_name,
268 const std::string& key_system) {
269 DCHECK(!is_pepper_cdm_registered_)
270 << "RegisterPepperCdm() can only be called once.";
271 is_pepper_cdm_registered_ = true;
273 // Append the switch to register the Clear Key CDM Adapter.
274 base::FilePath plugin_dir;
275 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
276 base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name);
277 EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value();
278 base::FilePath::StringType pepper_plugin = plugin_lib.value();
279 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;"));
280 #if defined(OS_WIN)
281 pepper_plugin.append(base::ASCIIToWide(GetPepperType(key_system)));
282 #else
283 pepper_plugin.append(GetPepperType(key_system));
284 #endif
285 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
286 pepper_plugin);
289 // Adapted from key_systems.cc.
290 std::string GetPepperType(const std::string& key_system) {
291 if (IsExternalClearKey(key_system))
292 return kClearKeyCdmPluginMimeType;
293 #if defined(WIDEVINE_CDM_AVAILABLE)
294 if (IsWidevine(key_system))
295 return kWidevineCdmPluginMimeType;
296 #endif // WIDEVINE_CDM_AVAILABLE
298 NOTREACHED();
299 return "";
301 #endif // defined(ENABLE_PEPPER_CDMS)
303 bool is_pepper_cdm_registered_;
306 #if defined(ENABLE_PEPPER_CDMS)
307 // Tests encrypted media playback using ExternalClearKey key system in
308 // decrypt-and-decode mode.
309 class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
310 public:
311 // We use special |key_system| names to do non-playback related tests, e.g.
312 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
313 void TestNonPlaybackCases(const std::string& key_system,
314 const std::string& expected_title) {
315 // Since we do not test playback, arbitrarily choose a test file and source
316 // type.
317 RunEncryptedMediaTest(kDefaultEmePlayer,
318 "bear-a_enc-a.webm",
319 kWebMAudioOnly,
320 key_system,
321 SRC,
322 PREFIXED,
323 kNoSessionToLoad,
324 false,
325 expected_title);
328 protected:
329 void SetUpCommandLine(CommandLine* command_line) override {
330 EncryptedMediaTestBase::SetUpCommandLine(command_line);
331 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
335 // Tests encrypted media playback using ExternalClearKey key system in
336 // decrypt-and-decode mode for unprefixed EME.
337 // TODO(jrummell): Merge with ECKEncryptedMediaTest once unprefixed is
338 // enabled by default.
339 class ECKUnprefixedEncryptedMediaTest : public EncryptedMediaTestBase {
340 protected:
341 virtual void SetUpCommandLine(CommandLine* command_line) override {
342 EncryptedMediaTestBase::SetUpCommandLine(command_line);
343 command_line->AppendSwitch(switches::kEnableEncryptedMedia);
344 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
348 #if defined(WIDEVINE_CDM_AVAILABLE)
349 // Tests encrypted media playback using Widevine key system.
350 class WVEncryptedMediaTest : public EncryptedMediaTestBase {
351 protected:
352 virtual void SetUpCommandLine(CommandLine* command_line) override {
353 EncryptedMediaTestBase::SetUpCommandLine(command_line);
354 command_line->AppendSwitch(switches::kEnableEncryptedMedia);
355 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line);
359 #endif // defined(WIDEVINE_CDM_AVAILABLE)
360 #endif // defined(ENABLE_PEPPER_CDMS)
362 // Tests encrypted media playback with a combination of parameters:
363 // - char*: Key system name.
364 // - bool: True to load media using MSE, otherwise use src.
365 // - bool: True to use unprefixed EME, otherwise use prefixed EME.
367 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
368 // tests will crash at GetParam(). To add non-parameterized tests, use
369 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
370 class EncryptedMediaTest
371 : public EncryptedMediaTestBase,
372 public testing::WithParamInterface<
373 std::tr1::tuple<const char*, SrcType, EmeVersion> > {
374 public:
375 std::string CurrentKeySystem() {
376 return std::tr1::get<0>(GetParam());
379 SrcType CurrentSourceType() {
380 return std::tr1::get<1>(GetParam());
383 EmeVersion CurrentEmeVersion() {
384 return std::tr1::get<2>(GetParam());
387 void TestSimplePlayback(const std::string& encrypted_media,
388 const std::string& media_type) {
389 RunSimpleEncryptedMediaTest(encrypted_media,
390 media_type,
391 CurrentKeySystem(),
392 CurrentSourceType(),
393 CurrentEmeVersion());
396 void RunInvalidResponseTest() {
397 RunEncryptedMediaTest(kDefaultEmePlayer,
398 "bear-320x240-av_enc-av.webm",
399 kWebMAudioVideo,
400 CurrentKeySystem(),
401 CurrentSourceType(),
402 CurrentEmeVersion(),
403 kNoSessionToLoad,
404 true,
405 kEmeKeyError);
408 void TestFrameSizeChange() {
409 RunEncryptedMediaTest("encrypted_frame_size_change.html",
410 "frame_size_change-av_enc-v.webm",
411 kWebMAudioVideo,
412 CurrentKeySystem(),
413 CurrentSourceType(),
414 CurrentEmeVersion(),
415 kNoSessionToLoad,
416 false,
417 kEnded);
420 void TestConfigChange() {
421 DCHECK(IsMSESupported());
422 base::StringPairs query_params;
423 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
424 query_params.push_back(std::make_pair("runEncrypted", "1"));
425 if (CurrentEmeVersion() == PREFIXED)
426 query_params.push_back(std::make_pair("usePrefixedEME", "1"));
427 RunEncryptedMediaTestPage("mse_config_change.html",
428 CurrentKeySystem(),
429 query_params,
430 kEnded);
433 protected:
434 void SetUpCommandLine(CommandLine* command_line) override {
435 EncryptedMediaTestBase::SetUpCommandLine(command_line);
436 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line);
438 if (CurrentEmeVersion() == UNPREFIXED)
439 command_line->AppendSwitch(switches::kEnableEncryptedMedia);
443 using ::testing::Combine;
444 using ::testing::Values;
446 #if !defined(OS_ANDROID)
447 INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed,
448 EncryptedMediaTest,
449 Combine(Values(kPrefixedClearKeyKeySystem),
450 Values(SRC),
451 Values(PREFIXED)));
453 // TODO(jrummell): Enable unprefixed tests before shipping unprefixed EME.
454 // Disabled now as they don't provide much additional coverage, but do take a
455 // bit of time to execute.
456 INSTANTIATE_TEST_CASE_P(DISABLED_SRC_ClearKey,
457 EncryptedMediaTest,
458 Combine(Values(kClearKeyKeySystem),
459 Values(SRC),
460 Values(UNPREFIXED)));
461 #endif // !defined(OS_ANDROID)
463 INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed,
464 EncryptedMediaTest,
465 Combine(Values(kPrefixedClearKeyKeySystem),
466 Values(MSE),
467 Values(PREFIXED)));
468 // http://crbug.com/402766
469 INSTANTIATE_TEST_CASE_P(DISABLED_MSE_ClearKey,
470 EncryptedMediaTest,
471 Combine(Values(kClearKeyKeySystem),
472 Values(MSE),
473 Values(UNPREFIXED)));
475 // External Clear Key is currently only used on platforms that use Pepper CDMs.
476 #if defined(ENABLE_PEPPER_CDMS)
477 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed,
478 EncryptedMediaTest,
479 Combine(Values(kExternalClearKeyKeySystem),
480 Values(SRC),
481 Values(PREFIXED)));
482 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey,
483 EncryptedMediaTest,
484 Combine(Values(kExternalClearKeyKeySystem),
485 Values(SRC),
486 Values(UNPREFIXED)));
487 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed,
488 EncryptedMediaTest,
489 Combine(Values(kExternalClearKeyKeySystem),
490 Values(MSE),
491 Values(PREFIXED)));
492 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey,
493 EncryptedMediaTest,
494 Combine(Values(kExternalClearKeyKeySystem),
495 Values(MSE),
496 Values(UNPREFIXED)));
497 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
498 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed,
499 EncryptedMediaTest,
500 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
501 Values(MSE),
502 Values(PREFIXED)));
503 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly,
504 EncryptedMediaTest,
505 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
506 Values(MSE),
507 Values(UNPREFIXED)));
508 #endif // defined(ENABLE_PEPPER_CDMS)
510 #if defined(WIDEVINE_CDM_AVAILABLE)
511 // This test doesn't fully test playback with Widevine. So we only run Widevine
512 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works
513 // with MSE and we cannot run this test with SRC.
514 INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed,
515 EncryptedMediaTest,
516 Combine(Values(kWidevineKeySystem),
517 Values(MSE),
518 Values(PREFIXED)));
520 // Following tests fail if Widevine is loaded as a component, crbug.com/356833.
521 #if !defined(WIDEVINE_CDM_IS_COMPONENT)
522 INSTANTIATE_TEST_CASE_P(MSE_Widevine,
523 EncryptedMediaTest,
524 Combine(Values(kWidevineKeySystem),
525 Values(MSE),
526 Values(UNPREFIXED)));
527 #endif // !defined(WIDEVINE_CDM_IS_COMPONENT)
528 #endif // defined(WIDEVINE_CDM_AVAILABLE)
530 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
531 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly);
534 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
535 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo);
538 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
539 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo);
542 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) {
543 TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly);
546 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) {
547 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo);
550 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) {
551 TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly);
554 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) {
555 RunInvalidResponseTest();
558 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) {
559 if (CurrentSourceType() != MSE || !IsMSESupported()) {
560 VLOG(0) << "Skipping test - ConfigChange test requires MSE.";
561 return;
563 if (!IsPlayBackPossible(CurrentKeySystem())) {
564 VLOG(0) << "Skipping test - ConfigChange test requires video playback.";
565 return;
567 TestConfigChange();
570 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) {
571 // Times out on Windows XP. http://crbug.com/171937
572 #if defined(OS_WIN)
573 if (base::win::GetVersion() < base::win::VERSION_VISTA)
574 return;
575 #endif
576 if (!IsPlayBackPossible(CurrentKeySystem())) {
577 VLOG(0) << "Skipping test - FrameSizeChange test requires video playback.";
578 return;
580 TestFrameSizeChange();
583 #if defined(USE_PROPRIETARY_CODECS)
584 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4) {
585 // MP4 without MSE is not support yet, http://crbug.com/170793.
586 if (CurrentSourceType() != MSE) {
587 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
588 return;
590 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly);
593 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) {
594 // MP4 without MSE is not support yet, http://crbug.com/170793.
595 if (CurrentSourceType() != MSE) {
596 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
597 return;
599 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly);
601 #endif // defined(USE_PROPRIETARY_CODECS)
603 #if defined(WIDEVINE_CDM_AVAILABLE)
604 // The parent key system cannot be used in generateKeyRequest.
605 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) {
606 RunEncryptedMediaTest(kDefaultEmePlayer,
607 "bear-a_enc-a.webm",
608 kWebMAudioOnly,
609 "com.widevine",
610 MSE,
611 PREFIXED,
612 kNoSessionToLoad,
613 false,
614 kEmeNotSupportedError);
617 // TODO(jrummell): http://crbug.com/349181
618 // The parent key system cannot be used when creating MediaKeys.
619 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
620 RunEncryptedMediaTest(kDefaultEmePlayer,
621 "bear-a_enc-a.webm",
622 kWebMAudioOnly,
623 "com.widevine",
624 MSE,
625 UNPREFIXED,
626 kNoSessionToLoad,
627 false,
628 kEmeNotSupportedError);
630 #endif // defined(WIDEVINE_CDM_AVAILABLE)
632 #if defined(ENABLE_PEPPER_CDMS)
633 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) {
634 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, kEmeKeyError);
637 // When CDM crashes, we should still get a decode error.
638 // crbug.com/386657
639 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DISABLED_CDMCrashDuringDecode) {
640 IgnorePluginCrash();
641 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError);
644 // Testing that the media browser test does fail on plugin crash.
645 // crbug.com/386657
646 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DISABLED_CDMExpectedCrash) {
647 // Plugin crash is not ignored by default, the test is expected to fail.
648 EXPECT_NONFATAL_FAILURE(
649 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError),
650 "plugin crash");
653 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) {
654 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem,
655 kFileIOTestSuccess);
658 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
659 RunEncryptedMediaTest(kDefaultEmePlayer,
660 "bear-320x240-v_enc-v.webm",
661 kWebMVideoOnly,
662 kExternalClearKeyKeySystem,
663 SRC,
664 PREFIXED,
665 kLoadableSession,
666 false,
667 kEnded);
670 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
671 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
672 RunEncryptedMediaTest(kDefaultEmePlayer,
673 "bear-320x240-v_enc-v.webm",
674 kWebMVideoOnly,
675 kExternalClearKeyKeySystem,
676 SRC,
677 PREFIXED,
678 kUnknownSession,
679 false,
680 kEmeKeyError);
683 IN_PROC_BROWSER_TEST_F(ECKUnprefixedEncryptedMediaTest, LoadLoadableSession) {
684 RunEncryptedMediaTest(kDefaultEmePlayer,
685 "bear-320x240-v_enc-v.webm",
686 kWebMVideoOnly,
687 kExternalClearKeyKeySystem,
688 SRC,
689 UNPREFIXED,
690 kLoadableSession,
691 false,
692 kEnded);
695 IN_PROC_BROWSER_TEST_F(ECKUnprefixedEncryptedMediaTest, LoadUnknownSession) {
696 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
697 RunEncryptedMediaTest(kDefaultEmePlayer,
698 "bear-320x240-v_enc-v.webm",
699 kWebMVideoOnly,
700 kExternalClearKeyKeySystem,
701 SRC,
702 UNPREFIXED,
703 kUnknownSession,
704 false,
705 kEmeKeyError);
707 #endif // defined(ENABLE_PEPPER_CDMS)