| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 274 |
| 275 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 275 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 276 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { | 276 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { |
| 277 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); | 277 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); |
| 278 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); | 278 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); |
| 279 test_launcher_utils::RemoveCommandLineSwitch( | 279 test_launcher_utils::RemoveCommandLineSwitch( |
| 280 default_command_line, switches::kDisableComponentUpdate, command_line); | 280 default_command_line, switches::kDisableComponentUpdate, command_line); |
| 281 } | 281 } |
| 282 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 282 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 283 | 283 |
| 284 void SetUpForKeySystem(const std::string& key_system, |
| 285 CdmHostType cdm_host_type) { |
| 286 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 287 if (IsExternalClearKey(key_system)) { |
| 288 if (cdm_host_type == CdmHostType::kMojo) { |
| 289 scoped_feature_list_.InitWithFeatures( |
| 290 {media::kExternalClearKeyForTesting, media::kMojoCdm}, {}); |
| 291 } else { |
| 292 scoped_feature_list_.InitWithFeatures( |
| 293 {media::kExternalClearKeyForTesting}, {}); |
| 294 } |
| 295 } |
| 296 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 297 } |
| 298 |
| 284 void SetUpCommandLineForKeySystem(const std::string& key_system, | 299 void SetUpCommandLineForKeySystem(const std::string& key_system, |
| 285 CdmHostType cdm_host_type, | |
| 286 base::CommandLine* command_line) { | 300 base::CommandLine* command_line) { |
| 287 if (GetServerConfig(key_system)) | 301 if (GetServerConfig(key_system)) |
| 288 // Since the web and license servers listen on different ports, we need to | 302 // Since the web and license servers listen on different ports, we need to |
| 289 // disable web-security to send license requests to the license server. | 303 // disable web-security to send license requests to the license server. |
| 290 // TODO(shadi): Add port forwarding to the test web server configuration. | 304 // TODO(shadi): Add port forwarding to the test web server configuration. |
| 291 command_line->AppendSwitch(switches::kDisableWebSecurity); | 305 command_line->AppendSwitch(switches::kDisableWebSecurity); |
| 292 | 306 |
| 293 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 307 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 294 if (IsExternalClearKey(key_system)) { | 308 if (IsExternalClearKey(key_system)) { |
| 295 RegisterPepperCdm(command_line, media::kClearKeyCdmBaseDirectory, | 309 RegisterPepperCdm(command_line, media::kClearKeyCdmBaseDirectory, |
| 296 media::kClearKeyCdmAdapterFileName, | 310 media::kClearKeyCdmAdapterFileName, |
| 297 media::kClearKeyCdmDisplayName, | 311 media::kClearKeyCdmDisplayName, |
| 298 media::kClearKeyCdmPepperMimeType); | 312 media::kClearKeyCdmPepperMimeType); |
| 299 if (cdm_host_type == CdmHostType::kMojo) { | |
| 300 scoped_feature_list_.InitWithFeatures( | |
| 301 {media::kExternalClearKeyForTesting, media::kMojoCdm}, {}); | |
| 302 } else { | |
| 303 scoped_feature_list_.InitWithFeatures( | |
| 304 {media::kExternalClearKeyForTesting}, {}); | |
| 305 } | |
| 306 } | 313 } |
| 307 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 314 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 308 } | 315 } |
| 309 | 316 |
| 310 base::test::ScopedFeatureList scoped_feature_list_; | 317 base::test::ScopedFeatureList scoped_feature_list_; |
| 311 }; | 318 }; |
| 312 | 319 |
| 313 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 320 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 314 // Tests encrypted media playback using ExternalClearKey key system in | 321 // Tests encrypted media playback using ExternalClearKey key system in |
| 315 // decrypt-and-decode mode. | 322 // decrypt-and-decode mode. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 333 const std::string& expected_title) { | 340 const std::string& expected_title) { |
| 334 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", | 341 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", |
| 335 kWebMVP8VideoOnly, key_system, SrcType::MSE, | 342 kWebMVP8VideoOnly, key_system, SrcType::MSE, |
| 336 session_to_load, false, PlayCount::ONCE, | 343 session_to_load, false, PlayCount::ONCE, |
| 337 expected_title); | 344 expected_title); |
| 338 } | 345 } |
| 339 | 346 |
| 340 bool IsUsingMojoCdm() const { return GetParam() == CdmHostType::kMojo; } | 347 bool IsUsingMojoCdm() const { return GetParam() == CdmHostType::kMojo; } |
| 341 | 348 |
| 342 protected: | 349 protected: |
| 350 void SetUp() override { |
| 351 SetUpForKeySystem(kExternalClearKeyKeySystem, GetParam()); |
| 352 EncryptedMediaTestBase::SetUp(); |
| 353 } |
| 354 |
| 343 void SetUpCommandLine(base::CommandLine* command_line) override { | 355 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 344 EncryptedMediaTestBase::SetUpCommandLine(command_line); | 356 EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 345 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, GetParam(), | 357 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
| 346 command_line); | |
| 347 } | 358 } |
| 348 }; | 359 }; |
| 349 | 360 |
| 350 #if defined(WIDEVINE_CDM_AVAILABLE) | 361 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 351 // Tests encrypted media playback using Widevine key system. | 362 // Tests encrypted media playback using Widevine key system. |
| 352 class WVEncryptedMediaTest : public EncryptedMediaTestBase { | 363 class WVEncryptedMediaTest : public EncryptedMediaTestBase { |
| 353 protected: | 364 protected: |
| 365 void SetUp() override { |
| 366 SetUpForKeySystem(kWidevineKeySystem, CdmHostType::kPepper); |
| 367 EncryptedMediaTestBase::SetUp(); |
| 368 } |
| 369 |
| 354 void SetUpCommandLine(base::CommandLine* command_line) override { | 370 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 355 EncryptedMediaTestBase::SetUpCommandLine(command_line); | 371 EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 356 SetUpCommandLineForKeySystem(kWidevineKeySystem, CdmHostType::kPepper, | 372 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line); |
| 357 command_line); | |
| 358 } | 373 } |
| 359 }; | 374 }; |
| 360 | 375 |
| 361 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 376 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 362 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 377 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 363 | 378 |
| 364 // Tests encrypted media playback with a combination of parameters: | 379 // Tests encrypted media playback with a combination of parameters: |
| 365 // - char*: Key system name. | 380 // - char*: Key system name. |
| 366 // - SrcType: Use MSE or SRC. | 381 // - SrcType: Use MSE or SRC. |
| 367 // | 382 // |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 RunEncryptedMediaTestPage("mse_different_containers.html", | 475 RunEncryptedMediaTestPage("mse_different_containers.html", |
| 461 CurrentKeySystem(), query_params, kEnded); | 476 CurrentKeySystem(), query_params, kEnded); |
| 462 } | 477 } |
| 463 | 478 |
| 464 void DisableEncryptedMedia() { | 479 void DisableEncryptedMedia() { |
| 465 PrefService* pref_service = browser()->profile()->GetPrefs(); | 480 PrefService* pref_service = browser()->profile()->GetPrefs(); |
| 466 pref_service->SetBoolean(prefs::kWebKitEncryptedMediaEnabled, false); | 481 pref_service->SetBoolean(prefs::kWebKitEncryptedMediaEnabled, false); |
| 467 } | 482 } |
| 468 | 483 |
| 469 protected: | 484 protected: |
| 485 void SetUp() override { |
| 486 SetUpForKeySystem(CurrentKeySystem(), CurrentCdmHostType()); |
| 487 EncryptedMediaTestBase::SetUp(); |
| 488 } |
| 489 |
| 470 void SetUpCommandLine(base::CommandLine* command_line) override { | 490 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 471 EncryptedMediaTestBase::SetUpCommandLine(command_line); | 491 EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 472 SetUpCommandLineForKeySystem(CurrentKeySystem(), CurrentCdmHostType(), | 492 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line); |
| 473 command_line); | |
| 474 } | 493 } |
| 475 }; | 494 }; |
| 476 | 495 |
| 477 using ::testing::Combine; | 496 using ::testing::Combine; |
| 478 using ::testing::Values; | 497 using ::testing::Values; |
| 479 | 498 |
| 480 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, | 499 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, |
| 481 EncryptedMediaTest, | 500 EncryptedMediaTest, |
| 482 Combine(Values(kClearKeyKeySystem), | 501 Combine(Values(kClearKeyKeySystem), |
| 483 Values(SrcType::MSE), | 502 Values(SrcType::MSE), |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 DVLOG(0) << "Skipping test; Not working with mojo CDM yet."; | 831 DVLOG(0) << "Skipping test; Not working with mojo CDM yet."; |
| 813 return; | 832 return; |
| 814 } | 833 } |
| 815 | 834 |
| 816 TestNonPlaybackCases(kExternalClearKeyVerifyCdmHostTestKeySystem, | 835 TestNonPlaybackCases(kExternalClearKeyVerifyCdmHostTestKeySystem, |
| 817 kUnitTestSuccess); | 836 kUnitTestSuccess); |
| 818 } | 837 } |
| 819 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) | 838 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) |
| 820 | 839 |
| 821 } // namespace chrome | 840 } // namespace chrome |
| OLD | NEW |