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

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

Issue 2910843002: [Cleanup] Move all browsertests to use ScopedFeatureList to modify features
Patch Set: Move SFL calls to constructor Created 3 years, 5 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 <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/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 275 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
276 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { 276 void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
277 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); 277 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM);
278 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); 278 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line);
279 test_launcher_utils::RemoveCommandLineSwitch( 279 test_launcher_utils::RemoveCommandLineSwitch(
280 default_command_line, switches::kDisableComponentUpdate, command_line); 280 default_command_line, switches::kDisableComponentUpdate, command_line);
281 } 281 }
282 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) 282 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
283 283
284 void SetUpCommandLineForKeySystem(const std::string& key_system, 284 void SetUpForKeySystem(const std::string& key_system,
285 CdmHostType cdm_host_type, 285 CdmHostType cdm_host_type) {
286 base::CommandLine* command_line) {
287 if (GetServerConfig(key_system))
288 // Since the web and license servers listen on different ports, we need to
289 // disable web-security to send license requests to the license server.
290 // TODO(shadi): Add port forwarding to the test web server configuration.
291 command_line->AppendSwitch(switches::kDisableWebSecurity);
292
293 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 286 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
294 if (IsExternalClearKey(key_system)) { 287 if (IsExternalClearKey(key_system)) {
295 RegisterPepperCdm(command_line, media::kClearKeyCdmBaseDirectory,
296 media::kClearKeyCdmAdapterFileName,
297 media::kClearKeyCdmDisplayName,
298 media::kClearKeyCdmPepperMimeType);
299 if (cdm_host_type == CdmHostType::kMojo) { 288 if (cdm_host_type == CdmHostType::kMojo) {
300 scoped_feature_list_.InitWithFeatures( 289 scoped_feature_list_.InitWithFeatures(
301 {media::kExternalClearKeyForTesting, media::kMojoCdm, 290 {media::kExternalClearKeyForTesting, media::kMojoCdm,
302 media::kSupportExperimentalCdmInterface}, 291 media::kSupportExperimentalCdmInterface},
303 {}); 292 {});
304 } else { 293 } else {
305 // Pepper CDMs are conditionally compiled with or without support for 294 // Pepper CDMs are conditionally compiled with or without support for
306 // experimental CDMs, so media::kSupportExperimentalCdmInterface is 295 // experimental CDMs, so media::kSupportExperimentalCdmInterface is
307 // not needed as it isn't checked. 296 // not needed as it isn't checked.
308 scoped_feature_list_.InitWithFeatures( 297 scoped_feature_list_.InitWithFeatures(
309 {media::kExternalClearKeyForTesting}, {}); 298 {media::kExternalClearKeyForTesting}, {});
310 } 299 }
311 } else { 300 } else {
312 if (cdm_host_type == CdmHostType::kMojo) { 301 if (cdm_host_type == CdmHostType::kMojo) {
313 scoped_feature_list_.InitWithFeatures( 302 scoped_feature_list_.InitWithFeatures(
314 {media::kMojoCdm, media::kSupportExperimentalCdmInterface}, {}); 303 {media::kMojoCdm, media::kSupportExperimentalCdmInterface}, {});
315 } 304 }
316 } 305 }
317 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) 306 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
318 } 307 }
319 308
309 void SetUpCommandLineForKeySystem(const std::string& key_system,
310 base::CommandLine* command_line) {
311 if (GetServerConfig(key_system))
312 // Since the web and license servers listen on different ports, we need to
313 // disable web-security to send license requests to the license server.
314 // TODO(shadi): Add port forwarding to the test web server configuration.
315 command_line->AppendSwitch(switches::kDisableWebSecurity);
316
317 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
318 if (IsExternalClearKey(key_system)) {
319 RegisterPepperCdm(command_line, media::kClearKeyCdmBaseDirectory,
320 media::kClearKeyCdmAdapterFileName,
321 media::kClearKeyCdmDisplayName,
322 media::kClearKeyCdmPepperMimeType);
323 }
324 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
325 }
326
320 base::test::ScopedFeatureList scoped_feature_list_; 327 base::test::ScopedFeatureList scoped_feature_list_;
321 }; 328 };
322 329
323 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 330 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
324 // Tests encrypted media playback using ExternalClearKey key system in 331 // Tests encrypted media playback using ExternalClearKey key system in
325 // decrypt-and-decode mode. 332 // decrypt-and-decode mode.
326 class ECKEncryptedMediaTest : public EncryptedMediaTestBase, 333 class ECKEncryptedMediaTest : public EncryptedMediaTestBase,
327 public testing::WithParamInterface<CdmHostType> { 334 public testing::WithParamInterface<CdmHostType> {
328 public: 335 public:
336 ECKEncryptedMediaTest() {
337 SetUpForKeySystem(kExternalClearKeyKeySystem, GetParam());
338 }
339
329 // We use special |key_system| names to do non-playback related tests, 340 // We use special |key_system| names to do non-playback related tests,
330 // e.g. kExternalClearKeyFileIOTestKeySystem is used to test file IO. 341 // e.g. kExternalClearKeyFileIOTestKeySystem is used to test file IO.
331 void TestNonPlaybackCases(const std::string& key_system, 342 void TestNonPlaybackCases(const std::string& key_system,
332 const std::string& expected_title) { 343 const std::string& expected_title) {
333 // Since we do not test playback, arbitrarily choose a test file and source 344 // Since we do not test playback, arbitrarily choose a test file and source
334 // type. 345 // type.
335 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", 346 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
336 kWebMVorbisAudioOnly, key_system, SrcType::SRC, 347 kWebMVorbisAudioOnly, key_system, SrcType::SRC,
337 kNoSessionToLoad, false, PlayCount::ONCE, 348 kNoSessionToLoad, false, PlayCount::ONCE,
338 expected_title); 349 expected_title);
339 } 350 }
340 351
341 void TestPlaybackCase(const std::string& key_system, 352 void TestPlaybackCase(const std::string& key_system,
342 const std::string& session_to_load, 353 const std::string& session_to_load,
343 const std::string& expected_title) { 354 const std::string& expected_title) {
344 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm", 355 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-320x240-v_enc-v.webm",
345 kWebMVP8VideoOnly, key_system, SrcType::MSE, 356 kWebMVP8VideoOnly, key_system, SrcType::MSE,
346 session_to_load, false, PlayCount::ONCE, 357 session_to_load, false, PlayCount::ONCE,
347 expected_title); 358 expected_title);
348 } 359 }
349 360
350 bool IsUsingMojoCdm() const { return GetParam() == CdmHostType::kMojo; } 361 bool IsUsingMojoCdm() const { return GetParam() == CdmHostType::kMojo; }
351 362
352 protected: 363 protected:
353 void SetUpCommandLine(base::CommandLine* command_line) override { 364 void SetUpCommandLine(base::CommandLine* command_line) override {
354 EncryptedMediaTestBase::SetUpCommandLine(command_line); 365 EncryptedMediaTestBase::SetUpCommandLine(command_line);
355 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, GetParam(), 366 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
356 command_line);
357 } 367 }
358 }; 368 };
359 369
360 #if defined(WIDEVINE_CDM_AVAILABLE) 370 #if defined(WIDEVINE_CDM_AVAILABLE)
361 // Tests encrypted media playback using Widevine key system. 371 // Tests encrypted media playback using Widevine key system.
362 class WVEncryptedMediaTest : public EncryptedMediaTestBase { 372 class WVEncryptedMediaTest : public EncryptedMediaTestBase {
373 public:
374 WVEncryptedMediaTest() {
375 SetUpForKeySystem(kWidevineKeySystem, CdmHostType::kPepper);
376 }
377
363 protected: 378 protected:
364 void SetUpCommandLine(base::CommandLine* command_line) override { 379 void SetUpCommandLine(base::CommandLine* command_line) override {
365 EncryptedMediaTestBase::SetUpCommandLine(command_line); 380 EncryptedMediaTestBase::SetUpCommandLine(command_line);
366 SetUpCommandLineForKeySystem(kWidevineKeySystem, CdmHostType::kPepper, 381 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line);
367 command_line);
368 } 382 }
369 }; 383 };
370 384
371 #endif // defined(WIDEVINE_CDM_AVAILABLE) 385 #endif // defined(WIDEVINE_CDM_AVAILABLE)
372 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) 386 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
373 387
374 // Tests encrypted media playback with a combination of parameters: 388 // Tests encrypted media playback with a combination of parameters:
375 // - char*: Key system name. 389 // - char*: Key system name.
376 // - SrcType: Use MSE or SRC. 390 // - SrcType: Use MSE or SRC.
377 // 391 //
378 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F) 392 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
379 // tests will crash at GetParam(). To add non-parameterized tests, use 393 // tests will crash at GetParam(). To add non-parameterized tests, use
380 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest). 394 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
381 class EncryptedMediaTest 395 class EncryptedMediaTest
382 : public EncryptedMediaTestBase, 396 : public EncryptedMediaTestBase,
383 public testing::WithParamInterface< 397 public testing::WithParamInterface<
384 std::tr1::tuple<const char*, SrcType, CdmHostType>> { 398 std::tr1::tuple<const char*, SrcType, CdmHostType>> {
385 public: 399 public:
400 EncryptedMediaTest() {
401 SetUpForKeySystem(CurrentKeySystem(), CurrentCdmHostType());
402 }
403
386 std::string CurrentKeySystem() { 404 std::string CurrentKeySystem() {
387 return std::tr1::get<0>(GetParam()); 405 return std::tr1::get<0>(GetParam());
388 } 406 }
389 407
390 SrcType CurrentSourceType() { 408 SrcType CurrentSourceType() {
391 return std::tr1::get<1>(GetParam()); 409 return std::tr1::get<1>(GetParam());
392 } 410 }
393 411
394 CdmHostType CurrentCdmHostType() { return std::tr1::get<2>(GetParam()); } 412 CdmHostType CurrentCdmHostType() { return std::tr1::get<2>(GetParam()); }
395 413
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 490 }
473 491
474 void DisableEncryptedMedia() { 492 void DisableEncryptedMedia() {
475 PrefService* pref_service = browser()->profile()->GetPrefs(); 493 PrefService* pref_service = browser()->profile()->GetPrefs();
476 pref_service->SetBoolean(prefs::kWebKitEncryptedMediaEnabled, false); 494 pref_service->SetBoolean(prefs::kWebKitEncryptedMediaEnabled, false);
477 } 495 }
478 496
479 protected: 497 protected:
480 void SetUpCommandLine(base::CommandLine* command_line) override { 498 void SetUpCommandLine(base::CommandLine* command_line) override {
481 EncryptedMediaTestBase::SetUpCommandLine(command_line); 499 EncryptedMediaTestBase::SetUpCommandLine(command_line);
482 SetUpCommandLineForKeySystem(CurrentKeySystem(), CurrentCdmHostType(), 500 SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line);
483 command_line);
484 } 501 }
485 }; 502 };
486 503
487 using ::testing::Combine; 504 using ::testing::Combine;
488 using ::testing::Values; 505 using ::testing::Values;
489 506
490 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, 507 INSTANTIATE_TEST_CASE_P(MSE_ClearKey,
491 EncryptedMediaTest, 508 EncryptedMediaTest,
492 Combine(Values(kClearKeyKeySystem), 509 Combine(Values(kClearKeyKeySystem),
493 Values(SrcType::MSE), 510 Values(SrcType::MSE),
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 DVLOG(0) << "Skipping test; Not working with mojo CDM yet."; 845 DVLOG(0) << "Skipping test; Not working with mojo CDM yet.";
829 return; 846 return;
830 } 847 }
831 848
832 TestNonPlaybackCases(kExternalClearKeyVerifyCdmHostTestKeySystem, 849 TestNonPlaybackCases(kExternalClearKeyVerifyCdmHostTestKeySystem,
833 kUnitTestSuccess); 850 kUnitTestSuccess);
834 } 851 }
835 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) 852 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
836 853
837 } // namespace chrome 854 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698