Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 57 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
| 58 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; | 58 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; |
| 59 #endif // defined(USE_PROPRIETARY_CODECS) | 59 #endif // defined(USE_PROPRIETARY_CODECS) |
| 60 | 60 |
| 61 // Sessions to load. | 61 // Sessions to load. |
| 62 const char kNoSessionToLoad[] = ""; | 62 const char kNoSessionToLoad[] = ""; |
| 63 const char kLoadableSession[] = "LoadableSession"; | 63 const char kLoadableSession[] = "LoadableSession"; |
| 64 const char kUnknownSession[] = "UnknownSession"; | 64 const char kUnknownSession[] = "UnknownSession"; |
| 65 | 65 |
| 66 // EME-specific test results and errors. | 66 // EME-specific test results and errors. |
| 67 const char kEmeKeyError[] = "KEYERROR"; | 67 const char kEmeKeyError[] = "KEY_ERROR"; |
| 68 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; | 68 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; |
| 69 const char kFileIOTestSuccess[] = "FILEIOTESTSUCCESS"; | 69 const char kFileIOTestSuccess[] = "FILE_IO_TEST_SUCCESS"; |
| 70 | |
| 71 const char kDefaultEMEPlayer[] = "eme_player.html"; | |
|
ddorwin
2014/05/30 17:42:56
"Eme"
shadi
2014/05/31 00:31:37
Done.
| |
| 70 | 72 |
| 71 // The type of video src used to load media. | 73 // The type of video src used to load media. |
| 72 enum SrcType { | 74 enum SrcType { |
| 73 SRC, | 75 SRC, |
| 74 MSE | 76 MSE |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 // Whether to use prefixed or unprefixed EME. | 79 // Whether to use prefixed or unprefixed EME. |
| 78 enum EmeVersion { | 80 enum EmeVersion { |
| 79 PREFIXED, | 81 PREFIXED, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 | 162 |
| 161 void RunSimpleEncryptedMediaTest(const std::string& media_file, | 163 void RunSimpleEncryptedMediaTest(const std::string& media_file, |
| 162 const std::string& media_type, | 164 const std::string& media_type, |
| 163 const std::string& key_system, | 165 const std::string& key_system, |
| 164 SrcType src_type, | 166 SrcType src_type, |
| 165 EmeVersion eme_version) { | 167 EmeVersion eme_version) { |
| 166 std::string expected_title = kEnded; | 168 std::string expected_title = kEnded; |
| 167 if (!IsPlayBackPossible(key_system)) | 169 if (!IsPlayBackPossible(key_system)) |
| 168 expected_title = kEmeKeyError; | 170 expected_title = kEmeKeyError; |
| 169 | 171 |
| 170 RunEncryptedMediaTest("encrypted_media_player.html", | 172 RunEncryptedMediaTest(kDefaultEMEPlayer, |
| 171 media_file, | 173 media_file, |
| 172 media_type, | 174 media_type, |
| 173 key_system, | 175 key_system, |
| 174 src_type, | 176 src_type, |
| 175 eme_version, | 177 eme_version, |
| 176 kNoSessionToLoad, | 178 kNoSessionToLoad, |
| 177 false, | 179 false, |
| 178 expected_title); | 180 expected_title); |
| 179 // Check KeyMessage received for all key systems. | 181 // Check KeyMessage received for all key systems. |
| 180 bool receivedKeyMessage = false; | 182 bool receivedKeyMessage = false; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 // Tests encrypted media playback using ExternalClearKey key system in | 303 // Tests encrypted media playback using ExternalClearKey key system in |
| 302 // decrypt-and-decode mode. | 304 // decrypt-and-decode mode. |
| 303 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { | 305 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { |
| 304 public: | 306 public: |
| 305 // We use special |key_system| names to do non-playback related tests, e.g. | 307 // We use special |key_system| names to do non-playback related tests, e.g. |
| 306 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. | 308 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. |
| 307 void TestNonPlaybackCases(const std::string& key_system, | 309 void TestNonPlaybackCases(const std::string& key_system, |
| 308 const std::string& expected_title) { | 310 const std::string& expected_title) { |
| 309 // Since we do not test playback, arbitrarily choose a test file and source | 311 // Since we do not test playback, arbitrarily choose a test file and source |
| 310 // type. | 312 // type. |
| 311 RunEncryptedMediaTest("encrypted_media_player.html", | 313 RunEncryptedMediaTest(kDefaultEMEPlayer, |
| 312 "bear-a-enc_a.webm", | 314 "bear-a-enc_a.webm", |
| 313 kWebMAudioOnly, | 315 kWebMAudioOnly, |
| 314 key_system, | 316 key_system, |
| 315 SRC, | 317 SRC, |
| 316 PREFIXED, | 318 PREFIXED, |
| 317 kNoSessionToLoad, | 319 kNoSessionToLoad, |
| 318 false, | 320 false, |
| 319 expected_title); | 321 expected_title); |
| 320 } | 322 } |
| 321 | 323 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 void TestSimplePlayback(const std::string& encrypted_media, | 370 void TestSimplePlayback(const std::string& encrypted_media, |
| 369 const std::string& media_type) { | 371 const std::string& media_type) { |
| 370 RunSimpleEncryptedMediaTest(encrypted_media, | 372 RunSimpleEncryptedMediaTest(encrypted_media, |
| 371 media_type, | 373 media_type, |
| 372 CurrentKeySystem(), | 374 CurrentKeySystem(), |
| 373 CurrentSourceType(), | 375 CurrentSourceType(), |
| 374 CurrentEmeVersion()); | 376 CurrentEmeVersion()); |
| 375 } | 377 } |
| 376 | 378 |
| 377 void RunInvalidResponseTest() { | 379 void RunInvalidResponseTest() { |
| 378 RunEncryptedMediaTest("encrypted_media_player.html", | 380 RunEncryptedMediaTest(kDefaultEMEPlayer, |
| 379 "bear-320x240-av-enc_av.webm", | 381 "bear-320x240-av-enc_av.webm", |
| 380 kWebMAudioVideo, | 382 kWebMAudioVideo, |
| 381 CurrentKeySystem(), | 383 CurrentKeySystem(), |
| 382 CurrentSourceType(), | 384 CurrentSourceType(), |
| 383 CurrentEmeVersion(), | 385 CurrentEmeVersion(), |
| 384 kNoSessionToLoad, | 386 kNoSessionToLoad, |
| 385 true, | 387 true, |
| 386 kEmeKeyError); | 388 kEmeKeyError); |
| 387 } | 389 } |
| 388 | 390 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; | 586 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
| 585 return; | 587 return; |
| 586 } | 588 } |
| 587 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); | 589 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); |
| 588 } | 590 } |
| 589 #endif // defined(USE_PROPRIETARY_CODECS) | 591 #endif // defined(USE_PROPRIETARY_CODECS) |
| 590 | 592 |
| 591 #if defined(WIDEVINE_CDM_AVAILABLE) | 593 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 592 // The parent key system cannot be used in generateKeyRequest. | 594 // The parent key system cannot be used in generateKeyRequest. |
| 593 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) { | 595 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) { |
| 594 RunEncryptedMediaTest("encrypted_media_player.html", | 596 RunEncryptedMediaTest(kDefaultEMEPlayer, |
| 595 "bear-a-enc_a.webm", | 597 "bear-a-enc_a.webm", |
| 596 kWebMAudioOnly, | 598 kWebMAudioOnly, |
| 597 "com.widevine", | 599 "com.widevine", |
| 598 MSE, | 600 MSE, |
| 599 PREFIXED, | 601 PREFIXED, |
| 600 kNoSessionToLoad, | 602 kNoSessionToLoad, |
| 601 false, | 603 false, |
| 602 kEmeNotSupportedError); | 604 kEmeNotSupportedError); |
| 603 } | 605 } |
| 604 | 606 |
| 605 // TODO(jrummell): http://crbug.com/349181 | 607 // TODO(jrummell): http://crbug.com/349181 |
| 606 // The parent key system cannot be used when creating MediaKeys. | 608 // The parent key system cannot be used when creating MediaKeys. |
| 607 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { | 609 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { |
| 608 RunEncryptedMediaTest("encrypted_media_player.html", | 610 RunEncryptedMediaTest(kDefaultEMEPlayer, |
| 609 "bear-a-enc_a.webm", | 611 "bear-a-enc_a.webm", |
| 610 kWebMAudioOnly, | 612 kWebMAudioOnly, |
| 611 "com.widevine", | 613 "com.widevine", |
| 612 MSE, | 614 MSE, |
| 613 UNPREFIXED, | 615 UNPREFIXED, |
| 614 kNoSessionToLoad, | 616 kNoSessionToLoad, |
| 615 false, | 617 false, |
| 616 kEmeNotSupportedError); | 618 kEmeNotSupportedError); |
| 617 } | 619 } |
| 618 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 620 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 635 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError), | 637 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError), |
| 636 "plugin crash"); | 638 "plugin crash"); |
| 637 } | 639 } |
| 638 | 640 |
| 639 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { | 641 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { |
| 640 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, | 642 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, |
| 641 kFileIOTestSuccess); | 643 kFileIOTestSuccess); |
| 642 } | 644 } |
| 643 | 645 |
| 644 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { | 646 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
| 645 RunEncryptedMediaTest("encrypted_media_player.html", | 647 RunEncryptedMediaTest(kDefaultEMEPlayer, |
| 646 "bear-320x240-v-enc_v.webm", | 648 "bear-320x240-v-enc_v.webm", |
| 647 kWebMVideoOnly, | 649 kWebMVideoOnly, |
| 648 kExternalClearKeyKeySystem, | 650 kExternalClearKeyKeySystem, |
| 649 SRC, | 651 SRC, |
| 650 PREFIXED, | 652 PREFIXED, |
| 651 kLoadableSession, | 653 kLoadableSession, |
| 652 false, | 654 false, |
| 653 kEnded); | 655 kEnded); |
| 654 } | 656 } |
| 655 | 657 |
| 656 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { | 658 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
| 657 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound. | 659 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound. |
| 658 RunEncryptedMediaTest("encrypted_media_player.html", | 660 RunEncryptedMediaTest(kDefaultEMEPlayer, |
| 659 "bear-320x240-v-enc_v.webm", | 661 "bear-320x240-v-enc_v.webm", |
| 660 kWebMVideoOnly, | 662 kWebMVideoOnly, |
| 661 kExternalClearKeyKeySystem, | 663 kExternalClearKeyKeySystem, |
| 662 SRC, | 664 SRC, |
| 663 PREFIXED, | 665 PREFIXED, |
| 664 kUnknownSession, | 666 kUnknownSession, |
| 665 false, | 667 false, |
| 666 kEmeKeyError); | 668 kEmeKeyError); |
| 667 } | 669 } |
| 668 #endif // defined(ENABLE_PEPPER_CDMS) | 670 #endif // defined(ENABLE_PEPPER_CDMS) |
| OLD | NEW |