blob: 3938185059a13c54ec7b2d9b9e54fbce8c7ad28e [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
dchengc16dc8092016-04-08 23:12:565#include <memory>
dchenge73d8520c2015-12-27 01:19:096#include <utility>
7
[email protected]63dc9072013-09-12 06:20:478#include "base/command_line.h"
9#include "base/path_service.h"
xhwang65c23032017-02-17 04:37:4210#include "base/strings/string_number_conversions.h"
[email protected]63dc9072013-09-12 06:20:4711#include "base/strings/utf_string_conversions.h"
jrummell90f8b202017-05-05 17:21:3912#include "base/threading/thread_restrictions.h"
avi6846aef2015-12-26 01:09:3813#include "build/build_config.h"
[email protected]63dc9072013-09-12 06:20:4714#include "chrome/browser/media/media_browsertest.h"
[email protected]df06a3e2014-01-31 21:36:5915#include "chrome/browser/media/test_license_server.h"
16#include "chrome/browser/media/wv_test_license_server_config.h"
xhwangd252d7b52017-02-08 18:52:3617#include "chrome/browser/profiles/profile.h"
[email protected]63dc9072013-09-12 06:20:4718#include "chrome/browser/ui/browser.h"
19#include "chrome/browser/ui/tabs/tab_strip_model.h"
20#include "chrome/common/chrome_switches.h"
xhwangd252d7b52017-02-08 18:52:3621#include "chrome/common/pref_names.h"
xhwang3be44be2016-05-25 17:24:4922#include "chrome/test/base/test_launcher_utils.h"
xhwangd252d7b52017-02-08 18:52:3623#include "components/prefs/pref_service.h"
brettw90e92602015-10-10 00:12:4024#include "content/public/common/content_switches.h"
[email protected]63dc9072013-09-12 06:20:4725#include "content/public/test/browser_test_utils.h"
xhwang34879342017-02-11 23:22:3326#include "media/base/key_system_names.h"
kqyangf93bb7b2016-12-03 02:28:1927#include "media/base/media_switches.h"
brettw68c77532017-01-21 00:28:0628#include "media/media_features.h"
brettwc5fcdd02016-10-12 07:25:1229#include "ppapi/features/features.h"
[email protected]1be9fa072014-03-21 22:50:2930#include "testing/gtest/include/gtest/gtest-spi.h"
brettwc5fcdd02016-10-12 07:25:1231
[email protected]6479b192013-10-19 18:28:0432#if defined(OS_ANDROID)
33#include "base/android/build_info.h"
34#endif
[email protected]63dc9072013-09-12 06:20:4735
wychen7b07e7b2017-01-10 17:48:2936#if defined(OS_WIN)
37#include "base/win/windows_version.h"
38#endif
39
brettwc5fcdd02016-10-12 07:25:1240#if BUILDFLAG(ENABLE_PEPPER_CDMS)
xhwangb9417142016-05-18 22:23:3641#include "chrome/browser/media/pepper_cdm_test_helper.h"
xhwang6bca3b792016-09-15 18:45:1742#include "media/base/media_switches.h"
Xiaohan Wang17d4ffa2017-06-06 19:10:1143#include "media/cdm/cdm_paths.h"
[email protected]63dc9072013-09-12 06:20:4744#endif
[email protected]1825e772013-10-08 06:39:1145
xhwangb9417142016-05-18 22:23:3646#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
[email protected]63dc9072013-09-12 06:20:4747
xhwang65c23032017-02-17 04:37:4248namespace chrome {
49
[email protected]63dc9072013-09-12 06:20:4750// Available key systems.
[email protected]a32ef592014-03-07 19:11:1551const char kClearKeyKeySystem[] = "org.w3.clearkey";
[email protected]ab998e82013-11-22 20:31:3552const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
xhwang640ef5d2016-08-17 16:46:0853
54// Variants of External Clear Key key system to test different scenarios.
55// To add a new variant, make sure you also update:
56// - media/test/data/eme_player_js/globals.js
57// - AddExternalClearKey() in chrome_key_systems.cc
58// - CreateCdmInstance() in clear_key_cdm.cc
xhwang0cfb5282016-08-25 03:33:2559const char kExternalClearKeyRenewalKeySystem[] =
60 "org.chromium.externalclearkey.renewal";
[email protected]34afd582013-12-20 07:26:1861const char kExternalClearKeyFileIOTestKeySystem[] =
62 "org.chromium.externalclearkey.fileiotest";
[email protected]ab998e82013-11-22 20:31:3563const char kExternalClearKeyInitializeFailKeySystem[] =
64 "org.chromium.externalclearkey.initializefail";
xhwang640ef5d2016-08-17 16:46:0865const char kExternalClearKeyOutputProtectionTestKeySystem[] =
66 "org.chromium.externalclearkey.outputprotectiontest";
xhwang382935d2016-10-27 22:11:2067const char kExternalClearKeyPlatformVerificationTestKeySystem[] =
68 "org.chromium.externalclearkey.platformverificationtest";
[email protected]a27d34ab2014-01-09 04:23:2969const char kExternalClearKeyCrashKeySystem[] =
70 "org.chromium.externalclearkey.crash";
xhwangc3941032017-03-20 18:50:3571#if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
xhwang785a8342017-01-26 06:46:3972const char kExternalClearKeyVerifyCdmHostTestKeySystem[] =
73 "org.chromium.externalclearkey.verifycdmhosttest";
xhwangc3941032017-03-20 18:50:3574#endif
[email protected]63dc9072013-09-12 06:20:4775
76// Supported media types.
servolk0b2146782016-08-30 03:47:4577const char kWebMVorbisAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
servolk0b2146782016-08-30 03:47:4578const char kWebMVP8VideoOnly[] = "video/webm; codecs=\"vp8\"";
79const char kWebMVorbisAudioVP8Video[] = "video/webm; codecs=\"vorbis, vp8\"";
80const char kWebMOpusAudioVP9Video[] = "video/webm; codecs=\"opus, vp9\"";
jamescook6107ed82014-11-06 06:59:2181const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\"";
brettw68c77532017-01-21 00:28:0682#if BUILDFLAG(USE_PROPRIETARY_CODECS)
jrummell2737b992016-10-03 23:30:1883const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D000C\"";
kqyangbfe10302017-05-06 19:06:4184const char kMP4VideoVp9Only[] =
85 "video/mp4; codecs=\"vp09.00.10.08.01.02.02.02.00\"";
brettw68c77532017-01-21 00:28:0686#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
[email protected]63dc9072013-09-12 06:20:4787
[email protected]0af5dfa2014-02-07 22:33:4488// Sessions to load.
89const char kNoSessionToLoad[] = "";
90const char kLoadableSession[] = "LoadableSession";
91const char kUnknownSession[] = "UnknownSession";
92
[email protected]2e850f12013-09-18 01:27:2993// EME-specific test results and errors.
xhwang640ef5d2016-08-17 16:46:0894const char kUnitTestSuccess[] = "UNIT_TEST_SUCCESS";
jrummell0c6ba542015-07-08 18:04:4495const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
96const char kEmeGenerateRequestFailed[] = "EME_GENERATEREQUEST_FAILED";
jrummell14fae6f2015-07-10 20:40:1597const char kEmeSessionNotFound[] = "EME_SESSION_NOT_FOUND";
jrummell0c6ba542015-07-08 18:04:4498const char kEmeLoadFailed[] = "EME_LOAD_FAILED";
99const char kEmeUpdateFailed[] = "EME_UPDATE_FAILED";
100const char kEmeErrorEvent[] = "EME_ERROR_EVENT";
101const char kEmeMessageUnexpectedType[] = "EME_MESSAGE_UNEXPECTED_TYPE";
ddorwinfdb9a2b2016-02-22 22:25:10102const char kEmeRenewalMissingHeader[] = "EME_RENEWAL_MISSING_HEADER";
jrummell35c1aa882016-11-16 00:49:15103const char kEmeSessionClosedAndError[] = "EME_SESSION_CLOSED_AND_ERROR";
[email protected]e11d89d2014-06-19 11:36:31104
105const char kDefaultEmePlayer[] = "eme_player.html";
[email protected]63dc9072013-09-12 06:20:47106
107// The type of video src used to load media.
xhwang65c23032017-02-17 04:37:42108enum class SrcType { SRC, MSE };
109
110// Must be in sync with CONFIG_CHANGE_TYPE in eme_player_js/global.js
111enum class ConfigChangeType {
112 CLEAR_TO_CLEAR = 0,
113 CLEAR_TO_ENCRYPTED = 1,
114 ENCRYPTED_TO_CLEAR = 2,
115 ENCRYPTED_TO_ENCRYPTED = 3,
[email protected]63dc9072013-09-12 06:20:47116};
117
jrummellb3944632015-03-14 00:19:42118// Whether the video should be played once or twice.
patricialor58397dcb2017-02-07 08:42:50119enum class PlayCount { ONCE, TWICE };
jrummellb3944632015-03-14 00:19:42120
jrummellc015cb962015-07-17 00:41:30121// Format of a container when testing different streams.
122enum class EncryptedContainer {
123 CLEAR_WEBM,
124 CLEAR_MP4,
125 ENCRYPTED_WEBM,
126 ENCRYPTED_MP4
127};
128
[email protected]e6bf64142013-10-18 23:07:54129// Base class for encrypted media tests.
130class EncryptedMediaTestBase : public MediaBrowserTest {
[email protected]63dc9072013-09-12 06:20:47131 public:
[email protected]ab998e82013-11-22 20:31:35132 bool IsExternalClearKey(const std::string& key_system) {
ddorwin40312df2016-02-26 01:25:01133 if (key_system == kExternalClearKeyKeySystem)
134 return true;
135 std::string prefix = std::string(kExternalClearKeyKeySystem) + '.';
136 return key_system.substr(0, prefix.size()) == prefix;
[email protected]63dc9072013-09-12 06:20:47137 }
138
[email protected]1825e772013-10-08 06:39:11139#if defined(WIDEVINE_CDM_AVAILABLE)
[email protected]ab998e82013-11-22 20:31:35140 bool IsWidevine(const std::string& key_system) {
141 return key_system == kWidevineKeySystem;
[email protected]1825e772013-10-08 06:39:11142 }
143#endif // defined(WIDEVINE_CDM_AVAILABLE)
144
[email protected]8a229322014-07-22 23:33:07145 void RunEncryptedMediaTestPage(
146 const std::string& html_page,
147 const std::string& key_system,
anand.ratn2636d972014-09-30 04:06:58148 base::StringPairs& query_params,
[email protected]8a229322014-07-22 23:33:07149 const std::string& expected_title) {
anand.ratn2636d972014-09-30 04:06:58150 base::StringPairs new_query_params = query_params;
[email protected]8a229322014-07-22 23:33:07151 StartLicenseServerIfNeeded(key_system, &new_query_params);
152 RunMediaTestPage(html_page, new_query_params, expected_title, true);
[email protected]df06a3e2014-01-31 21:36:59153 }
154
[email protected]0af5dfa2014-02-07 22:33:44155 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|.
156 // When |session_to_load| is not empty, the test will try to load
157 // |session_to_load| with stored keys, instead of creating a new session
158 // and trying to update it with licenses.
159 // When |force_invalid_response| is true, the test will provide invalid
160 // responses, which should trigger errors.
161 // TODO(xhwang): Find an easier way to pass multiple configuration test
162 // options.
[email protected]df06a3e2014-01-31 21:36:59163 void RunEncryptedMediaTest(const std::string& html_page,
164 const std::string& media_file,
165 const std::string& media_type,
166 const std::string& key_system,
[email protected]1825e772013-10-08 06:39:11167 SrcType src_type,
[email protected]0af5dfa2014-02-07 22:33:44168 const std::string& session_to_load,
[email protected]df06a3e2014-01-31 21:36:59169 bool force_invalid_response,
patricialor58397dcb2017-02-07 08:42:50170 PlayCount play_count,
[email protected]df06a3e2014-01-31 21:36:59171 const std::string& expected_title) {
anand.ratn2636d972014-09-30 04:06:58172 base::StringPairs query_params;
[email protected]df06a3e2014-01-31 21:36:59173 query_params.push_back(std::make_pair("mediaFile", media_file));
174 query_params.push_back(std::make_pair("mediaType", media_type));
175 query_params.push_back(std::make_pair("keySystem", key_system));
xhwang65c23032017-02-17 04:37:42176 if (src_type == SrcType::MSE)
[email protected]df06a3e2014-01-31 21:36:59177 query_params.push_back(std::make_pair("useMSE", "1"));
178 if (force_invalid_response)
179 query_params.push_back(std::make_pair("forceInvalidResponse", "1"));
[email protected]0af5dfa2014-02-07 22:33:44180 if (!session_to_load.empty())
181 query_params.push_back(std::make_pair("sessionToLoad", session_to_load));
patricialor58397dcb2017-02-07 08:42:50182 if (play_count == PlayCount::TWICE)
jrummellb3944632015-03-14 00:19:42183 query_params.push_back(std::make_pair("playTwice", "1"));
[email protected]8a229322014-07-22 23:33:07184 RunEncryptedMediaTestPage(html_page, key_system, query_params,
[email protected]df06a3e2014-01-31 21:36:59185 expected_title);
[email protected]63dc9072013-09-12 06:20:47186 }
187
[email protected]df06a3e2014-01-31 21:36:59188 void RunSimpleEncryptedMediaTest(const std::string& media_file,
189 const std::string& media_type,
190 const std::string& key_system,
ddorwinfdb9a2b2016-02-22 22:25:10191 SrcType src_type) {
[email protected]df06a3e2014-01-31 21:36:59192 std::string expected_title = kEnded;
jrummell0c6ba542015-07-08 18:04:44193 if (!IsPlayBackPossible(key_system)) {
ddorwinfdb9a2b2016-02-22 22:25:10194 expected_title = kEmeUpdateFailed;
jrummell0c6ba542015-07-08 18:04:44195 }
[email protected]1825e772013-10-08 06:39:11196
jrummellb3944632015-03-14 00:19:42197 RunEncryptedMediaTest(kDefaultEmePlayer, media_file, media_type, key_system,
patricialor58397dcb2017-02-07 08:42:50198 src_type, kNoSessionToLoad, false, PlayCount::ONCE,
ddorwinfdb9a2b2016-02-22 22:25:10199 expected_title);
[email protected]df06a3e2014-01-31 21:36:59200 // Check KeyMessage received for all key systems.
201 bool receivedKeyMessage = false;
202 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
203 browser()->tab_strip_model()->GetActiveWebContents(),
[email protected]e11d89d2014-06-19 11:36:31204 "window.domAutomationController.send("
205 "document.querySelector('video').receivedKeyMessage);",
[email protected]df06a3e2014-01-31 21:36:59206 &receivedKeyMessage));
207 EXPECT_TRUE(receivedKeyMessage);
208 }
209
[email protected]8a229322014-07-22 23:33:07210 // Starts a license server if available for the |key_system| and adds a
211 // 'licenseServerURL' query parameter to |query_params|.
[email protected]df06a3e2014-01-31 21:36:59212 void StartLicenseServerIfNeeded(const std::string& key_system,
anand.ratn2636d972014-09-30 04:06:58213 base::StringPairs* query_params) {
dchengc16dc8092016-04-08 23:12:56214 std::unique_ptr<TestLicenseServerConfig> config =
215 GetServerConfig(key_system);
[email protected]df06a3e2014-01-31 21:36:59216 if (!config)
217 return;
dchenge73d8520c2015-12-27 01:19:09218 license_server_.reset(new TestLicenseServer(std::move(config)));
jrummell90f8b202017-05-05 17:21:39219 {
220 base::ThreadRestrictions::ScopedAllowIO allow_io;
221 EXPECT_TRUE(license_server_->Start());
222 }
[email protected]8a229322014-07-22 23:33:07223 query_params->push_back(
224 std::make_pair("licenseServerURL", license_server_->GetServerURL()));
[email protected]df06a3e2014-01-31 21:36:59225 }
226
227 bool IsPlayBackPossible(const std::string& key_system) {
228#if defined(WIDEVINE_CDM_AVAILABLE)
229 if (IsWidevine(key_system) && !GetServerConfig(key_system))
230 return false;
231#endif // defined(WIDEVINE_CDM_AVAILABLE)
232 return true;
233 }
234
dchengc16dc8092016-04-08 23:12:56235 std::unique_ptr<TestLicenseServerConfig> GetServerConfig(
[email protected]df06a3e2014-01-31 21:36:59236 const std::string& key_system) {
237#if defined(WIDEVINE_CDM_AVAILABLE)
238 if (IsWidevine(key_system)) {
dchengc16dc8092016-04-08 23:12:56239 std::unique_ptr<TestLicenseServerConfig> config(
240 new WVTestLicenseServerConfig);
[email protected]df06a3e2014-01-31 21:36:59241 if (config->IsPlatformSupported())
dcheng7c133cc2015-12-31 06:57:59242 return config;
[email protected]df06a3e2014-01-31 21:36:59243 }
244#endif // defined(WIDEVINE_CDM_AVAILABLE)
dcheng7c133cc2015-12-31 06:57:59245 return nullptr;
[email protected]1825e772013-10-08 06:39:11246 }
247
[email protected]63dc9072013-09-12 06:20:47248 protected:
dchengc16dc8092016-04-08 23:12:56249 std::unique_ptr<TestLicenseServer> license_server_;
[email protected]df06a3e2014-01-31 21:36:59250
[email protected]2e850f12013-09-18 01:27:29251 // We want to fail quickly when a test fails because an error is encountered.
dchengd7e84a052014-10-22 00:18:51252 void AddWaitForTitles(content::TitleWatcher* title_watcher) override {
[email protected]2e850f12013-09-18 01:27:29253 MediaBrowserTest::AddWaitForTitles(title_watcher);
[email protected]6778fed2013-12-24 20:09:37254 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError));
jrummell0c6ba542015-07-08 18:04:44255 title_watcher->AlsoWaitForTitle(
256 base::ASCIIToUTF16(kEmeGenerateRequestFailed));
jrummell14fae6f2015-07-10 20:40:15257 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeSessionNotFound));
jrummell0c6ba542015-07-08 18:04:44258 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeLoadFailed));
259 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeUpdateFailed));
260 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeErrorEvent));
261 title_watcher->AlsoWaitForTitle(
262 base::ASCIIToUTF16(kEmeMessageUnexpectedType));
263 title_watcher->AlsoWaitForTitle(
ddorwinfdb9a2b2016-02-22 22:25:10264 base::ASCIIToUTF16(kEmeRenewalMissingHeader));
[email protected]2e850f12013-09-18 01:27:29265 }
266
avi556c05022014-12-22 23:31:43267 void SetUpCommandLine(base::CommandLine* command_line) override {
zmin32d29a12017-04-27 20:48:26268 command_line->AppendSwitch(switches::kIgnoreAutoplayRestrictionsForTests);
[email protected]2289b432014-08-08 17:52:11269 }
270
brettwc5fcdd02016-10-12 07:25:12271#if BUILDFLAG(ENABLE_PEPPER_CDMS)
xhwang3be44be2016-05-25 17:24:49272 void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
273 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM);
274 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line);
275 test_launcher_utils::RemoveCommandLineSwitch(
276 default_command_line, switches::kDisableComponentUpdate, command_line);
277 }
brettwc5fcdd02016-10-12 07:25:12278#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
xhwang3be44be2016-05-25 17:24:49279
[email protected]df06a3e2014-01-31 21:36:59280 void SetUpCommandLineForKeySystem(const std::string& key_system,
avi556c05022014-12-22 23:31:43281 base::CommandLine* command_line) {
[email protected]df06a3e2014-01-31 21:36:59282 if (GetServerConfig(key_system))
283 // Since the web and license servers listen on different ports, we need to
284 // disable web-security to send license requests to the license server.
285 // TODO(shadi): Add port forwarding to the test web server configuration.
286 command_line->AppendSwitch(switches::kDisableWebSecurity);
287
brettwc5fcdd02016-10-12 07:25:12288#if BUILDFLAG(ENABLE_PEPPER_CDMS)
[email protected]e6bf64142013-10-18 23:07:54289 if (IsExternalClearKey(key_system)) {
Xiaohan Wang17d4ffa2017-06-06 19:10:11290 RegisterPepperCdm(command_line, media::kClearKeyCdmBaseDirectory,
291 media::kClearKeyCdmAdapterFileName,
292 media::kClearKeyCdmDisplayName,
293 media::kClearKeyCdmPepperMimeType);
xhwang6bca3b792016-09-15 18:45:17294 command_line->AppendSwitchASCII(switches::kEnableFeatures,
295 media::kExternalClearKeyForTesting.name);
[email protected]e6bf64142013-10-18 23:07:54296 }
brettwc5fcdd02016-10-12 07:25:12297#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
[email protected]e6bf64142013-10-18 23:07:54298 }
[email protected]e6bf64142013-10-18 23:07:54299};
300
brettwc5fcdd02016-10-12 07:25:12301#if BUILDFLAG(ENABLE_PEPPER_CDMS)
[email protected]ab998e82013-11-22 20:31:35302// Tests encrypted media playback using ExternalClearKey key system in
303// decrypt-and-decode mode.
[email protected]e6bf64142013-10-18 23:07:54304class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
[email protected]0af5dfa2014-02-07 22:33:44305 public:
306 // We use special |key_system| names to do non-playback related tests, e.g.
307 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
308 void TestNonPlaybackCases(const std::string& key_system,
309 const std::string& expected_title) {
310 // Since we do not test playback, arbitrarily choose a test file and source
311 // type.
ddorwinfdb9a2b2016-02-22 22:25:10312 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
xhwang65c23032017-02-17 04:37:42313 kWebMVorbisAudioOnly, key_system, SrcType::SRC,
patricialor58397dcb2017-02-07 08:42:50314 kNoSessionToLoad, false, PlayCount::ONCE,
servolk0b2146782016-08-30 03:47:45315 expected_title);
jrummell19f2c902015-02-11 01:17:50316 }
317
xhwang0cfb5282016-08-25 03:33:25318 void TestPlaybackCase(const std::string& key_system,
319 const std::string& session_to_load,
jrummell19f2c902015-02-11 01:17:50320 const std::string& expected_title) {
321 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm",
xhwang65c23032017-02-17 04:37:42322 kWebMVP8VideoOnly, key_system, SrcType::SRC,
323 session_to_load, false, PlayCount::ONCE,
324 expected_title);
jrummell19f2c902015-02-11 01:17:50325 }
326
jrummellc467d232014-10-21 17:55:22327 protected:
avi556c05022014-12-22 23:31:43328 void SetUpCommandLine(base::CommandLine* command_line) override {
jrummellc467d232014-10-21 17:55:22329 EncryptedMediaTestBase::SetUpCommandLine(command_line);
jrummellc467d232014-10-21 17:55:22330 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
331 }
332};
333
[email protected]e6bf64142013-10-18 23:07:54334#if defined(WIDEVINE_CDM_AVAILABLE)
335// Tests encrypted media playback using Widevine key system.
336class WVEncryptedMediaTest : public EncryptedMediaTestBase {
337 protected:
Daniel Cheng43ba4a0122014-12-31 06:30:35338 void SetUpCommandLine(base::CommandLine* command_line) override {
[email protected]e6bf64142013-10-18 23:07:54339 EncryptedMediaTestBase::SetUpCommandLine(command_line);
340 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line);
341 }
342};
[email protected]df06a3e2014-01-31 21:36:59343
[email protected]e6bf64142013-10-18 23:07:54344#endif // defined(WIDEVINE_CDM_AVAILABLE)
brettwc5fcdd02016-10-12 07:25:12345#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
[email protected]e6bf64142013-10-18 23:07:54346
347// Tests encrypted media playback with a combination of parameters:
348// - char*: Key system name.
jrummell19f2c902015-02-11 01:17:50349// - SrcType: Use MSE or SRC.
[email protected]e6bf64142013-10-18 23:07:54350//
351// Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
352// tests will crash at GetParam(). To add non-parameterized tests, use
353// EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
ddorwinfdb9a2b2016-02-22 22:25:10354class EncryptedMediaTest : public EncryptedMediaTestBase,
355 public testing::WithParamInterface<
356 std::tr1::tuple<const char*, SrcType>> {
[email protected]e6bf64142013-10-18 23:07:54357 public:
[email protected]df06a3e2014-01-31 21:36:59358 std::string CurrentKeySystem() {
[email protected]e6bf64142013-10-18 23:07:54359 return std::tr1::get<0>(GetParam());
360 }
361
362 SrcType CurrentSourceType() {
363 return std::tr1::get<1>(GetParam());
364 }
365
[email protected]df06a3e2014-01-31 21:36:59366 void TestSimplePlayback(const std::string& encrypted_media,
367 const std::string& media_type) {
ddorwinfdb9a2b2016-02-22 22:25:10368 RunSimpleEncryptedMediaTest(encrypted_media, media_type, CurrentKeySystem(),
369 CurrentSourceType());
[email protected]e6bf64142013-10-18 23:07:54370 }
371
jrummellb3944632015-03-14 00:19:42372 void TestMultiplePlayback(const std::string& encrypted_media,
373 const std::string& media_type) {
jrummelld9dc7902015-03-16 20:59:28374 DCHECK(IsPlayBackPossible(CurrentKeySystem()));
jrummellb3944632015-03-14 00:19:42375 RunEncryptedMediaTest(kDefaultEmePlayer, encrypted_media, media_type,
376 CurrentKeySystem(), CurrentSourceType(),
patricialor58397dcb2017-02-07 08:42:50377 kNoSessionToLoad, false, PlayCount::TWICE, kEnded);
jrummellb3944632015-03-14 00:19:42378 }
379
[email protected]df06a3e2014-01-31 21:36:59380 void RunInvalidResponseTest() {
ddorwinfdb9a2b2016-02-22 22:25:10381 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-av_enc-av.webm",
servolk0b2146782016-08-30 03:47:45382 kWebMVorbisAudioVP8Video, CurrentKeySystem(),
ddorwinfdb9a2b2016-02-22 22:25:10383 CurrentSourceType(), kNoSessionToLoad, true,
patricialor58397dcb2017-02-07 08:42:50384 PlayCount::ONCE, kEmeUpdateFailed);
[email protected]df06a3e2014-01-31 21:36:59385 }
386
[email protected]e6bf64142013-10-18 23:07:54387 void TestFrameSizeChange() {
servolk0b2146782016-08-30 03:47:45388 RunEncryptedMediaTest(
389 "encrypted_frame_size_change.html", "frame_size_change-av_enc-v.webm",
390 kWebMVorbisAudioVP8Video, CurrentKeySystem(), CurrentSourceType(),
patricialor58397dcb2017-02-07 08:42:50391 kNoSessionToLoad, false, PlayCount::ONCE, kEnded);
[email protected]e6bf64142013-10-18 23:07:54392 }
393
xhwang65c23032017-02-17 04:37:42394 void TestConfigChange(ConfigChangeType config_change_type) {
395 // TODO(xhwang): Even when config change or playback is not supported we
396 // still start Chrome only to return directly here. We probably should not
397 // run these test cases at all. See http://crbug.com/693288
398 if (CurrentSourceType() != SrcType::MSE) {
399 DVLOG(0) << "Config change only happens when using MSE.";
400 return;
401 }
402 if (!IsPlayBackPossible(CurrentKeySystem())) {
403 DVLOG(0) << "Skipping test - ConfigChange test requires video playback.";
404 return;
405 }
406
anand.ratn2636d972014-09-30 04:06:58407 base::StringPairs query_params;
[email protected]df06a3e2014-01-31 21:36:59408 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
xhwang65c23032017-02-17 04:37:42409 query_params.push_back(std::make_pair(
410 "configChangeType",
411 base::IntToString(static_cast<int>(config_change_type))));
412 RunEncryptedMediaTestPage("mse_config_change.html", CurrentKeySystem(),
413 query_params, kEnded);
[email protected]e6bf64142013-10-18 23:07:54414 }
415
jrummellc015cb962015-07-17 00:41:30416 std::string ConvertContainerFormat(EncryptedContainer format) {
417 switch (format) {
418 case EncryptedContainer::CLEAR_MP4:
419 return "CLEAR_MP4";
420 case EncryptedContainer::CLEAR_WEBM:
421 return "CLEAR_WEBM";
422 case EncryptedContainer::ENCRYPTED_MP4:
423 return "ENCRYPTED_MP4";
424 case EncryptedContainer::ENCRYPTED_WEBM:
425 return "ENCRYPTED_WEBM";
426 }
427 NOTREACHED();
428 return "UNKNOWN";
429 }
430
431 void TestDifferentContainers(EncryptedContainer video_format,
432 EncryptedContainer audio_format) {
jrummellc015cb962015-07-17 00:41:30433 base::StringPairs query_params;
434 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
435 query_params.push_back(std::make_pair("runEncrypted", "1"));
436 query_params.push_back(
437 std::make_pair("videoFormat", ConvertContainerFormat(video_format)));
438 query_params.push_back(
439 std::make_pair("audioFormat", ConvertContainerFormat(audio_format)));
440 RunEncryptedMediaTestPage("mse_different_containers.html",
441 CurrentKeySystem(), query_params, kEnded);
442 }
443
xhwangd252d7b52017-02-08 18:52:36444 void DisableEncryptedMedia() {
445 PrefService* pref_service = browser()->profile()->GetPrefs();
446 pref_service->SetBoolean(prefs::kWebKitEncryptedMediaEnabled, false);
447 }
448
[email protected]e6bf64142013-10-18 23:07:54449 protected:
avi556c05022014-12-22 23:31:43450 void SetUpCommandLine(base::CommandLine* command_line) override {
[email protected]e6bf64142013-10-18 23:07:54451 EncryptedMediaTestBase::SetUpCommandLine(command_line);
452 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line);
453 }
[email protected]63dc9072013-09-12 06:20:47454};
455
[email protected]6479b192013-10-19 18:28:04456using ::testing::Combine;
457using ::testing::Values;
458
jrummell77419192014-10-31 21:40:44459INSTANTIATE_TEST_CASE_P(MSE_ClearKey,
[email protected]a32ef592014-03-07 19:11:15460 EncryptedMediaTest,
xhwang65c23032017-02-17 04:37:42461 Combine(Values(kClearKeyKeySystem),
462 Values(SrcType::MSE)));
[email protected]63dc9072013-09-12 06:20:47463
464// External Clear Key is currently only used on platforms that use Pepper CDMs.
brettwc5fcdd02016-10-12 07:25:12465#if BUILDFLAG(ENABLE_PEPPER_CDMS)
[email protected]1ab297a2014-03-26 04:52:12466INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey,
[email protected]a32ef592014-03-07 19:11:15467 EncryptedMediaTest,
468 Combine(Values(kExternalClearKeyKeySystem),
xhwang65c23032017-02-17 04:37:42469 Values(SrcType::SRC)));
jam79bf1f6c2015-08-13 20:46:04470
[email protected]1ab297a2014-03-26 04:52:12471INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey,
[email protected]a32ef592014-03-07 19:11:15472 EncryptedMediaTest,
473 Combine(Values(kExternalClearKeyKeySystem),
xhwang65c23032017-02-17 04:37:42474 Values(SrcType::MSE)));
Xiaohan Wang439859f32017-06-06 22:55:24475#else
476// To reduce test time, only run ClearKey SRC tests when we are not running
477// ExternalClearKey SRC tests.
478INSTANTIATE_TEST_CASE_P(SRC_ClearKey,
[email protected]a32ef592014-03-07 19:11:15479 EncryptedMediaTest,
Xiaohan Wang439859f32017-06-06 22:55:24480 Combine(Values(kClearKeyKeySystem),
481 Values(SrcType::SRC)));
brettwc5fcdd02016-10-12 07:25:12482#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
[email protected]63dc9072013-09-12 06:20:47483
[email protected]1825e772013-10-08 06:39:11484#if defined(WIDEVINE_CDM_AVAILABLE)
jonross5785b8662015-10-22 21:12:53485#if !defined(OS_CHROMEOS)
[email protected]1ab297a2014-03-26 04:52:12486INSTANTIATE_TEST_CASE_P(MSE_Widevine,
[email protected]a32ef592014-03-07 19:11:15487 EncryptedMediaTest,
xhwang65c23032017-02-17 04:37:42488 Combine(Values(kWidevineKeySystem),
489 Values(SrcType::MSE)));
jonross5785b8662015-10-22 21:12:53490#endif // !defined(OS_CHROMEOS)
[email protected]1825e772013-10-08 06:39:11491#endif // defined(WIDEVINE_CDM_AVAILABLE)
[email protected]63dc9072013-09-12 06:20:47492
[email protected]626e517c2014-08-19 00:49:46493IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
servolk0b2146782016-08-30 03:47:45494 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMVorbisAudioVP8Video);
[email protected]63dc9072013-09-12 06:20:47495}
496
[email protected]626e517c2014-08-19 00:49:46497IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
servolk0b2146782016-08-30 03:47:45498 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMVorbisAudioVP8Video);
[email protected]63dc9072013-09-12 06:20:47499}
500
[email protected]626e517c2014-08-19 00:49:46501IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) {
servolk0b2146782016-08-30 03:47:45502 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMVorbisAudioVP8Video);
[email protected]63dc9072013-09-12 06:20:47503}
504
kqyang2cf59b52016-10-10 22:16:17505IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM_Fullsample) {
506 TestSimplePlayback("bear-320x240-v-vp9_fullsample_enc-v.webm",
507 kWebMVP9VideoOnly);
508}
509
510IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM_Subsample) {
511 TestSimplePlayback("bear-320x240-v-vp9_subsample_enc-v.webm",
512 kWebMVP9VideoOnly);
[email protected]2b197ac72014-04-11 23:33:52513}
514
sandersd5ec6dcf2014-11-26 20:39:38515IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM_Opus) {
servolk0b2146782016-08-30 03:47:45516 TestSimplePlayback("bear-320x240-opus-av_enc-av.webm",
517 kWebMOpusAudioVP9Video);
sandersd5ec6dcf2014-11-26 20:39:38518}
519
520IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) {
servolk0b2146782016-08-30 03:47:45521 TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVP9Video);
sandersd5ec6dcf2014-11-26 20:39:38522}
523
jrummellb3944632015-03-14 00:19:42524IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Multiple_VideoAudio_WebM) {
jrummelld9dc7902015-03-16 20:59:28525 if (!IsPlayBackPossible(CurrentKeySystem())) {
526 DVLOG(0) << "Skipping test - Playback_Multiple test requires playback.";
527 return;
528 }
servolk0b2146782016-08-30 03:47:45529 TestMultiplePlayback("bear-320x240-av_enc-av.webm", kWebMVorbisAudioVP8Video);
jrummellb3944632015-03-14 00:19:42530}
531
[email protected]626e517c2014-08-19 00:49:46532IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) {
[email protected]df06a3e2014-01-31 21:36:59533 RunInvalidResponseTest();
534}
535
xhwang65c23032017-02-17 04:37:42536// Strictly speaking this is not an "encrypted" media test. Keep it here for
537// completeness.
538IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo_ClearToClear) {
539 TestConfigChange(ConfigChangeType::CLEAR_TO_CLEAR);
540}
541
xhwangb2827d22017-02-24 22:57:33542IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo_ClearToEncrypted) {
xhwang65c23032017-02-17 04:37:42543 TestConfigChange(ConfigChangeType::CLEAR_TO_ENCRYPTED);
544}
545
546IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo_EncryptedToClear) {
547 TestConfigChange(ConfigChangeType::ENCRYPTED_TO_CLEAR);
548}
549
550IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
551 ConfigChangeVideo_EncryptedToEncrypted) {
552 TestConfigChange(ConfigChangeType::ENCRYPTED_TO_ENCRYPTED);
[email protected]1825e772013-10-08 06:39:11553}
554
dalecurtis71bec5192016-10-28 03:16:44555IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) {
[email protected]df06a3e2014-01-31 21:36:59556 if (!IsPlayBackPossible(CurrentKeySystem())) {
anujk.sharma9da298e12014-11-07 04:48:43557 DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback.";
[email protected]df06a3e2014-01-31 21:36:59558 return;
559 }
[email protected]1825e772013-10-08 06:39:11560 TestFrameSizeChange();
[email protected]63dc9072013-09-12 06:20:47561}
562
xhwangd252d7b52017-02-08 18:52:36563IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, EncryptedMediaDisabled) {
564 DisableEncryptedMedia();
xhwang34879342017-02-11 23:22:33565
566 // Clear Key key system is always supported.
567 std::string expected_title =
568 media::IsClearKey(CurrentKeySystem()) ? kEnded : kEmeNotSupportedError;
569
xhwangd252d7b52017-02-08 18:52:36570 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
571 kWebMVorbisAudioOnly, CurrentKeySystem(),
572 CurrentSourceType(), kNoSessionToLoad, false,
xhwang34879342017-02-11 23:22:33573 PlayCount::ONCE, expected_title);
xhwangd252d7b52017-02-08 18:52:36574}
575
brettw68c77532017-01-21 00:28:06576#if BUILDFLAG(USE_PROPRIETARY_CODECS)
Xiaohan Wang70e545d22017-06-06 21:18:45577IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4) {
[email protected]63dc9072013-09-12 06:20:47578 // MP4 without MSE is not support yet, http://crbug.com/170793.
xhwang65c23032017-02-17 04:37:42579 if (CurrentSourceType() != SrcType::MSE) {
anujk.sharma9da298e12014-11-07 04:48:43580 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
[email protected]63dc9072013-09-12 06:20:47581 return;
582 }
[email protected]1825e772013-10-08 06:39:11583 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly);
[email protected]63dc9072013-09-12 06:20:47584}
585
kqyangf93bb7b2016-12-03 02:28:19586IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9) {
587 // MP4 without MSE is not support yet, http://crbug.com/170793.
xhwang65c23032017-02-17 04:37:42588 if (CurrentSourceType() != SrcType::MSE) {
kqyangf93bb7b2016-12-03 02:28:19589 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
590 return;
591 }
592 TestSimplePlayback("bear-320x240-v_frag-vp9-cenc.mp4", kMP4VideoVp9Only);
593}
594
jrummellc015cb962015-07-17 00:41:30595IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
596 Playback_EncryptedVideo_MP4_ClearAudio_WEBM) {
597 // MP4 without MSE is not support yet, http://crbug.com/170793.
xhwang65c23032017-02-17 04:37:42598 if (CurrentSourceType() != SrcType::MSE) {
jrummellc015cb962015-07-17 00:41:30599 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
600 return;
601 }
jrummellc015cb962015-07-17 00:41:30602 if (!IsPlayBackPossible(CurrentKeySystem())) {
603 DVLOG(0) << "Skipping test - Test requires video playback.";
604 return;
605 }
606 TestDifferentContainers(EncryptedContainer::ENCRYPTED_MP4,
607 EncryptedContainer::CLEAR_WEBM);
608}
609
610IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
611 Playback_ClearVideo_WEBM_EncryptedAudio_MP4) {
612 // MP4 without MSE is not support yet, http://crbug.com/170793.
xhwang65c23032017-02-17 04:37:42613 if (CurrentSourceType() != SrcType::MSE) {
jrummellc015cb962015-07-17 00:41:30614 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
615 return;
616 }
jrummellc015cb962015-07-17 00:41:30617 if (!IsPlayBackPossible(CurrentKeySystem())) {
618 DVLOG(0) << "Skipping test - Test requires video playback.";
619 return;
620 }
621 TestDifferentContainers(EncryptedContainer::CLEAR_WEBM,
622 EncryptedContainer::ENCRYPTED_MP4);
623}
624
625IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
626 Playback_EncryptedVideo_WEBM_EncryptedAudio_MP4) {
627 // MP4 without MSE is not support yet, http://crbug.com/170793.
xhwang65c23032017-02-17 04:37:42628 if (CurrentSourceType() != SrcType::MSE) {
jrummellc015cb962015-07-17 00:41:30629 DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
630 return;
631 }
jrummellc015cb962015-07-17 00:41:30632 if (!IsPlayBackPossible(CurrentKeySystem())) {
633 DVLOG(0) << "Skipping test - Test requires video playback.";
634 return;
635 }
636 TestDifferentContainers(EncryptedContainer::ENCRYPTED_WEBM,
637 EncryptedContainer::ENCRYPTED_MP4);
638}
brettw68c77532017-01-21 00:28:06639#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
[email protected]63dc9072013-09-12 06:20:47640
[email protected]63dc9072013-09-12 06:20:47641#if defined(WIDEVINE_CDM_AVAILABLE)
[email protected]a32ef592014-03-07 19:11:15642// The parent key system cannot be used when creating MediaKeys.
[email protected]b1620732014-04-01 23:17:18643IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
servolk0b2146782016-08-30 03:47:45644 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
xhwang65c23032017-02-17 04:37:42645 kWebMVorbisAudioOnly, "com.widevine", SrcType::MSE,
patricialor58397dcb2017-02-07 08:42:50646 kNoSessionToLoad, false, PlayCount::ONCE,
servolk0b2146782016-08-30 03:47:45647 kEmeNotSupportedError);
[email protected]63dc9072013-09-12 06:20:47648}
[email protected]63dc9072013-09-12 06:20:47649#endif // defined(WIDEVINE_CDM_AVAILABLE)
[email protected]a941d4e572013-10-14 21:22:05650
brettwc5fcdd02016-10-12 07:25:12651#if BUILDFLAG(ENABLE_PEPPER_CDMS)
[email protected]34afd582013-12-20 07:26:18652IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) {
jrummell87a2db52015-05-05 22:27:18653 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem,
654 kEmeNotSupportedError);
[email protected]a941d4e572013-10-14 21:22:05655}
[email protected]34afd582013-12-20 07:26:18656
jrummell35c1aa882016-11-16 00:49:15657// When CDM crashes, we should still get a decode error and all sessions should
658// be closed.
jrummellfed298d22015-07-01 00:26:51659IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) {
[email protected]1be9fa072014-03-21 22:50:29660 IgnorePluginCrash();
jrummell35c1aa882016-11-16 00:49:15661 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem,
662 kEmeSessionClosedAndError);
[email protected]a27d34ab2014-01-09 04:23:29663}
664
[email protected]1be9fa072014-03-21 22:50:29665// Testing that the media browser test does fail on plugin crash.
jrummellfed298d22015-07-01 00:26:51666IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMExpectedCrash) {
[email protected]1be9fa072014-03-21 22:50:29667 // Plugin crash is not ignored by default, the test is expected to fail.
jrummell35c1aa882016-11-16 00:49:15668 EXPECT_NONFATAL_FAILURE(TestNonPlaybackCases(kExternalClearKeyCrashKeySystem,
669 kEmeSessionClosedAndError),
670 "Failing test due to plugin crash.");
[email protected]1be9fa072014-03-21 22:50:29671}
672
xhwang0c617e112014-09-19 17:33:24673IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) {
xhwang640ef5d2016-08-17 16:46:08674 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, kUnitTestSuccess);
675}
676
677// TODO(xhwang): Investigate how to fake capturing activities to test the
678// network link detection logic in OutputProtectionProxy.
679IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, OutputProtectionTest) {
680 TestNonPlaybackCases(kExternalClearKeyOutputProtectionTestKeySystem,
681 kUnitTestSuccess);
[email protected]0af5dfa2014-02-07 22:33:44682}
683
xhwang382935d2016-10-27 22:11:20684IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, PlatformVerificationTest) {
685 TestNonPlaybackCases(kExternalClearKeyPlatformVerificationTestKeySystem,
686 kUnitTestSuccess);
687}
688
xhwang0cfb5282016-08-25 03:33:25689IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, Renewal) {
690 TestPlaybackCase(kExternalClearKeyRenewalKeySystem, kNoSessionToLoad, kEnded);
691}
692
[email protected]0af5dfa2014-02-07 22:33:44693IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
xhwang0cfb5282016-08-25 03:33:25694 TestPlaybackCase(kExternalClearKeyKeySystem, kLoadableSession, kEnded);
[email protected]0af5dfa2014-02-07 22:33:44695}
696
697IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
xhwang0cfb5282016-08-25 03:33:25698 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession,
699 kEmeSessionNotFound);
[email protected]34afd582013-12-20 07:26:18700}
Xiaohan Wang439859f32017-06-06 22:55:24701
702const char kExternalClearKeyDecryptOnlyKeySystem[] =
703 "org.chromium.externalclearkey.decryptonly";
704
705IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DecryptOnly_VideoAudio_WebM) {
706 RunSimpleEncryptedMediaTest(
707 "bear-320x240-av_enc-av.webm", kWebMVorbisAudioVP8Video,
708 kExternalClearKeyDecryptOnlyKeySystem, SrcType::MSE);
709}
710
711#if BUILDFLAG(USE_PROPRIETARY_CODECS)
712IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DecryptOnly_VideoOnly_MP4_VP9) {
713 RunSimpleEncryptedMediaTest(
714 "bear-320x240-v_frag-vp9-cenc.mp4", kMP4VideoVp9Only,
715 kExternalClearKeyDecryptOnlyKeySystem, SrcType::MSE);
716}
717#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
xhwangc3941032017-03-20 18:50:35718#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
jrummellc467d232014-10-21 17:55:22719
xhwangc3941032017-03-20 18:50:35720#if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
xhwang785a8342017-01-26 06:46:39721IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, VerifyCdmHostTest) {
722 TestNonPlaybackCases(kExternalClearKeyVerifyCdmHostTestKeySystem,
723 kUnitTestSuccess);
724}
xhwangc3941032017-03-20 18:50:35725#endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
xhwang65c23032017-02-17 04:37:42726
727} // namespace chrome