| 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/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/media/media_browsertest.h" | 13 #include "chrome/browser/media/media_browsertest.h" |
| 14 #include "chrome/browser/media/test_license_server.h" | 14 #include "chrome/browser/media/test_license_server.h" |
| 15 #include "chrome/browser/media/wv_test_license_server_config.h" | 15 #include "chrome/browser/media/wv_test_license_server_config.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/test_launcher_utils.h" | 19 #include "chrome/test/base/test_launcher_utils.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/test/browser_test_utils.h" | 21 #include "content/public/test/browser_test_utils.h" |
| 22 #include "ppapi/features/features.h" | |
| 23 #include "testing/gtest/include/gtest/gtest-spi.h" | 22 #include "testing/gtest/include/gtest/gtest-spi.h" |
| 24 | |
| 25 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
| 26 #include "base/android/build_info.h" | 24 #include "base/android/build_info.h" |
| 27 #endif | 25 #endif |
| 28 | 26 |
| 29 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 27 #if defined(ENABLE_PEPPER_CDMS) |
| 30 #include "chrome/browser/media/pepper_cdm_test_constants.h" | 28 #include "chrome/browser/media/pepper_cdm_test_constants.h" |
| 31 #include "chrome/browser/media/pepper_cdm_test_helper.h" | 29 #include "chrome/browser/media/pepper_cdm_test_helper.h" |
| 32 #include "media/base/media_switches.h" | 30 #include "media/base/media_switches.h" |
| 33 #endif | 31 #endif |
| 34 | 32 |
| 35 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 33 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 36 | 34 |
| 37 // Available key systems. | 35 // Available key systems. |
| 38 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 36 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 39 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; | 37 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 base::ASCIIToUTF16(kEmeMessageUnexpectedType)); | 232 base::ASCIIToUTF16(kEmeMessageUnexpectedType)); |
| 235 title_watcher->AlsoWaitForTitle( | 233 title_watcher->AlsoWaitForTitle( |
| 236 base::ASCIIToUTF16(kEmeRenewalMissingHeader)); | 234 base::ASCIIToUTF16(kEmeRenewalMissingHeader)); |
| 237 } | 235 } |
| 238 | 236 |
| 239 void SetUpCommandLine(base::CommandLine* command_line) override { | 237 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 240 command_line->AppendSwitch( | 238 command_line->AppendSwitch( |
| 241 switches::kDisableGestureRequirementForMediaPlayback); | 239 switches::kDisableGestureRequirementForMediaPlayback); |
| 242 } | 240 } |
| 243 | 241 |
| 244 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 242 #if defined(ENABLE_PEPPER_CDMS) |
| 245 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { | 243 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { |
| 246 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); | 244 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); |
| 247 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); | 245 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); |
| 248 test_launcher_utils::RemoveCommandLineSwitch( | 246 test_launcher_utils::RemoveCommandLineSwitch( |
| 249 default_command_line, switches::kDisableComponentUpdate, command_line); | 247 default_command_line, switches::kDisableComponentUpdate, command_line); |
| 250 } | 248 } |
| 251 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 249 #endif // defined(ENABLE_PEPPER_CDMS) |
| 252 | 250 |
| 253 void SetUpCommandLineForKeySystem(const std::string& key_system, | 251 void SetUpCommandLineForKeySystem(const std::string& key_system, |
| 254 base::CommandLine* command_line) { | 252 base::CommandLine* command_line) { |
| 255 if (GetServerConfig(key_system)) | 253 if (GetServerConfig(key_system)) |
| 256 // Since the web and license servers listen on different ports, we need to | 254 // Since the web and license servers listen on different ports, we need to |
| 257 // disable web-security to send license requests to the license server. | 255 // disable web-security to send license requests to the license server. |
| 258 // TODO(shadi): Add port forwarding to the test web server configuration. | 256 // TODO(shadi): Add port forwarding to the test web server configuration. |
| 259 command_line->AppendSwitch(switches::kDisableWebSecurity); | 257 command_line->AppendSwitch(switches::kDisableWebSecurity); |
| 260 | 258 |
| 261 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 259 #if defined(ENABLE_PEPPER_CDMS) |
| 262 if (IsExternalClearKey(key_system)) { | 260 if (IsExternalClearKey(key_system)) { |
| 263 RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory, | 261 RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory, |
| 264 kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName, | 262 kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName, |
| 265 kClearKeyCdmPepperMimeType); | 263 kClearKeyCdmPepperMimeType); |
| 266 command_line->AppendSwitchASCII(switches::kEnableFeatures, | 264 command_line->AppendSwitchASCII(switches::kEnableFeatures, |
| 267 media::kExternalClearKeyForTesting.name); | 265 media::kExternalClearKeyForTesting.name); |
| 268 } | 266 } |
| 269 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 267 #endif // defined(ENABLE_PEPPER_CDMS) |
| 270 } | 268 } |
| 271 }; | 269 }; |
| 272 | 270 |
| 273 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 271 #if defined(ENABLE_PEPPER_CDMS) |
| 274 // Tests encrypted media playback using ExternalClearKey key system in | 272 // Tests encrypted media playback using ExternalClearKey key system in |
| 275 // decrypt-and-decode mode. | 273 // decrypt-and-decode mode. |
| 276 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { | 274 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { |
| 277 public: | 275 public: |
| 278 // We use special |key_system| names to do non-playback related tests, e.g. | 276 // We use special |key_system| names to do non-playback related tests, e.g. |
| 279 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. | 277 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. |
| 280 void TestNonPlaybackCases(const std::string& key_system, | 278 void TestNonPlaybackCases(const std::string& key_system, |
| 281 const std::string& expected_title) { | 279 const std::string& expected_title) { |
| 282 // Since we do not test playback, arbitrarily choose a test file and source | 280 // Since we do not test playback, arbitrarily choose a test file and source |
| 283 // type. | 281 // type. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 306 // Tests encrypted media playback using Widevine key system. | 304 // Tests encrypted media playback using Widevine key system. |
| 307 class WVEncryptedMediaTest : public EncryptedMediaTestBase { | 305 class WVEncryptedMediaTest : public EncryptedMediaTestBase { |
| 308 protected: | 306 protected: |
| 309 void SetUpCommandLine(base::CommandLine* command_line) override { | 307 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 310 EncryptedMediaTestBase::SetUpCommandLine(command_line); | 308 EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 311 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line); | 309 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line); |
| 312 } | 310 } |
| 313 }; | 311 }; |
| 314 | 312 |
| 315 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 313 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 316 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 314 #endif // defined(ENABLE_PEPPER_CDMS) |
| 317 | 315 |
| 318 // Tests encrypted media playback with a combination of parameters: | 316 // Tests encrypted media playback with a combination of parameters: |
| 319 // - char*: Key system name. | 317 // - char*: Key system name. |
| 320 // - SrcType: Use MSE or SRC. | 318 // - SrcType: Use MSE or SRC. |
| 321 // | 319 // |
| 322 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F) | 320 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F) |
| 323 // tests will crash at GetParam(). To add non-parameterized tests, use | 321 // tests will crash at GetParam(). To add non-parameterized tests, use |
| 324 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest). | 322 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest). |
| 325 class EncryptedMediaTest : public EncryptedMediaTestBase, | 323 class EncryptedMediaTest : public EncryptedMediaTestBase, |
| 326 public testing::WithParamInterface< | 324 public testing::WithParamInterface< |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, | 412 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, |
| 415 EncryptedMediaTest, | 413 EncryptedMediaTest, |
| 416 Combine(Values(kClearKeyKeySystem), Values(SRC))); | 414 Combine(Values(kClearKeyKeySystem), Values(SRC))); |
| 417 #endif // !defined(OS_ANDROID) | 415 #endif // !defined(OS_ANDROID) |
| 418 | 416 |
| 419 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, | 417 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, |
| 420 EncryptedMediaTest, | 418 EncryptedMediaTest, |
| 421 Combine(Values(kClearKeyKeySystem), Values(MSE))); | 419 Combine(Values(kClearKeyKeySystem), Values(MSE))); |
| 422 | 420 |
| 423 // External Clear Key is currently only used on platforms that use Pepper CDMs. | 421 // External Clear Key is currently only used on platforms that use Pepper CDMs. |
| 424 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 422 #if defined(ENABLE_PEPPER_CDMS) |
| 425 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, | 423 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, |
| 426 EncryptedMediaTest, | 424 EncryptedMediaTest, |
| 427 Combine(Values(kExternalClearKeyKeySystem), | 425 Combine(Values(kExternalClearKeyKeySystem), |
| 428 Values(SRC))); | 426 Values(SRC))); |
| 429 | 427 |
| 430 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, | 428 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, |
| 431 EncryptedMediaTest, | 429 EncryptedMediaTest, |
| 432 Combine(Values(kExternalClearKeyKeySystem), | 430 Combine(Values(kExternalClearKeyKeySystem), |
| 433 Values(MSE))); | 431 Values(MSE))); |
| 434 | 432 |
| 435 const char kExternalClearKeyDecryptOnlyKeySystem[] = | 433 const char kExternalClearKeyDecryptOnlyKeySystem[] = |
| 436 "org.chromium.externalclearkey.decryptonly"; | 434 "org.chromium.externalclearkey.decryptonly"; |
| 437 | 435 |
| 438 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE. | 436 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE. |
| 439 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, | 437 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, |
| 440 EncryptedMediaTest, | 438 EncryptedMediaTest, |
| 441 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), | 439 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), |
| 442 Values(MSE))); | 440 Values(MSE))); |
| 443 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 441 #endif // defined(ENABLE_PEPPER_CDMS) |
| 444 | 442 |
| 445 #if defined(WIDEVINE_CDM_AVAILABLE) | 443 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 446 #if !defined(OS_CHROMEOS) | 444 #if !defined(OS_CHROMEOS) |
| 447 INSTANTIATE_TEST_CASE_P(MSE_Widevine, | 445 INSTANTIATE_TEST_CASE_P(MSE_Widevine, |
| 448 EncryptedMediaTest, | 446 EncryptedMediaTest, |
| 449 Combine(Values(kWidevineKeySystem), Values(MSE))); | 447 Combine(Values(kWidevineKeySystem), Values(MSE))); |
| 450 #endif // !defined(OS_CHROMEOS) | 448 #endif // !defined(OS_CHROMEOS) |
| 451 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 449 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 452 | 450 |
| 453 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 451 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 #if defined(WIDEVINE_CDM_AVAILABLE) | 592 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 595 // The parent key system cannot be used when creating MediaKeys. | 593 // The parent key system cannot be used when creating MediaKeys. |
| 596 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { | 594 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { |
| 597 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", | 595 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", |
| 598 kWebMVorbisAudioOnly, "com.widevine", MSE, | 596 kWebMVorbisAudioOnly, "com.widevine", MSE, |
| 599 kNoSessionToLoad, false, PlayTwice::NO, | 597 kNoSessionToLoad, false, PlayTwice::NO, |
| 600 kEmeNotSupportedError); | 598 kEmeNotSupportedError); |
| 601 } | 599 } |
| 602 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 600 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 603 | 601 |
| 604 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 602 #if defined(ENABLE_PEPPER_CDMS) |
| 605 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { | 603 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { |
| 606 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, | 604 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, |
| 607 kEmeNotSupportedError); | 605 kEmeNotSupportedError); |
| 608 } | 606 } |
| 609 | 607 |
| 610 // When CDM crashes, we should still get a decode error. |kError| is reported | 608 // When CDM crashes, we should still get a decode error. |kError| is reported |
| 611 // when the HTMLVideoElement error event fires, indicating an error happened | 609 // when the HTMLVideoElement error event fires, indicating an error happened |
| 612 // during playback. | 610 // during playback. |
| 613 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) { | 611 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) { |
| 614 IgnorePluginCrash(); | 612 IgnorePluginCrash(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 640 | 638 |
| 641 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { | 639 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
| 642 TestPlaybackCase(kExternalClearKeyKeySystem, kLoadableSession, kEnded); | 640 TestPlaybackCase(kExternalClearKeyKeySystem, kLoadableSession, kEnded); |
| 643 } | 641 } |
| 644 | 642 |
| 645 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { | 643 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
| 646 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession, | 644 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession, |
| 647 kEmeSessionNotFound); | 645 kEmeSessionNotFound); |
| 648 } | 646 } |
| 649 | 647 |
| 650 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 648 #endif // defined(ENABLE_PEPPER_CDMS) |
| OLD | NEW |