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 // Whether the video should be played once or twice.
89 enum class PlayTwice
{ NO
, YES
};
91 // MSE is available on all desktop platforms and on Android 4.1 and later.
92 static bool IsMSESupported() {
93 #if defined(OS_ANDROID)
94 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
95 DVLOG(0) << "MSE is only supported in Android 4.1 and later.";
98 #endif // defined(OS_ANDROID)
102 static bool IsParentKeySystemOf(const std::string
& parent_key_system
,
103 const std::string
& key_system
) {
104 std::string prefix
= parent_key_system
+ '.';
105 return key_system
.substr(0, prefix
.size()) == prefix
;
108 // Base class for encrypted media tests.
109 class EncryptedMediaTestBase
: public MediaBrowserTest
{
111 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {}
113 bool IsExternalClearKey(const std::string
& key_system
) {
114 return key_system
== kExternalClearKeyKeySystem
||
115 IsParentKeySystemOf(kExternalClearKeyKeySystem
, key_system
);
118 #if defined(WIDEVINE_CDM_AVAILABLE)
119 bool IsWidevine(const std::string
& key_system
) {
120 return key_system
== kWidevineKeySystem
;
122 #endif // defined(WIDEVINE_CDM_AVAILABLE)
124 void RunEncryptedMediaTestPage(
125 const std::string
& html_page
,
126 const std::string
& key_system
,
127 base::StringPairs
& query_params
,
128 const std::string
& expected_title
) {
129 base::StringPairs new_query_params
= query_params
;
130 StartLicenseServerIfNeeded(key_system
, &new_query_params
);
131 RunMediaTestPage(html_page
, new_query_params
, expected_title
, true);
134 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|.
135 // When |session_to_load| is not empty, the test will try to load
136 // |session_to_load| with stored keys, instead of creating a new session
137 // and trying to update it with licenses.
138 // When |force_invalid_response| is true, the test will provide invalid
139 // responses, which should trigger errors.
140 // TODO(xhwang): Find an easier way to pass multiple configuration test
142 void RunEncryptedMediaTest(const std::string
& html_page
,
143 const std::string
& media_file
,
144 const std::string
& media_type
,
145 const std::string
& key_system
,
147 EmeVersion eme_version
,
148 const std::string
& session_to_load
,
149 bool force_invalid_response
,
150 PlayTwice play_twice
,
151 const std::string
& expected_title
) {
152 if (src_type
== MSE
&& !IsMSESupported()) {
153 DVLOG(0) << "Skipping test - MSE not supported.";
156 base::StringPairs query_params
;
157 query_params
.push_back(std::make_pair("mediaFile", media_file
));
158 query_params
.push_back(std::make_pair("mediaType", media_type
));
159 query_params
.push_back(std::make_pair("keySystem", key_system
));
161 query_params
.push_back(std::make_pair("useMSE", "1"));
162 if (eme_version
== PREFIXED
)
163 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
164 if (force_invalid_response
)
165 query_params
.push_back(std::make_pair("forceInvalidResponse", "1"));
166 if (!session_to_load
.empty())
167 query_params
.push_back(std::make_pair("sessionToLoad", session_to_load
));
168 if (play_twice
== PlayTwice::YES
)
169 query_params
.push_back(std::make_pair("playTwice", "1"));
170 RunEncryptedMediaTestPage(html_page
, key_system
, query_params
,
174 void RunSimpleEncryptedMediaTest(const std::string
& media_file
,
175 const std::string
& media_type
,
176 const std::string
& key_system
,
178 EmeVersion eme_version
) {
179 std::string expected_title
= kEnded
;
180 if (!IsPlayBackPossible(key_system
))
181 expected_title
= kEmeKeyError
;
183 RunEncryptedMediaTest(kDefaultEmePlayer
, media_file
, media_type
, key_system
,
184 src_type
, eme_version
, kNoSessionToLoad
, false,
185 PlayTwice::NO
, expected_title
);
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(base::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 base::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(base::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(
321 kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
, key_system
, SRC
,
322 UNPREFIXED
, kNoSessionToLoad
, false, PlayTwice::NO
, expected_title
);
325 void TestPlaybackCase(const std::string
& session_to_load
,
326 const std::string
& expected_title
) {
327 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-320x240-v_enc-v.webm",
328 kWebMVideoOnly
, kExternalClearKeyKeySystem
, SRC
,
329 UNPREFIXED
, session_to_load
, false, PlayTwice::NO
,
334 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
335 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
336 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem
, command_line
);
340 // Tests encrypted media playback using ExternalClearKey key system in
341 // decrypt-and-decode mode for unprefixed EME.
342 class ECKPrefixedEncryptedMediaTest
: public EncryptedMediaTestBase
{
344 // We use special |key_system| names to do non-playback related tests, e.g.
345 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
346 void TestNonPlaybackCases(const std::string
& key_system
,
347 const std::string
& expected_title
) {
348 // Since we do not test playback, arbitrarily choose a test file and source
350 RunEncryptedMediaTest(
351 kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
, key_system
, SRC
,
352 PREFIXED
, kNoSessionToLoad
, false, PlayTwice::NO
, expected_title
);
355 void TestPlaybackCase(const std::string
& session_to_load
,
356 const std::string
& expected_title
) {
357 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-320x240-v_enc-v.webm",
358 kWebMVideoOnly
, kExternalClearKeyKeySystem
, SRC
,
359 PREFIXED
, session_to_load
, false, PlayTwice::NO
,
364 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
365 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
366 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem
, command_line
);
370 #if defined(WIDEVINE_CDM_AVAILABLE)
371 // Tests encrypted media playback using Widevine key system.
372 class WVEncryptedMediaTest
: public EncryptedMediaTestBase
{
374 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
375 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
376 SetUpCommandLineForKeySystem(kWidevineKeySystem
, command_line
);
380 #endif // defined(WIDEVINE_CDM_AVAILABLE)
381 #endif // defined(ENABLE_PEPPER_CDMS)
383 // Tests encrypted media playback with a combination of parameters:
384 // - char*: Key system name.
385 // - SrcType: Use MSE or SRC.
386 // - EmeVersion: Use PREFIXED or UNPREFIXED EME.
388 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
389 // tests will crash at GetParam(). To add non-parameterized tests, use
390 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
391 class EncryptedMediaTest
392 : public EncryptedMediaTestBase
,
393 public testing::WithParamInterface
<
394 std::tr1::tuple
<const char*, SrcType
, EmeVersion
> > {
396 std::string
CurrentKeySystem() {
397 return std::tr1::get
<0>(GetParam());
400 SrcType
CurrentSourceType() {
401 return std::tr1::get
<1>(GetParam());
404 EmeVersion
CurrentEmeVersion() {
405 return std::tr1::get
<2>(GetParam());
408 void TestSimplePlayback(const std::string
& encrypted_media
,
409 const std::string
& media_type
) {
410 RunSimpleEncryptedMediaTest(encrypted_media
,
414 CurrentEmeVersion());
417 void TestMultiplePlayback(const std::string
& encrypted_media
,
418 const std::string
& media_type
) {
419 DCHECK(IsPlayBackPossible(CurrentKeySystem()));
420 RunEncryptedMediaTest(kDefaultEmePlayer
, encrypted_media
, media_type
,
421 CurrentKeySystem(), CurrentSourceType(),
422 CurrentEmeVersion(), kNoSessionToLoad
, false,
423 PlayTwice::YES
, kEnded
);
426 void RunInvalidResponseTest() {
427 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-320x240-av_enc-av.webm",
428 kWebMAudioVideo
, CurrentKeySystem(),
429 CurrentSourceType(), CurrentEmeVersion(),
430 kNoSessionToLoad
, true, PlayTwice::NO
, kEmeKeyError
);
433 void TestFrameSizeChange() {
434 RunEncryptedMediaTest(
435 "encrypted_frame_size_change.html", "frame_size_change-av_enc-v.webm",
436 kWebMAudioVideo
, CurrentKeySystem(), CurrentSourceType(),
437 CurrentEmeVersion(), kNoSessionToLoad
, false, PlayTwice::NO
, kEnded
);
440 void TestConfigChange() {
441 DCHECK(IsMSESupported());
442 base::StringPairs query_params
;
443 query_params
.push_back(std::make_pair("keySystem", CurrentKeySystem()));
444 query_params
.push_back(std::make_pair("runEncrypted", "1"));
445 if (CurrentEmeVersion() == PREFIXED
)
446 query_params
.push_back(std::make_pair("usePrefixedEME", "1"));
447 RunEncryptedMediaTestPage("mse_config_change.html",
454 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
455 EncryptedMediaTestBase::SetUpCommandLine(command_line
);
456 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line
);
460 using ::testing::Combine
;
461 using ::testing::Values
;
463 #if !defined(OS_ANDROID)
464 INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed
,
466 Combine(Values(kPrefixedClearKeyKeySystem
),
470 INSTANTIATE_TEST_CASE_P(SRC_ClearKey
,
472 Combine(Values(kClearKeyKeySystem
),
474 Values(UNPREFIXED
)));
475 #endif // !defined(OS_ANDROID)
477 INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed
,
479 Combine(Values(kPrefixedClearKeyKeySystem
),
482 INSTANTIATE_TEST_CASE_P(MSE_ClearKey
,
484 Combine(Values(kClearKeyKeySystem
),
486 Values(UNPREFIXED
)));
488 // External Clear Key is currently only used on platforms that use Pepper CDMs.
489 #if defined(ENABLE_PEPPER_CDMS)
490 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed
,
492 Combine(Values(kExternalClearKeyKeySystem
),
495 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey
,
497 Combine(Values(kExternalClearKeyKeySystem
),
499 Values(UNPREFIXED
)));
500 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed
,
502 Combine(Values(kExternalClearKeyKeySystem
),
505 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey
,
507 Combine(Values(kExternalClearKeyKeySystem
),
509 Values(UNPREFIXED
)));
510 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
511 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed
,
513 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem
),
516 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly
,
518 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem
),
520 Values(UNPREFIXED
)));
521 #endif // defined(ENABLE_PEPPER_CDMS)
523 #if defined(WIDEVINE_CDM_AVAILABLE)
524 // This test doesn't fully test playback with Widevine. So we only run Widevine
525 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works
526 // with MSE and we cannot run this test with SRC.
527 INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed
,
529 Combine(Values(kWidevineKeySystem
),
533 INSTANTIATE_TEST_CASE_P(MSE_Widevine
,
535 Combine(Values(kWidevineKeySystem
),
537 Values(UNPREFIXED
)));
538 #endif // defined(WIDEVINE_CDM_AVAILABLE)
540 // These tests time out in Chrome OS official builds. http://crbug.com/430711
541 #if !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
542 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_WebM
) {
543 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly
);
546 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioClearVideo_WebM
) {
547 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo
);
550 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoAudio_WebM
) {
551 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo
);
554 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoOnly_WebM
) {
555 TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly
);
558 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoClearAudio_WebM
) {
559 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo
);
562 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VP9Video_WebM
) {
563 TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly
);
566 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_WebM_Opus
) {
567 TestSimplePlayback("bear-320x240-opus-a_enc-a.webm", kWebMAudioOnly
);
570 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoAudio_WebM_Opus
) {
571 TestSimplePlayback("bear-320x240-opus-av_enc-av.webm", kWebMAudioVideo
);
574 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoClearAudio_WebM_Opus
) {
575 TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMAudioVideo
);
578 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_Multiple_VideoAudio_WebM
) {
579 if (!IsPlayBackPossible(CurrentKeySystem())) {
580 DVLOG(0) << "Skipping test - Playback_Multiple test requires playback.";
583 TestMultiplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo
);
586 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, InvalidResponseKeyError
) {
587 RunInvalidResponseTest();
590 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, ConfigChangeVideo
) {
591 if (CurrentSourceType() != MSE
|| !IsMSESupported()) {
592 DVLOG(0) << "Skipping test - ConfigChange test requires MSE.";
595 if (!IsPlayBackPossible(CurrentKeySystem())) {
596 DVLOG(0) << "Skipping test - ConfigChange test requires video playback.";
602 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, FrameSizeChangeVideo
) {
603 // Times out on Windows XP. http://crbug.com/171937
605 if (base::win::GetVersion() < base::win::VERSION_VISTA
)
608 if (!IsPlayBackPossible(CurrentKeySystem())) {
609 DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback.";
612 TestFrameSizeChange();
615 #if defined(USE_PROPRIETARY_CODECS)
616 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_VideoOnly_MP4
) {
617 // MP4 without MSE is not support yet, http://crbug.com/170793.
618 if (CurrentSourceType() != MSE
) {
619 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
622 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly
);
625 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest
, Playback_AudioOnly_MP4
) {
626 // MP4 without MSE is not support yet, http://crbug.com/170793.
627 if (CurrentSourceType() != MSE
) {
628 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
631 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly
);
633 #endif // defined(USE_PROPRIETARY_CODECS)
634 #endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
636 #if defined(WIDEVINE_CDM_AVAILABLE)
637 // The parent key system cannot be used in generateKeyRequest.
638 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest
, ParentThrowsException_Prefixed
) {
639 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
,
640 "com.widevine", MSE
, PREFIXED
, kNoSessionToLoad
, false,
641 PlayTwice::NO
, kEmeNotSupportedError
);
644 // TODO(jrummell): http://crbug.com/349181
645 // The parent key system cannot be used when creating MediaKeys.
646 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest
, ParentThrowsException
) {
647 RunEncryptedMediaTest(kDefaultEmePlayer
, "bear-a_enc-a.webm", kWebMAudioOnly
,
648 "com.widevine", MSE
, UNPREFIXED
, kNoSessionToLoad
,
649 false, PlayTwice::NO
, kEmeNotSupportedError
);
651 #endif // defined(WIDEVINE_CDM_AVAILABLE)
653 #if defined(ENABLE_PEPPER_CDMS)
654 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, InitializeCDMFail
) {
655 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem
, kEmeKeyError
);
658 // When CDM crashes, we should still get a decode error.
660 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, DISABLED_CDMCrashDuringDecode
) {
662 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
);
665 // Testing that the media browser test does fail on plugin crash.
667 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, DISABLED_CDMExpectedCrash
) {
668 // Plugin crash is not ignored by default, the test is expected to fail.
669 EXPECT_NONFATAL_FAILURE(
670 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
),
674 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, FileIOTest
) {
675 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem
,
679 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, LoadLoadableSession
) {
680 TestPlaybackCase(kLoadableSession
, kEnded
);
683 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest
, LoadUnknownSession
) {
684 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
685 TestPlaybackCase(kUnknownSession
, kEmeKeyError
);
688 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, InitializeCDMFail
) {
689 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem
, kEmeKeyError
);
692 // When CDM crashes, we should still get a decode error.
694 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
,
695 DISABLED_CDMCrashDuringDecode
) {
697 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
);
700 // Testing that the media browser test does fail on plugin crash.
702 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
,
703 DISABLED_CDMExpectedCrash
) {
704 // Plugin crash is not ignored by default, the test is expected to fail.
705 EXPECT_NONFATAL_FAILURE(
706 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem
, kError
),
710 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, FileIOTest
) {
711 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem
,
715 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, LoadLoadableSession
) {
716 TestPlaybackCase(kLoadableSession
, kEnded
);
719 IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest
, LoadUnknownSession
) {
720 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
721 TestPlaybackCase(kUnknownSession
, kEmeKeyError
);
723 #endif // defined(ENABLE_PEPPER_CDMS)