| 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" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // Available key systems. | 34 // Available key systems. |
| 35 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 35 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 36 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; | 36 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
| 37 | 37 |
| 38 // Variants of External Clear Key key system to test different scenarios. | 38 // Variants of External Clear Key key system to test different scenarios. |
| 39 // To add a new variant, make sure you also update: | 39 // To add a new variant, make sure you also update: |
| 40 // - media/test/data/eme_player_js/globals.js | 40 // - media/test/data/eme_player_js/globals.js |
| 41 // - AddExternalClearKey() in chrome_key_systems.cc | 41 // - AddExternalClearKey() in chrome_key_systems.cc |
| 42 // - CreateCdmInstance() in clear_key_cdm.cc | 42 // - CreateCdmInstance() in clear_key_cdm.cc |
| 43 const char kExternalClearKeyRenewalKeySystem[] = |
| 44 "org.chromium.externalclearkey.renewal"; |
| 43 const char kExternalClearKeyFileIOTestKeySystem[] = | 45 const char kExternalClearKeyFileIOTestKeySystem[] = |
| 44 "org.chromium.externalclearkey.fileiotest"; | 46 "org.chromium.externalclearkey.fileiotest"; |
| 45 const char kExternalClearKeyInitializeFailKeySystem[] = | 47 const char kExternalClearKeyInitializeFailKeySystem[] = |
| 46 "org.chromium.externalclearkey.initializefail"; | 48 "org.chromium.externalclearkey.initializefail"; |
| 47 const char kExternalClearKeyOutputProtectionTestKeySystem[] = | 49 const char kExternalClearKeyOutputProtectionTestKeySystem[] = |
| 48 "org.chromium.externalclearkey.outputprotectiontest"; | 50 "org.chromium.externalclearkey.outputprotectiontest"; |
| 49 const char kExternalClearKeyCrashKeySystem[] = | 51 const char kExternalClearKeyCrashKeySystem[] = |
| 50 "org.chromium.externalclearkey.crash"; | 52 "org.chromium.externalclearkey.crash"; |
| 51 | 53 |
| 52 // Supported media types. | 54 // Supported media types. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. | 287 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. |
| 286 void TestNonPlaybackCases(const std::string& key_system, | 288 void TestNonPlaybackCases(const std::string& key_system, |
| 287 const std::string& expected_title) { | 289 const std::string& expected_title) { |
| 288 // Since we do not test playback, arbitrarily choose a test file and source | 290 // Since we do not test playback, arbitrarily choose a test file and source |
| 289 // type. | 291 // type. |
| 290 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", | 292 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", |
| 291 kWebMAudioOnly, key_system, SRC, kNoSessionToLoad, | 293 kWebMAudioOnly, key_system, SRC, kNoSessionToLoad, |
| 292 false, PlayTwice::NO, expected_title); | 294 false, PlayTwice::NO, expected_title); |
| 293 } | 295 } |
| 294 | 296 |
| 295 void TestPlaybackCase(const std::string& session_to_load, | 297 void TestPlaybackCase(const std::string& key_system, |
| 298 const std::string& session_to_load, |
| 296 const std::string& expected_title) { | 299 const std::string& expected_title) { |
| 297 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", | 300 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", |
| 298 kWebMVideoOnly, kExternalClearKeyKeySystem, SRC, | 301 kWebMVideoOnly, key_system, SRC, session_to_load, |
| 299 session_to_load, false, PlayTwice::NO, | 302 false, PlayTwice::NO, expected_title); |
| 300 expected_title); | |
| 301 } | 303 } |
| 302 | 304 |
| 303 protected: | 305 protected: |
| 304 void SetUpCommandLine(base::CommandLine* command_line) override { | 306 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 305 EncryptedMediaTestBase::SetUpCommandLine(command_line); | 307 EncryptedMediaTestBase::SetUpCommandLine(command_line); |
| 306 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); | 308 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
| 307 } | 309 } |
| 308 }; | 310 }; |
| 309 | 311 |
| 310 #if defined(WIDEVINE_CDM_AVAILABLE) | 312 #if defined(WIDEVINE_CDM_AVAILABLE) |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, kUnitTestSuccess); | 638 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, kUnitTestSuccess); |
| 637 } | 639 } |
| 638 | 640 |
| 639 // TODO(xhwang): Investigate how to fake capturing activities to test the | 641 // TODO(xhwang): Investigate how to fake capturing activities to test the |
| 640 // network link detection logic in OutputProtectionProxy. | 642 // network link detection logic in OutputProtectionProxy. |
| 641 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, OutputProtectionTest) { | 643 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, OutputProtectionTest) { |
| 642 TestNonPlaybackCases(kExternalClearKeyOutputProtectionTestKeySystem, | 644 TestNonPlaybackCases(kExternalClearKeyOutputProtectionTestKeySystem, |
| 643 kUnitTestSuccess); | 645 kUnitTestSuccess); |
| 644 } | 646 } |
| 645 | 647 |
| 648 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, Renewal) { |
| 649 TestPlaybackCase(kExternalClearKeyRenewalKeySystem, kNoSessionToLoad, kEnded); |
| 650 } |
| 651 |
| 646 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { | 652 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
| 647 TestPlaybackCase(kLoadableSession, kEnded); | 653 TestPlaybackCase(kExternalClearKeyKeySystem, kLoadableSession, kEnded); |
| 648 } | 654 } |
| 649 | 655 |
| 650 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { | 656 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
| 651 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound); | 657 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession, |
| 658 kEmeSessionNotFound); |
| 652 } | 659 } |
| 653 | 660 |
| 654 #endif // defined(ENABLE_PEPPER_CDMS) | 661 #endif // defined(ENABLE_PEPPER_CDMS) |
| OLD | NEW |