[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 | |
dcheng | c16dc809 | 2016-04-08 23:12:56 | [diff] [blame] | 5 | #include <memory> |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 6 | #include <utility> |
| 7 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 8 | #include "base/command_line.h" |
| 9 | #include "base/path_service.h" |
| 10 | #include "base/strings/utf_string_conversions.h" |
| 11 | #include "base/win/windows_version.h" |
avi | 6846aef | 2015-12-26 01:09:38 | [diff] [blame] | 12 | #include "build/build_config.h" |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 13 | #include "chrome/browser/media/media_browsertest.h" |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 14 | #include "chrome/browser/media/test_license_server.h" |
| 15 | #include "chrome/browser/media/wv_test_license_server_config.h" |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 16 | #include "chrome/browser/ui/browser.h" |
| 17 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 | #include "chrome/common/chrome_switches.h" |
xhwang | 3be44be | 2016-05-25 17:24:49 | [diff] [blame] | 19 | #include "chrome/test/base/test_launcher_utils.h" |
brettw | 90e9260 | 2015-10-10 00:12:40 | [diff] [blame] | 20 | #include "content/public/common/content_switches.h" |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 21 | #include "content/public/test/browser_test_utils.h" |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 22 | #include "testing/gtest/include/gtest/gtest-spi.h" |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 23 | #if defined(OS_ANDROID) |
| 24 | #include "base/android/build_info.h" |
| 25 | #endif |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 26 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 27 | #if defined(ENABLE_PEPPER_CDMS) |
brettw | f5431b3d | 2016-06-07 23:14:37 | [diff] [blame] | 28 | #include "chrome/browser/media/pepper_cdm_test_constants.h" |
xhwang | b941714 | 2016-05-18 22:23:36 | [diff] [blame] | 29 | #include "chrome/browser/media/pepper_cdm_test_helper.h" |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 30 | #endif |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 31 | |
xhwang | b941714 | 2016-05-18 22:23:36 | [diff] [blame] | 32 | #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 33 | |
| 34 | // Available key systems. |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 35 | const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 36 | const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
xhwang | 640ef5d | 2016-08-17 16:46:08 | [diff] [blame] | 37 | |
| 38 | // Variants of External Clear Key key system to test different scenarios. |
| 39 | // To add a new variant, make sure you also update: |
| 40 | // - media/test/data/eme_player_js/globals.js |
| 41 | // - AddExternalClearKey() in chrome_key_systems.cc |
| 42 | // - CreateCdmInstance() in clear_key_cdm.cc |
xhwang | 0cfb528 | 2016-08-25 03:33:25 | [diff] [blame^] | 43 | const char kExternalClearKeyRenewalKeySystem[] = |
| 44 | "org.chromium.externalclearkey.renewal"; |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 45 | const char kExternalClearKeyFileIOTestKeySystem[] = |
| 46 | "org.chromium.externalclearkey.fileiotest"; |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 47 | const char kExternalClearKeyInitializeFailKeySystem[] = |
| 48 | "org.chromium.externalclearkey.initializefail"; |
xhwang | 640ef5d | 2016-08-17 16:46:08 | [diff] [blame] | 49 | const char kExternalClearKeyOutputProtectionTestKeySystem[] = |
| 50 | "org.chromium.externalclearkey.outputprotectiontest"; |
[email protected] | a27d34ab | 2014-01-09 04:23:29 | [diff] [blame] | 51 | const char kExternalClearKeyCrashKeySystem[] = |
| 52 | "org.chromium.externalclearkey.crash"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 53 | |
| 54 | // Supported media types. |
[email protected] | 095ccbe4 | 2013-09-26 00:06:42 | [diff] [blame] | 55 | const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
| 56 | const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
| 57 | const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; |
jamescook | 6107ed8 | 2014-11-06 06:59:21 | [diff] [blame] | 58 | const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\""; |
[email protected] | 095ccbe4 | 2013-09-26 00:06:42 | [diff] [blame] | 59 | #if defined(USE_PROPRIETARY_CODECS) |
| 60 | const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
| 61 | const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; |
| 62 | #endif // defined(USE_PROPRIETARY_CODECS) |
[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. |
xhwang | 640ef5d | 2016-08-17 16:46:08 | [diff] [blame] | 70 | const char kUnitTestSuccess[] = "UNIT_TEST_SUCCESS"; |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 71 | const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; |
| 72 | const char kEmeGenerateRequestFailed[] = "EME_GENERATEREQUEST_FAILED"; |
jrummell | 14fae6f | 2015-07-10 20:40:15 | [diff] [blame] | 73 | const char kEmeSessionNotFound[] = "EME_SESSION_NOT_FOUND"; |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 74 | const char kEmeLoadFailed[] = "EME_LOAD_FAILED"; |
| 75 | const char kEmeUpdateFailed[] = "EME_UPDATE_FAILED"; |
| 76 | const char kEmeErrorEvent[] = "EME_ERROR_EVENT"; |
| 77 | const char kEmeMessageUnexpectedType[] = "EME_MESSAGE_UNEXPECTED_TYPE"; |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 78 | const char kEmeRenewalMissingHeader[] = "EME_RENEWAL_MISSING_HEADER"; |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 79 | |
| 80 | const char kDefaultEmePlayer[] = "eme_player.html"; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 81 | |
| 82 | // The type of video src used to load media. |
| 83 | enum SrcType { |
| 84 | SRC, |
| 85 | MSE |
| 86 | }; |
| 87 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 88 | // Whether the video should be played once or twice. |
| 89 | enum class PlayTwice { NO, YES }; |
| 90 | |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 91 | // Format of a container when testing different streams. |
| 92 | enum class EncryptedContainer { |
| 93 | CLEAR_WEBM, |
| 94 | CLEAR_MP4, |
| 95 | ENCRYPTED_WEBM, |
| 96 | ENCRYPTED_MP4 |
| 97 | }; |
| 98 | |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 99 | // MSE is available on all desktop platforms and on Android 4.1 and later. |
| 100 | static bool IsMSESupported() { |
| 101 | #if defined(OS_ANDROID) |
| 102 | if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 103 | DVLOG(0) << "MSE is only supported in Android 4.1 and later."; |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 104 | return false; |
| 105 | } |
| 106 | #endif // defined(OS_ANDROID) |
| 107 | return true; |
| 108 | } |
| 109 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 110 | // Base class for encrypted media tests. |
| 111 | class EncryptedMediaTestBase : public MediaBrowserTest { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 112 | public: |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 113 | bool IsExternalClearKey(const std::string& key_system) { |
ddorwin | 40312df | 2016-02-26 01:25:01 | [diff] [blame] | 114 | if (key_system == kExternalClearKeyKeySystem) |
| 115 | return true; |
| 116 | std::string prefix = std::string(kExternalClearKeyKeySystem) + '.'; |
| 117 | return key_system.substr(0, prefix.size()) == prefix; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 118 | } |
| 119 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 120 | #if defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 121 | bool IsWidevine(const std::string& key_system) { |
| 122 | return key_system == kWidevineKeySystem; |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 123 | } |
| 124 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 125 | |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 126 | void RunEncryptedMediaTestPage( |
| 127 | const std::string& html_page, |
| 128 | const std::string& key_system, |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 129 | base::StringPairs& query_params, |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 130 | const std::string& expected_title) { |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 131 | base::StringPairs new_query_params = query_params; |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 132 | StartLicenseServerIfNeeded(key_system, &new_query_params); |
| 133 | RunMediaTestPage(html_page, new_query_params, expected_title, true); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 134 | } |
| 135 | |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 136 | // Tests |html_page| using |media_file| (with |media_type|) and |key_system|. |
| 137 | // When |session_to_load| is not empty, the test will try to load |
| 138 | // |session_to_load| with stored keys, instead of creating a new session |
| 139 | // and trying to update it with licenses. |
| 140 | // When |force_invalid_response| is true, the test will provide invalid |
| 141 | // responses, which should trigger errors. |
| 142 | // TODO(xhwang): Find an easier way to pass multiple configuration test |
| 143 | // options. |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 144 | void RunEncryptedMediaTest(const std::string& html_page, |
| 145 | const std::string& media_file, |
| 146 | const std::string& media_type, |
| 147 | const std::string& key_system, |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 148 | SrcType src_type, |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 149 | const std::string& session_to_load, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 150 | bool force_invalid_response, |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 151 | PlayTwice play_twice, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 152 | const std::string& expected_title) { |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 153 | if (src_type == MSE && !IsMSESupported()) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 154 | DVLOG(0) << "Skipping test - MSE not supported."; |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 155 | return; |
| 156 | } |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 157 | base::StringPairs query_params; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 158 | query_params.push_back(std::make_pair("mediaFile", media_file)); |
| 159 | query_params.push_back(std::make_pair("mediaType", media_type)); |
| 160 | query_params.push_back(std::make_pair("keySystem", key_system)); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 161 | if (src_type == MSE) |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 162 | query_params.push_back(std::make_pair("useMSE", "1")); |
| 163 | if (force_invalid_response) |
| 164 | query_params.push_back(std::make_pair("forceInvalidResponse", "1")); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 165 | if (!session_to_load.empty()) |
| 166 | query_params.push_back(std::make_pair("sessionToLoad", session_to_load)); |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 167 | if (play_twice == PlayTwice::YES) |
| 168 | query_params.push_back(std::make_pair("playTwice", "1")); |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 169 | RunEncryptedMediaTestPage(html_page, key_system, query_params, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 170 | expected_title); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 171 | } |
| 172 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 173 | void RunSimpleEncryptedMediaTest(const std::string& media_file, |
| 174 | const std::string& media_type, |
| 175 | const std::string& key_system, |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 176 | SrcType src_type) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 177 | std::string expected_title = kEnded; |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 178 | if (!IsPlayBackPossible(key_system)) { |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 179 | expected_title = kEmeUpdateFailed; |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 180 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 181 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 182 | RunEncryptedMediaTest(kDefaultEmePlayer, media_file, media_type, key_system, |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 183 | src_type, kNoSessionToLoad, false, PlayTwice::NO, |
| 184 | expected_title); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 185 | // Check KeyMessage received for all key systems. |
| 186 | bool receivedKeyMessage = false; |
| 187 | EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 188 | browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | e11d89d | 2014-06-19 11:36:31 | [diff] [blame] | 189 | "window.domAutomationController.send(" |
| 190 | "document.querySelector('video').receivedKeyMessage);", |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 191 | &receivedKeyMessage)); |
| 192 | EXPECT_TRUE(receivedKeyMessage); |
| 193 | } |
| 194 | |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 195 | // Starts a license server if available for the |key_system| and adds a |
| 196 | // 'licenseServerURL' query parameter to |query_params|. |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 197 | void StartLicenseServerIfNeeded(const std::string& key_system, |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 198 | base::StringPairs* query_params) { |
dcheng | c16dc809 | 2016-04-08 23:12:56 | [diff] [blame] | 199 | std::unique_ptr<TestLicenseServerConfig> config = |
| 200 | GetServerConfig(key_system); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 201 | if (!config) |
| 202 | return; |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 203 | license_server_.reset(new TestLicenseServer(std::move(config))); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 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 | |
dcheng | c16dc809 | 2016-04-08 23:12:56 | [diff] [blame] | 217 | std::unique_ptr<TestLicenseServerConfig> GetServerConfig( |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 218 | const std::string& key_system) { |
| 219 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 220 | if (IsWidevine(key_system)) { |
dcheng | c16dc809 | 2016-04-08 23:12:56 | [diff] [blame] | 221 | std::unique_ptr<TestLicenseServerConfig> config( |
| 222 | new WVTestLicenseServerConfig); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 223 | if (config->IsPlatformSupported()) |
dcheng | 7c133cc | 2015-12-31 06:57:59 | [diff] [blame] | 224 | return config; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 225 | } |
| 226 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
dcheng | 7c133cc | 2015-12-31 06:57:59 | [diff] [blame] | 227 | return nullptr; |
[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: |
dcheng | c16dc809 | 2016-04-08 23:12:56 | [diff] [blame] | 231 | std::unique_ptr<TestLicenseServer> license_server_; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 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)); |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 237 | title_watcher->AlsoWaitForTitle( |
| 238 | base::ASCIIToUTF16(kEmeGenerateRequestFailed)); |
jrummell | 14fae6f | 2015-07-10 20:40:15 | [diff] [blame] | 239 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeSessionNotFound)); |
jrummell | 0c6ba54 | 2015-07-08 18:04:44 | [diff] [blame] | 240 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeLoadFailed)); |
| 241 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeUpdateFailed)); |
| 242 | title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeErrorEvent)); |
| 243 | title_watcher->AlsoWaitForTitle( |
| 244 | base::ASCIIToUTF16(kEmeMessageUnexpectedType)); |
| 245 | title_watcher->AlsoWaitForTitle( |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 246 | base::ASCIIToUTF16(kEmeRenewalMissingHeader)); |
[email protected] | 2e850f1 | 2013-09-18 01:27:29 | [diff] [blame] | 247 | } |
| 248 | |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 249 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | 2289b43 | 2014-08-08 17:52:11 | [diff] [blame] | 250 | command_line->AppendSwitch( |
| 251 | switches::kDisableGestureRequirementForMediaPlayback); |
[email protected] | 2289b43 | 2014-08-08 17:52:11 | [diff] [blame] | 252 | } |
| 253 | |
xhwang | 3be44be | 2016-05-25 17:24:49 | [diff] [blame] | 254 | #if defined(ENABLE_PEPPER_CDMS) |
| 255 | void SetUpDefaultCommandLine(base::CommandLine* command_line) override { |
| 256 | base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); |
| 257 | InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); |
| 258 | test_launcher_utils::RemoveCommandLineSwitch( |
| 259 | default_command_line, switches::kDisableComponentUpdate, command_line); |
| 260 | } |
| 261 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 262 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 263 | void SetUpCommandLineForKeySystem(const std::string& key_system, |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 264 | base::CommandLine* command_line) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 265 | if (GetServerConfig(key_system)) |
| 266 | // Since the web and license servers listen on different ports, we need to |
| 267 | // disable web-security to send license requests to the license server. |
| 268 | // TODO(shadi): Add port forwarding to the test web server configuration. |
| 269 | command_line->AppendSwitch(switches::kDisableWebSecurity); |
| 270 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 271 | #if defined(ENABLE_PEPPER_CDMS) |
| 272 | if (IsExternalClearKey(key_system)) { |
xhwang | c3a252b | 2016-05-23 02:35:48 | [diff] [blame] | 273 | RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory, |
| 274 | kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName, |
| 275 | kClearKeyCdmPepperMimeType); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 276 | } |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 277 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 278 | } |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 279 | }; |
| 280 | |
| 281 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 282 | // Tests encrypted media playback using ExternalClearKey key system in |
| 283 | // decrypt-and-decode mode. |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 284 | class ECKEncryptedMediaTest : public EncryptedMediaTestBase { |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 285 | public: |
| 286 | // We use special |key_system| names to do non-playback related tests, e.g. |
| 287 | // kExternalClearKeyFileIOTestKeySystem is used to test file IO. |
| 288 | void TestNonPlaybackCases(const std::string& key_system, |
| 289 | const std::string& expected_title) { |
| 290 | // Since we do not test playback, arbitrarily choose a test file and source |
| 291 | // type. |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 292 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", |
| 293 | kWebMAudioOnly, key_system, SRC, kNoSessionToLoad, |
| 294 | false, PlayTwice::NO, expected_title); |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 295 | } |
| 296 | |
xhwang | 0cfb528 | 2016-08-25 03:33:25 | [diff] [blame^] | 297 | void TestPlaybackCase(const std::string& key_system, |
| 298 | const std::string& session_to_load, |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 299 | const std::string& expected_title) { |
| 300 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", |
xhwang | 0cfb528 | 2016-08-25 03:33:25 | [diff] [blame^] | 301 | kWebMVideoOnly, key_system, SRC, session_to_load, |
| 302 | false, PlayTwice::NO, expected_title); |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 303 | } |
| 304 | |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 305 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 306 | void SetUpCommandLine(base::CommandLine* command_line) override { |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 307 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 308 | SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
| 309 | } |
| 310 | }; |
| 311 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 312 | #if defined(WIDEVINE_CDM_AVAILABLE) |
| 313 | // Tests encrypted media playback using Widevine key system. |
| 314 | class WVEncryptedMediaTest : public EncryptedMediaTestBase { |
| 315 | protected: |
Daniel Cheng | 43ba4a012 | 2014-12-31 06:30:35 | [diff] [blame] | 316 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 317 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 318 | SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line); |
| 319 | } |
| 320 | }; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 321 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 322 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 323 | #endif // defined(ENABLE_PEPPER_CDMS) |
| 324 | |
| 325 | // Tests encrypted media playback with a combination of parameters: |
| 326 | // - char*: Key system name. |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 327 | // - SrcType: Use MSE or SRC. |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 328 | // |
| 329 | // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F) |
| 330 | // tests will crash at GetParam(). To add non-parameterized tests, use |
| 331 | // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest). |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 332 | class EncryptedMediaTest : public EncryptedMediaTestBase, |
| 333 | public testing::WithParamInterface< |
| 334 | std::tr1::tuple<const char*, SrcType>> { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 335 | public: |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 336 | std::string CurrentKeySystem() { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 337 | return std::tr1::get<0>(GetParam()); |
| 338 | } |
| 339 | |
| 340 | SrcType CurrentSourceType() { |
| 341 | return std::tr1::get<1>(GetParam()); |
| 342 | } |
| 343 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 344 | void TestSimplePlayback(const std::string& encrypted_media, |
| 345 | const std::string& media_type) { |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 346 | RunSimpleEncryptedMediaTest(encrypted_media, media_type, CurrentKeySystem(), |
| 347 | CurrentSourceType()); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 348 | } |
| 349 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 350 | void TestMultiplePlayback(const std::string& encrypted_media, |
| 351 | const std::string& media_type) { |
jrummell | d9dc790 | 2015-03-16 20:59:28 | [diff] [blame] | 352 | DCHECK(IsPlayBackPossible(CurrentKeySystem())); |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 353 | RunEncryptedMediaTest(kDefaultEmePlayer, encrypted_media, media_type, |
| 354 | CurrentKeySystem(), CurrentSourceType(), |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 355 | kNoSessionToLoad, false, PlayTwice::YES, kEnded); |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 356 | } |
| 357 | |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 358 | void RunInvalidResponseTest() { |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 359 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-av_enc-av.webm", |
| 360 | kWebMAudioVideo, CurrentKeySystem(), |
| 361 | CurrentSourceType(), kNoSessionToLoad, true, |
| 362 | PlayTwice::NO, kEmeUpdateFailed); |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 363 | } |
| 364 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 365 | void TestFrameSizeChange() { |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 366 | RunEncryptedMediaTest("encrypted_frame_size_change.html", |
| 367 | "frame_size_change-av_enc-v.webm", kWebMAudioVideo, |
| 368 | CurrentKeySystem(), CurrentSourceType(), |
| 369 | kNoSessionToLoad, false, PlayTwice::NO, kEnded); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | void TestConfigChange() { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 373 | DCHECK(IsMSESupported()); |
anand.ratn | 2636d97 | 2014-09-30 04:06:58 | [diff] [blame] | 374 | base::StringPairs query_params; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 375 | query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); |
| 376 | query_params.push_back(std::make_pair("runEncrypted", "1")); |
| 377 | RunEncryptedMediaTestPage("mse_config_change.html", |
| 378 | CurrentKeySystem(), |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 379 | query_params, |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 380 | kEnded); |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 381 | } |
| 382 | |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 383 | std::string ConvertContainerFormat(EncryptedContainer format) { |
| 384 | switch (format) { |
| 385 | case EncryptedContainer::CLEAR_MP4: |
| 386 | return "CLEAR_MP4"; |
| 387 | case EncryptedContainer::CLEAR_WEBM: |
| 388 | return "CLEAR_WEBM"; |
| 389 | case EncryptedContainer::ENCRYPTED_MP4: |
| 390 | return "ENCRYPTED_MP4"; |
| 391 | case EncryptedContainer::ENCRYPTED_WEBM: |
| 392 | return "ENCRYPTED_WEBM"; |
| 393 | } |
| 394 | NOTREACHED(); |
| 395 | return "UNKNOWN"; |
| 396 | } |
| 397 | |
| 398 | void TestDifferentContainers(EncryptedContainer video_format, |
| 399 | EncryptedContainer audio_format) { |
| 400 | DCHECK(IsMSESupported()); |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 401 | base::StringPairs query_params; |
| 402 | query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); |
| 403 | query_params.push_back(std::make_pair("runEncrypted", "1")); |
| 404 | query_params.push_back( |
| 405 | std::make_pair("videoFormat", ConvertContainerFormat(video_format))); |
| 406 | query_params.push_back( |
| 407 | std::make_pair("audioFormat", ConvertContainerFormat(audio_format))); |
| 408 | RunEncryptedMediaTestPage("mse_different_containers.html", |
| 409 | CurrentKeySystem(), query_params, kEnded); |
| 410 | } |
| 411 | |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 412 | protected: |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 413 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | e6bf6414 | 2013-10-18 23:07:54 | [diff] [blame] | 414 | EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 415 | SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line); |
| 416 | } |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 417 | }; |
| 418 | |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 419 | using ::testing::Combine; |
| 420 | using ::testing::Values; |
| 421 | |
| 422 | #if !defined(OS_ANDROID) |
jrummell | 19f2c90 | 2015-02-11 01:17:50 | [diff] [blame] | 423 | INSTANTIATE_TEST_CASE_P(SRC_ClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 424 | EncryptedMediaTest, |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 425 | Combine(Values(kClearKeyKeySystem), Values(SRC))); |
[email protected] | 6479b19 | 2013-10-19 18:28:04 | [diff] [blame] | 426 | #endif // !defined(OS_ANDROID) |
| 427 | |
jrummell | 7741919 | 2014-10-31 21:40:44 | [diff] [blame] | 428 | INSTANTIATE_TEST_CASE_P(MSE_ClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 429 | EncryptedMediaTest, |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 430 | Combine(Values(kClearKeyKeySystem), Values(MSE))); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 431 | |
| 432 | // External Clear Key is currently only used on platforms that use Pepper CDMs. |
| 433 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 434 | INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 435 | EncryptedMediaTest, |
| 436 | Combine(Values(kExternalClearKeyKeySystem), |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 437 | Values(SRC))); |
jam | 79bf1f6c | 2015-08-13 20:46:04 | [diff] [blame] | 438 | |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 439 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 440 | EncryptedMediaTest, |
| 441 | Combine(Values(kExternalClearKeyKeySystem), |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 442 | Values(MSE))); |
mnissler | 2702537 | 2015-10-19 14:26:23 | [diff] [blame] | 443 | |
mnissler | 2702537 | 2015-10-19 14:26:23 | [diff] [blame] | 444 | const char kExternalClearKeyDecryptOnlyKeySystem[] = |
| 445 | "org.chromium.externalclearkey.decryptonly"; |
| 446 | |
[email protected] | ab998e8 | 2013-11-22 20:31:35 | [diff] [blame] | 447 | // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE. |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 448 | INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 449 | EncryptedMediaTest, |
| 450 | Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 451 | Values(MSE))); |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 452 | #endif // defined(ENABLE_PEPPER_CDMS) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 453 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 454 | #if defined(WIDEVINE_CDM_AVAILABLE) |
jonross | 5785b866 | 2015-10-22 21:12:53 | [diff] [blame] | 455 | #if !defined(OS_CHROMEOS) |
[email protected] | 1ab297a | 2014-03-26 04:52:12 | [diff] [blame] | 456 | INSTANTIATE_TEST_CASE_P(MSE_Widevine, |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 457 | EncryptedMediaTest, |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 458 | Combine(Values(kWidevineKeySystem), Values(MSE))); |
jonross | 5785b866 | 2015-10-22 21:12:53 | [diff] [blame] | 459 | #endif // !defined(OS_CHROMEOS) |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 460 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 461 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 462 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 463 | TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 464 | } |
| 465 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 466 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 467 | TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 468 | } |
| 469 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 470 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 471 | TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 472 | } |
| 473 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 474 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 475 | TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 476 | } |
| 477 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 478 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 479 | TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 480 | } |
| 481 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 482 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) { |
[email protected] | 8a22932 | 2014-07-22 23:33:07 | [diff] [blame] | 483 | TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly); |
[email protected] | 2b197ac7 | 2014-04-11 23:33:52 | [diff] [blame] | 484 | } |
| 485 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 486 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM_Opus) { |
sandersd | 5ec6dcf | 2014-11-26 20:39:38 | [diff] [blame] | 487 | TestSimplePlayback("bear-320x240-opus-a_enc-a.webm", kWebMAudioOnly); |
| 488 | } |
| 489 | |
| 490 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM_Opus) { |
| 491 | TestSimplePlayback("bear-320x240-opus-av_enc-av.webm", kWebMAudioVideo); |
| 492 | } |
| 493 | |
| 494 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) { |
| 495 | TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMAudioVideo); |
| 496 | } |
| 497 | |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 498 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Multiple_VideoAudio_WebM) { |
jrummell | d9dc790 | 2015-03-16 20:59:28 | [diff] [blame] | 499 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
| 500 | DVLOG(0) << "Skipping test - Playback_Multiple test requires playback."; |
| 501 | return; |
| 502 | } |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 503 | TestMultiplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo); |
| 504 | } |
| 505 | |
[email protected] | 626e517c | 2014-08-19 00:49:46 | [diff] [blame] | 506 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 507 | RunInvalidResponseTest(); |
| 508 | } |
| 509 | |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 510 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 511 | if (CurrentSourceType() != MSE || !IsMSESupported()) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 512 | DVLOG(0) << "Skipping test - ConfigChange test requires MSE."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 513 | return; |
| 514 | } |
| 515 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 516 | DVLOG(0) << "Skipping test - ConfigChange test requires video playback."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 517 | return; |
| 518 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 519 | TestConfigChange(); |
| 520 | } |
| 521 | |
jrummell | 2fe8767 | 2015-01-02 19:13:51 | [diff] [blame] | 522 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 523 | // Times out on Windows XP. http://crbug.com/171937 |
| 524 | #if defined(OS_WIN) |
| 525 | if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 526 | return; |
| 527 | #endif |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 528 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 529 | DVLOG(0) << "Skipping test - FrameSizeChange test requires video playback."; |
[email protected] | df06a3e | 2014-01-31 21:36:59 | [diff] [blame] | 530 | return; |
| 531 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 532 | TestFrameSizeChange(); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | #if defined(USE_PROPRIETARY_CODECS) |
Vasilii Sukhanov | a6b5cff | 2016-06-21 11:04:37 | [diff] [blame] | 536 | // Crashes on Mac only. http://crbug.com/621857 |
| 537 | #if defined(OS_MACOSX) |
| 538 | #define MAYBE_Playback_VideoOnly_MP4 DISABLED_Playback_VideoOnly_MP4 |
| 539 | #else |
| 540 | #define MAYBE_Playback_VideoOnly_MP4 Playback_VideoOnly_MP4 |
| 541 | #endif |
| 542 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, MAYBE_Playback_VideoOnly_MP4) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 543 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 544 | if (CurrentSourceType() != MSE) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 545 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 546 | return; |
| 547 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 548 | TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) { |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 552 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 553 | if (CurrentSourceType() != MSE) { |
anujk.sharma | 9da298e1 | 2014-11-07 04:48:43 | [diff] [blame] | 554 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 555 | return; |
| 556 | } |
[email protected] | 1825e77 | 2013-10-08 06:39:11 | [diff] [blame] | 557 | TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 558 | } |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 559 | |
| 560 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, |
| 561 | Playback_EncryptedVideo_MP4_ClearAudio_WEBM) { |
| 562 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
| 563 | if (CurrentSourceType() != MSE) { |
| 564 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
| 565 | return; |
| 566 | } |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 567 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
| 568 | DVLOG(0) << "Skipping test - Test requires video playback."; |
| 569 | return; |
| 570 | } |
| 571 | TestDifferentContainers(EncryptedContainer::ENCRYPTED_MP4, |
| 572 | EncryptedContainer::CLEAR_WEBM); |
| 573 | } |
| 574 | |
| 575 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, |
| 576 | Playback_ClearVideo_WEBM_EncryptedAudio_MP4) { |
| 577 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
| 578 | if (CurrentSourceType() != MSE) { |
| 579 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
| 580 | return; |
| 581 | } |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 582 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
| 583 | DVLOG(0) << "Skipping test - Test requires video playback."; |
| 584 | return; |
| 585 | } |
| 586 | TestDifferentContainers(EncryptedContainer::CLEAR_WEBM, |
| 587 | EncryptedContainer::ENCRYPTED_MP4); |
| 588 | } |
| 589 | |
| 590 | IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, |
| 591 | Playback_EncryptedVideo_WEBM_EncryptedAudio_MP4) { |
| 592 | // MP4 without MSE is not support yet, http://crbug.com/170793. |
| 593 | if (CurrentSourceType() != MSE) { |
| 594 | DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
| 595 | return; |
| 596 | } |
jrummell | c015cb96 | 2015-07-17 00:41:30 | [diff] [blame] | 597 | if (!IsPlayBackPossible(CurrentKeySystem())) { |
| 598 | DVLOG(0) << "Skipping test - Test requires video playback."; |
| 599 | return; |
| 600 | } |
| 601 | TestDifferentContainers(EncryptedContainer::ENCRYPTED_WEBM, |
| 602 | EncryptedContainer::ENCRYPTED_MP4); |
| 603 | } |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 604 | #endif // defined(USE_PROPRIETARY_CODECS) |
| 605 | |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 606 | #if defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | a32ef59 | 2014-03-07 19:11:15 | [diff] [blame] | 607 | // The parent key system cannot be used when creating MediaKeys. |
[email protected] | b162073 | 2014-04-01 23:17:18 | [diff] [blame] | 608 | IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { |
jrummell | b394463 | 2015-03-14 00:19:42 | [diff] [blame] | 609 | RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", kWebMAudioOnly, |
ddorwin | fdb9a2b | 2016-02-22 22:25:10 | [diff] [blame] | 610 | "com.widevine", MSE, kNoSessionToLoad, false, |
| 611 | PlayTwice::NO, kEmeNotSupportedError); |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 612 | } |
[email protected] | 63dc907 | 2013-09-12 06:20:47 | [diff] [blame] | 613 | #endif // defined(WIDEVINE_CDM_AVAILABLE) |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 614 | |
| 615 | #if defined(ENABLE_PEPPER_CDMS) |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 616 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 617 | TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, |
| 618 | kEmeNotSupportedError); |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 619 | } |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 620 | |
jrummell | fed298d2 | 2015-07-01 00:26:51 | [diff] [blame] | 621 | // When CDM crashes, we should still get a decode error. |kError| is reported |
| 622 | // when the HTMLVideoElement error event fires, indicating an error happened |
| 623 | // during playback. |
| 624 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) { |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 625 | IgnorePluginCrash(); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 626 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError); |
[email protected] | a27d34ab | 2014-01-09 04:23:29 | [diff] [blame] | 627 | } |
| 628 | |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 629 | // Testing that the media browser test does fail on plugin crash. |
jrummell | fed298d2 | 2015-07-01 00:26:51 | [diff] [blame] | 630 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMExpectedCrash) { |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 631 | // Plugin crash is not ignored by default, the test is expected to fail. |
| 632 | EXPECT_NONFATAL_FAILURE( |
| 633 | TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError), |
jrummell | fed298d2 | 2015-07-01 00:26:51 | [diff] [blame] | 634 | "Failing test due to plugin crash."); |
[email protected] | 1be9fa07 | 2014-03-21 22:50:29 | [diff] [blame] | 635 | } |
| 636 | |
xhwang | 0c617e11 | 2014-09-19 17:33:24 | [diff] [blame] | 637 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { |
xhwang | 640ef5d | 2016-08-17 16:46:08 | [diff] [blame] | 638 | TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, kUnitTestSuccess); |
| 639 | } |
| 640 | |
| 641 | // TODO(xhwang): Investigate how to fake capturing activities to test the |
| 642 | // network link detection logic in OutputProtectionProxy. |
| 643 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, OutputProtectionTest) { |
| 644 | TestNonPlaybackCases(kExternalClearKeyOutputProtectionTestKeySystem, |
| 645 | kUnitTestSuccess); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 646 | } |
| 647 | |
xhwang | 0cfb528 | 2016-08-25 03:33:25 | [diff] [blame^] | 648 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, Renewal) { |
| 649 | TestPlaybackCase(kExternalClearKeyRenewalKeySystem, kNoSessionToLoad, kEnded); |
| 650 | } |
| 651 | |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 652 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
xhwang | 0cfb528 | 2016-08-25 03:33:25 | [diff] [blame^] | 653 | TestPlaybackCase(kExternalClearKeyKeySystem, kLoadableSession, kEnded); |
[email protected] | 0af5dfa | 2014-02-07 22:33:44 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
xhwang | 0cfb528 | 2016-08-25 03:33:25 | [diff] [blame^] | 657 | TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession, |
| 658 | kEmeSessionNotFound); |
[email protected] | 34afd58 | 2013-12-20 07:26:18 | [diff] [blame] | 659 | } |
jrummell | c467d23 | 2014-10-21 17:55:22 | [diff] [blame] | 660 | |
[email protected] | a941d4e57 | 2013-10-14 21:22:05 | [diff] [blame] | 661 | #endif // defined(ENABLE_PEPPER_CDMS) |