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