[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" |
| 16 | #include "content/public/test/browser_test_utils.h" |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 17 | #include "testing/gtest/include/gtest/gtest-spi.h" |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 18 | #if defined(OS_ANDROID) |
| 19 | #include "base/android/build_info.h" |
| 20 | #endif |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 21 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 22 | #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 23 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 24 | #if defined(ENABLE_PEPPER_CDMS) |
| 25 | // Platform-specific filename relative to the chrome executable. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 26 | const char kClearKeyCdmAdapterFileName[] = |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 27 | #if defined(OS_MACOSX) |
| 28 | "clearkeycdmadapter.plugin"; |
| 29 | #elif defined(OS_WIN) |
| 30 | "clearkeycdmadapter.dll"; |
| 31 | #elif defined(OS_POSIX) |
| 32 | "libclearkeycdmadapter.so"; |
| 33 | #endif |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 34 | |
| 35 | const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 36 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 37 | |
| 38 | // Available key systems. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 39 | const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 40 | const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 41 | const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
| 42 | const char kExternalClearKeyDecryptOnlyKeySystem[] = |
| 43 | "org.chromium.externalclearkey.decryptonly"; |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 44 | const char kExternalClearKeyFileIOTestKeySystem[] = |
| 45 | "org.chromium.externalclearkey.fileiotest"; |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 46 | const char kExternalClearKeyInitializeFailKeySystem[] = |
| 47 | "org.chromium.externalclearkey.initializefail"; |
[email protected] | a27d34ab | 2014-01-09 04:23:29 | [diff] [blame] | 48 | const char kExternalClearKeyCrashKeySystem[] = |
| 49 | "org.chromium.externalclearkey.crash"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 50 | |
| 51 | // Supported media types. |
[email protected] | 095ccbe4 | 2013-09-26 00:06:42 | [diff] [blame] | 52 | const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
| 53 | const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
| 54 | const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; |
jamescook | 6107ed8 | 2014-11-06 06:59:21 | [diff] [blame] | 55 | // Some tests are disabled in Chrome OS official builds. http://crbug.com/430711 |
| 56 | #if !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) |
| 57 | const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\""; |
[email protected] | 095ccbe4 | 2013-09-26 00:06:42 | [diff] [blame] | 58 | #if defined(USE_PROPRIETARY_CODECS) |
| 59 | const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
| 60 | const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; |
| 61 | #endif // defined(USE_PROPRIETARY_CODECS) |
jamescook | 6107ed8 | 2014-11-06 06:59:21 | [diff] [blame] | 62 | #endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 63 | |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 64 | // Sessions to load. |
| 65 | const char kNoSessionToLoad[] = ""; |
| 66 | const char kLoadableSession[] = "LoadableSession"; |
| 67 | const char kUnknownSession[] = "UnknownSession"; |
| 68 | |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 69 | // EME-specific test results and errors. |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 70 | const char kEmeKeyError[] = "KEY_ERROR"; |
[email protected] | 297b5a35 | 2013-10-18 00:09:17 | [diff] [blame] | 71 | const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 72 | const char kFileIOTestSuccess[] = "FILE_IO_TEST_SUCCESS"; |
| 73 | |
| 74 | const char kDefaultEmePlayer[] = "eme_player.html"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 75 | |
| 76 | // The type of video src used to load media. |
| 77 | enum SrcType { |
| 78 | SRC, |
| 79 | MSE |
| 80 | }; |
| 81 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 82 | // Whether to use prefixed or unprefixed EME. |
| 83 | enum EmeVersion { |
| 84 | PREFIXED, |
| 85 | UNPREFIXED |
| 86 | }; |
| 87 | |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 88 | // MSE is available on all desktop platforms and on Android 4.1 and later. |
| 89 | static bool IsMSESupported() { |
| 90 | #if defined(OS_ANDROID) |
| 91 | if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 92 | DVLOG(0) << "MSE is only supported in Android 4.1 and later."; |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 93 | return false; |
| 94 | } |
| 95 | #endif // defined(OS_ANDROID) |
| 96 | return true; |
| 97 | } |
| 98 | |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 99 | static bool IsParentKeySystemOf(const std::string& parent_key_system, |
| 100 | const std::string& key_system) { |
| 101 | std::string prefix = parent_key_system + '.'; |
| 102 | return key_system.substr(0, prefix.size()) == prefix; |
| 103 | } |
| 104 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 105 | // Base class for encrypted media tests. |
| 106 | class EncryptedMediaTestBase : public MediaBrowserTest { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 107 | public: |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 108 | EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 109 | |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 110 | bool IsExternalClearKey(const std::string& key_system) { |
| 111 | return key_system == kExternalClearKeyKeySystem || |
| 112 | IsParentKeySystemOf(kExternalClearKeyKeySystem, key_system); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 113 | } |
| 114 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 115 | #if defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 116 | bool IsWidevine(const std::string& key_system) { |
| 117 | return key_system == kWidevineKeySystem; |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 118 | } |
| 119 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 120 | |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 121 | void RunEncryptedMediaTestPage( |
| 122 | const std::string& html_page, |
| 123 | const std::string& key_system, |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 124 | base::StringPairs& query_params, |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 125 | const std::string& expected_title) { |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 126 | base::StringPairs new_query_params = query_params; |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 127 | StartLicenseServerIfNeeded(key_system, &new_query_params); |
| 128 | RunMediaTestPage(html_page, new_query_params, expected_title, true); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 129 | } |
| 130 | |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 131 | // Tests |html_page| using |media_file| (with |media_type|) and |key_system|. |
| 132 | // When |session_to_load| is not empty, the test will try to load |
| 133 | // |session_to_load| with stored keys, instead of creating a new session |
| 134 | // and trying to update it with licenses. |
| 135 | // When |force_invalid_response| is true, the test will provide invalid |
| 136 | // responses, which should trigger errors. |
| 137 | // TODO(xhwang): Find an easier way to pass multiple configuration test |
| 138 | // options. |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 139 | void RunEncryptedMediaTest(const std::string& html_page, |
| 140 | const std::string& media_file, |
| 141 | const std::string& media_type, |
| 142 | const std::string& key_system, |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 143 | SrcType src_type, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 144 | EmeVersion eme_version, |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 145 | const std::string& session_to_load, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 146 | bool force_invalid_response, |
| 147 | const std::string& expected_title) { |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 148 | if (src_type == MSE && !IsMSESupported()) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 149 | DVLOG(0) << "Skipping test - MSE not supported."; |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 150 | return; |
| 151 | } |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 152 | base::StringPairs query_params; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 153 | query_params.push_back(std::make_pair("mediaFile", media_file)); |
| 154 | query_params.push_back(std::make_pair("mediaType", media_type)); |
| 155 | query_params.push_back(std::make_pair("keySystem", key_system)); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 156 | if (src_type == MSE) |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 157 | query_params.push_back(std::make_pair("useMSE", "1")); |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 158 | if (eme_version == PREFIXED) |
| 159 | query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 160 | if (force_invalid_response) |
| 161 | query_params.push_back(std::make_pair("forceInvalidResponse", "1")); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 162 | if (!session_to_load.empty()) |
| 163 | query_params.push_back(std::make_pair("sessionToLoad", session_to_load)); |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 164 | RunEncryptedMediaTestPage(html_page, key_system, query_params, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 165 | expected_title); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 166 | } |
| 167 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 168 | void RunSimpleEncryptedMediaTest(const std::string& media_file, |
| 169 | const std::string& media_type, |
| 170 | const std::string& key_system, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 171 | SrcType src_type, |
| 172 | EmeVersion eme_version) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 173 | std::string expected_title = kEnded; |
| 174 | if (!IsPlayBackPossible(key_system)) |
| 175 | expected_title = kEmeKeyError; |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 176 | |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 177 | RunEncryptedMediaTest(kDefaultEmePlayer, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 178 | media_file, |
| 179 | media_type, |
| 180 | key_system, |
| 181 | src_type, |
| 182 | eme_version, |
| 183 | kNoSessionToLoad, |
| 184 | false, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 185 | expected_title); |
| 186 | // Check KeyMessage received for all key systems. |
| 187 | bool receivedKeyMessage = false; |
| 188 | EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 189 | browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 190 | "window.domAutomationController.send(" |
| 191 | "document.querySelector('video').receivedKeyMessage);", |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 192 | &receivedKeyMessage)); |
| 193 | EXPECT_TRUE(receivedKeyMessage); |
| 194 | } |
| 195 | |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 196 | // Starts a license server if available for the |key_system| and adds a |
| 197 | // 'licenseServerURL' query parameter to |query_params|. |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 198 | void StartLicenseServerIfNeeded(const std::string& key_system, |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 199 | base::StringPairs* query_params) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 200 | scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system); |
| 201 | if (!config) |
| 202 | return; |
| 203 | license_server_.reset(new TestLicenseServer(config.Pass())); |
| 204 | EXPECT_TRUE(license_server_->Start()); |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 205 | query_params->push_back( |
| 206 | std::make_pair("licenseServerURL", license_server_->GetServerURL())); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | bool IsPlayBackPossible(const std::string& key_system) { |
| 210 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 211 | if (IsWidevine(key_system) && !GetServerConfig(key_system)) |
| 212 | return false; |
| 213 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 214 | return true; |
| 215 | } |
| 216 | |
| 217 | scoped_ptr<TestLicenseServerConfig> GetServerConfig( |
| 218 | const std::string& key_system) { |
| 219 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 220 | if (IsWidevine(key_system)) { |
| 221 | scoped_ptr<TestLicenseServerConfig> config = |
| 222 | scoped_ptr<TestLicenseServerConfig>(new WVTestLicenseServerConfig()); |
| 223 | if (config->IsPlatformSupported()) |
| 224 | return config.Pass(); |
| 225 | } |
| 226 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 227 | return scoped_ptr<TestLicenseServerConfig>(); |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 228 | } |
| 229 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 230 | protected: |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 231 | scoped_ptr<TestLicenseServer> license_server_; |
| 232 | |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 233 | // We want to fail quickly when a test fails because an error is encountered. |
dcheng | d7e84a05 | 2014-10-22 00:18:51 | [diff] [blame] | 234 | void AddWaitForTitles(content::TitleWatcher* title_watcher) override { |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 235 | MediaBrowserTest::AddWaitForTitles(title_watcher); |
[email protected] | 6778fed | 2013-12-24 20:09:37 | [diff] [blame] | 236 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); |
| 237 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError)); |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 238 | } |
| 239 | |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 240 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | 2289b43 | 2014-08-08 17:52:11 | [diff] [blame] | 241 | #if defined(OS_ANDROID) |
| 242 | command_line->AppendSwitch( |
| 243 | switches::kDisableGestureRequirementForMediaPlayback); |
| 244 | #endif // defined(OS_ANDROID) |
| 245 | } |
| 246 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 247 | void SetUpCommandLineForKeySystem(const std::string& key_system, |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 248 | base::CommandLine* command_line) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 249 | if (GetServerConfig(key_system)) |
| 250 | // Since the web and license servers listen on different ports, we need to |
| 251 | // disable web-security to send license requests to the license server. |
| 252 | // TODO(shadi): Add port forwarding to the test web server configuration. |
| 253 | command_line->AppendSwitch(switches::kDisableWebSecurity); |
| 254 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 255 | #if defined(ENABLE_PEPPER_CDMS) |
| 256 | if (IsExternalClearKey(key_system)) { |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 257 | RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 258 | } |
| 259 | #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
thestig | 11bf74d | 2014-11-24 20:14:42 | [diff] [blame] | 260 | else if (IsWidevine(key_system)) { // NOLINT |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 261 | RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 262 | } |
| 263 | #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 264 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 265 | } |
| 266 | |
| 267 | private: |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 268 | #if defined(ENABLE_PEPPER_CDMS) |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 269 | void RegisterPepperCdm(base::CommandLine* command_line, |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 270 | const std::string& adapter_name, |
| 271 | const std::string& key_system) { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 272 | DCHECK(!is_pepper_cdm_registered_) |
| 273 | << "RegisterPepperCdm() can only be called once."; |
| 274 | is_pepper_cdm_registered_ = true; |
| 275 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 276 | // Append the switch to register the Clear Key CDM Adapter. |
| 277 | base::FilePath plugin_dir; |
| 278 | EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
| 279 | base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 280 | EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 281 | base::FilePath::StringType pepper_plugin = plugin_lib.value(); |
| 282 | pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); |
| 283 | #if defined(OS_WIN) |
thestig | 11bf74d | 2014-11-24 20:14:42 | [diff] [blame] | 284 | pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system))); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 285 | #else |
| 286 | pepper_plugin.append(GetPepperType(key_system)); |
| 287 | #endif |
| 288 | command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
| 289 | pepper_plugin); |
| 290 | } |
| 291 | |
| 292 | // Adapted from key_systems.cc. |
| 293 | std::string GetPepperType(const std::string& key_system) { |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 294 | if (IsExternalClearKey(key_system)) |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 295 | return kClearKeyCdmPluginMimeType; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 296 | #if defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 297 | if (IsWidevine(key_system)) |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 298 | return kWidevineCdmPluginMimeType; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 299 | #endif // WIDEVINE_CDM_AVAILABLE |
| 300 | |
| 301 | NOTREACHED(); |
| 302 | return ""; |
| 303 | } |
| 304 | #endif // defined(ENABLE_PEPPER_CDMS) |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 305 | |
| 306 | bool is_pepper_cdm_registered_; |
| 307 | }; |
| 308 | |
| 309 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 310 | // Tests encrypted media playback using ExternalClearKey key system in |
| 311 | // decrypt-and-decode mode. |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 312 | class ECKEncryptedMediaTest : public EncryptedMediaTestBase { |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 313 | public: |
| 314 | // We use special |key_system| names to do non-playback related tests, e.g. |
| 315 | // kExternalClearKeyFileIOTestKeySystem is used to test file IO. |
| 316 | void TestNonPlaybackCases(const std::string& key_system, |
| 317 | const std::string& expected_title) { |
| 318 | // Since we do not test playback, arbitrarily choose a test file and source |
| 319 | // type. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 320 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", |
| 321 | kWebMAudioOnly, key_system, SRC, UNPREFIXED, |
| 322 | kNoSessionToLoad, false, expected_title); |
| 323 | } |
| 324 | |
| 325 | void TestPlaybackCase(const std::string& session_to_load, |
| 326 | const std::string& expected_title) { |
| 327 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", |
| 328 | kWebMVideoOnly, kExternalClearKeyKeySystem, SRC, |
| 329 | UNPREFIXED, session_to_load, false, expected_title); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 330 | } |
| 331 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 332 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 333 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 334 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 335 | SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
| 336 | } |
| 337 | }; |
| 338 | |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 339 | // Tests encrypted media playback using ExternalClearKey key system in |
| 340 | // decrypt-and-decode mode for unprefixed EME. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 341 | class ECKPrefixedEncryptedMediaTest : public EncryptedMediaTestBase { |
| 342 | public: |
| 343 | // We use special |key_system| names to do non-playback related tests, e.g. |
| 344 | // kExternalClearKeyFileIOTestKeySystem is used to test file IO. |
| 345 | void TestNonPlaybackCases(const std::string& key_system, |
| 346 | const std::string& expected_title) { |
| 347 | // Since we do not test playback, arbitrarily choose a test file and source |
| 348 | // type. |
| 349 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", |
| 350 | kWebMAudioOnly, key_system, SRC, PREFIXED, |
| 351 | kNoSessionToLoad, false, expected_title); |
| 352 | } |
| 353 | |
| 354 | void TestPlaybackCase(const std::string& session_to_load, |
| 355 | const std::string& expected_title) { |
| 356 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", |
| 357 | kWebMVideoOnly, kExternalClearKeyKeySystem, SRC, |
| 358 | PREFIXED, session_to_load, false, expected_title); |
| 359 | } |
| 360 | |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 361 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 362 | void SetUpCommandLine(base::CommandLine* command_line) override { |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 363 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 364 | SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
| 365 | } |
| 366 | }; |
| 367 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 368 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 369 | // Tests encrypted media playback using Widevine key system. |
| 370 | class WVEncryptedMediaTest : public EncryptedMediaTestBase { |
| 371 | protected: |
Daniel Cheng | 43ba4a012 | 2014-12-31 06:30:35 | [diff] [blame] | 372 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 373 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 374 | SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line); |
| 375 | } |
| 376 | }; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 377 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 378 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 379 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 380 | |
| 381 | // Tests encrypted media playback with a combination of parameters: |
| 382 | // - char*: Key system name. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 383 | // - SrcType: Use MSE or SRC. |
| 384 | // - EmeVersion: Use PREFIXED or UNPREFIXED EME. |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 385 | // |
| 386 | // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F) |
| 387 | // tests will crash at GetParam(). To add non-parameterized tests, use |
| 388 | // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest). |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 389 | class EncryptedMediaTest |
| 390 | : public EncryptedMediaTestBase, |
| 391 | public testing::WithParamInterface< |
| 392 | std::tr1::tuple<const char*, SrcType, EmeVersion> > { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 393 | public: |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 394 | std::string CurrentKeySystem() { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 395 | return std::tr1::get<0>(GetParam()); |
| 396 | } |
| 397 | |
| 398 | SrcType CurrentSourceType() { |
| 399 | return std::tr1::get<1>(GetParam()); |
| 400 | } |
| 401 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 402 | EmeVersion CurrentEmeVersion() { |
| 403 | return std::tr1::get<2>(GetParam()); |
| 404 | } |
| 405 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 406 | void TestSimplePlayback(const std::string& encrypted_media, |
| 407 | const std::string& media_type) { |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 408 | RunSimpleEncryptedMediaTest(encrypted_media, |
| 409 | media_type, |
| 410 | CurrentKeySystem(), |
| 411 | CurrentSourceType(), |
| 412 | CurrentEmeVersion()); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 413 | } |
| 414 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 415 | void RunInvalidResponseTest() { |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 416 | RunEncryptedMediaTest(kDefaultEmePlayer, |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 417 | "bear-320x240-av_enc-av.webm", |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 418 | kWebMAudioVideo, |
| 419 | CurrentKeySystem(), |
| 420 | CurrentSourceType(), |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 421 | CurrentEmeVersion(), |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 422 | kNoSessionToLoad, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 423 | true, |
| 424 | kEmeKeyError); |
| 425 | } |
| 426 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 427 | void TestFrameSizeChange() { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 428 | RunEncryptedMediaTest("encrypted_frame_size_change.html", |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 429 | "frame_size_change-av_enc-v.webm", |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 430 | kWebMAudioVideo, |
| 431 | CurrentKeySystem(), |
| 432 | CurrentSourceType(), |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 433 | CurrentEmeVersion(), |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 434 | kNoSessionToLoad, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 435 | false, |
| 436 | kEnded); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | void TestConfigChange() { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 440 | DCHECK(IsMSESupported()); |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 441 | base::StringPairs query_params; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 442 | query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); |
| 443 | query_params.push_back(std::make_pair("runEncrypted", "1")); |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 444 | if (CurrentEmeVersion() == PREFIXED) |
| 445 | query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 446 | RunEncryptedMediaTestPage("mse_config_change.html", |
| 447 | CurrentKeySystem(), |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 448 | query_params, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 449 | kEnded); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 453 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 454 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 455 | SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line); |
| 456 | } |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 457 | }; |
| 458 | |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 459 | using ::testing::Combine; |
| 460 | using ::testing::Values; |
| 461 | |
| 462 | #if !defined(OS_ANDROID) |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 463 | INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed, |
| 464 | EncryptedMediaTest, |
| 465 | Combine(Values(kPrefixedClearKeyKeySystem), |
| 466 | Values(SRC), |
| 467 | Values(PREFIXED))); |
| 468 | |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 469 | INSTANTIATE_TEST_CASE_P(SRC_ClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 470 | EncryptedMediaTest, |
| 471 | Combine(Values(kClearKeyKeySystem), |
| 472 | Values(SRC), |
| 473 | Values(UNPREFIXED))); |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 474 | #endif // !defined(OS_ANDROID) |
| 475 | |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 476 | INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed, |
| 477 | EncryptedMediaTest, |
| 478 | Combine(Values(kPrefixedClearKeyKeySystem), |
| 479 | Values(MSE), |
| 480 | Values(PREFIXED))); |
jrummell | 7741919 | 2014-10-31 21:40:44 | [diff] [blame] | 481 | INSTANTIATE_TEST_CASE_P(MSE_ClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 482 | EncryptedMediaTest, |
| 483 | Combine(Values(kClearKeyKeySystem), |
| 484 | Values(MSE), |
| 485 | Values(UNPREFIXED))); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 486 | |
| 487 | // External Clear Key is currently only used on platforms that use Pepper CDMs. |
| 488 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 489 | INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed, |
| 490 | EncryptedMediaTest, |
| 491 | Combine(Values(kExternalClearKeyKeySystem), |
| 492 | Values(SRC), |
| 493 | Values(PREFIXED))); |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 494 | INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 495 | EncryptedMediaTest, |
| 496 | Combine(Values(kExternalClearKeyKeySystem), |
| 497 | Values(SRC), |
| 498 | Values(UNPREFIXED))); |
| 499 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed, |
| 500 | EncryptedMediaTest, |
| 501 | Combine(Values(kExternalClearKeyKeySystem), |
| 502 | Values(MSE), |
| 503 | Values(PREFIXED))); |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 504 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 505 | EncryptedMediaTest, |
| 506 | Combine(Values(kExternalClearKeyKeySystem), |
| 507 | Values(MSE), |
| 508 | Values(UNPREFIXED))); |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 509 | // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 510 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed, |
| 511 | EncryptedMediaTest, |
| 512 | Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), |
| 513 | Values(MSE), |
| 514 | Values(PREFIXED))); |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 515 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 516 | EncryptedMediaTest, |
| 517 | Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), |
| 518 | Values(MSE), |
| 519 | Values(UNPREFIXED))); |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 520 | #endif // defined(ENABLE_PEPPER_CDMS) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 521 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 522 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 523 | // 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] | 524 | // test with MSE (no SRC) to reduce test time. Also, on Android EME only works |
| 525 | // with MSE and we cannot run this test with SRC. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 526 | INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed, |
| 527 | EncryptedMediaTest, |
| 528 | Combine(Values(kWidevineKeySystem), |
| 529 | Values(MSE), |
| 530 | Values(PREFIXED))); |
[email protected] | 78d9654 | 2014-03-27 11:45:47 | [diff] [blame] | 531 | |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 532 | INSTANTIATE_TEST_CASE_P(MSE_Widevine, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 533 | EncryptedMediaTest, |
| 534 | Combine(Values(kWidevineKeySystem), |
| 535 | Values(MSE), |
| 536 | Values(UNPREFIXED))); |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 537 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 538 | |
jamescook | 6107ed8 | 2014-11-06 06:59:21 | [diff] [blame] | 539 | // These tests time out in Chrome OS official builds. http://crbug.com/430711 |
| 540 | #if !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 541 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 542 | TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 543 | } |
| 544 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 545 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 546 | TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 547 | } |
| 548 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 549 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 550 | TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 551 | } |
| 552 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 553 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 554 | TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 555 | } |
| 556 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 557 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 558 | TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 559 | } |
| 560 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 561 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 562 | TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly); |
[email protected] | 2b197ac7 | 2014-04-11 23:33:52 | [diff] [blame] | 563 | } |
| 564 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 565 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM_Opus) { |
sandersd | 5ec6dcf | 2014-11-26 20:39:38 | [diff] [blame] | 566 | TestSimplePlayback("bear-320x240-opus-a_enc-a.webm", kWebMAudioOnly); |
| 567 | } |
| 568 | |
| 569 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM_Opus) { |
| 570 | TestSimplePlayback("bear-320x240-opus-av_enc-av.webm", kWebMAudioVideo); |
| 571 | } |
| 572 | |
| 573 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) { |
| 574 | TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMAudioVideo); |
| 575 | } |
| 576 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 577 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 578 | RunInvalidResponseTest(); |
| 579 | } |
| 580 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 581 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 582 | if (CurrentSourceType() != MSE || !IsMSESupported()) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 583 | DVLOG(0) << "Skipping test - ConfigChange test requires MSE."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 584 | return; |
| 585 | } |
| 586 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 587 | DVLOG(0) << "Skipping test - ConfigChange test requires video playback."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 588 | return; |
| 589 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 590 | TestConfigChange(); |
| 591 | } |
| 592 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 593 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 594 | // Times out on Windows XP. http://crbug.com/171937 |
| 595 | #if defined(OS_WIN) |
| 596 | if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 597 | return; |
| 598 | #endif |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 599 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 600 | DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 601 | return; |
| 602 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 603 | TestFrameSizeChange(); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | #if defined(USE_PROPRIETARY_CODECS) |
| 607 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 608 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 609 | if (CurrentSourceType() != MSE) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 610 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 611 | return; |
| 612 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 613 | TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 617 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 618 | if (CurrentSourceType() != MSE) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 619 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 620 | return; |
| 621 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 622 | TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 623 | } |
| 624 | #endif // defined(USE_PROPRIETARY_CODECS) |
jamescook | 6107ed8 | 2014-11-06 06:59:21 | [diff] [blame] | 625 | #endif // !(defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 626 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 627 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 628 | // The parent key system cannot be used in generateKeyRequest. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 629 | IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) { |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 630 | RunEncryptedMediaTest(kDefaultEmePlayer, |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 631 | "bear-a_enc-a.webm", |
[email protected] | 297b5a35 | 2013-10-18 00:09:17 | [diff] [blame] | 632 | kWebMAudioOnly, |
| 633 | "com.widevine", |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 634 | MSE, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 635 | PREFIXED, |
| 636 | kNoSessionToLoad, |
| 637 | false, |
| 638 | kEmeNotSupportedError); |
| 639 | } |
| 640 | |
| 641 | // TODO(jrummell): http://crbug.com/349181 |
| 642 | // The parent key system cannot be used when creating MediaKeys. |
[email protected] | b162073 | 2014-04-01 23:17:18 | [diff] [blame] | 643 | IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 644 | RunEncryptedMediaTest(kDefaultEmePlayer, |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 645 | "bear-a_enc-a.webm", |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 646 | kWebMAudioOnly, |
| 647 | "com.widevine", |
| 648 | MSE, |
| 649 | UNPREFIXED, |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 650 | kNoSessionToLoad, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 651 | false, |
[email protected] | 297b5a35 | 2013-10-18 00:09:17 | [diff] [blame] | 652 | kEmeNotSupportedError); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 653 | } |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 654 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 655 | |
| 656 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 657 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 658 | TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, kEmeKeyError); |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 659 | } |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 660 | |
[email protected] | a27d34ab | 2014-01-09 04:23:29 | [diff] [blame] | 661 | // When CDM crashes, we should still get a decode error. |
[email protected] | edaeb3f9 | 2014-06-19 18:27:22 | [diff] [blame] | 662 | // crbug.com/386657 |
| 663 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DISABLED_CDMCrashDuringDecode) { |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 664 | IgnorePluginCrash(); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 665 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError); |
[email protected] | a27d34ab | 2014-01-09 04:23:29 | [diff] [blame] | 666 | } |
| 667 | |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 668 | // Testing that the media browser test does fail on plugin crash. |
[email protected] | edaeb3f9 | 2014-06-19 18:27:22 | [diff] [blame] | 669 | // crbug.com/386657 |
| 670 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DISABLED_CDMExpectedCrash) { |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 671 | // Plugin crash is not ignored by default, the test is expected to fail. |
| 672 | EXPECT_NONFATAL_FAILURE( |
| 673 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError), |
| 674 | "plugin crash"); |
| 675 | } |
| 676 | |
xhwang | 0c617e11 | 2014-09-19 17:33:24 | [diff] [blame] | 677 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 678 | TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, |
| 679 | kFileIOTestSuccess); |
| 680 | } |
| 681 | |
| 682 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 683 | TestPlaybackCase(kLoadableSession, kEnded); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
| 687 | // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 688 | TestPlaybackCase(kUnknownSession, kEmeKeyError); |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 689 | } |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 690 | |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 691 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, InitializeCDMFail) { |
| 692 | TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, kEmeKeyError); |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 693 | } |
| 694 | |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 695 | // When CDM crashes, we should still get a decode error. |
| 696 | // crbug.com/386657 |
| 697 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, |
| 698 | DISABLED_CDMCrashDuringDecode) { |
| 699 | IgnorePluginCrash(); |
| 700 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError); |
| 701 | } |
| 702 | |
| 703 | // Testing that the media browser test does fail on plugin crash. |
| 704 | // crbug.com/386657 |
| 705 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, |
| 706 | DISABLED_CDMExpectedCrash) { |
| 707 | // Plugin crash is not ignored by default, the test is expected to fail. |
| 708 | EXPECT_NONFATAL_FAILURE( |
| 709 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError), |
| 710 | "plugin crash"); |
| 711 | } |
| 712 | |
| 713 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, FileIOTest) { |
| 714 | TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, |
| 715 | kFileIOTestSuccess); |
| 716 | } |
| 717 | |
| 718 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, LoadLoadableSession) { |
| 719 | TestPlaybackCase(kLoadableSession, kEnded); |
| 720 | } |
| 721 | |
| 722 | IN_PROC_BROWSER_TEST_F(ECKPrefixedEncryptedMediaTest, LoadUnknownSession) { |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 723 | // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame^] | 724 | TestPlaybackCase(kUnknownSession, kEmeKeyError); |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 725 | } |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 726 | #endif // defined(ENABLE_PEPPER_CDMS) |