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 // TODO(sandersd): Refactor to remove recomputed codec arrays, and generally | 5 // TODO(sandersd): Refactor to remove recomputed codec arrays, and generally |
6 // shorten and improve coverage. | 6 // shorten and improve coverage. |
7 // - http://crbug.com/417444 | 7 // - http://crbug.com/417444 |
8 // - http://crbug.com/457438 | 8 // - http://crbug.com/457438 |
9 // TODO(sandersd): Add tests to cover codec vectors with empty items. | 9 // TODO(sandersd): Add tests to cover codec vectors with empty items. |
10 // http://crbug.com/417461 | 10 // http://crbug.com/417461 |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "media/base/eme_constants.h" | 16 #include "media/base/eme_constants.h" |
17 #include "media/base/key_systems.h" | 17 #include "media/base/key_systems.h" |
18 #include "media/base/media.h" | 18 #include "media/base/media.h" |
19 #include "media/base/media_client.h" | 19 #include "media/base/media_client.h" |
| 20 #include "ppapi/features/features.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace media { | 23 namespace media { |
23 | 24 |
24 // These are the (fake) key systems that are registered for these tests. | 25 // These are the (fake) key systems that are registered for these tests. |
25 // kUsesAes uses the AesDecryptor like Clear Key. | 26 // kUsesAes uses the AesDecryptor like Clear Key. |
26 // kExternal uses an external CDM, such as Pepper-based or Android platform CDM. | 27 // kExternal uses an external CDM, such as Pepper-based or Android platform CDM. |
27 const char kUsesAes[] = "x-org.example.clear"; | 28 const char kUsesAes[] = "x-org.example.clear"; |
28 const char kUseAesNameForUMA[] = "UseAes"; | 29 const char kUseAesNameForUMA[] = "UseAes"; |
29 const char kExternal[] = "x-com.example.test"; | 30 const char kExternal[] = "x-com.example.test"; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 417 |
417 // The key system is not registered and therefore is unrecognized. | 418 // The key system is not registered and therefore is unrecognized. |
418 TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) { | 419 TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) { |
419 static const char* const kUnrecognized = "x-org.example.unrecognized"; | 420 static const char* const kUnrecognized = "x-org.example.unrecognized"; |
420 | 421 |
421 EXPECT_FALSE(IsSupportedKeySystem(kUnrecognized)); | 422 EXPECT_FALSE(IsSupportedKeySystem(kUnrecognized)); |
422 | 423 |
423 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kUnrecognized)); | 424 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kUnrecognized)); |
424 EXPECT_FALSE(CanUseAesDecryptor(kUnrecognized)); | 425 EXPECT_FALSE(CanUseAesDecryptor(kUnrecognized)); |
425 | 426 |
426 #if defined(ENABLE_PEPPER_CDMS) | 427 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
427 std::string type; | 428 std::string type; |
428 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 429 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
429 EXPECT_DEATH(type = GetPepperType(kUnrecognized), | 430 EXPECT_DEATH(type = GetPepperType(kUnrecognized), |
430 "x-org.example.unrecognized is not a known system"); | 431 "x-org.example.unrecognized is not a known system"); |
431 #endif | 432 #endif |
432 EXPECT_TRUE(type.empty()); | 433 EXPECT_TRUE(type.empty()); |
433 #endif | 434 #endif |
434 } | 435 } |
435 | 436 |
436 TEST_F(KeySystemsTest, Basic_UsesAesDecryptor) { | 437 TEST_F(KeySystemsTest, Basic_UsesAesDecryptor) { |
437 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); | 438 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); |
438 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 439 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
439 kVideoWebM, no_codecs(), kUsesAes)); | 440 kVideoWebM, no_codecs(), kUsesAes)); |
440 | 441 |
441 // No UMA value for this test key system. | 442 // No UMA value for this test key system. |
442 EXPECT_EQ("UseAes", GetKeySystemNameForUMA(kUsesAes)); | 443 EXPECT_EQ("UseAes", GetKeySystemNameForUMA(kUsesAes)); |
443 | 444 |
444 EXPECT_TRUE(CanUseAesDecryptor(kUsesAes)); | 445 EXPECT_TRUE(CanUseAesDecryptor(kUsesAes)); |
445 #if defined(ENABLE_PEPPER_CDMS) | 446 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
446 std::string type; | 447 std::string type; |
447 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 448 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
448 EXPECT_DEATH(type = GetPepperType(kUsesAes), | 449 EXPECT_DEATH(type = GetPepperType(kUsesAes), |
449 "x-org.example.clear is not Pepper-based"); | 450 "x-org.example.clear is not Pepper-based"); |
450 #endif | 451 #endif |
451 EXPECT_TRUE(type.empty()); | 452 EXPECT_TRUE(type.empty()); |
452 #endif | 453 #endif |
453 } | 454 } |
454 | 455 |
455 TEST_F(KeySystemsTest, | 456 TEST_F(KeySystemsTest, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 | 593 |
593 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { | 594 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { |
594 if (!CanRunExternalKeySystemTests()) | 595 if (!CanRunExternalKeySystemTests()) |
595 return; | 596 return; |
596 | 597 |
597 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); | 598 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); |
598 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 599 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
599 kVideoWebM, no_codecs(), kExternal)); | 600 kVideoWebM, no_codecs(), kExternal)); |
600 | 601 |
601 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); | 602 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); |
602 #if defined(ENABLE_PEPPER_CDMS) | 603 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
603 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); | 604 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); |
604 #endif // defined(ENABLE_PEPPER_CDMS) | 605 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
605 } | 606 } |
606 | 607 |
607 TEST_F( | 608 TEST_F( |
608 KeySystemsTest, | 609 KeySystemsTest, |
609 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { | 610 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { |
610 if (!CanRunExternalKeySystemTests()) | 611 if (!CanRunExternalKeySystemTests()) |
611 return; | 612 return; |
612 | 613 |
613 // Valid video types. | 614 // Valid video types. |
614 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 615 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); | 773 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); |
773 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); | 774 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); |
774 | 775 |
775 EXPECT_FALSE(IsSupportedKeySystem("x-")); | 776 EXPECT_FALSE(IsSupportedKeySystem("x-")); |
776 EXPECT_TRUE(IsSupportedKeySystem("x-something")); | 777 EXPECT_TRUE(IsSupportedKeySystem("x-something")); |
777 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); | 778 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); |
778 EXPECT_FALSE(IsSupportedKeySystem("x-other")); | 779 EXPECT_FALSE(IsSupportedKeySystem("x-other")); |
779 } | 780 } |
780 | 781 |
781 } // namespace media | 782 } // namespace media |
OLD | NEW |