[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "base/command_line.h" |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 6 | #include "base/memory/scoped_ptr.h" |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 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" |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 11 | #include "chrome/browser/media/test_license_server.h" |
| 12 | #include "chrome/browser/media/wv_test_license_server_config.h" |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 13 | #include "chrome/browser/ui/browser.h" |
| 14 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 | #include "chrome/common/chrome_switches.h" |
brettw | 90e9260 | 2015-10-10 00:12:40 | [diff] [blame] | 16 | #include "content/public/common/content_switches.h" |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 17 | #include "content/public/test/browser_test_utils.h" |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 18 | #include "testing/gtest/include/gtest/gtest-spi.h" |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 19 | #if defined(OS_ANDROID) |
| 20 | #include "base/android/build_info.h" |
| 21 | #endif |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 22 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 23 | #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 24 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 25 | #if defined(ENABLE_PEPPER_CDMS) |
| 26 | // Platform-specific filename relative to the chrome executable. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 27 | const char kClearKeyCdmAdapterFileName[] = |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 28 | #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] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 35 | |
| 36 | const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 37 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 38 | |
| 39 | // Available key systems. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 40 | const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 41 | const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 42 | const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 43 | const char kExternalClearKeyFileIOTestKeySystem[] = |
| 44 | "org.chromium.externalclearkey.fileiotest"; |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 45 | const char kExternalClearKeyInitializeFailKeySystem[] = |
| 46 | "org.chromium.externalclearkey.initializefail"; |
[email protected] | a27d34ab | 2014-01-09 04:23:29 | [diff] [blame] | 47 | const char kExternalClearKeyCrashKeySystem[] = |
| 48 | "org.chromium.externalclearkey.crash"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 49 | |
| 50 | // Supported media types. |
[email protected] | 095ccbe4 | 2013-09-26 00:06:42 | [diff] [blame] | 51 | const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
| 52 | const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
| 53 | const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; |
jamescook | 6107ed8 | 2014-11-06 06:59:21 | [diff] [blame] | 54 | const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\""; |
[email protected] | 095ccbe4 | 2013-09-26 00:06:42 | [diff] [blame] | 55 | #if defined(USE_PROPRIETARY_CODECS) |
| 56 | const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
| 57 | const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; |
| 58 | #endif // defined(USE_PROPRIETARY_CODECS) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 59 | |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 60 | // Sessions to load. |
| 61 | const char kNoSessionToLoad[] = ""; |
| 62 | const char kLoadableSession[] = "LoadableSession"; |
| 63 | const char kUnknownSession[] = "UnknownSession"; |
| 64 | |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 65 | // EME-specific test results and errors. |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 66 | const char kFileIOTestSuccess[] = "FILE_IO_TEST_SUCCESS"; |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 67 | const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; |
| 68 | const char kEmeGenerateRequestFailed[] = "EME_GENERATEREQUEST_FAILED"; |
jrummell | 14fae6f | 2015-07-10 20:40:15 | [diff] [blame] | 69 | const char kEmeSessionNotFound[] = "EME_SESSION_NOT_FOUND"; |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 70 | const char kEmeLoadFailed[] = "EME_LOAD_FAILED"; |
| 71 | const char kEmeUpdateFailed[] = "EME_UPDATE_FAILED"; |
| 72 | const char kEmeErrorEvent[] = "EME_ERROR_EVENT"; |
| 73 | const char kEmeMessageUnexpectedType[] = "EME_MESSAGE_UNEXPECTED_TYPE"; |
| 74 | const char kPrefixedEmeRenewalMissingHeader[] = |
| 75 | "PREFIXED_EME_RENEWAL_MISSING_HEADER"; |
| 76 | const char kPrefixedEmeErrorEvent[] = "PREFIXED_EME_ERROR_EVENT"; |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 77 | |
| 78 | const char kDefaultEmePlayer[] = "eme_player.html"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 79 | |
| 80 | // The type of video src used to load media. |
| 81 | enum SrcType { |
| 82 | SRC, |
| 83 | MSE |
| 84 | }; |
| 85 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 86 | // Whether to use prefixed or unprefixed EME. |
| 87 | enum EmeVersion { |
| 88 | PREFIXED, |
| 89 | UNPREFIXED |
| 90 | }; |
| 91 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 92 | // Whether the video should be played once or twice. |
| 93 | enum class PlayTwice { NO, YES }; |
| 94 | |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 95 | // Format of a container when testing different streams. |
| 96 | enum class EncryptedContainer { |
| 97 | CLEAR_WEBM, |
| 98 | CLEAR_MP4, |
| 99 | ENCRYPTED_WEBM, |
| 100 | ENCRYPTED_MP4 |
| 101 | }; |
| 102 | |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 103 | // MSE is available on all desktop platforms and on Android 4.1 and later. |
| 104 | static bool IsMSESupported() { |
| 105 | #if defined(OS_ANDROID) |
| 106 | if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 107 | DVLOG(0) << "MSE is only supported in Android 4.1 and later."; |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 108 | return false; |
| 109 | } |
| 110 | #endif // defined(OS_ANDROID) |
| 111 | return true; |
| 112 | } |
| 113 | |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 114 | static 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] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 120 | // Base class for encrypted media tests. |
| 121 | class EncryptedMediaTestBase : public MediaBrowserTest { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 122 | public: |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 123 | EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 124 | |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 125 | bool IsExternalClearKey(const std::string& key_system) { |
| 126 | return key_system == kExternalClearKeyKeySystem || |
| 127 | IsParentKeySystemOf(kExternalClearKeyKeySystem, key_system); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 128 | } |
| 129 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 130 | #if defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 131 | bool IsWidevine(const std::string& key_system) { |
| 132 | return key_system == kWidevineKeySystem; |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 133 | } |
| 134 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 135 | |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 136 | void RunEncryptedMediaTestPage( |
| 137 | const std::string& html_page, |
| 138 | const std::string& key_system, |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 139 | base::StringPairs& query_params, |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 140 | const std::string& expected_title) { |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 141 | base::StringPairs new_query_params = query_params; |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 142 | StartLicenseServerIfNeeded(key_system, &new_query_params); |
| 143 | RunMediaTestPage(html_page, new_query_params, expected_title, true); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 144 | } |
| 145 | |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 146 | // 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] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 154 | 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] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 158 | SrcType src_type, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 159 | EmeVersion eme_version, |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 160 | const std::string& session_to_load, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 161 | bool force_invalid_response, |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 162 | PlayTwice play_twice, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 163 | const std::string& expected_title) { |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 164 | if (src_type == MSE && !IsMSESupported()) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 165 | DVLOG(0) << "Skipping test - MSE not supported."; |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 166 | return; |
| 167 | } |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 168 | base::StringPairs query_params; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 169 | 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] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 172 | if (src_type == MSE) |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 173 | query_params.push_back(std::make_pair("useMSE", "1")); |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 174 | if (eme_version == PREFIXED) |
| 175 | query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 176 | if (force_invalid_response) |
| 177 | query_params.push_back(std::make_pair("forceInvalidResponse", "1")); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 178 | if (!session_to_load.empty()) |
| 179 | query_params.push_back(std::make_pair("sessionToLoad", session_to_load)); |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 180 | if (play_twice == PlayTwice::YES) |
| 181 | query_params.push_back(std::make_pair("playTwice", "1")); |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 182 | RunEncryptedMediaTestPage(html_page, key_system, query_params, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 183 | expected_title); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 184 | } |
| 185 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 186 | void RunSimpleEncryptedMediaTest(const std::string& media_file, |
| 187 | const std::string& media_type, |
| 188 | const std::string& key_system, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 189 | SrcType src_type, |
| 190 | EmeVersion eme_version) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 191 | std::string expected_title = kEnded; |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 192 | if (!IsPlayBackPossible(key_system)) { |
| 193 | expected_title = (eme_version == EmeVersion::UNPREFIXED) |
| 194 | ? kEmeUpdateFailed |
| 195 | : kPrefixedEmeErrorEvent; |
| 196 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 197 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 198 | RunEncryptedMediaTest(kDefaultEmePlayer, media_file, media_type, key_system, |
| 199 | src_type, eme_version, kNoSessionToLoad, false, |
| 200 | PlayTwice::NO, expected_title); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 201 | // Check KeyMessage received for all key systems. |
| 202 | bool receivedKeyMessage = false; |
| 203 | EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 204 | browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 205 | "window.domAutomationController.send(" |
| 206 | "document.querySelector('video').receivedKeyMessage);", |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 207 | &receivedKeyMessage)); |
| 208 | EXPECT_TRUE(receivedKeyMessage); |
| 209 | } |
| 210 | |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 211 | // Starts a license server if available for the |key_system| and adds a |
| 212 | // 'licenseServerURL' query parameter to |query_params|. |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 213 | void StartLicenseServerIfNeeded(const std::string& key_system, |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 214 | base::StringPairs* query_params) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 215 | 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] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 220 | query_params->push_back( |
| 221 | std::make_pair("licenseServerURL", license_server_->GetServerURL())); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 222 | } |
| 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] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 243 | } |
| 244 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 245 | protected: |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 246 | scoped_ptr<TestLicenseServer> license_server_; |
| 247 | |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 248 | // We want to fail quickly when a test fails because an error is encountered. |
dcheng | d7e84a05 | 2014-10-22 00:18:51 | [diff] [blame] | 249 | void AddWaitForTitles(content::TitleWatcher* title_watcher) override { |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 250 | MediaBrowserTest::AddWaitForTitles(title_watcher); |
[email protected] | 6778fed | 2013-12-24 20:09:37 | [diff] [blame] | 251 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 252 | title_watcher->AlsoWaitForTitle( |
| 253 | base::ASCIIToUTF16(kEmeGenerateRequestFailed)); |
jrummell | 14fae6f | 2015-07-10 20:40:15 | [diff] [blame] | 254 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeSessionNotFound)); |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 255 | 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] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 263 | } |
| 264 | |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 265 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | 2289b43 | 2014-08-08 17:52:11 | [diff] [blame] | 266 | #if defined(OS_ANDROID) |
| 267 | command_line->AppendSwitch( |
| 268 | switches::kDisableGestureRequirementForMediaPlayback); |
| 269 | #endif // defined(OS_ANDROID) |
ddorwin | e12c5ce0 | 2015-09-10 18:38:39 | [diff] [blame] | 270 | // For simplicity with respect to parameterized tests, enable for all tests. |
| 271 | command_line->AppendSwitch(switches::kEnablePrefixedEncryptedMedia); |
[email protected] | 2289b43 | 2014-08-08 17:52:11 | [diff] [blame] | 272 | } |
| 273 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 274 | void SetUpCommandLineForKeySystem(const std::string& key_system, |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 275 | base::CommandLine* command_line) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 276 | 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] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 282 | #if defined(ENABLE_PEPPER_CDMS) |
| 283 | if (IsExternalClearKey(key_system)) { |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 284 | RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 285 | } |
| 286 | #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
thestig | 11bf74d | 2014-11-24 20:14:42 | [diff] [blame] | 287 | else if (IsWidevine(key_system)) { // NOLINT |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 288 | RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 289 | } |
| 290 | #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 291 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 292 | } |
| 293 | |
| 294 | private: |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 295 | #if defined(ENABLE_PEPPER_CDMS) |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 296 | void RegisterPepperCdm(base::CommandLine* command_line, |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 297 | const std::string& adapter_name, |
| 298 | const std::string& key_system) { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 299 | DCHECK(!is_pepper_cdm_registered_) |
| 300 | << "RegisterPepperCdm() can only be called once."; |
| 301 | is_pepper_cdm_registered_ = true; |
| 302 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 303 | // 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] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 307 | EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 308 | 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) |
thestig | 11bf74d | 2014-11-24 20:14:42 | [diff] [blame] | 311 | pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system))); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 312 | #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] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 321 | if (IsExternalClearKey(key_system)) |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 322 | return kClearKeyCdmPluginMimeType; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 323 | #if defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 324 | if (IsWidevine(key_system)) |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 325 | return kWidevineCdmPluginMimeType; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 326 | #endif // WIDEVINE_CDM_AVAILABLE |
| 327 | |
| 328 | NOTREACHED(); |
| 329 | return ""; |
| 330 | } |
| 331 | #endif // defined(ENABLE_PEPPER_CDMS) |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 332 | |
| 333 | bool is_pepper_cdm_registered_; |
| 334 | }; |
| 335 | |
| 336 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 337 | // Tests encrypted media playback using ExternalClearKey key system in |
| 338 | // decrypt-and-decode mode. |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 339 | class ECKEncryptedMediaTest : public EncryptedMediaTestBase { |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 340 | 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. |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 347 | RunEncryptedMediaTest( |
| 348 | kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly, key_system, SRC, |
| 349 | UNPREFIXED, kNoSessionToLoad, false, PlayTwice::NO, expected_title); |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 350 | } |
| 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, |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 356 | UNPREFIXED, session_to_load, false, PlayTwice::NO, |
| 357 | expected_title); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 358 | } |
| 359 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 360 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 361 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 362 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 363 | SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
| 364 | } |
| 365 | }; |
| 366 | |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 367 | // Tests encrypted media playback using ExternalClearKey key system in |
ddorwin | e12c5ce0 | 2015-09-10 18:38:39 | [diff] [blame] | 368 | // decrypt-and-decode mode for prefixed EME. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 369 | class 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. |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 377 | RunEncryptedMediaTest( |
| 378 | kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly, key_system, SRC, |
| 379 | PREFIXED, kNoSessionToLoad, false, PlayTwice::NO, expected_title); |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 380 | } |
| 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, |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 386 | PREFIXED, session_to_load, false, PlayTwice::NO, |
| 387 | expected_title); |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 388 | } |
| 389 | |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 390 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 391 | void SetUpCommandLine(base::CommandLine* command_line) override { |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 392 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 393 | SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
| 394 | } |
| 395 | }; |
| 396 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 397 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 398 | // Tests encrypted media playback using Widevine key system. |
| 399 | class WVEncryptedMediaTest : public EncryptedMediaTestBase { |
| 400 | protected: |
Daniel Cheng | 43ba4a012 | 2014-12-31 06:30:35 | [diff] [blame] | 401 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 402 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 403 | SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line); |
| 404 | } |
| 405 | }; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 406 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 407 | #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. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 412 | // - SrcType: Use MSE or SRC. |
| 413 | // - EmeVersion: Use PREFIXED or UNPREFIXED EME. |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 414 | // |
| 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] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 418 | class EncryptedMediaTest |
| 419 | : public EncryptedMediaTestBase, |
| 420 | public testing::WithParamInterface< |
| 421 | std::tr1::tuple<const char*, SrcType, EmeVersion> > { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 422 | public: |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 423 | std::string CurrentKeySystem() { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 424 | return std::tr1::get<0>(GetParam()); |
| 425 | } |
| 426 | |
| 427 | SrcType CurrentSourceType() { |
| 428 | return std::tr1::get<1>(GetParam()); |
| 429 | } |
| 430 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 431 | EmeVersion CurrentEmeVersion() { |
| 432 | return std::tr1::get<2>(GetParam()); |
| 433 | } |
| 434 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 435 | void TestSimplePlayback(const std::string& encrypted_media, |
| 436 | const std::string& media_type) { |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 437 | RunSimpleEncryptedMediaTest(encrypted_media, |
| 438 | media_type, |
| 439 | CurrentKeySystem(), |
| 440 | CurrentSourceType(), |
| 441 | CurrentEmeVersion()); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 442 | } |
| 443 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 444 | void TestMultiplePlayback(const std::string& encrypted_media, |
| 445 | const std::string& media_type) { |
jrummell | d9dc790 | 2015-03-16 20:59:28 | [diff] [blame] | 446 | DCHECK(IsPlayBackPossible(CurrentKeySystem())); |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 447 | RunEncryptedMediaTest(kDefaultEmePlayer, encrypted_media, media_type, |
| 448 | CurrentKeySystem(), CurrentSourceType(), |
| 449 | CurrentEmeVersion(), kNoSessionToLoad, false, |
| 450 | PlayTwice::YES, kEnded); |
| 451 | } |
| 452 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 453 | void RunInvalidResponseTest() { |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 454 | 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] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 462 | } |
| 463 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 464 | void TestFrameSizeChange() { |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 465 | 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] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | void TestConfigChange() { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 472 | DCHECK(IsMSESupported()); |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 473 | base::StringPairs query_params; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 474 | query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); |
| 475 | query_params.push_back(std::make_pair("runEncrypted", "1")); |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 476 | if (CurrentEmeVersion() == PREFIXED) |
| 477 | query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 478 | RunEncryptedMediaTestPage("mse_config_change.html", |
| 479 | CurrentKeySystem(), |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 480 | query_params, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 481 | kEnded); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 482 | } |
| 483 | |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 484 | 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] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 514 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 515 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 516 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 517 | SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line); |
| 518 | } |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 519 | }; |
| 520 | |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 521 | using ::testing::Combine; |
| 522 | using ::testing::Values; |
| 523 | |
| 524 | #if !defined(OS_ANDROID) |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 525 | INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed, |
| 526 | EncryptedMediaTest, |
| 527 | Combine(Values(kPrefixedClearKeyKeySystem), |
| 528 | Values(SRC), |
| 529 | Values(PREFIXED))); |
| 530 | |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 531 | INSTANTIATE_TEST_CASE_P(SRC_ClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 532 | EncryptedMediaTest, |
| 533 | Combine(Values(kClearKeyKeySystem), |
| 534 | Values(SRC), |
| 535 | Values(UNPREFIXED))); |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 536 | #endif // !defined(OS_ANDROID) |
| 537 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 538 | INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed, |
| 539 | EncryptedMediaTest, |
| 540 | Combine(Values(kPrefixedClearKeyKeySystem), |
| 541 | Values(MSE), |
| 542 | Values(PREFIXED))); |
jrummell | 7741919 | 2014-10-31 21:40:44 | [diff] [blame] | 543 | INSTANTIATE_TEST_CASE_P(MSE_ClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 544 | EncryptedMediaTest, |
| 545 | Combine(Values(kClearKeyKeySystem), |
| 546 | Values(MSE), |
| 547 | Values(UNPREFIXED))); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 548 | |
| 549 | // External Clear Key is currently only used on platforms that use Pepper CDMs. |
| 550 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 551 | INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed, |
| 552 | EncryptedMediaTest, |
| 553 | Combine(Values(kExternalClearKeyKeySystem), |
| 554 | Values(SRC), |
| 555 | Values(PREFIXED))); |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 556 | INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 557 | EncryptedMediaTest, |
| 558 | Combine(Values(kExternalClearKeyKeySystem), |
| 559 | Values(SRC), |
| 560 | Values(UNPREFIXED))); |
jam | 79bf1f6c | 2015-08-13 20:46:04 | [diff] [blame] | 561 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 562 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed, |
| 563 | EncryptedMediaTest, |
| 564 | Combine(Values(kExternalClearKeyKeySystem), |
| 565 | Values(MSE), |
| 566 | Values(PREFIXED))); |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 567 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 568 | EncryptedMediaTest, |
| 569 | Combine(Values(kExternalClearKeyKeySystem), |
| 570 | Values(MSE), |
| 571 | Values(UNPREFIXED))); |
mnissler | 2702537 | 2015-10-19 14:26:23 | [diff] [blame] | 572 | |
| 573 | // Flaky on Mac 10.9, see http://crbug.com/544891. |
| 574 | #if !defined(OS_MACOSX) |
| 575 | |
| 576 | const char kExternalClearKeyDecryptOnlyKeySystem[] = |
| 577 | "org.chromium.externalclearkey.decryptonly"; |
| 578 | |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 579 | // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 580 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed, |
| 581 | EncryptedMediaTest, |
| 582 | Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), |
| 583 | Values(MSE), |
| 584 | Values(PREFIXED))); |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 585 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 586 | EncryptedMediaTest, |
| 587 | Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), |
| 588 | Values(MSE), |
| 589 | Values(UNPREFIXED))); |
mnissler | 2702537 | 2015-10-19 14:26:23 | [diff] [blame] | 590 | #endif // !defined(OS_MACOSX) |
| 591 | |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 592 | #endif // defined(ENABLE_PEPPER_CDMS) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 593 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 594 | #if defined(WIDEVINE_CDM_AVAILABLE) |
jrummell | 56fb797 | 2015-04-11 00:01:32 | [diff] [blame] | 595 | |
| 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] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 601 | // This test doesn't fully test playback with Widevine. So we only run Widevine |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 602 | // 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] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 604 | INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed, |
| 605 | EncryptedMediaTest, |
| 606 | Combine(Values(kWidevineKeySystem), |
| 607 | Values(MSE), |
| 608 | Values(PREFIXED))); |
jrummell | 56fb797 | 2015-04-11 00:01:32 | [diff] [blame] | 609 | #endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) |
[email protected] | 78d9654 | 2014-03-27 11:45:47 | [diff] [blame] | 610 | |
jonross | 5785b866 | 2015-10-22 21:12:53 | [diff] [blame^] | 611 | #if !defined(OS_CHROMEOS) |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 612 | INSTANTIATE_TEST_CASE_P(MSE_Widevine, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 613 | EncryptedMediaTest, |
| 614 | Combine(Values(kWidevineKeySystem), |
| 615 | Values(MSE), |
| 616 | Values(UNPREFIXED))); |
jonross | 5785b866 | 2015-10-22 21:12:53 | [diff] [blame^] | 617 | #endif // !defined(OS_CHROMEOS) |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 618 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 619 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 620 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 621 | TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 622 | } |
| 623 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 624 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 625 | TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 626 | } |
| 627 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 628 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 629 | TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 630 | } |
| 631 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 632 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 633 | TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 634 | } |
| 635 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 636 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 637 | TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 638 | } |
| 639 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 640 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 641 | TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly); |
[email protected] | 2b197ac7 | 2014-04-11 23:33:52 | [diff] [blame] | 642 | } |
| 643 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 644 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM_Opus) { |
sandersd | 5ec6dcf | 2014-11-26 20:39:38 | [diff] [blame] | 645 | TestSimplePlayback("bear-320x240-opus-a_enc-a.webm", kWebMAudioOnly); |
| 646 | } |
| 647 | |
| 648 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM_Opus) { |
| 649 | TestSimplePlayback("bear-320x240-opus-av_enc-av.webm", kWebMAudioVideo); |
| 650 | } |
| 651 | |
| 652 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) { |
| 653 | TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMAudioVideo); |
| 654 | } |
| 655 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 656 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Multiple_VideoAudio_WebM) { |
jrummell | d9dc790 | 2015-03-16 20:59:28 | [diff] [blame] | 657 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
| 658 | DVLOG(0) << "Skipping test - Playback_Multiple test requires playback."; |
| 659 | return; |
| 660 | } |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 661 | TestMultiplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo); |
| 662 | } |
| 663 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 664 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 665 | RunInvalidResponseTest(); |
| 666 | } |
| 667 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 668 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 669 | if (CurrentSourceType() != MSE || !IsMSESupported()) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 670 | DVLOG(0) << "Skipping test - ConfigChange test requires MSE."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 671 | return; |
| 672 | } |
| 673 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 674 | DVLOG(0) << "Skipping test - ConfigChange test requires video playback."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 675 | return; |
| 676 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 677 | TestConfigChange(); |
| 678 | } |
| 679 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 680 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 681 | // 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] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 686 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 687 | DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 688 | return; |
| 689 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 690 | TestFrameSizeChange(); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | #if defined(USE_PROPRIETARY_CODECS) |
| 694 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 695 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 696 | if (CurrentSourceType() != MSE) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 697 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 698 | return; |
| 699 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 700 | TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 704 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 705 | if (CurrentSourceType() != MSE) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 706 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 707 | return; |
| 708 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 709 | TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 710 | } |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 711 | |
| 712 | IN_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 | |
| 731 | IN_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 | |
| 750 | IN_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] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 768 | #endif // defined(USE_PROPRIETARY_CODECS) |
| 769 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 770 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 771 | // The parent key system cannot be used in generateKeyRequest. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 772 | IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) { |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 773 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly, |
| 774 | "com.widevine", MSE, PREFIXED, kNoSessionToLoad, false, |
| 775 | PlayTwice::NO, kEmeNotSupportedError); |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 776 | } |
| 777 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 778 | // The parent key system cannot be used when creating MediaKeys. |
[email protected] | b162073 | 2014-04-01 23:17:18 | [diff] [blame] | 779 | IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 780 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly, |
| 781 | "com.widevine", MSE, UNPREFIXED, kNoSessionToLoad, |
| 782 | false, PlayTwice::NO, kEmeNotSupportedError); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 783 | } |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 784 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 785 | |
| 786 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 787 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 788 | TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, |
| 789 | kEmeNotSupportedError); |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 790 | } |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 791 | |
jrummell | fed298d2 | 2015-07-01 00:26:51 | [diff] [blame] | 792 | // 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. |
| 795 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) { |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 796 | IgnorePluginCrash(); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 797 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError); |
[email protected] | a27d34ab | 2014-01-09 04:23:29 | [diff] [blame] | 798 | } |
| 799 | |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 800 | // Testing that the media browser test does fail on plugin crash. |
jrummell | fed298d2 | 2015-07-01 00:26:51 | [diff] [blame] | 801 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMExpectedCrash) { |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 802 | // Plugin crash is not ignored by default, the test is expected to fail. |
| 803 | EXPECT_NONFATAL_FAILURE( |
| 804 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError), |
jrummell | fed298d2 | 2015-07-01 00:26:51 | [diff] [blame] | 805 | "Failing test due to plugin crash."); |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 806 | } |
| 807 | |
xhwang | 0c617e11 | 2014-09-19 17:33:24 | [diff] [blame] | 808 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 809 | TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, |
| 810 | kFileIOTestSuccess); |
| 811 | } |
| 812 | |
| 813 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 814 | TestPlaybackCase(kLoadableSession, kEnded); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 815 | } |
| 816 | |
| 817 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
jrummell | 14fae6f | 2015-07-10 20:40:15 | [diff] [blame] | 818 | TestPlaybackCase(kUnknownSession, kEmeSessionNotFound); |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 819 | } |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 820 | |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 821 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, InitializeCDMFail) { |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 822 | TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, |
| 823 | kPrefixedEmeErrorEvent); |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 824 | } |
| 825 | |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 826 | // When CDM crashes, we should still get a decode error. |
| 827 | // crbug.com/386657 |
| 828 | IN_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 |
| 836 | IN_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 | |
| 844 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, FileIOTest) { |
| 845 | TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, |
| 846 | kFileIOTestSuccess); |
| 847 | } |
| 848 | |
| 849 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, LoadLoadableSession) { |
| 850 | TestPlaybackCase(kLoadableSession, kEnded); |
| 851 | } |
| 852 | |
| 853 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, LoadUnknownSession) { |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 854 | TestPlaybackCase(kUnknownSession, kPrefixedEmeErrorEvent); |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 855 | } |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 856 | #endif // defined(ENABLE_PEPPER_CDMS) |