blob: a70f889d82e630a6f2ea27815cb1901dd910ca70 [file] [log] [blame]
[email protected]63dc9072013-09-12 06:20:471// 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.
4
5#include "base/command_line.h"
[email protected]df06a3e2014-01-31 21:36:596#include "base/memory/scoped_ptr.h"
[email protected]63dc9072013-09-12 06:20:477#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"
[email protected]df06a3e2014-01-31 21:36:5911#include "chrome/browser/media/test_license_server.h"
12#include "chrome/browser/media/wv_test_license_server_config.h"
[email protected]63dc9072013-09-12 06:20:4713#include "chrome/browser/ui/browser.h"
14#include "chrome/browser/ui/tabs/tab_strip_model.h"
15#include "chrome/common/chrome_switches.h"
brettw90e92602015-10-10 00:12:4016#include "content/public/common/content_switches.h"
[email protected]63dc9072013-09-12 06:20:4717#include "content/public/test/browser_test_utils.h"
[email protected]1be9fa072014-03-21 22:50:2918#include "testing/gtest/include/gtest/gtest-spi.h"
[email protected]6479b192013-10-19 18:28:0419#if defined(OS_ANDROID)
20#include "base/android/build_info.h"
21#endif
[email protected]63dc9072013-09-12 06:20:4722
[email protected]df06a3e2014-01-31 21:36:5923#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
[email protected]63dc9072013-09-12 06:20:4724
[email protected]63dc9072013-09-12 06:20:4725#if defined(ENABLE_PEPPER_CDMS)
26// Platform-specific filename relative to the chrome executable.
[email protected]1825e772013-10-08 06:39:1127const char kClearKeyCdmAdapterFileName[] =
[email protected]63dc9072013-09-12 06:20:4728#if defined(OS_MACOSX)
29 "clearkeycdmadapter.plugin";
30#elif defined(OS_WIN)
31 "clearkeycdmadapter.dll";
32#elif defined(OS_POSIX)
33 "libclearkeycdmadapter.so";
34#endif
[email protected]1825e772013-10-08 06:39:1135
36const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm";
[email protected]63dc9072013-09-12 06:20:4737#endif // defined(ENABLE_PEPPER_CDMS)
38
39// Available key systems.
[email protected]a32ef592014-03-07 19:11:1540const char kClearKeyKeySystem[] = "org.w3.clearkey";
41const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey";
[email protected]ab998e82013-11-22 20:31:3542const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
[email protected]34afd582013-12-20 07:26:1843const char kExternalClearKeyFileIOTestKeySystem[] =
44 "org.chromium.externalclearkey.fileiotest";
[email protected]ab998e82013-11-22 20:31:3545const char kExternalClearKeyInitializeFailKeySystem[] =
46 "org.chromium.externalclearkey.initializefail";
[email protected]a27d34ab2014-01-09 04:23:2947const char kExternalClearKeyCrashKeySystem[] =
48 "org.chromium.externalclearkey.crash";
[email protected]63dc9072013-09-12 06:20:4749
50// Supported media types.
[email protected]095ccbe42013-09-26 00:06:4251const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
52const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
53const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
jamescook6107ed82014-11-06 06:59:2154const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\"";
[email protected]095ccbe42013-09-26 00:06:4255#if defined(USE_PROPRIETARY_CODECS)
56const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\"";
57const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\"";
58#endif // defined(USE_PROPRIETARY_CODECS)
[email protected]63dc9072013-09-12 06:20:4759
[email protected]0af5dfa2014-02-07 22:33:4460// Sessions to load.
61const char kNoSessionToLoad[] = "";
62const char kLoadableSession[] = "LoadableSession";
63const char kUnknownSession[] = "UnknownSession";
64
[email protected]2e850f12013-09-18 01:27:2965// EME-specific test results and errors.
[email protected]e11d89d2014-06-19 11:36:3166const char kFileIOTestSuccess[] = "FILE_IO_TEST_SUCCESS";
jrummell0c6ba542015-07-08 18:04:4467const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
68const char kEmeGenerateRequestFailed[] = "EME_GENERATEREQUEST_FAILED";
jrummell14fae6f2015-07-10 20:40:1569const char kEmeSessionNotFound[] = "EME_SESSION_NOT_FOUND";
jrummell0c6ba542015-07-08 18:04:4470const char kEmeLoadFailed[] = "EME_LOAD_FAILED";
71const char kEmeUpdateFailed[] = "EME_UPDATE_FAILED";
72const char kEmeErrorEvent[] = "EME_ERROR_EVENT";
73const char kEmeMessageUnexpectedType[] = "EME_MESSAGE_UNEXPECTED_TYPE";
74const char kPrefixedEmeRenewalMissingHeader[] =
75 "PREFIXED_EME_RENEWAL_MISSING_HEADER";
76const char kPrefixedEmeErrorEvent[] = "PREFIXED_EME_ERROR_EVENT";
[email protected]e11d89d2014-06-19 11:36:3177
78const char kDefaultEmePlayer[] = "eme_player.html";
[email protected]63dc9072013-09-12 06:20:4779
80// The type of video src used to load media.
81enum SrcType {
82 SRC,
83 MSE
84};
85
[email protected]a32ef592014-03-07 19:11:1586// Whether to use prefixed or unprefixed EME.
87enum EmeVersion {
88 PREFIXED,
89 UNPREFIXED
90};
91
jrummellb3944632015-03-14 00:19:4292// Whether the video should be played once or twice.
93enum class PlayTwice { NO, YES };
94
jrummellc015cb962015-07-17 00:41:3095// Format of a container when testing different streams.
96enum class EncryptedContainer {
97 CLEAR_WEBM,
98 CLEAR_MP4,
99 ENCRYPTED_WEBM,
100 ENCRYPTED_MP4
101};
102
[email protected]6479b192013-10-19 18:28:04103// MSE is available on all desktop platforms and on Android 4.1 and later.
104static bool IsMSESupported() {
105#if defined(OS_ANDROID)
106 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
anujk.sharma9da298e12014-11-07 04:48:43107 DVLOG(0) << "MSE is only supported in Android 4.1 and later.";
[email protected]6479b192013-10-19 18:28:04108 return false;
109 }
110#endif // defined(OS_ANDROID)
111 return true;
112}
113
[email protected]ab998e82013-11-22 20:31:35114static bool IsParentKeySystemOf(const std::string& parent_key_system,
115 const std::string& key_system) {
116 std::string prefix = parent_key_system + '.';
117 return key_system.substr(0, prefix.size()) == prefix;
118}
119
[email protected]e6bf64142013-10-18 23:07:54120// Base class for encrypted media tests.
121class EncryptedMediaTestBase : public MediaBrowserTest {
[email protected]63dc9072013-09-12 06:20:47122 public:
[email protected]e6bf64142013-10-18 23:07:54123 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {}
[email protected]63dc9072013-09-12 06:20:47124
[email protected]ab998e82013-11-22 20:31:35125 bool IsExternalClearKey(const std::string& key_system) {
126 return key_system == kExternalClearKeyKeySystem ||
127 IsParentKeySystemOf(kExternalClearKeyKeySystem, key_system);
[email protected]63dc9072013-09-12 06:20:47128 }
129
[email protected]1825e772013-10-08 06:39:11130#if defined(WIDEVINE_CDM_AVAILABLE)
[email protected]ab998e82013-11-22 20:31:35131 bool IsWidevine(const std::string& key_system) {
132 return key_system == kWidevineKeySystem;
[email protected]1825e772013-10-08 06:39:11133 }
134#endif // defined(WIDEVINE_CDM_AVAILABLE)
135
[email protected]8a229322014-07-22 23:33:07136 void RunEncryptedMediaTestPage(
137 const std::string& html_page,
138 const std::string& key_system,
anand.ratn2636d972014-09-30 04:06:58139 base::StringPairs& query_params,
[email protected]8a229322014-07-22 23:33:07140 const std::string& expected_title) {
anand.ratn2636d972014-09-30 04:06:58141 base::StringPairs new_query_params = query_params;
[email protected]8a229322014-07-22 23:33:07142 StartLicenseServerIfNeeded(key_system, &new_query_params);
143 RunMediaTestPage(html_page, new_query_params, expected_title, true);
[email protected]df06a3e2014-01-31 21:36:59144 }
145
[email protected]0af5dfa2014-02-07 22:33:44146 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|.
147 // When |session_to_load| is not empty, the test will try to load
148 // |session_to_load| with stored keys, instead of creating a new session
149 // and trying to update it with licenses.
150 // When |force_invalid_response| is true, the test will provide invalid
151 // responses, which should trigger errors.
152 // TODO(xhwang): Find an easier way to pass multiple configuration test
153 // options.
[email protected]df06a3e2014-01-31 21:36:59154 void RunEncryptedMediaTest(const std::string& html_page,
155 const std::string& media_file,
156 const std::string& media_type,
157 const std::string& key_system,
[email protected]1825e772013-10-08 06:39:11158 SrcType src_type,
[email protected]a32ef592014-03-07 19:11:15159 EmeVersion eme_version,
[email protected]0af5dfa2014-02-07 22:33:44160 const std::string& session_to_load,
[email protected]df06a3e2014-01-31 21:36:59161 bool force_invalid_response,
jrummellb3944632015-03-14 00:19:42162 PlayTwice play_twice,
[email protected]df06a3e2014-01-31 21:36:59163 const std::string& expected_title) {
[email protected]6479b192013-10-19 18:28:04164 if (src_type == MSE && !IsMSESupported()) {
anujk.sharma9da298e12014-11-07 04:48:43165 DVLOG(0) << "Skipping test - MSE not supported.";
[email protected]6479b192013-10-19 18:28:04166 return;
167 }
anand.ratn2636d972014-09-30 04:06:58168 base::StringPairs query_params;
[email protected]df06a3e2014-01-31 21:36:59169 query_params.push_back(std::make_pair("mediaFile", media_file));
170 query_params.push_back(std::make_pair("mediaType", media_type));
171 query_params.push_back(std::make_pair("keySystem", key_system));
[email protected]63dc9072013-09-12 06:20:47172 if (src_type == MSE)
[email protected]df06a3e2014-01-31 21:36:59173 query_params.push_back(std::make_pair("useMSE", "1"));
[email protected]a32ef592014-03-07 19:11:15174 if (eme_version == PREFIXED)
175 query_params.push_back(std::make_pair("usePrefixedEME", "1"));
[email protected]df06a3e2014-01-31 21:36:59176 if (force_invalid_response)
177 query_params.push_back(std::make_pair("forceInvalidResponse", "1"));
[email protected]0af5dfa2014-02-07 22:33:44178 if (!session_to_load.empty())
179 query_params.push_back(std::make_pair("sessionToLoad", session_to_load));
jrummellb3944632015-03-14 00:19:42180 if (play_twice == PlayTwice::YES)
181 query_params.push_back(std::make_pair("playTwice", "1"));
[email protected]8a229322014-07-22 23:33:07182 RunEncryptedMediaTestPage(html_page, key_system, query_params,
[email protected]df06a3e2014-01-31 21:36:59183 expected_title);
[email protected]63dc9072013-09-12 06:20:47184 }
185
[email protected]df06a3e2014-01-31 21:36:59186 void RunSimpleEncryptedMediaTest(const std::string& media_file,
187 const std::string& media_type,
188 const std::string& key_system,
[email protected]a32ef592014-03-07 19:11:15189 SrcType src_type,
190 EmeVersion eme_version) {
[email protected]df06a3e2014-01-31 21:36:59191 std::string expected_title = kEnded;
jrummell0c6ba542015-07-08 18:04:44192 if (!IsPlayBackPossible(key_system)) {
193 expected_title = (eme_version == EmeVersion::UNPREFIXED)
194 ? kEmeUpdateFailed
195 : kPrefixedEmeErrorEvent;
196 }
[email protected]1825e772013-10-08 06:39:11197
jrummellb3944632015-03-14 00:19:42198 RunEncryptedMediaTest(kDefaultEmePlayer, media_file, media_type, key_system,
199 src_type, eme_version, kNoSessionToLoad, false,
200 PlayTwice::NO, expected_title);
[email protected]df06a3e2014-01-31 21:36:59201 // Check KeyMessage received for all key systems.
202 bool receivedKeyMessage = false;
203 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
204 browser()->tab_strip_model()->GetActiveWebContents(),
[email protected]e11d89d2014-06-19 11:36:31205 "window.domAutomationController.send("
206 "document.querySelector('video').receivedKeyMessage);",
[email protected]df06a3e2014-01-31 21:36:59207 &receivedKeyMessage));
208 EXPECT_TRUE(receivedKeyMessage);
209 }
210
[email protected]8a229322014-07-22 23:33:07211 // Starts a license server if available for the |key_system| and adds a
212 // 'licenseServerURL' query parameter to |query_params|.
[email protected]df06a3e2014-01-31 21:36:59213 void StartLicenseServerIfNeeded(const std::string& key_system,
anand.ratn2636d972014-09-30 04:06:58214 base::StringPairs* query_params) {
[email protected]df06a3e2014-01-31 21:36:59215 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system);
216 if (!config)
217 return;
218 license_server_.reset(new TestLicenseServer(config.Pass()));
219 EXPECT_TRUE(license_server_->Start());
[email protected]8a229322014-07-22 23:33:07220 query_params->push_back(
221 std::make_pair("licenseServerURL", license_server_->GetServerURL()));
[email protected]df06a3e2014-01-31 21:36:59222 }
223
224 bool IsPlayBackPossible(const std::string& key_system) {
225#if defined(WIDEVINE_CDM_AVAILABLE)
226 if (IsWidevine(key_system) && !GetServerConfig(key_system))
227 return false;
228#endif // defined(WIDEVINE_CDM_AVAILABLE)
229 return true;
230 }
231
232 scoped_ptr<TestLicenseServerConfig> GetServerConfig(
233 const std::string& key_system) {
234#if defined(WIDEVINE_CDM_AVAILABLE)
235 if (IsWidevine(key_system)) {
236 scoped_ptr<TestLicenseServerConfig> config =
237 scoped_ptr<TestLicenseServerConfig>(new WVTestLicenseServerConfig());
238 if (config->IsPlatformSupported())
239 return config.Pass();
240 }
241#endif // defined(WIDEVINE_CDM_AVAILABLE)
242 return scoped_ptr<TestLicenseServerConfig>();
[email protected]1825e772013-10-08 06:39:11243 }
244
[email protected]63dc9072013-09-12 06:20:47245 protected:
[email protected]df06a3e2014-01-31 21:36:59246 scoped_ptr<TestLicenseServer> license_server_;
247
[email protected]2e850f12013-09-18 01:27:29248 // We want to fail quickly when a test fails because an error is encountered.
dchengd7e84a052014-10-22 00:18:51249 void AddWaitForTitles(content::TitleWatcher* title_watcher) override {
[email protected]2e850f12013-09-18 01:27:29250 MediaBrowserTest::AddWaitForTitles(title_watcher);
[email protected]6778fed2013-12-24 20:09:37251 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError));
jrummell0c6ba542015-07-08 18:04:44252 title_watcher->AlsoWaitForTitle(
253 base::ASCIIToUTF16(kEmeGenerateRequestFailed));
jrummell14fae6f2015-07-10 20:40:15254 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeSessionNotFound));
jrummell0c6ba542015-07-08 18:04:44255 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeLoadFailed));
256 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeUpdateFailed));
257 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeErrorEvent));
258 title_watcher->AlsoWaitForTitle(
259 base::ASCIIToUTF16(kEmeMessageUnexpectedType));
260 title_watcher->AlsoWaitForTitle(
261 base::ASCIIToUTF16(kPrefixedEmeRenewalMissingHeader));
262 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kPrefixedEmeErrorEvent));
[email protected]2e850f12013-09-18 01:27:29263 }
264
avi556c05022014-12-22 23:31:43265 void SetUpCommandLine(base::CommandLine* command_line) override {
[email protected]2289b432014-08-08 17:52:11266#if defined(OS_ANDROID)
267 command_line->AppendSwitch(
268 switches::kDisableGestureRequirementForMediaPlayback);
269#endif // defined(OS_ANDROID)
ddorwine12c5ce02015-09-10 18:38:39270 // For simplicity with respect to parameterized tests, enable for all tests.
271 command_line->AppendSwitch(switches::kEnablePrefixedEncryptedMedia);
[email protected]2289b432014-08-08 17:52:11272 }
273
[email protected]df06a3e2014-01-31 21:36:59274 void SetUpCommandLineForKeySystem(const std::string& key_system,
avi556c05022014-12-22 23:31:43275 base::CommandLine* command_line) {
[email protected]df06a3e2014-01-31 21:36:59276 if (GetServerConfig(key_system))
277 // Since the web and license servers listen on different ports, we need to
278 // disable web-security to send license requests to the license server.
279 // TODO(shadi): Add port forwarding to the test web server configuration.
280 command_line->AppendSwitch(switches::kDisableWebSecurity);
281
[email protected]e6bf64142013-10-18 23:07:54282#if defined(ENABLE_PEPPER_CDMS)
283 if (IsExternalClearKey(key_system)) {
[email protected]ab998e82013-11-22 20:31:35284 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system);
[email protected]e6bf64142013-10-18 23:07:54285 }
286#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
thestig11bf74d2014-11-24 20:14:42287 else if (IsWidevine(key_system)) { // NOLINT
[email protected]ab998e82013-11-22 20:31:35288 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system);
[email protected]e6bf64142013-10-18 23:07:54289 }
290#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
291#endif // defined(ENABLE_PEPPER_CDMS)
292 }
293
294 private:
[email protected]1825e772013-10-08 06:39:11295#if defined(ENABLE_PEPPER_CDMS)
avi556c05022014-12-22 23:31:43296 void RegisterPepperCdm(base::CommandLine* command_line,
[email protected]63dc9072013-09-12 06:20:47297 const std::string& adapter_name,
298 const std::string& key_system) {
[email protected]e6bf64142013-10-18 23:07:54299 DCHECK(!is_pepper_cdm_registered_)
300 << "RegisterPepperCdm() can only be called once.";
301 is_pepper_cdm_registered_ = true;
302
[email protected]63dc9072013-09-12 06:20:47303 // Append the switch to register the Clear Key CDM Adapter.
304 base::FilePath plugin_dir;
305 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
306 base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name);
[email protected]1825e772013-10-08 06:39:11307 EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value();
[email protected]63dc9072013-09-12 06:20:47308 base::FilePath::StringType pepper_plugin = plugin_lib.value();
309 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;"));
310#if defined(OS_WIN)
thestig11bf74d2014-11-24 20:14:42311 pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system)));
[email protected]63dc9072013-09-12 06:20:47312#else
313 pepper_plugin.append(GetPepperType(key_system));
314#endif
315 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
316 pepper_plugin);
317 }
318
319 // Adapted from key_systems.cc.
320 std::string GetPepperType(const std::string& key_system) {
[email protected]ab998e82013-11-22 20:31:35321 if (IsExternalClearKey(key_system))
[email protected]1825e772013-10-08 06:39:11322 return kClearKeyCdmPluginMimeType;
[email protected]63dc9072013-09-12 06:20:47323#if defined(WIDEVINE_CDM_AVAILABLE)
[email protected]ab998e82013-11-22 20:31:35324 if (IsWidevine(key_system))
[email protected]1825e772013-10-08 06:39:11325 return kWidevineCdmPluginMimeType;
[email protected]63dc9072013-09-12 06:20:47326#endif // WIDEVINE_CDM_AVAILABLE
327
328 NOTREACHED();
329 return "";
330 }
331#endif // defined(ENABLE_PEPPER_CDMS)
[email protected]e6bf64142013-10-18 23:07:54332
333 bool is_pepper_cdm_registered_;
334};
335
336#if defined(ENABLE_PEPPER_CDMS)
[email protected]ab998e82013-11-22 20:31:35337// Tests encrypted media playback using ExternalClearKey key system in
338// decrypt-and-decode mode.
[email protected]e6bf64142013-10-18 23:07:54339class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
[email protected]0af5dfa2014-02-07 22:33:44340 public:
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
346 // type.
jrummellb3944632015-03-14 00:19:42347 RunEncryptedMediaTest(
348 kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly, key_system, SRC,
349 UNPREFIXED, kNoSessionToLoad, false, PlayTwice::NO, expected_title);
jrummell19f2c902015-02-11 01:17:50350 }
351
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,
jrummellb3944632015-03-14 00:19:42356 UNPREFIXED, session_to_load, false, PlayTwice::NO,
357 expected_title);
[email protected]0af5dfa2014-02-07 22:33:44358 }
359
[email protected]e6bf64142013-10-18 23:07:54360 protected:
avi556c05022014-12-22 23:31:43361 void SetUpCommandLine(base::CommandLine* command_line) override {
[email protected]e6bf64142013-10-18 23:07:54362 EncryptedMediaTestBase::SetUpCommandLine(command_line);
363 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
364 }
365};
366
jrummellc467d232014-10-21 17:55:22367// Tests encrypted media playback using ExternalClearKey key system in
ddorwine12c5ce02015-09-10 18:38:39368// decrypt-and-decode mode for prefixed EME.
jrummell19f2c902015-02-11 01:17:50369class ECKPrefixedEncryptedMediaTest : public EncryptedMediaTestBase {
370 public:
371 // We use special |key_system| names to do non-playback related tests, e.g.
372 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
373 void TestNonPlaybackCases(const std::string& key_system,
374 const std::string& expected_title) {
375 // Since we do not test playback, arbitrarily choose a test file and source
376 // type.
jrummellb3944632015-03-14 00:19:42377 RunEncryptedMediaTest(
378 kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly, key_system, SRC,
379 PREFIXED, kNoSessionToLoad, false, PlayTwice::NO, expected_title);
jrummell19f2c902015-02-11 01:17:50380 }
381
382 void TestPlaybackCase(const std::string& session_to_load,
383 const std::string& expected_title) {
384 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm",
385 kWebMVideoOnly, kExternalClearKeyKeySystem, SRC,
jrummellb3944632015-03-14 00:19:42386 PREFIXED, session_to_load, false, PlayTwice::NO,
387 expected_title);
jrummell19f2c902015-02-11 01:17:50388 }
389
jrummellc467d232014-10-21 17:55:22390 protected:
avi556c05022014-12-22 23:31:43391 void SetUpCommandLine(base::CommandLine* command_line) override {
jrummellc467d232014-10-21 17:55:22392 EncryptedMediaTestBase::SetUpCommandLine(command_line);
jrummellc467d232014-10-21 17:55:22393 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
394 }
395};
396
[email protected]e6bf64142013-10-18 23:07:54397#if defined(WIDEVINE_CDM_AVAILABLE)
398// Tests encrypted media playback using Widevine key system.
399class WVEncryptedMediaTest : public EncryptedMediaTestBase {
400 protected:
Daniel Cheng43ba4a0122014-12-31 06:30:35401 void SetUpCommandLine(base::CommandLine* command_line) override {
[email protected]e6bf64142013-10-18 23:07:54402 EncryptedMediaTestBase::SetUpCommandLine(command_line);
403 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line);
404 }
405};
[email protected]df06a3e2014-01-31 21:36:59406
[email protected]e6bf64142013-10-18 23:07:54407#endif // defined(WIDEVINE_CDM_AVAILABLE)
408#endif // defined(ENABLE_PEPPER_CDMS)
409
410// Tests encrypted media playback with a combination of parameters:
411// - char*: Key system name.
jrummell19f2c902015-02-11 01:17:50412// - SrcType: Use MSE or SRC.
413// - EmeVersion: Use PREFIXED or UNPREFIXED EME.
[email protected]e6bf64142013-10-18 23:07:54414//
415// Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
416// tests will crash at GetParam(). To add non-parameterized tests, use
417// EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
[email protected]a32ef592014-03-07 19:11:15418class EncryptedMediaTest
419 : public EncryptedMediaTestBase,
420 public testing::WithParamInterface<
421 std::tr1::tuple<const char*, SrcType, EmeVersion> > {
[email protected]e6bf64142013-10-18 23:07:54422 public:
[email protected]df06a3e2014-01-31 21:36:59423 std::string CurrentKeySystem() {
[email protected]e6bf64142013-10-18 23:07:54424 return std::tr1::get<0>(GetParam());
425 }
426
427 SrcType CurrentSourceType() {
428 return std::tr1::get<1>(GetParam());
429 }
430
[email protected]a32ef592014-03-07 19:11:15431 EmeVersion CurrentEmeVersion() {
432 return std::tr1::get<2>(GetParam());
433 }
434
[email protected]df06a3e2014-01-31 21:36:59435 void TestSimplePlayback(const std::string& encrypted_media,
436 const std::string& media_type) {
[email protected]a32ef592014-03-07 19:11:15437 RunSimpleEncryptedMediaTest(encrypted_media,
438 media_type,
439 CurrentKeySystem(),
440 CurrentSourceType(),
441 CurrentEmeVersion());
[email protected]e6bf64142013-10-18 23:07:54442 }
443
jrummellb3944632015-03-14 00:19:42444 void TestMultiplePlayback(const std::string& encrypted_media,
445 const std::string& media_type) {
jrummelld9dc7902015-03-16 20:59:28446 DCHECK(IsPlayBackPossible(CurrentKeySystem()));
jrummellb3944632015-03-14 00:19:42447 RunEncryptedMediaTest(kDefaultEmePlayer, encrypted_media, media_type,
448 CurrentKeySystem(), CurrentSourceType(),
449 CurrentEmeVersion(), kNoSessionToLoad, false,
450 PlayTwice::YES, kEnded);
451 }
452
[email protected]df06a3e2014-01-31 21:36:59453 void RunInvalidResponseTest() {
jrummell0c6ba542015-07-08 18:04:44454 std::string expected_response =
455 (CurrentEmeVersion() == EmeVersion::UNPREFIXED)
456 ? kEmeUpdateFailed
457 : kPrefixedEmeErrorEvent;
458 RunEncryptedMediaTest(
459 kDefaultEmePlayer, "bear-320x240-av_enc-av.webm", kWebMAudioVideo,
460 CurrentKeySystem(), CurrentSourceType(), CurrentEmeVersion(),
461 kNoSessionToLoad, true, PlayTwice::NO, expected_response);
[email protected]df06a3e2014-01-31 21:36:59462 }
463
[email protected]e6bf64142013-10-18 23:07:54464 void TestFrameSizeChange() {
jrummellb3944632015-03-14 00:19:42465 RunEncryptedMediaTest(
466 "encrypted_frame_size_change.html", "frame_size_change-av_enc-v.webm",
467 kWebMAudioVideo, CurrentKeySystem(), CurrentSourceType(),
468 CurrentEmeVersion(), kNoSessionToLoad, false, PlayTwice::NO, kEnded);
[email protected]e6bf64142013-10-18 23:07:54469 }
470
471 void TestConfigChange() {
[email protected]df06a3e2014-01-31 21:36:59472 DCHECK(IsMSESupported());
anand.ratn2636d972014-09-30 04:06:58473 base::StringPairs query_params;
[email protected]df06a3e2014-01-31 21:36:59474 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
475 query_params.push_back(std::make_pair("runEncrypted", "1"));
[email protected]a32ef592014-03-07 19:11:15476 if (CurrentEmeVersion() == PREFIXED)
477 query_params.push_back(std::make_pair("usePrefixedEME", "1"));
[email protected]df06a3e2014-01-31 21:36:59478 RunEncryptedMediaTestPage("mse_config_change.html",
479 CurrentKeySystem(),
[email protected]8a229322014-07-22 23:33:07480 query_params,
[email protected]df06a3e2014-01-31 21:36:59481 kEnded);
[email protected]e6bf64142013-10-18 23:07:54482 }
483
jrummellc015cb962015-07-17 00:41:30484 std::string ConvertContainerFormat(EncryptedContainer format) {
485 switch (format) {
486 case EncryptedContainer::CLEAR_MP4:
487 return "CLEAR_MP4";
488 case EncryptedContainer::CLEAR_WEBM:
489 return "CLEAR_WEBM";
490 case EncryptedContainer::ENCRYPTED_MP4:
491 return "ENCRYPTED_MP4";
492 case EncryptedContainer::ENCRYPTED_WEBM:
493 return "ENCRYPTED_WEBM";
494 }
495 NOTREACHED();
496 return "UNKNOWN";
497 }
498
499 void TestDifferentContainers(EncryptedContainer video_format,
500 EncryptedContainer audio_format) {
501 DCHECK(IsMSESupported());
502 DCHECK_NE(CurrentEmeVersion(), PREFIXED);
503 base::StringPairs query_params;
504 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
505 query_params.push_back(std::make_pair("runEncrypted", "1"));
506 query_params.push_back(
507 std::make_pair("videoFormat", ConvertContainerFormat(video_format)));
508 query_params.push_back(
509 std::make_pair("audioFormat", ConvertContainerFormat(audio_format)));
510 RunEncryptedMediaTestPage("mse_different_containers.html",
511 CurrentKeySystem(), query_params, kEnded);
512 }
513
[email protected]e6bf64142013-10-18 23:07:54514 protected:
avi556c05022014-12-22 23:31:43515 void SetUpCommandLine(base::CommandLine* command_line) override {
[email protected]e6bf64142013-10-18 23:07:54516 EncryptedMediaTestBase::SetUpCommandLine(command_line);
517 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line);
518 }
[email protected]63dc9072013-09-12 06:20:47519};
520
[email protected]6479b192013-10-19 18:28:04521using ::testing::Combine;
522using ::testing::Values;
523
524#if !defined(OS_ANDROID)
[email protected]a32ef592014-03-07 19:11:15525INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed,
526 EncryptedMediaTest,
527 Combine(Values(kPrefixedClearKeyKeySystem),
528 Values(SRC),
529 Values(PREFIXED)));
530
jrummell19f2c902015-02-11 01:17:50531INSTANTIATE_TEST_CASE_P(SRC_ClearKey,
[email protected]a32ef592014-03-07 19:11:15532 EncryptedMediaTest,
533 Combine(Values(kClearKeyKeySystem),
534 Values(SRC),
535 Values(UNPREFIXED)));
[email protected]6479b192013-10-19 18:28:04536#endif // !defined(OS_ANDROID)
537
[email protected]a32ef592014-03-07 19:11:15538INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed,
539 EncryptedMediaTest,
540 Combine(Values(kPrefixedClearKeyKeySystem),
541 Values(MSE),
542 Values(PREFIXED)));
jrummell77419192014-10-31 21:40:44543INSTANTIATE_TEST_CASE_P(MSE_ClearKey,
[email protected]a32ef592014-03-07 19:11:15544 EncryptedMediaTest,
545 Combine(Values(kClearKeyKeySystem),
546 Values(MSE),
547 Values(UNPREFIXED)));
[email protected]63dc9072013-09-12 06:20:47548
549// External Clear Key is currently only used on platforms that use Pepper CDMs.
550#if defined(ENABLE_PEPPER_CDMS)
[email protected]a32ef592014-03-07 19:11:15551INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed,
552 EncryptedMediaTest,
553 Combine(Values(kExternalClearKeyKeySystem),
554 Values(SRC),
555 Values(PREFIXED)));
[email protected]1ab297a2014-03-26 04:52:12556INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey,
[email protected]a32ef592014-03-07 19:11:15557 EncryptedMediaTest,
558 Combine(Values(kExternalClearKeyKeySystem),
559 Values(SRC),
560 Values(UNPREFIXED)));
jam79bf1f6c2015-08-13 20:46:04561
[email protected]a32ef592014-03-07 19:11:15562INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed,
563 EncryptedMediaTest,
564 Combine(Values(kExternalClearKeyKeySystem),
565 Values(MSE),
566 Values(PREFIXED)));
[email protected]1ab297a2014-03-26 04:52:12567INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey,
[email protected]a32ef592014-03-07 19:11:15568 EncryptedMediaTest,
569 Combine(Values(kExternalClearKeyKeySystem),
570 Values(MSE),
571 Values(UNPREFIXED)));
mnissler27025372015-10-19 14:26:23572
573// Flaky on Mac 10.9, see http://crbug.com/544891.
574#if !defined(OS_MACOSX)
575
576const char kExternalClearKeyDecryptOnlyKeySystem[] =
577 "org.chromium.externalclearkey.decryptonly";
578
[email protected]ab998e82013-11-22 20:31:35579// To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
[email protected]a32ef592014-03-07 19:11:15580INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed,
581 EncryptedMediaTest,
582 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
583 Values(MSE),
584 Values(PREFIXED)));
[email protected]1ab297a2014-03-26 04:52:12585INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly,
[email protected]a32ef592014-03-07 19:11:15586 EncryptedMediaTest,
587 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
588 Values(MSE),
589 Values(UNPREFIXED)));
mnissler27025372015-10-19 14:26:23590#endif // !defined(OS_MACOSX)
591
[email protected]8a229322014-07-22 23:33:07592#endif // defined(ENABLE_PEPPER_CDMS)
[email protected]63dc9072013-09-12 06:20:47593
[email protected]1825e772013-10-08 06:39:11594#if defined(WIDEVINE_CDM_AVAILABLE)
jrummell56fb7972015-04-11 00:01:32595
596// Prefixed Widevine tests fail in Chrome OS official builds due to the request
597// for permissions. Since prefixed EME is deprecated and will be removed soon,
598// don't run these tests. http://crbug.com/430711
599#if !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
600
[email protected]1825e772013-10-08 06:39:11601// This test doesn't fully test playback with Widevine. So we only run Widevine
[email protected]6479b192013-10-19 18:28:04602// test with MSE (no SRC) to reduce test time. Also, on Android EME only works
603// with MSE and we cannot run this test with SRC.
[email protected]a32ef592014-03-07 19:11:15604INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed,
605 EncryptedMediaTest,
606 Combine(Values(kWidevineKeySystem),
607 Values(MSE),
608 Values(PREFIXED)));
jrummell56fb7972015-04-11 00:01:32609#endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
[email protected]78d96542014-03-27 11:45:47610
jonross5785b8662015-10-22 21:12:53611#if !defined(OS_CHROMEOS)
[email protected]1ab297a2014-03-26 04:52:12612INSTANTIATE_TEST_CASE_P(MSE_Widevine,
[email protected]a32ef592014-03-07 19:11:15613 EncryptedMediaTest,
614 Combine(Values(kWidevineKeySystem),
615 Values(MSE),
616 Values(UNPREFIXED)));
jonross5785b8662015-10-22 21:12:53617#endif // !defined(OS_CHROMEOS)
[email protected]1825e772013-10-08 06:39:11618#endif // defined(WIDEVINE_CDM_AVAILABLE)
[email protected]63dc9072013-09-12 06:20:47619
[email protected]626e517c2014-08-19 00:49:46620IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
[email protected]8a229322014-07-22 23:33:07621 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly);
[email protected]63dc9072013-09-12 06:20:47622}
623
[email protected]626e517c2014-08-19 00:49:46624IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
[email protected]8a229322014-07-22 23:33:07625 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo);
[email protected]63dc9072013-09-12 06:20:47626}
627
[email protected]626e517c2014-08-19 00:49:46628IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
[email protected]8a229322014-07-22 23:33:07629 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo);
[email protected]63dc9072013-09-12 06:20:47630}
631
[email protected]626e517c2014-08-19 00:49:46632IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) {
[email protected]8a229322014-07-22 23:33:07633 TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly);
[email protected]63dc9072013-09-12 06:20:47634}
635
[email protected]626e517c2014-08-19 00:49:46636IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) {
[email protected]8a229322014-07-22 23:33:07637 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo);
[email protected]63dc9072013-09-12 06:20:47638}
639
jrummell2fe87672015-01-02 19:13:51640IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) {
[email protected]8a229322014-07-22 23:33:07641 TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly);
[email protected]2b197ac72014-04-11 23:33:52642}
643
jrummell2fe87672015-01-02 19:13:51644IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM_Opus) {
sandersd5ec6dcf2014-11-26 20:39:38645 TestSimplePlayback("bear-320x240-opus-a_enc-a.webm", kWebMAudioOnly);
646}
647
648IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM_Opus) {
649 TestSimplePlayback("bear-320x240-opus-av_enc-av.webm", kWebMAudioVideo);
650}
651
652IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) {
653 TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMAudioVideo);
654}
655
jrummellb3944632015-03-14 00:19:42656IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Multiple_VideoAudio_WebM) {
jrummelld9dc7902015-03-16 20:59:28657 if (!IsPlayBackPossible(CurrentKeySystem())) {
658 DVLOG(0) << "Skipping test - Playback_Multiple test requires playback.";
659 return;
660 }
jrummellb3944632015-03-14 00:19:42661 TestMultiplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo);
662}
663
[email protected]626e517c2014-08-19 00:49:46664IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) {
[email protected]df06a3e2014-01-31 21:36:59665 RunInvalidResponseTest();
666}
667
[email protected]1825e772013-10-08 06:39:11668IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) {
[email protected]df06a3e2014-01-31 21:36:59669 if (CurrentSourceType() != MSE || !IsMSESupported()) {
anujk.sharma9da298e12014-11-07 04:48:43670 DVLOG(0) << "Skipping test - ConfigChange test requires MSE.";
[email protected]df06a3e2014-01-31 21:36:59671 return;
672 }
673 if (!IsPlayBackPossible(CurrentKeySystem())) {
anujk.sharma9da298e12014-11-07 04:48:43674 DVLOG(0) << "Skipping test - ConfigChange test requires video playback.";
[email protected]df06a3e2014-01-31 21:36:59675 return;
676 }
[email protected]1825e772013-10-08 06:39:11677 TestConfigChange();
678}
679
jrummell2fe87672015-01-02 19:13:51680IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) {
[email protected]63dc9072013-09-12 06:20:47681 // Times out on Windows XP. http://crbug.com/171937
682#if defined(OS_WIN)
683 if (base::win::GetVersion() < base::win::VERSION_VISTA)
684 return;
685#endif
[email protected]df06a3e2014-01-31 21:36:59686 if (!IsPlayBackPossible(CurrentKeySystem())) {
anujk.sharma9da298e12014-11-07 04:48:43687 DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback.";
[email protected]df06a3e2014-01-31 21:36:59688 return;
689 }
[email protected]1825e772013-10-08 06:39:11690 TestFrameSizeChange();
[email protected]63dc9072013-09-12 06:20:47691}
692
693#if defined(USE_PROPRIETARY_CODECS)
694IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4) {
[email protected]63dc9072013-09-12 06:20:47695 // MP4 without MSE is not support yet, http://crbug.com/170793.
[email protected]1825e772013-10-08 06:39:11696 if (CurrentSourceType() != MSE) {
anujk.sharma9da298e12014-11-07 04:48:43697 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
[email protected]63dc9072013-09-12 06:20:47698 return;
699 }
[email protected]1825e772013-10-08 06:39:11700 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly);
[email protected]63dc9072013-09-12 06:20:47701}
702
703IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) {
[email protected]63dc9072013-09-12 06:20:47704 // MP4 without MSE is not support yet, http://crbug.com/170793.
[email protected]1825e772013-10-08 06:39:11705 if (CurrentSourceType() != MSE) {
anujk.sharma9da298e12014-11-07 04:48:43706 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
[email protected]63dc9072013-09-12 06:20:47707 return;
708 }
[email protected]1825e772013-10-08 06:39:11709 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly);
[email protected]63dc9072013-09-12 06:20:47710}
jrummellc015cb962015-07-17 00:41:30711
712IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
713 Playback_EncryptedVideo_MP4_ClearAudio_WEBM) {
714 // MP4 without MSE is not support yet, http://crbug.com/170793.
715 if (CurrentSourceType() != MSE) {
716 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
717 return;
718 }
719 if (CurrentEmeVersion() != UNPREFIXED) {
720 DVLOG(0) << "Skipping test; Only supported by unprefixed EME";
721 return;
722 }
723 if (!IsPlayBackPossible(CurrentKeySystem())) {
724 DVLOG(0) << "Skipping test - Test requires video playback.";
725 return;
726 }
727 TestDifferentContainers(EncryptedContainer::ENCRYPTED_MP4,
728 EncryptedContainer::CLEAR_WEBM);
729}
730
731IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
732 Playback_ClearVideo_WEBM_EncryptedAudio_MP4) {
733 // MP4 without MSE is not support yet, http://crbug.com/170793.
734 if (CurrentSourceType() != MSE) {
735 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
736 return;
737 }
738 if (CurrentEmeVersion() != UNPREFIXED) {
739 DVLOG(0) << "Skipping test; Only supported by unprefixed EME";
740 return;
741 }
742 if (!IsPlayBackPossible(CurrentKeySystem())) {
743 DVLOG(0) << "Skipping test - Test requires video playback.";
744 return;
745 }
746 TestDifferentContainers(EncryptedContainer::CLEAR_WEBM,
747 EncryptedContainer::ENCRYPTED_MP4);
748}
749
750IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
751 Playback_EncryptedVideo_WEBM_EncryptedAudio_MP4) {
752 // MP4 without MSE is not support yet, http://crbug.com/170793.
753 if (CurrentSourceType() != MSE) {
754 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
755 return;
756 }
757 if (CurrentEmeVersion() != UNPREFIXED) {
758 DVLOG(0) << "Skipping test; Only supported by unprefixed EME";
759 return;
760 }
761 if (!IsPlayBackPossible(CurrentKeySystem())) {
762 DVLOG(0) << "Skipping test - Test requires video playback.";
763 return;
764 }
765 TestDifferentContainers(EncryptedContainer::ENCRYPTED_WEBM,
766 EncryptedContainer::ENCRYPTED_MP4);
767}
[email protected]63dc9072013-09-12 06:20:47768#endif // defined(USE_PROPRIETARY_CODECS)
769
[email protected]63dc9072013-09-12 06:20:47770#if defined(WIDEVINE_CDM_AVAILABLE)
771// The parent key system cannot be used in generateKeyRequest.
[email protected]a32ef592014-03-07 19:11:15772IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) {
jrummellb3944632015-03-14 00:19:42773 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly,
774 "com.widevine", MSE, PREFIXED, kNoSessionToLoad, false,
775 PlayTwice::NO, kEmeNotSupportedError);
[email protected]a32ef592014-03-07 19:11:15776}
777
[email protected]a32ef592014-03-07 19:11:15778// The parent key system cannot be used when creating MediaKeys.
[email protected]b1620732014-04-01 23:17:18779IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
jrummellb3944632015-03-14 00:19:42780 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly,
781 "com.widevine", MSE, UNPREFIXED, kNoSessionToLoad,
782 false, PlayTwice::NO, kEmeNotSupportedError);
[email protected]63dc9072013-09-12 06:20:47783}
[email protected]63dc9072013-09-12 06:20:47784#endif // defined(WIDEVINE_CDM_AVAILABLE)
[email protected]a941d4e572013-10-14 21:22:05785
786#if defined(ENABLE_PEPPER_CDMS)
[email protected]34afd582013-12-20 07:26:18787IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) {
jrummell87a2db52015-05-05 22:27:18788 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem,
789 kEmeNotSupportedError);
[email protected]a941d4e572013-10-14 21:22:05790}
[email protected]34afd582013-12-20 07:26:18791
jrummellfed298d22015-07-01 00:26:51792// When CDM crashes, we should still get a decode error. |kError| is reported
793// when the HTMLVideoElement error event fires, indicating an error happened
794// during playback.
795IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) {
[email protected]1be9fa072014-03-21 22:50:29796 IgnorePluginCrash();
[email protected]0af5dfa2014-02-07 22:33:44797 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError);
[email protected]a27d34ab2014-01-09 04:23:29798}
799
[email protected]1be9fa072014-03-21 22:50:29800// Testing that the media browser test does fail on plugin crash.
jrummellfed298d22015-07-01 00:26:51801IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMExpectedCrash) {
[email protected]1be9fa072014-03-21 22:50:29802 // Plugin crash is not ignored by default, the test is expected to fail.
803 EXPECT_NONFATAL_FAILURE(
804 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError),
jrummellfed298d22015-07-01 00:26:51805 "Failing test due to plugin crash.");
[email protected]1be9fa072014-03-21 22:50:29806}
807
xhwang0c617e112014-09-19 17:33:24808IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) {
[email protected]0af5dfa2014-02-07 22:33:44809 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem,
810 kFileIOTestSuccess);
811}
812
813IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
jrummell19f2c902015-02-11 01:17:50814 TestPlaybackCase(kLoadableSession, kEnded);
[email protected]0af5dfa2014-02-07 22:33:44815}
816
817IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
jrummell14fae6f2015-07-10 20:40:15818 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound);
[email protected]34afd582013-12-20 07:26:18819}
jrummellc467d232014-10-21 17:55:22820
jrummell19f2c902015-02-11 01:17:50821IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, InitializeCDMFail) {
jrummell0c6ba542015-07-08 18:04:44822 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem,
823 kPrefixedEmeErrorEvent);
jrummellc467d232014-10-21 17:55:22824}
825
jrummell19f2c902015-02-11 01:17:50826// When CDM crashes, we should still get a decode error.
827// crbug.com/386657
828IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest,
829 DISABLED_CDMCrashDuringDecode) {
830 IgnorePluginCrash();
831 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError);
832}
833
834// Testing that the media browser test does fail on plugin crash.
835// crbug.com/386657
836IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest,
837 DISABLED_CDMExpectedCrash) {
838 // Plugin crash is not ignored by default, the test is expected to fail.
839 EXPECT_NONFATAL_FAILURE(
840 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError),
841 "plugin crash");
842}
843
844IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, FileIOTest) {
845 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem,
846 kFileIOTestSuccess);
847}
848
849IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, LoadLoadableSession) {
850 TestPlaybackCase(kLoadableSession, kEnded);
851}
852
853IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, LoadUnknownSession) {
jrummell0c6ba542015-07-08 18:04:44854 TestPlaybackCase(kUnknownSession, kPrefixedEmeErrorEvent);
jrummellc467d232014-10-21 17:55:22855}
[email protected]a941d4e572013-10-14 21:22:05856#endif // defined(ENABLE_PEPPER_CDMS)