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

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

Issue 2677063002: Rename encrypted media browsertest enum to not use YES/NO. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 const char kDefaultEmePlayer[] = "eme_player.html"; 97 const char kDefaultEmePlayer[] = "eme_player.html";
98 98
99 // The type of video src used to load media. 99 // The type of video src used to load media.
100 enum SrcType { 100 enum SrcType {
101 SRC, 101 SRC,
102 MSE 102 MSE
103 }; 103 };
104 104
105 // Whether the video should be played once or twice. 105 // Whether the video should be played once or twice.
106 enum class PlayTwice { NO, YES }; 106 enum class PlayCount { ONCE, TWICE };
107 107
108 // Format of a container when testing different streams. 108 // Format of a container when testing different streams.
109 enum class EncryptedContainer { 109 enum class EncryptedContainer {
110 CLEAR_WEBM, 110 CLEAR_WEBM,
111 CLEAR_MP4, 111 CLEAR_MP4,
112 ENCRYPTED_WEBM, 112 ENCRYPTED_WEBM,
113 ENCRYPTED_MP4 113 ENCRYPTED_MP4
114 }; 114 };
115 115
116 // Base class for encrypted media tests. 116 // Base class for encrypted media tests.
(...skipping 30 matching lines...) Expand all
147 // responses, which should trigger errors. 147 // responses, which should trigger errors.
148 // TODO(xhwang): Find an easier way to pass multiple configuration test 148 // TODO(xhwang): Find an easier way to pass multiple configuration test
149 // options. 149 // options.
150 void RunEncryptedMediaTest(const std::string& html_page, 150 void RunEncryptedMediaTest(const std::string& html_page,
151 const std::string& media_file, 151 const std::string& media_file,
152 const std::string& media_type, 152 const std::string& media_type,
153 const std::string& key_system, 153 const std::string& key_system,
154 SrcType src_type, 154 SrcType src_type,
155 const std::string& session_to_load, 155 const std::string& session_to_load,
156 bool force_invalid_response, 156 bool force_invalid_response,
157 PlayTwice play_twice, 157 PlayCount play_count,
158 const std::string& expected_title) { 158 const std::string& expected_title) {
159 base::StringPairs query_params; 159 base::StringPairs query_params;
160 query_params.push_back(std::make_pair("mediaFile", media_file)); 160 query_params.push_back(std::make_pair("mediaFile", media_file));
161 query_params.push_back(std::make_pair("mediaType", media_type)); 161 query_params.push_back(std::make_pair("mediaType", media_type));
162 query_params.push_back(std::make_pair("keySystem", key_system)); 162 query_params.push_back(std::make_pair("keySystem", key_system));
163 if (src_type == MSE) 163 if (src_type == MSE)
164 query_params.push_back(std::make_pair("useMSE", "1")); 164 query_params.push_back(std::make_pair("useMSE", "1"));
165 if (force_invalid_response) 165 if (force_invalid_response)
166 query_params.push_back(std::make_pair("forceInvalidResponse", "1")); 166 query_params.push_back(std::make_pair("forceInvalidResponse", "1"));
167 if (!session_to_load.empty()) 167 if (!session_to_load.empty())
168 query_params.push_back(std::make_pair("sessionToLoad", session_to_load)); 168 query_params.push_back(std::make_pair("sessionToLoad", session_to_load));
169 if (play_twice == PlayTwice::YES) 169 if (play_count == PlayCount::TWICE)
170 query_params.push_back(std::make_pair("playTwice", "1")); 170 query_params.push_back(std::make_pair("playTwice", "1"));
171 RunEncryptedMediaTestPage(html_page, key_system, query_params, 171 RunEncryptedMediaTestPage(html_page, key_system, query_params,
172 expected_title); 172 expected_title);
173 } 173 }
174 174
175 void RunSimpleEncryptedMediaTest(const std::string& media_file, 175 void RunSimpleEncryptedMediaTest(const std::string& media_file,
176 const std::string& media_type, 176 const std::string& media_type,
177 const std::string& key_system, 177 const std::string& key_system,
178 SrcType src_type) { 178 SrcType src_type) {
179 std::string expected_title = kEnded; 179 std::string expected_title = kEnded;
180 if (!IsPlayBackPossible(key_system)) { 180 if (!IsPlayBackPossible(key_system)) {
181 expected_title = kEmeUpdateFailed; 181 expected_title = kEmeUpdateFailed;
182 } 182 }
183 183
184 RunEncryptedMediaTest(kDefaultEmePlayer, media_file, media_type, key_system, 184 RunEncryptedMediaTest(kDefaultEmePlayer, media_file, media_type, key_system,
185 src_type, kNoSessionToLoad, false, PlayTwice::NO, 185 src_type, kNoSessionToLoad, false, PlayCount::ONCE,
186 expected_title); 186 expected_title);
187 // Check KeyMessage received for all key systems. 187 // Check KeyMessage received for all key systems.
188 bool receivedKeyMessage = false; 188 bool receivedKeyMessage = false;
189 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 189 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
190 browser()->tab_strip_model()->GetActiveWebContents(), 190 browser()->tab_strip_model()->GetActiveWebContents(),
191 "window.domAutomationController.send(" 191 "window.domAutomationController.send("
192 "document.querySelector('video').receivedKeyMessage);", 192 "document.querySelector('video').receivedKeyMessage);",
193 &receivedKeyMessage)); 193 &receivedKeyMessage));
194 EXPECT_TRUE(receivedKeyMessage); 194 EXPECT_TRUE(receivedKeyMessage);
195 } 195 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { 291 class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
292 public: 292 public:
293 // We use special |key_system| names to do non-playback related tests, e.g. 293 // We use special |key_system| names to do non-playback related tests, e.g.
294 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. 294 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
295 void TestNonPlaybackCases(const std::string& key_system, 295 void TestNonPlaybackCases(const std::string& key_system,
296 const std::string& expected_title) { 296 const std::string& expected_title) {
297 // Since we do not test playback, arbitrarily choose a test file and source 297 // Since we do not test playback, arbitrarily choose a test file and source
298 // type. 298 // type.
299 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", 299 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
300 kWebMVorbisAudioOnly, key_system, SRC, 300 kWebMVorbisAudioOnly, key_system, SRC,
301 kNoSessionToLoad, false, PlayTwice::NO, 301 kNoSessionToLoad, false, PlayCount::ONCE,
302 expected_title); 302 expected_title);
303 } 303 }
304 304
305 void TestPlaybackCase(const std::string& key_system, 305 void TestPlaybackCase(const std::string& key_system,
306 const std::string& session_to_load, 306 const std::string& session_to_load,
307 const std::string& expected_title) { 307 const std::string& expected_title) {
308 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", 308 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm",
309 kWebMVP8VideoOnly, key_system, SRC, session_to_load, 309 kWebMVP8VideoOnly, key_system, SRC, session_to_load,
310 false, PlayTwice::NO, expected_title); 310 false, PlayCount::ONCE, expected_title);
311 } 311 }
312 312
313 protected: 313 protected:
314 void SetUpCommandLine(base::CommandLine* command_line) override { 314 void SetUpCommandLine(base::CommandLine* command_line) override {
315 EncryptedMediaTestBase::SetUpCommandLine(command_line); 315 EncryptedMediaTestBase::SetUpCommandLine(command_line);
316 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); 316 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
317 } 317 }
318 }; 318 };
319 319
320 #if defined(WIDEVINE_CDM_AVAILABLE) 320 #if defined(WIDEVINE_CDM_AVAILABLE)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 const std::string& media_type) { 353 const std::string& media_type) {
354 RunSimpleEncryptedMediaTest(encrypted_media, media_type, CurrentKeySystem(), 354 RunSimpleEncryptedMediaTest(encrypted_media, media_type, CurrentKeySystem(),
355 CurrentSourceType()); 355 CurrentSourceType());
356 } 356 }
357 357
358 void TestMultiplePlayback(const std::string& encrypted_media, 358 void TestMultiplePlayback(const std::string& encrypted_media,
359 const std::string& media_type) { 359 const std::string& media_type) {
360 DCHECK(IsPlayBackPossible(CurrentKeySystem())); 360 DCHECK(IsPlayBackPossible(CurrentKeySystem()));
361 RunEncryptedMediaTest(kDefaultEmePlayer, encrypted_media, media_type, 361 RunEncryptedMediaTest(kDefaultEmePlayer, encrypted_media, media_type,
362 CurrentKeySystem(), CurrentSourceType(), 362 CurrentKeySystem(), CurrentSourceType(),
363 kNoSessionToLoad, false, PlayTwice::YES, kEnded); 363 kNoSessionToLoad, false, PlayCount::TWICE, kEnded);
364 } 364 }
365 365
366 void RunInvalidResponseTest() { 366 void RunInvalidResponseTest() {
367 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-av_enc-av.webm", 367 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-av_enc-av.webm",
368 kWebMVorbisAudioVP8Video, CurrentKeySystem(), 368 kWebMVorbisAudioVP8Video, CurrentKeySystem(),
369 CurrentSourceType(), kNoSessionToLoad, true, 369 CurrentSourceType(), kNoSessionToLoad, true,
370 PlayTwice::NO, kEmeUpdateFailed); 370 PlayCount::ONCE, kEmeUpdateFailed);
371 } 371 }
372 372
373 void TestFrameSizeChange() { 373 void TestFrameSizeChange() {
374 RunEncryptedMediaTest( 374 RunEncryptedMediaTest(
375 "encrypted_frame_size_change.html", "frame_size_change-av_enc-v.webm", 375 "encrypted_frame_size_change.html", "frame_size_change-av_enc-v.webm",
376 kWebMVorbisAudioVP8Video, CurrentKeySystem(), CurrentSourceType(), 376 kWebMVorbisAudioVP8Video, CurrentKeySystem(), CurrentSourceType(),
377 kNoSessionToLoad, false, PlayTwice::NO, kEnded); 377 kNoSessionToLoad, false, PlayCount::ONCE, kEnded);
378 } 378 }
379 379
380 void TestConfigChange() { 380 void TestConfigChange() {
381 base::StringPairs query_params; 381 base::StringPairs query_params;
382 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); 382 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
383 query_params.push_back(std::make_pair("runEncrypted", "1")); 383 query_params.push_back(std::make_pair("runEncrypted", "1"));
384 RunEncryptedMediaTestPage("mse_config_change.html", 384 RunEncryptedMediaTestPage("mse_config_change.html",
385 CurrentKeySystem(), 385 CurrentKeySystem(),
386 query_params, 386 query_params,
387 kEnded); 387 kEnded);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 TestDifferentContainers(EncryptedContainer::ENCRYPTED_WEBM, 614 TestDifferentContainers(EncryptedContainer::ENCRYPTED_WEBM,
615 EncryptedContainer::ENCRYPTED_MP4); 615 EncryptedContainer::ENCRYPTED_MP4);
616 } 616 }
617 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) 617 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
618 618
619 #if defined(WIDEVINE_CDM_AVAILABLE) 619 #if defined(WIDEVINE_CDM_AVAILABLE)
620 // The parent key system cannot be used when creating MediaKeys. 620 // The parent key system cannot be used when creating MediaKeys.
621 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { 621 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
622 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", 622 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
623 kWebMVorbisAudioOnly, "com.widevine", MSE, 623 kWebMVorbisAudioOnly, "com.widevine", MSE,
624 kNoSessionToLoad, false, PlayTwice::NO, 624 kNoSessionToLoad, false, PlayCount::ONCE,
625 kEmeNotSupportedError); 625 kEmeNotSupportedError);
626 } 626 }
627 #endif // defined(WIDEVINE_CDM_AVAILABLE) 627 #endif // defined(WIDEVINE_CDM_AVAILABLE)
628 628
629 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 629 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
630 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { 630 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) {
631 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, 631 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem,
632 kEmeNotSupportedError); 632 kEmeNotSupportedError);
633 } 633 }
634 634
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession, 676 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession,
677 kEmeSessionNotFound); 677 kEmeSessionNotFound);
678 } 678 }
679 679
680 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, VerifyCdmHostTest) { 680 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, VerifyCdmHostTest) {
681 TestNonPlaybackCases(kExternalClearKeyVerifyCdmHostTestKeySystem, 681 TestNonPlaybackCases(kExternalClearKeyVerifyCdmHostTestKeySystem,
682 kUnitTestSuccess); 682 kUnitTestSuccess);
683 } 683 }
684 684
685 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) 685 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698