Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/media/encrypted_media_browsertest.cc

Issue 27230004: Do not run MSE related tests when MSE is not available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/path_service.h" 6 #include "base/path_service.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
9 #include "chrome/browser/media/media_browsertest.h" 9 #include "chrome/browser/media/media_browsertest.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
14 #if defined(OS_ANDROID)
15 #include "base/android/build_info.h"
16 #endif
14 17
15 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
16 19
17 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) 20 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX)
18 #include <gnu/libc-version.h> 21 #include <gnu/libc-version.h>
19 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) 22 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX)
20 23
21 #if defined(ENABLE_PEPPER_CDMS) 24 #if defined(ENABLE_PEPPER_CDMS)
22 // Platform-specific filename relative to the chrome executable. 25 // Platform-specific filename relative to the chrome executable.
23 const char kClearKeyCdmAdapterFileName[] = 26 const char kClearKeyCdmAdapterFileName[] =
(...skipping 25 matching lines...) Expand all
49 // EME-specific test results and errors. 52 // EME-specific test results and errors.
50 const char kEmeKeyError[] = "KEYERROR"; 53 const char kEmeKeyError[] = "KEYERROR";
51 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; 54 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
52 55
53 // The type of video src used to load media. 56 // The type of video src used to load media.
54 enum SrcType { 57 enum SrcType {
55 SRC, 58 SRC,
56 MSE 59 MSE
57 }; 60 };
58 61
62 // MSE is available on all desktop platforms and on Android 4.1 and later.
63 static bool IsMSESupported() {
64 #if defined(OS_ANDROID)
65 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
66 LOG(INFO) << "MSE is only supported in Android 4.1 and later.";
67 return false;
68 }
69 #endif // defined(OS_ANDROID)
70 return true;
71 }
72
59 // Base class for encrypted media tests. 73 // Base class for encrypted media tests.
60 class EncryptedMediaTestBase : public MediaBrowserTest { 74 class EncryptedMediaTestBase : public MediaBrowserTest {
61 public: 75 public:
62 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} 76 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {}
63 77
64 bool IsExternalClearKey(const char* key_system) { 78 bool IsExternalClearKey(const char* key_system) {
65 return (strcmp(key_system, kExternalClearKeyKeySystem) == 0); 79 return (strcmp(key_system, kExternalClearKeyKeySystem) == 0);
66 } 80 }
67 81
68 #if defined(WIDEVINE_CDM_AVAILABLE) 82 #if defined(WIDEVINE_CDM_AVAILABLE)
69 bool IsWidevine(const char* key_system) { 83 bool IsWidevine(const char* key_system) {
70 return (strcmp(key_system, kWidevineKeySystem) == 0); 84 return (strcmp(key_system, kWidevineKeySystem) == 0);
71 } 85 }
72 #endif // defined(WIDEVINE_CDM_AVAILABLE) 86 #endif // defined(WIDEVINE_CDM_AVAILABLE)
73 87
74 void RunEncryptedMediaTest(const char* html_page, 88 void RunEncryptedMediaTest(const char* html_page,
75 const char* media_file, 89 const char* media_file,
76 const char* media_type, 90 const char* media_type,
77 const char* key_system, 91 const char* key_system,
78 SrcType src_type, 92 SrcType src_type,
79 const char* expectation) { 93 const char* expectation) {
94 if (src_type == MSE && !IsMSESupported()) {
95 LOG(INFO) << "Skipping test - MSE not supported.";
96 return;
97 }
98
80 std::vector<StringPair> query_params; 99 std::vector<StringPair> query_params;
81 query_params.push_back(std::make_pair("mediafile", media_file)); 100 query_params.push_back(std::make_pair("mediafile", media_file));
82 query_params.push_back(std::make_pair("mediatype", media_type)); 101 query_params.push_back(std::make_pair("mediatype", media_type));
83 query_params.push_back(std::make_pair("keysystem", key_system)); 102 query_params.push_back(std::make_pair("keysystem", key_system));
84 if (src_type == MSE) 103 if (src_type == MSE)
85 query_params.push_back(std::make_pair("usemse", "1")); 104 query_params.push_back(std::make_pair("usemse", "1"));
86 RunMediaTestPage(html_page, &query_params, expectation, true); 105 RunMediaTestPage(html_page, &query_params, expectation, true);
87 } 106 }
88 107
89 void RunSimpleEncryptedMediaTest(const char* media_file, 108 void RunSimpleEncryptedMediaTest(const char* media_file,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 LOG(INFO) << "FrameSizeChange test cannot run with Widevine."; 273 LOG(INFO) << "FrameSizeChange test cannot run with Widevine.";
255 return; 274 return;
256 } 275 }
257 #endif // defined(WIDEVINE_CDM_AVAILABLE) 276 #endif // defined(WIDEVINE_CDM_AVAILABLE)
258 RunEncryptedMediaTest("encrypted_frame_size_change.html", 277 RunEncryptedMediaTest("encrypted_frame_size_change.html",
259 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, 278 "frame_size_change-av-enc-v.webm", kWebMAudioVideo,
260 CurrentKeySystem(), CurrentSourceType(), kEnded); 279 CurrentKeySystem(), CurrentSourceType(), kEnded);
261 } 280 }
262 281
263 void TestConfigChange() { 282 void TestConfigChange() {
283 if (CurrentSourceType() != MSE || !IsMSESupported()) {
284 LOG(INFO) << "Skipping test - config change test requires MSE.";
285 return;
286 }
264 #if defined(WIDEVINE_CDM_AVAILABLE) 287 #if defined(WIDEVINE_CDM_AVAILABLE)
265 if (IsWidevine(CurrentKeySystem())) { 288 if (IsWidevine(CurrentKeySystem())) {
266 LOG(INFO) << "ConfigChange test cannot run with Widevine."; 289 LOG(INFO) << "ConfigChange test cannot run with Widevine.";
267 return; 290 return;
268 } 291 }
269 #endif // defined(WIDEVINE_CDM_AVAILABLE) 292 #endif // defined(WIDEVINE_CDM_AVAILABLE)
270 std::vector<StringPair> query_params; 293 std::vector<StringPair> query_params;
271 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); 294 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem()));
272 query_params.push_back(std::make_pair("runencrypted", "1")); 295 query_params.push_back(std::make_pair("runencrypted", "1"));
273 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); 296 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true);
274 } 297 }
275 298
276 protected: 299 protected:
277 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 300 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
278 EncryptedMediaTestBase::SetUpCommandLine(command_line); 301 EncryptedMediaTestBase::SetUpCommandLine(command_line);
279 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line); 302 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line);
280 } 303 }
281 }; 304 };
282 305
283 INSTANTIATE_TEST_CASE_P(ClearKey, EncryptedMediaTest, 306 using ::testing::Combine;
284 ::testing::Combine( 307 using ::testing::Values;
285 ::testing::Values(kClearKeyKeySystem), ::testing::Values(SRC, MSE))); 308
309 #if !defined(OS_ANDROID)
310 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest,
311 Combine(Values(kClearKeyKeySystem), Values(SRC)));
312 #endif // !defined(OS_ANDROID)
313
314 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
315 Combine(Values(kClearKeyKeySystem), Values(MSE)));
286 316
287 // External Clear Key is currently only used on platforms that use Pepper CDMs. 317 // External Clear Key is currently only used on platforms that use Pepper CDMs.
288 #if defined(ENABLE_PEPPER_CDMS) 318 #if defined(ENABLE_PEPPER_CDMS)
289 INSTANTIATE_TEST_CASE_P(ExternalClearKey, EncryptedMediaTest, 319 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest,
290 ::testing::Combine( 320 Combine(Values(kExternalClearKeyKeySystem), Values(SRC)));
291 ::testing::Values(kExternalClearKeyKeySystem), 321 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest,
292 ::testing::Values(SRC, MSE))); 322 Combine(Values(kExternalClearKeyKeySystem), Values(MSE)));
323 #endif // defined(ENABLE_PEPPER_CDMS)
293 324
294 #if defined(WIDEVINE_CDM_AVAILABLE) 325 #if defined(WIDEVINE_CDM_AVAILABLE)
295 // This test doesn't fully test playback with Widevine. So we only run Widevine 326 // This test doesn't fully test playback with Widevine. So we only run Widevine
296 // test with MSE (no SRC) to reduce test time. 327 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works
297 INSTANTIATE_TEST_CASE_P(Widevine, EncryptedMediaTest, 328 // with MSE and we cannot run this test with SRC.
298 ::testing::Combine( 329 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest,
299 ::testing::Values(kWidevineKeySystem), ::testing::Values(MSE))); 330 Combine(Values(kWidevineKeySystem), Values(MSE)));
300 #endif // defined(WIDEVINE_CDM_AVAILABLE) 331 #endif // defined(WIDEVINE_CDM_AVAILABLE)
301 #endif // defined(ENABLE_PEPPER_CDMS)
302 332
303 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { 333 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
304 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); 334 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly);
305 } 335 }
306 336
307 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { 337 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
308 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); 338 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo);
309 } 339 }
310 340
311 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { 341 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, 399 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest,
370 ExternalClearKeyInitializeCDMFail) { 400 ExternalClearKeyInitializeCDMFail) {
371 RunEncryptedMediaTest("encrypted_media_player.html", 401 RunEncryptedMediaTest("encrypted_media_player.html",
372 "bear-a-enc_a.webm", 402 "bear-a-enc_a.webm",
373 kWebMAudioOnly, 403 kWebMAudioOnly,
374 "org.chromium.externalclearkey.initializefail", 404 "org.chromium.externalclearkey.initializefail",
375 SRC, 405 SRC,
376 kEmeKeyError); 406 kEmeKeyError);
377 } 407 }
378 #endif // defined(ENABLE_PEPPER_CDMS) 408 #endif // defined(ENABLE_PEPPER_CDMS)
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/filter/content_browsertests_disabled ('k') | content/browser/media/encrypted_media_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698