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"
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";
30 "clearkeycdmadapter.dll";
31 #elif defined(OS_POSIX)
32 "libclearkeycdmadapter.so";
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 kWebMAudioVideo
[] = "video/webm; codecs=\"vorbis, vp8\"";
55 // Some tests are disabled in Chrome OS official builds. http://crbug.com/430711
56 #if !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
57 const char kWebMVP9VideoOnly
[] = "video/webm; codecs=\"vp9\"";
58 #if defined(USE_PROPRIETARY_CODECS)
59 const char kMP4AudioOnly
[] = "audio/mp4; codecs=\"mp4a.40.2\"";
60 const char kMP4VideoOnly
[] = "video/mp4; codecs=\"avc1.4D4041\"";
61 #endif // defined(USE_PROPRIETARY_CODECS)
62 #endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
65 const char kNoSessionToLoad
[] = "";
66 const char kLoadableSession
[] = "LoadableSession";
67 const char kUnknownSession
[] = "UnknownSession";
69 // EME-specific test results and errors.
70 const char kEmeKeyError
[] = "KEY_ERROR";
71 const char kEmeNotSupportedError
[] = "NOTSUPPORTEDERROR";
72 const char kFileIOTestSuccess
[] = "FILE_IO_TEST_SUCCESS";
74 const char kDefaultEmePlayer
[] = "eme_player.html";
76 // The type of video src used to load media.
82 // Whether to use prefixed or unprefixed EME.
88 // MSE is available on all desktop platforms and on Android 4.1 and later.
89 static bool IsMSESupported() {
90 #if defined(OS_ANDROID)
91 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
92 DVLOG(0) << "MSE is only supported in Android 4.1 and later.";
95 #endif // defined(OS_ANDROID)
99 static bool IsParentKeySystemOf(const std::string
& parent_key_system
,
100 const std::string
& key_system
) {
101 std::string prefix
= parent_key_system
+ '.';
102 return key_system
.substr(0, prefix
.size()) == prefix
;
105 // Base class for encrypted media tests.
106 class EncryptedMediaTestBase
: public MediaBrowserTest
{
108 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {}
110 bool IsExternalClearKey(const std::string
& key_system
) {
111 return key_system
== kExternalClearKeyKeySystem
||
112 IsParentKeySystemOf(kExternalClearKeyKeySystem
, key_system
);
115 #if defined(WIDEVINE_CDM_AVAILABLE)
116 bool IsWidevine(const std::string
& key_system
) {
117 return key_system
== kWidevineKeySystem
;
119 #endif // defined(WIDEVINE_CDM_AVAILABLE)
121 void RunEncryptedMediaTestPage(
122 const std::string
& html_page
,
123 const std::string
& key_system
,
124 base::StringPairs
& query_params
,
125 const std::string
& expected_title
) {
126 base::StringPairs new_query_params
= query_params
;
127 StartLicenseServerIfNeeded(key_system
, &new_query_params
);
128 RunMediaTestPage(html_page
, new_query_params
, expected_title
, true);
131 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|.
132 // When |session_to_load| is not empty, the test will try to load
133 // |session_to_load| with stored keys, instead of creating a new session
134 // and trying to update it with licenses.
135 // When |force_invalid_response| is true, the test will provide invalid
136 // responses, which should trigger errors.
137 // TODO(xhwang): Find an easier way to pass multiple configuration test
139 void RunEncryptedMediaTest(const std::string
& html_page
,
140 const std::string
& media_file
,
141 const std::string
& media_type
,
142 const std::string
& key_system
,
144 EmeVersion eme_version
,
145 const std::string
& session_to_load
,
146 bool force_invalid_response
,
147 const std::string
& expected_title
) {
148 if (src_type
== MSE
&& !IsMSESupported()) {
149 DVLOG(0) << "Skipping test - MSE not supported.";
152 base::StringPairs query_params
;
153 query_params
.push_back(std::make_pair("mediaFile", media_file
));
154 query_params
.push_back(std::make_pair("mediaType", media_type
));
155 query_params
.push_back(std::make_pair("keySystem", key_system
));
157 query_params
.push_back(std::make_pair("useMSE", "1"));
158 if (eme_version
== PREFIXED
)
159 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
160 if (force_invalid_response
)
161 query_params
.push_back(std::make_pair("forceInvalidResponse", "1"));
162 if (!session_to_load
.empty())
163 query_params
.push_back(std::make_pair("sessionToLoad", session_to_load
));
164 RunEncryptedMediaTestPage(html_page
, key_system
, query_params
,
168 void RunSimpleEncryptedMediaTest(const std::string
& media_file
,
169 const std::string
& media_type
,
170 const std::string
& key_system
,
172 EmeVersion eme_version
) {
173 std::string expected_title
= kEnded
;
174 if (!IsPlayBackPossible(key_system
))
175 expected_title
= kEmeKeyError
;
177 RunEncryptedMediaTest(kDefaultEmePlayer
,
186 // Check KeyMessage received for all key systems.
187 bool receivedKeyMessage
= false;
188 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
189 browser()->tab_strip_model()->GetActiveWebContents(),
190 "window.domAutomationController.send("
191 "document.querySelector('video').receivedKeyMessage);",
192 &receivedKeyMessage
));
193 EXPECT_TRUE(receivedKeyMessage
);
196 // Starts a license server if available for the |key_system| and adds a
197 // 'licenseServerURL' query parameter to |query_params|.
198 void StartLicenseServerIfNeeded(const std::string
& key_system
,
199 base::StringPairs
* query_params
) {
200 scoped_ptr
<TestLicenseServerConfig
> config
= GetServerConfig(key_system
);
203 license_server_
.reset(new TestLicenseServer(config
.Pass()));
204 EXPECT_TRUE(license_server_
->Start());
205 query_params
->push_back(
206 std::make_pair("licenseServerURL", license_server_
->GetServerURL()));
209 bool IsPlayBackPossible(const std::string
& key_system
) {
210 #if defined(WIDEVINE_CDM_AVAILABLE)
211 if (IsWidevine(key_system
) && !GetServerConfig(key_system
))
213 #endif // defined(WIDEVINE_CDM_AVAILABLE)
217 scoped_ptr
<TestLicenseServerConfig
> GetServerConfig(
218 const std::string
& key_system
) {
219 #if defined(WIDEVINE_CDM_AVAILABLE)
220 if (IsWidevine(key_system
)) {
221 scoped_ptr
<TestLicenseServerConfig
> config
=
222 scoped_ptr
<TestLicenseServerConfig
>(new WVTestLicenseServerConfig());
223 if (config
->IsPlatformSupported())
224 return config
.Pass();
226 #endif // defined(WIDEVINE_CDM_AVAILABLE)
227 return scoped_ptr
<TestLicenseServerConfig
>();
231 scoped_ptr
<TestLicenseServer
> license_server_
;
233 // We want to fail quickly when a test fails because an error is encountered.
234 void AddWaitForTitles(content::TitleWatcher
* title_watcher
) override
{
235 MediaBrowserTest::AddWaitForTitles(title_watcher
);
236 title_watcher
->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError
));
237 title_watcher
->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError
));
240 void SetUpCommandLine(CommandLine
* command_line
) override
{
241 #if defined(OS_ANDROID)
242 command_line
->AppendSwitch(
243 switches::kDisableGestureRequirementForMediaPlayback
);
244 #endif // defined(OS_ANDROID)
247 void SetUpCommandLineForKeySystem(const std::string
& key_system
,
248 CommandLine
* command_line
) {
249 if (GetServerConfig(key_system
))
250 // Since the web and license servers listen on different ports, we need to
251 // disable web-security to send license requests to the license server.
252 // TODO(shadi): Add port forwarding to the test web server configuration.
253 command_line
->AppendSwitch(switches::kDisableWebSecurity
);
255 #if defined(ENABLE_PEPPER_CDMS)
256 if (IsExternalClearKey(key_system
)) {
257 RegisterPepperCdm(command_line
, kClearKeyCdmAdapterFileName
, key_system
);
259 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
260 else if (IsWidevine(key_system
)) { // NOLINT
261 RegisterPepperCdm(command_line
, kWidevineCdmAdapterFileName
, key_system
);
263 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
264 #endif // defined(ENABLE_PEPPER_CDMS)
268 #if defined(ENABLE_PEPPER_CDMS)
269 void RegisterPepperCdm(CommandLine
* command_line
,
270 const std::string
& adapter_name
,
271 const std::string
& key_system
) {
272 DCHECK(!is_pepper_cdm_registered_
)
273 << "RegisterPepperCdm() can only be called once.";
274 is_pepper_cdm_registered_
= true;
276 // Append the switch to register the Clear Key CDM Adapter.
277 base::FilePath plugin_dir
;
278 EXPECT_TRUE(PathService::Get(base::DIR_MODULE
, &plugin_dir
));
279 base::FilePath plugin_lib
= plugin_dir
.AppendASCII(adapter_name
);
280 EXPECT_TRUE(base::PathExists(plugin_lib
)) << plugin_lib
.value();
281 base::FilePath::StringType pepper_plugin
= plugin_lib
.value();
282 pepper_plugin
.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;"));
284 pepper_plugin
.append(base::ASCIIToUTF16(GetPepperType(key_system
)));
286 pepper_plugin
.append(GetPepperType(key_system
));
288 command_line
->AppendSwitchNative(switches::kRegisterPepperPlugins
,
292 // Adapted from key_systems.cc.
293 std::string
GetPepperType(const std::string
& key_system
) {
294 if (IsExternalClearKey(key_system
))
295 return kClearKeyCdmPluginMimeType
;
296 #if defined(WIDEVINE_CDM_AVAILABLE)
297 if (IsWidevine(key_system
))
298 return kWidevineCdmPluginMimeType
;
299 #endif // WIDEVINE_CDM_AVAILABLE
304 #endif // defined(ENABLE_PEPPER_CDMS)
306 bool is_pepper_cdm_registered_
;
309 #if defined(ENABLE_PEPPER_CDMS)
310 // Tests encrypted media playback using ExternalClearKey key system in
311 // decrypt-and-decode mode.
312 class ECKEncryptedMediaTest
: public EncryptedMediaTestBase
{
314 // We use special |key_system| names to do non-playback related tests, e.g.
315 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
316 void TestNonPlaybackCases(const std::string
& key_system
,
317 const std::string
& expected_title
) {
318 // Since we do not test playback, arbitrarily choose a test file and source
320 RunEncryptedMediaTest(kDefaultEmePlayer
,
332 void SetUpCommandLine(CommandLine
* command_line
) override
{
333 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
334 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem
, command_line
);
338 // Tests encrypted media playback using ExternalClearKey key system in
339 // decrypt-and-decode mode for unprefixed EME.
340 // TODO(jrummell): Merge with ECKEncryptedMediaTest once unprefixed is
341 // enabled by default.
342 class ECKUnprefixedEncryptedMediaTest
: public EncryptedMediaTestBase
{
344 void SetUpCommandLine(CommandLine
* command_line
) override
{
345 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
346 command_line
->AppendSwitch(switches::kEnableEncryptedMedia
);
347 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem
, command_line
);
351 #if defined(WIDEVINE_CDM_AVAILABLE)
352 // Tests encrypted media playback using Widevine key system.
353 class WVEncryptedMediaTest
: public EncryptedMediaTestBase
{
355 virtual void SetUpCommandLine(CommandLine
* command_line
) override
{
356 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
357 command_line
->AppendSwitch(switches::kEnableEncryptedMedia
);
358 SetUpCommandLineForKeySystem(kWidevineKeySystem
, command_line
);
362 #endif // defined(WIDEVINE_CDM_AVAILABLE)
363 #endif // defined(ENABLE_PEPPER_CDMS)
365 // Tests encrypted media playback with a combination of parameters:
366 // - char*: Key system name.
367 // - bool: True to load media using MSE, otherwise use src.
368 // - bool: True to use unprefixed EME, otherwise use prefixed EME.
370 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
371 // tests will crash at GetParam(). To add non-parameterized tests, use
372 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
373 class EncryptedMediaTest
374 : public EncryptedMediaTestBase
,
375 public testing::WithParamInterface
<
376 std::tr1::tuple
<const char*, SrcType
, EmeVersion
> > {
378 std::string
CurrentKeySystem() {
379 return std::tr1::get
<0>(GetParam());
382 SrcType
CurrentSourceType() {
383 return std::tr1::get
<1>(GetParam());
386 EmeVersion
CurrentEmeVersion() {
387 return std::tr1::get
<2>(GetParam());
390 void TestSimplePlayback(const std::string
& encrypted_media
,
391 const std::string
& media_type
) {
392 RunSimpleEncryptedMediaTest(encrypted_media
,
396 CurrentEmeVersion());
399 void RunInvalidResponseTest() {
400 RunEncryptedMediaTest(kDefaultEmePlayer
,
401 "bear-320x240-av_enc-av.webm",
411 void TestFrameSizeChange() {
412 RunEncryptedMediaTest("encrypted_frame_size_change.html",
413 "frame_size_change-av_enc-v.webm",
423 void TestConfigChange() {
424 DCHECK(IsMSESupported());
425 base::StringPairs query_params
;
426 query_params
.push_back(std::make_pair("keySystem", CurrentKeySystem()));
427 query_params
.push_back(std::make_pair("runEncrypted", "1"));
428 if (CurrentEmeVersion() == PREFIXED
)
429 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
430 RunEncryptedMediaTestPage("mse_config_change.html",
437 void SetUpCommandLine(CommandLine
* command_line
) override
{
438 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
439 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line
);
441 if (CurrentEmeVersion() == UNPREFIXED
)
442 command_line
->AppendSwitch(switches::kEnableEncryptedMedia
);
446 using ::testing::Combine
;
447 using ::testing::Values
;
449 #if !defined(OS_ANDROID)
450 INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed
,
452 Combine(Values(kPrefixedClearKeyKeySystem
),
456 // TODO(jrummell): Enable unprefixed tests before shipping unprefixed EME.
457 // Disabled now as they don't provide much additional coverage, but do take a
458 // bit of time to execute.
459 INSTANTIATE_TEST_CASE_P(DISABLED_SRC_ClearKey
,
461 Combine(Values(kClearKeyKeySystem
),
463 Values(UNPREFIXED
)));
464 #endif // !defined(OS_ANDROID)
466 INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed
,
468 Combine(Values(kPrefixedClearKeyKeySystem
),
471 INSTANTIATE_TEST_CASE_P(MSE_ClearKey
,
473 Combine(Values(kClearKeyKeySystem
),
475 Values(UNPREFIXED
)));
477 // External Clear Key is currently only used on platforms that use Pepper CDMs.
478 #if defined(ENABLE_PEPPER_CDMS)
479 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed
,
481 Combine(Values(kExternalClearKeyKeySystem
),
484 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey
,
486 Combine(Values(kExternalClearKeyKeySystem
),
488 Values(UNPREFIXED
)));
489 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed
,
491 Combine(Values(kExternalClearKeyKeySystem
),
494 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey
,
496 Combine(Values(kExternalClearKeyKeySystem
),
498 Values(UNPREFIXED
)));
499 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
500 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed
,
502 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem
),
505 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly
,
507 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem
),
509 Values(UNPREFIXED
)));
510 #endif // defined(ENABLE_PEPPER_CDMS)
512 #if defined(WIDEVINE_CDM_AVAILABLE)
513 // This test doesn't fully test playback with Widevine. So we only run Widevine
514 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works
515 // with MSE and we cannot run this test with SRC.
516 INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed
,
518 Combine(Values(kWidevineKeySystem
),
522 // Following tests fail if Widevine is loaded as a component, crbug.com/356833.
523 #if !defined(WIDEVINE_CDM_IS_COMPONENT)
524 INSTANTIATE_TEST_CASE_P(MSE_Widevine
,
526 Combine(Values(kWidevineKeySystem
),
528 Values(UNPREFIXED
)));
529 #endif // !defined(WIDEVINE_CDM_IS_COMPONENT)
530 #endif // defined(WIDEVINE_CDM_AVAILABLE)
532 // These tests time out in Chrome OS official builds. http://crbug.com/430711
533 #if !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
534 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_WebM
) {
535 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly
);
538 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioClearVideo_WebM
) {
539 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo
);
542 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoAudio_WebM
) {
543 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo
);
546 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoOnly_WebM
) {
547 TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly
);
550 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoClearAudio_WebM
) {
551 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo
);
554 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VP9Video_WebM
) {
555 TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly
);
558 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_WebM_Opus
) {
559 TestSimplePlayback("bear-320x240-opus-a_enc-a.webm", kWebMAudioOnly
);
562 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoAudio_WebM_Opus
) {
563 TestSimplePlayback("bear-320x240-opus-av_enc-av.webm", kWebMAudioVideo
);
566 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoClearAudio_WebM_Opus
) {
567 TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMAudioVideo
);
570 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, InvalidResponseKeyError
) {
571 RunInvalidResponseTest();
574 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, ConfigChangeVideo
) {
575 if (CurrentSourceType() != MSE
|| !IsMSESupported()) {
576 DVLOG(0) << "Skipping test - ConfigChange test requires MSE.";
579 if (!IsPlayBackPossible(CurrentKeySystem())) {
580 DVLOG(0) << "Skipping test - ConfigChange test requires video playback.";
586 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, FrameSizeChangeVideo
) {
587 // Times out on Windows XP. http://crbug.com/171937
589 if (base::win::GetVersion() < base::win::VERSION_VISTA
)
592 if (!IsPlayBackPossible(CurrentKeySystem())) {
593 DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback.";
596 TestFrameSizeChange();
599 #if defined(USE_PROPRIETARY_CODECS)
600 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoOnly_MP4
) {
601 // MP4 without MSE is not support yet, http://crbug.com/170793.
602 if (CurrentSourceType() != MSE
) {
603 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
606 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly
);
609 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_MP4
) {
610 // MP4 without MSE is not support yet, http://crbug.com/170793.
611 if (CurrentSourceType() != MSE
) {
612 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
615 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly
);
617 #endif // defined(USE_PROPRIETARY_CODECS)
618 #endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
620 #if defined(WIDEVINE_CDM_AVAILABLE)
621 // The parent key system cannot be used in generateKeyRequest.
622 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest
, ParentThrowsException_Prefixed
) {
623 RunEncryptedMediaTest(kDefaultEmePlayer
,
631 kEmeNotSupportedError
);
634 // TODO(jrummell): http://crbug.com/349181
635 // The parent key system cannot be used when creating MediaKeys.
636 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest
, ParentThrowsException
) {
637 RunEncryptedMediaTest(kDefaultEmePlayer
,
645 kEmeNotSupportedError
);
647 #endif // defined(WIDEVINE_CDM_AVAILABLE)
649 #if defined(ENABLE_PEPPER_CDMS)
650 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, InitializeCDMFail
) {
651 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem
, kEmeKeyError
);
654 // When CDM crashes, we should still get a decode error.
656 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, DISABLED_CDMCrashDuringDecode
) {
658 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
);
661 // Testing that the media browser test does fail on plugin crash.
663 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, DISABLED_CDMExpectedCrash
) {
664 // Plugin crash is not ignored by default, the test is expected to fail.
665 EXPECT_NONFATAL_FAILURE(
666 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
),
670 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, FileIOTest
) {
671 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem
,
675 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, LoadLoadableSession
) {
676 RunEncryptedMediaTest(kDefaultEmePlayer
,
677 "bear-320x240-v_enc-v.webm",
679 kExternalClearKeyKeySystem
,
687 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, LoadUnknownSession
) {
688 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
689 RunEncryptedMediaTest(kDefaultEmePlayer
,
690 "bear-320x240-v_enc-v.webm",
692 kExternalClearKeyKeySystem
,
700 IN_PROC_BROWSER_TEST_F(ECKUnprefixedEncryptedMediaTest
, LoadLoadableSession
) {
701 RunEncryptedMediaTest(kDefaultEmePlayer
,
702 "bear-320x240-v_enc-v.webm",
704 kExternalClearKeyKeySystem
,
712 IN_PROC_BROWSER_TEST_F(ECKUnprefixedEncryptedMediaTest
, LoadUnknownSession
) {
713 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
714 RunEncryptedMediaTest(kDefaultEmePlayer
,
715 "bear-320x240-v_enc-v.webm",
717 kExternalClearKeyKeySystem
,
724 #endif // defined(ENABLE_PEPPER_CDMS)