OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "chrome/browser/media/media_browsertest.h" | 10 #include "chrome/browser/media/media_browsertest.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 #if defined(WIDEVINE_CDM_AVAILABLE) | 112 #if defined(WIDEVINE_CDM_AVAILABLE) |
113 bool IsWidevine(const std::string& key_system) { | 113 bool IsWidevine(const std::string& key_system) { |
114 return key_system == kWidevineKeySystem; | 114 return key_system == kWidevineKeySystem; |
115 } | 115 } |
116 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 116 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
117 | 117 |
118 void RunEncryptedMediaTestPage( | 118 void RunEncryptedMediaTestPage( |
119 const std::string& html_page, | 119 const std::string& html_page, |
120 const std::string& key_system, | 120 const std::string& key_system, |
121 const media::QueryParams& query_params, | 121 base::StringPairs& query_params, |
122 const std::string& expected_title) { | 122 const std::string& expected_title) { |
123 media::QueryParams new_query_params = query_params; | 123 base::StringPairs new_query_params = query_params; |
124 StartLicenseServerIfNeeded(key_system, &new_query_params); | 124 StartLicenseServerIfNeeded(key_system, &new_query_params); |
125 RunMediaTestPage(html_page, new_query_params, expected_title, true); | 125 RunMediaTestPage(html_page, new_query_params, expected_title, true); |
126 } | 126 } |
127 | 127 |
128 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|. | 128 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|. |
129 // When |session_to_load| is not empty, the test will try to load | 129 // When |session_to_load| is not empty, the test will try to load |
130 // |session_to_load| with stored keys, instead of creating a new session | 130 // |session_to_load| with stored keys, instead of creating a new session |
131 // and trying to update it with licenses. | 131 // and trying to update it with licenses. |
132 // When |force_invalid_response| is true, the test will provide invalid | 132 // When |force_invalid_response| is true, the test will provide invalid |
133 // responses, which should trigger errors. | 133 // responses, which should trigger errors. |
134 // TODO(xhwang): Find an easier way to pass multiple configuration test | 134 // TODO(xhwang): Find an easier way to pass multiple configuration test |
135 // options. | 135 // options. |
136 void RunEncryptedMediaTest(const std::string& html_page, | 136 void RunEncryptedMediaTest(const std::string& html_page, |
137 const std::string& media_file, | 137 const std::string& media_file, |
138 const std::string& media_type, | 138 const std::string& media_type, |
139 const std::string& key_system, | 139 const std::string& key_system, |
140 SrcType src_type, | 140 SrcType src_type, |
141 EmeVersion eme_version, | 141 EmeVersion eme_version, |
142 const std::string& session_to_load, | 142 const std::string& session_to_load, |
143 bool force_invalid_response, | 143 bool force_invalid_response, |
144 const std::string& expected_title) { | 144 const std::string& expected_title) { |
145 if (src_type == MSE && !IsMSESupported()) { | 145 if (src_type == MSE && !IsMSESupported()) { |
146 VLOG(0) << "Skipping test - MSE not supported."; | 146 VLOG(0) << "Skipping test - MSE not supported."; |
147 return; | 147 return; |
148 } | 148 } |
149 media::QueryParams query_params; | 149 base::StringPairs query_params; |
150 query_params.push_back(std::make_pair("mediaFile", media_file)); | 150 query_params.push_back(std::make_pair("mediaFile", media_file)); |
151 query_params.push_back(std::make_pair("mediaType", media_type)); | 151 query_params.push_back(std::make_pair("mediaType", media_type)); |
152 query_params.push_back(std::make_pair("keySystem", key_system)); | 152 query_params.push_back(std::make_pair("keySystem", key_system)); |
153 if (src_type == MSE) | 153 if (src_type == MSE) |
154 query_params.push_back(std::make_pair("useMSE", "1")); | 154 query_params.push_back(std::make_pair("useMSE", "1")); |
155 if (eme_version == PREFIXED) | 155 if (eme_version == PREFIXED) |
156 query_params.push_back(std::make_pair("usePrefixedEME", "1")); | 156 query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
157 if (force_invalid_response) | 157 if (force_invalid_response) |
158 query_params.push_back(std::make_pair("forceInvalidResponse", "1")); | 158 query_params.push_back(std::make_pair("forceInvalidResponse", "1")); |
159 if (!session_to_load.empty()) | 159 if (!session_to_load.empty()) |
(...skipping 26 matching lines...) Expand all Loading... |
186 browser()->tab_strip_model()->GetActiveWebContents(), | 186 browser()->tab_strip_model()->GetActiveWebContents(), |
187 "window.domAutomationController.send(" | 187 "window.domAutomationController.send(" |
188 "document.querySelector('video').receivedKeyMessage);", | 188 "document.querySelector('video').receivedKeyMessage);", |
189 &receivedKeyMessage)); | 189 &receivedKeyMessage)); |
190 EXPECT_TRUE(receivedKeyMessage); | 190 EXPECT_TRUE(receivedKeyMessage); |
191 } | 191 } |
192 | 192 |
193 // Starts a license server if available for the |key_system| and adds a | 193 // Starts a license server if available for the |key_system| and adds a |
194 // 'licenseServerURL' query parameter to |query_params|. | 194 // 'licenseServerURL' query parameter to |query_params|. |
195 void StartLicenseServerIfNeeded(const std::string& key_system, | 195 void StartLicenseServerIfNeeded(const std::string& key_system, |
196 media::QueryParams* query_params) { | 196 base::StringPairs* query_params) { |
197 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system); | 197 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system); |
198 if (!config) | 198 if (!config) |
199 return; | 199 return; |
200 license_server_.reset(new TestLicenseServer(config.Pass())); | 200 license_server_.reset(new TestLicenseServer(config.Pass())); |
201 EXPECT_TRUE(license_server_->Start()); | 201 EXPECT_TRUE(license_server_->Start()); |
202 query_params->push_back( | 202 query_params->push_back( |
203 std::make_pair("licenseServerURL", license_server_->GetServerURL())); | 203 std::make_pair("licenseServerURL", license_server_->GetServerURL())); |
204 } | 204 } |
205 | 205 |
206 bool IsPlayBackPossible(const std::string& key_system) { | 206 bool IsPlayBackPossible(const std::string& key_system) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 CurrentKeySystem(), | 399 CurrentKeySystem(), |
400 CurrentSourceType(), | 400 CurrentSourceType(), |
401 CurrentEmeVersion(), | 401 CurrentEmeVersion(), |
402 kNoSessionToLoad, | 402 kNoSessionToLoad, |
403 false, | 403 false, |
404 kEnded); | 404 kEnded); |
405 } | 405 } |
406 | 406 |
407 void TestConfigChange() { | 407 void TestConfigChange() { |
408 DCHECK(IsMSESupported()); | 408 DCHECK(IsMSESupported()); |
409 media::QueryParams query_params; | 409 base::StringPairs query_params; |
410 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); | 410 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); |
411 query_params.push_back(std::make_pair("runEncrypted", "1")); | 411 query_params.push_back(std::make_pair("runEncrypted", "1")); |
412 if (CurrentEmeVersion() == PREFIXED) | 412 if (CurrentEmeVersion() == PREFIXED) |
413 query_params.push_back(std::make_pair("usePrefixedEME", "1")); | 413 query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
414 RunEncryptedMediaTestPage("mse_config_change.html", | 414 RunEncryptedMediaTestPage("mse_config_change.html", |
415 CurrentKeySystem(), | 415 CurrentKeySystem(), |
416 query_params, | 416 query_params, |
417 kEnded); | 417 kEnded); |
418 } | 418 } |
419 | 419 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 "bear-320x240-v_enc-v.webm", | 660 "bear-320x240-v_enc-v.webm", |
661 kWebMVideoOnly, | 661 kWebMVideoOnly, |
662 kExternalClearKeyKeySystem, | 662 kExternalClearKeyKeySystem, |
663 SRC, | 663 SRC, |
664 PREFIXED, | 664 PREFIXED, |
665 kUnknownSession, | 665 kUnknownSession, |
666 false, | 666 false, |
667 kEmeKeyError); | 667 kEmeKeyError); |
668 } | 668 } |
669 #endif // defined(ENABLE_PEPPER_CDMS) | 669 #endif // defined(ENABLE_PEPPER_CDMS) |
OLD | NEW |