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

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

Issue 2409423002: Move ENABLE_PEPPER_CDMS to a buildflag header. (Closed)
Patch Set: Fix and format Created 4 years, 2 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/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/media/media_browsertest.h" 13 #include "chrome/browser/media/media_browsertest.h"
14 #include "chrome/browser/media/test_license_server.h" 14 #include "chrome/browser/media/test_license_server.h"
15 #include "chrome/browser/media/wv_test_license_server_config.h" 15 #include "chrome/browser/media/wv_test_license_server_config.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/test_launcher_utils.h" 19 #include "chrome/test/base/test_launcher_utils.h"
20 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
22 #include "ppapi/features/features.h"
22 #include "testing/gtest/include/gtest/gtest-spi.h" 23 #include "testing/gtest/include/gtest/gtest-spi.h"
24
23 #if defined(OS_ANDROID) 25 #if defined(OS_ANDROID)
24 #include "base/android/build_info.h" 26 #include "base/android/build_info.h"
25 #endif 27 #endif
26 28
27 #if defined(ENABLE_PEPPER_CDMS) 29 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
28 #include "chrome/browser/media/pepper_cdm_test_constants.h" 30 #include "chrome/browser/media/pepper_cdm_test_constants.h"
29 #include "chrome/browser/media/pepper_cdm_test_helper.h" 31 #include "chrome/browser/media/pepper_cdm_test_helper.h"
30 #include "media/base/media_switches.h" 32 #include "media/base/media_switches.h"
31 #endif 33 #endif
32 34
33 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 35 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
34 36
35 // Available key systems. 37 // Available key systems.
36 const char kClearKeyKeySystem[] = "org.w3.clearkey"; 38 const char kClearKeyKeySystem[] = "org.w3.clearkey";
37 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; 39 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 base::ASCIIToUTF16(kEmeMessageUnexpectedType)); 234 base::ASCIIToUTF16(kEmeMessageUnexpectedType));
233 title_watcher->AlsoWaitForTitle( 235 title_watcher->AlsoWaitForTitle(
234 base::ASCIIToUTF16(kEmeRenewalMissingHeader)); 236 base::ASCIIToUTF16(kEmeRenewalMissingHeader));
235 } 237 }
236 238
237 void SetUpCommandLine(base::CommandLine* command_line) override { 239 void SetUpCommandLine(base::CommandLine* command_line) override {
238 command_line->AppendSwitch( 240 command_line->AppendSwitch(
239 switches::kDisableGestureRequirementForMediaPlayback); 241 switches::kDisableGestureRequirementForMediaPlayback);
240 } 242 }
241 243
242 #if defined(ENABLE_PEPPER_CDMS) 244 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
243 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { 245 void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
244 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); 246 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM);
245 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); 247 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line);
246 test_launcher_utils::RemoveCommandLineSwitch( 248 test_launcher_utils::RemoveCommandLineSwitch(
247 default_command_line, switches::kDisableComponentUpdate, command_line); 249 default_command_line, switches::kDisableComponentUpdate, command_line);
248 } 250 }
249 #endif // defined(ENABLE_PEPPER_CDMS) 251 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
250 252
251 void SetUpCommandLineForKeySystem(const std::string& key_system, 253 void SetUpCommandLineForKeySystem(const std::string& key_system,
252 base::CommandLine* command_line) { 254 base::CommandLine* command_line) {
253 if (GetServerConfig(key_system)) 255 if (GetServerConfig(key_system))
254 // Since the web and license servers listen on different ports, we need to 256 // Since the web and license servers listen on different ports, we need to
255 // disable web-security to send license requests to the license server. 257 // disable web-security to send license requests to the license server.
256 // TODO(shadi): Add port forwarding to the test web server configuration. 258 // TODO(shadi): Add port forwarding to the test web server configuration.
257 command_line->AppendSwitch(switches::kDisableWebSecurity); 259 command_line->AppendSwitch(switches::kDisableWebSecurity);
258 260
259 #if defined(ENABLE_PEPPER_CDMS) 261 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
260 if (IsExternalClearKey(key_system)) { 262 if (IsExternalClearKey(key_system)) {
261 RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory, 263 RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory,
262 kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName, 264 kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName,
263 kClearKeyCdmPepperMimeType); 265 kClearKeyCdmPepperMimeType);
264 command_line->AppendSwitchASCII(switches::kEnableFeatures, 266 command_line->AppendSwitchASCII(switches::kEnableFeatures,
265 media::kExternalClearKeyForTesting.name); 267 media::kExternalClearKeyForTesting.name);
266 } 268 }
267 #endif // defined(ENABLE_PEPPER_CDMS) 269 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
268 } 270 }
269 }; 271 };
270 272
271 #if defined(ENABLE_PEPPER_CDMS) 273 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
272 // Tests encrypted media playback using ExternalClearKey key system in 274 // Tests encrypted media playback using ExternalClearKey key system in
273 // decrypt-and-decode mode. 275 // decrypt-and-decode mode.
274 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { 276 class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
275 public: 277 public:
276 // We use special |key_system| names to do non-playback related tests, e.g. 278 // We use special |key_system| names to do non-playback related tests, e.g.
277 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. 279 // kExternalClearKeyFileIOTestKeySystem is used to test file IO.
278 void TestNonPlaybackCases(const std::string& key_system, 280 void TestNonPlaybackCases(const std::string& key_system,
279 const std::string& expected_title) { 281 const std::string& expected_title) {
280 // Since we do not test playback, arbitrarily choose a test file and source 282 // Since we do not test playback, arbitrarily choose a test file and source
281 // type. 283 // type.
(...skipping 22 matching lines...) Expand all
304 // Tests encrypted media playback using Widevine key system. 306 // Tests encrypted media playback using Widevine key system.
305 class WVEncryptedMediaTest : public EncryptedMediaTestBase { 307 class WVEncryptedMediaTest : public EncryptedMediaTestBase {
306 protected: 308 protected:
307 void SetUpCommandLine(base::CommandLine* command_line) override { 309 void SetUpCommandLine(base::CommandLine* command_line) override {
308 EncryptedMediaTestBase::SetUpCommandLine(command_line); 310 EncryptedMediaTestBase::SetUpCommandLine(command_line);
309 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line); 311 SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line);
310 } 312 }
311 }; 313 };
312 314
313 #endif // defined(WIDEVINE_CDM_AVAILABLE) 315 #endif // defined(WIDEVINE_CDM_AVAILABLE)
314 #endif // defined(ENABLE_PEPPER_CDMS) 316 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
315 317
316 // Tests encrypted media playback with a combination of parameters: 318 // Tests encrypted media playback with a combination of parameters:
317 // - char*: Key system name. 319 // - char*: Key system name.
318 // - SrcType: Use MSE or SRC. 320 // - SrcType: Use MSE or SRC.
319 // 321 //
320 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F) 322 // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
321 // tests will crash at GetParam(). To add non-parameterized tests, use 323 // tests will crash at GetParam(). To add non-parameterized tests, use
322 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest). 324 // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
323 class EncryptedMediaTest : public EncryptedMediaTestBase, 325 class EncryptedMediaTest : public EncryptedMediaTestBase,
324 public testing::WithParamInterface< 326 public testing::WithParamInterface<
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, 414 INSTANTIATE_TEST_CASE_P(SRC_ClearKey,
413 EncryptedMediaTest, 415 EncryptedMediaTest,
414 Combine(Values(kClearKeyKeySystem), Values(SRC))); 416 Combine(Values(kClearKeyKeySystem), Values(SRC)));
415 #endif // !defined(OS_ANDROID) 417 #endif // !defined(OS_ANDROID)
416 418
417 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, 419 INSTANTIATE_TEST_CASE_P(MSE_ClearKey,
418 EncryptedMediaTest, 420 EncryptedMediaTest,
419 Combine(Values(kClearKeyKeySystem), Values(MSE))); 421 Combine(Values(kClearKeyKeySystem), Values(MSE)));
420 422
421 // External Clear Key is currently only used on platforms that use Pepper CDMs. 423 // External Clear Key is currently only used on platforms that use Pepper CDMs.
422 #if defined(ENABLE_PEPPER_CDMS) 424 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
423 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, 425 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey,
424 EncryptedMediaTest, 426 EncryptedMediaTest,
425 Combine(Values(kExternalClearKeyKeySystem), 427 Combine(Values(kExternalClearKeyKeySystem),
426 Values(SRC))); 428 Values(SRC)));
427 429
428 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, 430 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey,
429 EncryptedMediaTest, 431 EncryptedMediaTest,
430 Combine(Values(kExternalClearKeyKeySystem), 432 Combine(Values(kExternalClearKeyKeySystem),
431 Values(MSE))); 433 Values(MSE)));
432 434
433 const char kExternalClearKeyDecryptOnlyKeySystem[] = 435 const char kExternalClearKeyDecryptOnlyKeySystem[] =
434 "org.chromium.externalclearkey.decryptonly"; 436 "org.chromium.externalclearkey.decryptonly";
435 437
436 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE. 438 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
437 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, 439 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly,
438 EncryptedMediaTest, 440 EncryptedMediaTest,
439 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), 441 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
440 Values(MSE))); 442 Values(MSE)));
441 #endif // defined(ENABLE_PEPPER_CDMS) 443 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
442 444
443 #if defined(WIDEVINE_CDM_AVAILABLE) 445 #if defined(WIDEVINE_CDM_AVAILABLE)
444 #if !defined(OS_CHROMEOS) 446 #if !defined(OS_CHROMEOS)
445 INSTANTIATE_TEST_CASE_P(MSE_Widevine, 447 INSTANTIATE_TEST_CASE_P(MSE_Widevine,
446 EncryptedMediaTest, 448 EncryptedMediaTest,
447 Combine(Values(kWidevineKeySystem), Values(MSE))); 449 Combine(Values(kWidevineKeySystem), Values(MSE)));
448 #endif // !defined(OS_CHROMEOS) 450 #endif // !defined(OS_CHROMEOS)
449 #endif // defined(WIDEVINE_CDM_AVAILABLE) 451 #endif // defined(WIDEVINE_CDM_AVAILABLE)
450 452
451 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { 453 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 #if defined(WIDEVINE_CDM_AVAILABLE) 600 #if defined(WIDEVINE_CDM_AVAILABLE)
599 // The parent key system cannot be used when creating MediaKeys. 601 // The parent key system cannot be used when creating MediaKeys.
600 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { 602 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
601 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", 603 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
602 kWebMVorbisAudioOnly, "com.widevine", MSE, 604 kWebMVorbisAudioOnly, "com.widevine", MSE,
603 kNoSessionToLoad, false, PlayTwice::NO, 605 kNoSessionToLoad, false, PlayTwice::NO,
604 kEmeNotSupportedError); 606 kEmeNotSupportedError);
605 } 607 }
606 #endif // defined(WIDEVINE_CDM_AVAILABLE) 608 #endif // defined(WIDEVINE_CDM_AVAILABLE)
607 609
608 #if defined(ENABLE_PEPPER_CDMS) 610 #if BUILDFLAG(ENABLE_PEPPER_CDMS)
609 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) { 611 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) {
610 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem, 612 TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem,
611 kEmeNotSupportedError); 613 kEmeNotSupportedError);
612 } 614 }
613 615
614 // When CDM crashes, we should still get a decode error. |kError| is reported 616 // When CDM crashes, we should still get a decode error. |kError| is reported
615 // when the HTMLVideoElement error event fires, indicating an error happened 617 // when the HTMLVideoElement error event fires, indicating an error happened
616 // during playback. 618 // during playback.
617 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) { 619 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, CDMCrashDuringDecode) {
618 IgnorePluginCrash(); 620 IgnorePluginCrash();
(...skipping 25 matching lines...) Expand all
644 646
645 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { 647 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
646 TestPlaybackCase(kExternalClearKeyKeySystem, kLoadableSession, kEnded); 648 TestPlaybackCase(kExternalClearKeyKeySystem, kLoadableSession, kEnded);
647 } 649 }
648 650
649 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { 651 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
650 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession, 652 TestPlaybackCase(kExternalClearKeyKeySystem, kUnknownSession,
651 kEmeSessionNotFound); 653 kEmeSessionNotFound);
652 } 654 }
653 655
654 #endif // defined(ENABLE_PEPPER_CDMS) 656 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
OLDNEW
« no previous file with comments | « chrome/browser/load_library_perf_test.cc ('k') | chrome/browser/media/encrypted_media_supported_types_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698