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 const char kWebMVP9VideoOnly
[] = "video/webm; codecs=\"vp9\"";
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)
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.
79 // Whether to use prefixed or unprefixed EME.
85 // Whether the video should be played once or twice.
86 enum class PlayTwice
{ NO
, YES
};
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 PlayTwice play_twice
,
148 const std::string
& expected_title
) {
149 if (src_type
== MSE
&& !IsMSESupported()) {
150 DVLOG(0) << "Skipping test - MSE not supported.";
153 base::StringPairs query_params
;
154 query_params
.push_back(std::make_pair("mediaFile", media_file
));
155 query_params
.push_back(std::make_pair("mediaType", media_type
));
156 query_params
.push_back(std::make_pair("keySystem", key_system
));
158 query_params
.push_back(std::make_pair("useMSE", "1"));
159 if (eme_version
== PREFIXED
)
160 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
161 if (force_invalid_response
)
162 query_params
.push_back(std::make_pair("forceInvalidResponse", "1"));
163 if (!session_to_load
.empty())
164 query_params
.push_back(std::make_pair("sessionToLoad", session_to_load
));
165 if (play_twice
== PlayTwice::YES
)
166 query_params
.push_back(std::make_pair("playTwice", "1"));
167 RunEncryptedMediaTestPage(html_page
, key_system
, query_params
,
171 void RunSimpleEncryptedMediaTest(const std::string
& media_file
,
172 const std::string
& media_type
,
173 const std::string
& key_system
,
175 EmeVersion eme_version
) {
176 std::string expected_title
= kEnded
;
177 if (!IsPlayBackPossible(key_system
))
178 expected_title
= kEmeKeyError
;
180 RunEncryptedMediaTest(kDefaultEmePlayer
, media_file
, media_type
, key_system
,
181 src_type
, eme_version
, kNoSessionToLoad
, false,
182 PlayTwice::NO
, 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
);
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
))
210 #endif // defined(WIDEVINE_CDM_AVAILABLE)
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
>();
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(base::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 base::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
)) { // NOLINT
258 RegisterPepperCdm(command_line
, kWidevineCdmAdapterFileName
, key_system
);
260 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
261 #endif // defined(ENABLE_PEPPER_CDMS)
265 #if defined(ENABLE_PEPPER_CDMS)
266 void RegisterPepperCdm(base::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;"));
281 pepper_plugin
.append(base::ASCIIToUTF16(GetPepperType(key_system
)));
283 pepper_plugin
.append(GetPepperType(key_system
));
285 command_line
->AppendSwitchNative(switches::kRegisterPepperPlugins
,
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
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
{
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
317 RunEncryptedMediaTest(
318 kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
, key_system
, SRC
,
319 UNPREFIXED
, kNoSessionToLoad
, false, PlayTwice::NO
, expected_title
);
322 void TestPlaybackCase(const std::string
& session_to_load
,
323 const std::string
& expected_title
) {
324 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-320x240-v_enc-v.webm",
325 kWebMVideoOnly
, kExternalClearKeyKeySystem
, SRC
,
326 UNPREFIXED
, session_to_load
, false, PlayTwice::NO
,
331 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
332 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
333 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem
, command_line
);
337 // Tests encrypted media playback using ExternalClearKey key system in
338 // decrypt-and-decode mode for unprefixed EME.
339 class ECKPrefixedEncryptedMediaTest
: public EncryptedMediaTestBase
{
341 // We use special |key_system| names to do non-playback related tests, e.g.
342 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
343 void TestNonPlaybackCases(const std::string
& key_system
,
344 const std::string
& expected_title
) {
345 // Since we do not test playback, arbitrarily choose a test file and source
347 RunEncryptedMediaTest(
348 kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
, key_system
, SRC
,
349 PREFIXED
, kNoSessionToLoad
, false, PlayTwice::NO
, expected_title
);
352 void TestPlaybackCase(const std::string
& session_to_load
,
353 const std::string
& expected_title
) {
354 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-320x240-v_enc-v.webm",
355 kWebMVideoOnly
, kExternalClearKeyKeySystem
, SRC
,
356 PREFIXED
, session_to_load
, false, PlayTwice::NO
,
361 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
362 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
363 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem
, command_line
);
367 #if defined(WIDEVINE_CDM_AVAILABLE)
368 // Tests encrypted media playback using Widevine key system.
369 class WVEncryptedMediaTest
: public EncryptedMediaTestBase
{
371 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
372 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
373 SetUpCommandLineForKeySystem(kWidevineKeySystem
, command_line
);
377 #endif // defined(WIDEVINE_CDM_AVAILABLE)
378 #endif // defined(ENABLE_PEPPER_CDMS)
380 // Tests encrypted media playback with a combination of parameters:
381 // - char*: Key system name.
382 // - SrcType: Use MSE or SRC.
383 // - EmeVersion: Use PREFIXED or UNPREFIXED EME.
385 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
386 // tests will crash at GetParam(). To add non-parameterized tests, use
387 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
388 class EncryptedMediaTest
389 : public EncryptedMediaTestBase
,
390 public testing::WithParamInterface
<
391 std::tr1::tuple
<const char*, SrcType
, EmeVersion
> > {
393 std::string
CurrentKeySystem() {
394 return std::tr1::get
<0>(GetParam());
397 SrcType
CurrentSourceType() {
398 return std::tr1::get
<1>(GetParam());
401 EmeVersion
CurrentEmeVersion() {
402 return std::tr1::get
<2>(GetParam());
405 void TestSimplePlayback(const std::string
& encrypted_media
,
406 const std::string
& media_type
) {
407 RunSimpleEncryptedMediaTest(encrypted_media
,
411 CurrentEmeVersion());
414 void TestMultiplePlayback(const std::string
& encrypted_media
,
415 const std::string
& media_type
) {
416 DCHECK(IsPlayBackPossible(CurrentKeySystem()));
417 RunEncryptedMediaTest(kDefaultEmePlayer
, encrypted_media
, media_type
,
418 CurrentKeySystem(), CurrentSourceType(),
419 CurrentEmeVersion(), kNoSessionToLoad
, false,
420 PlayTwice::YES
, kEnded
);
423 void RunInvalidResponseTest() {
424 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-320x240-av_enc-av.webm",
425 kWebMAudioVideo
, CurrentKeySystem(),
426 CurrentSourceType(), CurrentEmeVersion(),
427 kNoSessionToLoad
, true, PlayTwice::NO
, kEmeKeyError
);
430 void TestFrameSizeChange() {
431 RunEncryptedMediaTest(
432 "encrypted_frame_size_change.html", "frame_size_change-av_enc-v.webm",
433 kWebMAudioVideo
, CurrentKeySystem(), CurrentSourceType(),
434 CurrentEmeVersion(), kNoSessionToLoad
, false, PlayTwice::NO
, kEnded
);
437 void TestConfigChange() {
438 DCHECK(IsMSESupported());
439 base::StringPairs query_params
;
440 query_params
.push_back(std::make_pair("keySystem", CurrentKeySystem()));
441 query_params
.push_back(std::make_pair("runEncrypted", "1"));
442 if (CurrentEmeVersion() == PREFIXED
)
443 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
444 RunEncryptedMediaTestPage("mse_config_change.html",
451 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
452 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
453 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line
);
457 using ::testing::Combine
;
458 using ::testing::Values
;
460 #if !defined(OS_ANDROID)
461 INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed
,
463 Combine(Values(kPrefixedClearKeyKeySystem
),
467 INSTANTIATE_TEST_CASE_P(SRC_ClearKey
,
469 Combine(Values(kClearKeyKeySystem
),
471 Values(UNPREFIXED
)));
472 #endif // !defined(OS_ANDROID)
474 INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed
,
476 Combine(Values(kPrefixedClearKeyKeySystem
),
479 INSTANTIATE_TEST_CASE_P(MSE_ClearKey
,
481 Combine(Values(kClearKeyKeySystem
),
483 Values(UNPREFIXED
)));
485 // External Clear Key is currently only used on platforms that use Pepper CDMs.
486 #if defined(ENABLE_PEPPER_CDMS)
487 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed
,
489 Combine(Values(kExternalClearKeyKeySystem
),
492 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey
,
494 Combine(Values(kExternalClearKeyKeySystem
),
496 Values(UNPREFIXED
)));
497 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed
,
499 Combine(Values(kExternalClearKeyKeySystem
),
502 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey
,
504 Combine(Values(kExternalClearKeyKeySystem
),
506 Values(UNPREFIXED
)));
507 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
508 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed
,
510 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem
),
513 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly
,
515 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem
),
517 Values(UNPREFIXED
)));
518 #endif // defined(ENABLE_PEPPER_CDMS)
520 #if defined(WIDEVINE_CDM_AVAILABLE)
522 // Prefixed Widevine tests fail in Chrome OS official builds due to the request
523 // for permissions. Since prefixed EME is deprecated and will be removed soon,
524 // don't run these tests. http://crbug.com/430711
525 #if !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
527 // This test doesn't fully test playback with Widevine. So we only run Widevine
528 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works
529 // with MSE and we cannot run this test with SRC.
530 INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed
,
532 Combine(Values(kWidevineKeySystem
),
535 #endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
537 INSTANTIATE_TEST_CASE_P(MSE_Widevine
,
539 Combine(Values(kWidevineKeySystem
),
541 Values(UNPREFIXED
)));
542 #endif // defined(WIDEVINE_CDM_AVAILABLE)
544 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_WebM
) {
545 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly
);
548 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioClearVideo_WebM
) {
549 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo
);
552 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoAudio_WebM
) {
553 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo
);
556 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoOnly_WebM
) {
557 TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly
);
560 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoClearAudio_WebM
) {
561 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo
);
564 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VP9Video_WebM
) {
565 TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly
);
568 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_WebM_Opus
) {
569 TestSimplePlayback("bear-320x240-opus-a_enc-a.webm", kWebMAudioOnly
);
572 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoAudio_WebM_Opus
) {
573 TestSimplePlayback("bear-320x240-opus-av_enc-av.webm", kWebMAudioVideo
);
576 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoClearAudio_WebM_Opus
) {
577 TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMAudioVideo
);
580 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_Multiple_VideoAudio_WebM
) {
581 if (!IsPlayBackPossible(CurrentKeySystem())) {
582 DVLOG(0) << "Skipping test - Playback_Multiple test requires playback.";
585 TestMultiplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo
);
588 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, InvalidResponseKeyError
) {
589 RunInvalidResponseTest();
592 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, ConfigChangeVideo
) {
593 if (CurrentSourceType() != MSE
|| !IsMSESupported()) {
594 DVLOG(0) << "Skipping test - ConfigChange test requires MSE.";
597 if (!IsPlayBackPossible(CurrentKeySystem())) {
598 DVLOG(0) << "Skipping test - ConfigChange test requires video playback.";
604 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, FrameSizeChangeVideo
) {
605 // Times out on Windows XP. http://crbug.com/171937
607 if (base::win::GetVersion() < base::win::VERSION_VISTA
)
610 if (!IsPlayBackPossible(CurrentKeySystem())) {
611 DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback.";
614 TestFrameSizeChange();
617 #if defined(USE_PROPRIETARY_CODECS)
618 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoOnly_MP4
) {
619 // MP4 without MSE is not support yet, http://crbug.com/170793.
620 if (CurrentSourceType() != MSE
) {
621 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
624 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly
);
627 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_MP4
) {
628 // MP4 without MSE is not support yet, http://crbug.com/170793.
629 if (CurrentSourceType() != MSE
) {
630 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
633 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly
);
635 #endif // defined(USE_PROPRIETARY_CODECS)
637 #if defined(WIDEVINE_CDM_AVAILABLE)
638 // The parent key system cannot be used in generateKeyRequest.
639 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest
, ParentThrowsException_Prefixed
) {
640 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
,
641 "com.widevine", MSE
, PREFIXED
, kNoSessionToLoad
, false,
642 PlayTwice::NO
, kEmeNotSupportedError
);
645 // TODO(jrummell): http://crbug.com/349181
646 // The parent key system cannot be used when creating MediaKeys.
647 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest
, ParentThrowsException
) {
648 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
,
649 "com.widevine", MSE
, UNPREFIXED
, kNoSessionToLoad
,
650 false, PlayTwice::NO
, kEmeNotSupportedError
);
652 #endif // defined(WIDEVINE_CDM_AVAILABLE)
654 #if defined(ENABLE_PEPPER_CDMS)
655 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, InitializeCDMFail
) {
656 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem
,
657 kEmeNotSupportedError
);
660 // When CDM crashes, we should still get a decode error.
662 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, DISABLED_CDMCrashDuringDecode
) {
664 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
);
667 // Testing that the media browser test does fail on plugin crash.
669 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, DISABLED_CDMExpectedCrash
) {
670 // Plugin crash is not ignored by default, the test is expected to fail.
671 EXPECT_NONFATAL_FAILURE(
672 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
),
676 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, FileIOTest
) {
677 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem
,
681 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, LoadLoadableSession
) {
682 TestPlaybackCase(kLoadableSession
, kEnded
);
685 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, LoadUnknownSession
) {
686 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
687 TestPlaybackCase(kUnknownSession
, kEmeKeyError
);
690 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, InitializeCDMFail
) {
691 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem
, kEmeKeyError
);
694 // When CDM crashes, we should still get a decode error.
696 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
,
697 DISABLED_CDMCrashDuringDecode
) {
699 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
);
702 // Testing that the media browser test does fail on plugin crash.
704 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
,
705 DISABLED_CDMExpectedCrash
) {
706 // Plugin crash is not ignored by default, the test is expected to fail.
707 EXPECT_NONFATAL_FAILURE(
708 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
),
712 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, FileIOTest
) {
713 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem
,
717 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, LoadLoadableSession
) {
718 TestPlaybackCase(kLoadableSession
, kEnded
);
721 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, LoadUnknownSession
) {
722 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
723 TestPlaybackCase(kUnknownSession
, kEmeKeyError
);
725 #endif // defined(ENABLE_PEPPER_CDMS)