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

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

Issue 308553002: Integrate browser tests with new EME player. (Closed) Base URL: http://git.chromium.org/chromium/src.git@eme_player
Patch Set: Add support for FileIO and LoadSession test cases Created 6 years, 6 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
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/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
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";
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
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;
181 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 183 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
182 browser()->tab_strip_model()->GetActiveWebContents(), 184 browser()->tab_strip_model()->GetActiveWebContents(),
183 "window.domAutomationController.send(video.receivedKeyMessage);", 185 "window.domAutomationController.send("
186 "document.querySelector('video').receivedKeyMessage);",
184 &receivedKeyMessage)); 187 &receivedKeyMessage));
185 EXPECT_TRUE(receivedKeyMessage); 188 EXPECT_TRUE(receivedKeyMessage);
186 } 189 }
187 190
188 191
189 void StartLicenseServerIfNeeded(const std::string& key_system, 192 void StartLicenseServerIfNeeded(const std::string& key_system,
190 std::vector<StringPair>* query_params) { 193 std::vector<StringPair>* query_params) {
191 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system); 194 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system);
192 if (!config) 195 if (!config)
193 return; 196 return;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // Tests encrypted media playback using ExternalClearKey key system in 304 // Tests encrypted media playback using ExternalClearKey key system in
302 // decrypt-and-decode mode. 305 // decrypt-and-decode mode.
303 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { 306 class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
304 public: 307 public:
305 // We use special |key_system| names to do non-playback related tests, e.g. 308 // We use special |key_system| names to do non-playback related tests, e.g.
306 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. 309 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
307 void TestNonPlaybackCases(const std::string& key_system, 310 void TestNonPlaybackCases(const std::string& key_system,
308 const std::string& expected_title) { 311 const std::string& expected_title) {
309 // Since we do not test playback, arbitrarily choose a test file and source 312 // Since we do not test playback, arbitrarily choose a test file and source
310 // type. 313 // type.
311 RunEncryptedMediaTest("encrypted_media_player.html", 314 RunEncryptedMediaTest(kDefaultEmePlayer,
312 "bear-a-enc_a.webm", 315 "bear-a-enc_a.webm",
313 kWebMAudioOnly, 316 kWebMAudioOnly,
314 key_system, 317 key_system,
315 SRC, 318 SRC,
316 PREFIXED, 319 PREFIXED,
317 kNoSessionToLoad, 320 kNoSessionToLoad,
318 false, 321 false,
319 expected_title); 322 expected_title);
320 } 323 }
321 324
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 void TestSimplePlayback(const std::string& encrypted_media, 371 void TestSimplePlayback(const std::string& encrypted_media,
369 const std::string& media_type) { 372 const std::string& media_type) {
370 RunSimpleEncryptedMediaTest(encrypted_media, 373 RunSimpleEncryptedMediaTest(encrypted_media,
371 media_type, 374 media_type,
372 CurrentKeySystem(), 375 CurrentKeySystem(),
373 CurrentSourceType(), 376 CurrentSourceType(),
374 CurrentEmeVersion()); 377 CurrentEmeVersion());
375 } 378 }
376 379
377 void RunInvalidResponseTest() { 380 void RunInvalidResponseTest() {
378 RunEncryptedMediaTest("encrypted_media_player.html", 381 RunEncryptedMediaTest(kDefaultEmePlayer,
379 "bear-320x240-av-enc_av.webm", 382 "bear-320x240-av-enc_av.webm",
380 kWebMAudioVideo, 383 kWebMAudioVideo,
381 CurrentKeySystem(), 384 CurrentKeySystem(),
382 CurrentSourceType(), 385 CurrentSourceType(),
383 CurrentEmeVersion(), 386 CurrentEmeVersion(),
384 kNoSessionToLoad, 387 kNoSessionToLoad,
385 true, 388 true,
386 kEmeKeyError); 389 kEmeKeyError);
387 } 390 }
388 391
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; 587 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
585 return; 588 return;
586 } 589 }
587 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); 590 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly);
588 } 591 }
589 #endif // defined(USE_PROPRIETARY_CODECS) 592 #endif // defined(USE_PROPRIETARY_CODECS)
590 593
591 #if defined(WIDEVINE_CDM_AVAILABLE) 594 #if defined(WIDEVINE_CDM_AVAILABLE)
592 // The parent key system cannot be used in generateKeyRequest. 595 // The parent key system cannot be used in generateKeyRequest.
593 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) { 596 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) {
594 RunEncryptedMediaTest("encrypted_media_player.html", 597 RunEncryptedMediaTest(kDefaultEmePlayer,
595 "bear-a-enc_a.webm", 598 "bear-a-enc_a.webm",
596 kWebMAudioOnly, 599 kWebMAudioOnly,
597 "com.widevine", 600 "com.widevine",
598 MSE, 601 MSE,
599 PREFIXED, 602 PREFIXED,
600 kNoSessionToLoad, 603 kNoSessionToLoad,
601 false, 604 false,
602 kEmeNotSupportedError); 605 kEmeNotSupportedError);
603 } 606 }
604 607
605 // TODO(jrummell): http://crbug.com/349181 608 // TODO(jrummell): http://crbug.com/349181
606 // The parent key system cannot be used when creating MediaKeys. 609 // The parent key system cannot be used when creating MediaKeys.
607 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { 610 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
608 RunEncryptedMediaTest("encrypted_media_player.html", 611 RunEncryptedMediaTest(kDefaultEmePlayer,
609 "bear-a-enc_a.webm", 612 "bear-a-enc_a.webm",
610 kWebMAudioOnly, 613 kWebMAudioOnly,
611 "com.widevine", 614 "com.widevine",
612 MSE, 615 MSE,
613 UNPREFIXED, 616 UNPREFIXED,
614 kNoSessionToLoad, 617 kNoSessionToLoad,
615 false, 618 false,
616 kEmeNotSupportedError); 619 kEmeNotSupportedError);
617 } 620 }
618 #endif // defined(WIDEVINE_CDM_AVAILABLE) 621 #endif // defined(WIDEVINE_CDM_AVAILABLE)
619 622
620 #if defined(ENABLE_PEPPER_CDMS) 623 #if defined(ENABLE_PEPPER_CDMS)
621 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { 624 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) {
622 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, kEmeKeyError); 625 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, kEmeKeyError);
623 } 626 }
624 627
625 // TODO(jrummell): Fix these tests to handle rejected promises when the CDM
jrummell 2014/06/13 21:53:58 Thanks for re-enabling these tests.
626 // crashes. Currently the JavaScript doesn't expect to get any more events
627 // after a crash.
628
629 // When CDM crashes, we should still get a decode error. 628 // When CDM crashes, we should still get a decode error.
630 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DISABLED_CDMCrashDuringDecode) { 629 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) {
631 IgnorePluginCrash(); 630 IgnorePluginCrash();
632 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError); 631 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError);
633 } 632 }
634 633
635 // Testing that the media browser test does fail on plugin crash. 634 // Testing that the media browser test does fail on plugin crash.
636 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, DISABLED_CDMExpectedCrash) { 635 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMExpectedCrash) {
637 // Plugin crash is not ignored by default, the test is expected to fail. 636 // Plugin crash is not ignored by default, the test is expected to fail.
638 EXPECT_NONFATAL_FAILURE( 637 EXPECT_NONFATAL_FAILURE(
639 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError), 638 TestNonPlaybackCases(kExternalClearKeyCrashKeySystem, kError),
640 "plugin crash"); 639 "plugin crash");
641 } 640 }
642 641
643 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { 642 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) {
644 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, 643 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem,
645 kFileIOTestSuccess); 644 kFileIOTestSuccess);
646 } 645 }
647 646
648 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { 647 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
649 RunEncryptedMediaTest("encrypted_media_player.html", 648 RunEncryptedMediaTest(kDefaultEmePlayer,
650 "bear-320x240-v-enc_v.webm", 649 "bear-320x240-v-enc_v.webm",
651 kWebMVideoOnly, 650 kWebMVideoOnly,
652 kExternalClearKeyKeySystem, 651 kExternalClearKeyKeySystem,
653 SRC, 652 SRC,
654 PREFIXED, 653 PREFIXED,
655 kLoadableSession, 654 kLoadableSession,
656 false, 655 false,
657 kEnded); 656 kEnded);
658 } 657 }
659 658
660 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { 659 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
661 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound. 660 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
662 RunEncryptedMediaTest("encrypted_media_player.html", 661 RunEncryptedMediaTest(kDefaultEmePlayer,
663 "bear-320x240-v-enc_v.webm", 662 "bear-320x240-v-enc_v.webm",
664 kWebMVideoOnly, 663 kWebMVideoOnly,
665 kExternalClearKeyKeySystem, 664 kExternalClearKeyKeySystem,
666 SRC, 665 SRC,
667 PREFIXED, 666 PREFIXED,
668 kUnknownSession, 667 kUnknownSession,
669 false, 668 false,
670 kEmeKeyError); 669 kEmeKeyError);
671 } 670 }
672 #endif // defined(ENABLE_PEPPER_CDMS) 671 #endif // defined(ENABLE_PEPPER_CDMS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/media_browsertest.cc » ('j') | chrome/test/data/media/eme_player_js/globals.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698