Chromium Code Reviews| 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 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "media/base/eme_constants.h" | 9 #include "media/base/eme_constants.h" |
| 10 #include "media/base/key_system_info.h" | 10 #include "media/base/key_system_info.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 TEST_CODEC_FOO_AUDIO = 1 << 10, // An audio codec for foo container. | 57 TEST_CODEC_FOO_AUDIO = 1 << 10, // An audio codec for foo container. |
| 58 TEST_CODEC_FOO_AUDIO_ALL = TEST_CODEC_FOO_AUDIO, | 58 TEST_CODEC_FOO_AUDIO_ALL = TEST_CODEC_FOO_AUDIO, |
| 59 TEST_CODEC_FOO_VIDEO = 1 << 11, // A video codec for foo container. | 59 TEST_CODEC_FOO_VIDEO = 1 << 11, // A video codec for foo container. |
| 60 TEST_CODEC_FOO_VIDEO_ALL = TEST_CODEC_FOO_VIDEO, | 60 TEST_CODEC_FOO_VIDEO_ALL = TEST_CODEC_FOO_VIDEO, |
| 61 TEST_CODEC_FOO_ALL = TEST_CODEC_FOO_AUDIO_ALL | TEST_CODEC_FOO_VIDEO_ALL | 61 TEST_CODEC_FOO_ALL = TEST_CODEC_FOO_AUDIO_ALL | TEST_CODEC_FOO_VIDEO_ALL |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 static_assert((TEST_CODEC_FOO_ALL & EME_CODEC_ALL) == EME_CODEC_NONE, | 64 static_assert((TEST_CODEC_FOO_ALL & EME_CODEC_ALL) == EME_CODEC_NONE, |
| 65 "test codec masks should only use invalid codec masks"); | 65 "test codec masks should only use invalid codec masks"); |
| 66 | 66 |
| 67 // Adapt IsSupportedKeySystemWithMediaMimeType() to the new API, | |
| 68 // IsSupportedCodecCombination(). | |
| 69 static bool IsSupportedKeySystemWithMediaMimeType( | |
| 70 const std::string& mime_type, | |
| 71 const std::vector<std::string>& codecs, | |
| 72 const std::string& key_system) { | |
| 73 return KeySystems::GetInstance().IsSupportedCodecCombination( | |
| 74 key_system, EmeMediaType::VIDEO, mime_type, codecs); | |
| 75 } | |
| 76 | |
| 77 static bool IsSupportedKeySystemWithAudioMimeType( | |
| 78 const std::string& mime_type, | |
| 79 const std::vector<std::string>& codecs, | |
| 80 const std::string& key_system) { | |
| 81 return KeySystems::GetInstance().IsSupportedCodecCombination( | |
| 82 key_system, EmeMediaType::AUDIO, mime_type, codecs); | |
| 83 } | |
| 84 | |
| 67 // Adds test container and codec masks. | 85 // Adds test container and codec masks. |
| 68 // This function must be called after SetMediaClient() if a MediaClient will be | 86 // This function must be called after SetMediaClient() if a MediaClient will be |
| 69 // provided. | 87 // provided. |
| 70 // More details: AddXxxMask() will create KeySystems if it hasn't been created. | 88 // More details: AddXxxMask() will create KeySystems if it hasn't been created. |
| 71 // During KeySystems's construction GetMediaClient() will be used to add key | 89 // During KeySystems's construction GetMediaClient() will be used to add key |
| 72 // systems. In test code, the MediaClient is set by SetMediaClient(). | 90 // systems. In test code, the MediaClient is set by SetMediaClient(). |
| 73 // Therefore, SetMediaClient() must be called before this function to make sure | 91 // Therefore, SetMediaClient() must be called before this function to make sure |
| 74 // MediaClient in effect when constructing KeySystems. | 92 // MediaClient in effect when constructing KeySystems. |
| 75 static void AddContainerAndCodecMasksForTest() { | 93 static void AddContainerAndCodecMasksForTest() { |
| 76 // Since KeySystems is a singleton. Make sure we only add test container and | 94 // Since KeySystems is a singleton. Make sure we only add test container and |
| 77 // codec masks once per process. | 95 // codec masks once per process. |
| 78 static bool is_test_masks_added = false; | 96 static bool is_test_masks_added = false; |
| 79 | 97 |
| 80 if (is_test_masks_added) | 98 if (is_test_masks_added) |
| 81 return; | 99 return; |
| 82 | 100 |
| 83 AddContainerMask("audio/foo", TEST_CODEC_FOO_AUDIO_ALL); | 101 AddContainerMask("audio/foo", TEST_CODEC_FOO_AUDIO_ALL); |
| 84 AddContainerMask("video/foo", TEST_CODEC_FOO_ALL); | 102 AddContainerMask("video/foo", TEST_CODEC_FOO_ALL); |
| 85 AddCodecMask("fooaudio", TEST_CODEC_FOO_AUDIO); | 103 AddCodecMask(EmeMediaType::AUDIO, "fooaudio", TEST_CODEC_FOO_AUDIO); |
| 86 AddCodecMask("foovideo", TEST_CODEC_FOO_VIDEO); | 104 AddCodecMask(EmeMediaType::VIDEO, "foovideo", TEST_CODEC_FOO_VIDEO); |
| 87 | 105 |
| 88 is_test_masks_added = true; | 106 is_test_masks_added = true; |
| 89 } | 107 } |
| 90 | 108 |
| 91 class TestMediaClient : public MediaClient { | 109 class TestMediaClient : public MediaClient { |
| 92 public: | 110 public: |
| 93 TestMediaClient(); | 111 TestMediaClient(); |
| 94 ~TestMediaClient() override; | 112 ~TestMediaClient() override; |
| 95 | 113 |
| 96 // MediaClient implementation. | 114 // MediaClient implementation. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 | 349 |
| 332 CodecVector mixed_codecs_; | 350 CodecVector mixed_codecs_; |
| 333 | 351 |
| 334 TestMediaClient test_media_client_; | 352 TestMediaClient test_media_client_; |
| 335 }; | 353 }; |
| 336 | 354 |
| 337 // TODO(ddorwin): Consider moving GetPepperType() calls out to their own test. | 355 // TODO(ddorwin): Consider moving GetPepperType() calls out to their own test. |
| 338 | 356 |
| 339 TEST_F(KeySystemsTest, EmptyKeySystem) { | 357 TEST_F(KeySystemsTest, EmptyKeySystem) { |
| 340 EXPECT_FALSE(IsSupportedKeySystem(std::string())); | 358 EXPECT_FALSE(IsSupportedKeySystem(std::string())); |
| 341 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 342 kVideoWebM, no_codecs(), std::string())); | |
| 343 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(std::string())); | 359 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(std::string())); |
| 344 } | 360 } |
| 345 | 361 |
| 346 // Clear Key is the only key system registered in content. | 362 // Clear Key is the only key system registered in content. |
| 347 TEST_F(KeySystemsTest, ClearKey) { | 363 TEST_F(KeySystemsTest, ClearKey) { |
| 348 EXPECT_TRUE(IsSupportedKeySystem(kClearKey)); | 364 EXPECT_TRUE(IsSupportedKeySystem(kClearKey)); |
| 349 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 365 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 350 kVideoWebM, no_codecs(), kClearKey)); | 366 kVideoWebM, no_codecs(), kClearKey)); |
| 351 | 367 |
| 352 EXPECT_EQ("ClearKey", GetKeySystemNameForUMA(kClearKey)); | 368 EXPECT_EQ("ClearKey", GetKeySystemNameForUMA(kClearKey)); |
| 353 | 369 |
| 354 // Prefixed Clear Key is not supported internally. | 370 // Prefixed Clear Key is not supported internally. |
| 355 EXPECT_FALSE(IsSupportedKeySystem(kPrefixedClearKey)); | 371 EXPECT_FALSE(IsSupportedKeySystem(kPrefixedClearKey)); |
| 356 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 357 kVideoWebM, no_codecs(), kPrefixedClearKey)); | |
| 358 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kPrefixedClearKey)); | 372 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kPrefixedClearKey)); |
| 359 } | 373 } |
| 360 | 374 |
| 361 TEST_F(KeySystemsTest, ClearKeyWithInitDataType) { | 375 TEST_F(KeySystemsTest, ClearKeyWithInitDataType) { |
| 362 EXPECT_TRUE(IsSupportedKeySystem(kClearKey)); | 376 EXPECT_TRUE(IsSupportedKeySystem(kClearKey)); |
| 363 EXPECT_TRUE(IsSupportedKeySystemWithInitDataType(kClearKey, "webm")); | 377 EXPECT_TRUE(IsSupportedKeySystemWithInitDataType(kClearKey, "webm")); |
| 364 EXPECT_TRUE(IsSupportedKeySystemWithInitDataType(kClearKey, "keyids")); | 378 EXPECT_TRUE(IsSupportedKeySystemWithInitDataType(kClearKey, "keyids")); |
| 365 | 379 |
| 366 // All other InitDataTypes are not supported. | 380 // All other InitDataTypes are not supported. |
| 367 EXPECT_FALSE(IsSupportedKeySystemWithInitDataType(kClearKey, "unknown")); | 381 EXPECT_FALSE(IsSupportedKeySystemWithInitDataType(kClearKey, "unknown")); |
| 368 } | 382 } |
| 369 | 383 |
| 370 // The key system is not registered and therefore is unrecognized. | 384 // The key system is not registered and therefore is unrecognized. |
| 371 TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) { | 385 TEST_F(KeySystemsTest, Basic_UnrecognizedKeySystem) { |
| 372 static const char* const kUnrecognized = "x-org.example.unrecognized"; | 386 static const char* const kUnrecognized = "x-org.example.unrecognized"; |
| 373 | 387 |
| 374 EXPECT_FALSE(IsSupportedKeySystem(kUnrecognized)); | 388 EXPECT_FALSE(IsSupportedKeySystem(kUnrecognized)); |
| 375 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 376 kVideoWebM, no_codecs(), kUnrecognized)); | |
| 377 | 389 |
| 378 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kUnrecognized)); | 390 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kUnrecognized)); |
| 379 | 391 |
| 380 bool can_use = false; | 392 bool can_use = false; |
| 381 EXPECT_DEBUG_DEATH_PORTABLE( | 393 EXPECT_DEBUG_DEATH_PORTABLE( |
| 382 can_use = CanUseAesDecryptor(kUnrecognized), | 394 can_use = CanUseAesDecryptor(kUnrecognized), |
| 383 "x-org.example.unrecognized is not a known concrete system"); | 395 "x-org.example.unrecognized is not a known concrete system"); |
| 384 EXPECT_FALSE(can_use); | 396 EXPECT_FALSE(can_use); |
| 385 | 397 |
| 386 #if defined(ENABLE_PEPPER_CDMS) | 398 #if defined(ENABLE_PEPPER_CDMS) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 410 } | 422 } |
| 411 | 423 |
| 412 TEST_F(KeySystemsTest, | 424 TEST_F(KeySystemsTest, |
| 413 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) { | 425 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) { |
| 414 // Valid video types. | 426 // Valid video types. |
| 415 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 427 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 416 kVideoWebM, vp8_codec(), kUsesAes)); | 428 kVideoWebM, vp8_codec(), kUsesAes)); |
| 417 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 429 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 418 kVideoWebM, vp80_codec(), kUsesAes)); | 430 kVideoWebM, vp80_codec(), kUsesAes)); |
| 419 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 431 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 420 kVideoWebM, vp8_and_vorbis_codecs(), kUsesAes)); | |
| 421 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 422 kVideoWebM, vp9_codec(), kUsesAes)); | 432 kVideoWebM, vp9_codec(), kUsesAes)); |
| 423 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 433 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 424 kVideoWebM, vp90_codec(), kUsesAes)); | 434 kVideoWebM, vp90_codec(), kUsesAes)); |
| 425 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 435 |
| 436 // Audio in a video container. | |
| 437 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 438 kVideoWebM, vp8_and_vorbis_codecs(), kUsesAes)); | |
| 439 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 426 kVideoWebM, vp9_and_vorbis_codecs(), kUsesAes)); | 440 kVideoWebM, vp9_and_vorbis_codecs(), kUsesAes)); |
| 427 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 441 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 428 kVideoWebM, vorbis_codec(), kUsesAes)); | 442 kVideoWebM, vorbis_codec(), kUsesAes)); |
| 429 | 443 |
| 430 // Non-Webm codecs. | 444 // Non-Webm codecs. |
| 431 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 445 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 432 kVideoWebM, foovideo_codec(), kUsesAes)); | 446 kVideoWebM, foovideo_codec(), kUsesAes)); |
| 433 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 447 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 434 kVideoWebM, unknown_codec(), kUsesAes)); | 448 kVideoWebM, unknown_codec(), kUsesAes)); |
| 435 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 449 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 436 kVideoWebM, mixed_codecs(), kUsesAes)); | 450 kVideoWebM, mixed_codecs(), kUsesAes)); |
| 437 | 451 |
| 438 // Valid audio types. | 452 // Valid audio types. |
| 439 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 453 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 440 kAudioWebM, no_codecs(), kUsesAes)); | 454 kAudioWebM, no_codecs(), kUsesAes)); |
| 441 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 455 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 442 kAudioWebM, vorbis_codec(), kUsesAes)); | 456 kAudioWebM, vorbis_codec(), kUsesAes)); |
| 443 | 457 |
| 444 // Non-audio codecs. | 458 // Non-audio codecs. |
| 445 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 459 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 446 kAudioWebM, vp8_codec(), kUsesAes)); | 460 kAudioWebM, vp8_codec(), kUsesAes)); |
| 447 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 461 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 448 kAudioWebM, vp8_and_vorbis_codecs(), kUsesAes)); | 462 kAudioWebM, vp8_and_vorbis_codecs(), kUsesAes)); |
| 449 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 463 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 450 kAudioWebM, vp9_codec(), kUsesAes)); | 464 kAudioWebM, vp9_codec(), kUsesAes)); |
| 451 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 465 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 452 kAudioWebM, vp9_and_vorbis_codecs(), kUsesAes)); | 466 kAudioWebM, vp9_and_vorbis_codecs(), kUsesAes)); |
| 453 | 467 |
| 454 // Non-Webm codec. | 468 // Non-Webm codec. |
| 455 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 469 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 456 kAudioWebM, fooaudio_codec(), kUsesAes)); | 470 kAudioWebM, fooaudio_codec(), kUsesAes)); |
| 457 } | 471 } |
| 458 | 472 |
| 459 // No parent is registered for UsesAes. | 473 // No parent is registered for UsesAes. |
| 460 TEST_F(KeySystemsTest, Parent_NoParentRegistered) { | 474 TEST_F(KeySystemsTest, Parent_NoParentRegistered) { |
| 461 EXPECT_FALSE(IsSupportedKeySystem(kUsesAesParent)); | 475 EXPECT_FALSE(IsSupportedKeySystem(kUsesAesParent)); |
| 462 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 463 kVideoWebM, no_codecs(), kUsesAesParent)); | |
| 464 | 476 |
| 465 // The parent is not supported for most things. | 477 // The parent is not supported for most things. |
| 466 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kUsesAesParent)); | 478 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kUsesAesParent)); |
| 467 bool result = false; | 479 bool result = false; |
| 468 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kUsesAesParent), | 480 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kUsesAesParent), |
| 469 "x-org.example is not a known concrete system"); | 481 "x-org.example is not a known concrete system"); |
| 470 EXPECT_FALSE(result); | 482 EXPECT_FALSE(result); |
| 471 #if defined(ENABLE_PEPPER_CDMS) | 483 #if defined(ENABLE_PEPPER_CDMS) |
| 472 std::string type; | 484 std::string type; |
| 473 EXPECT_DEBUG_DEATH(type = GetPepperType(kUsesAesParent), | 485 EXPECT_DEBUG_DEATH(type = GetPepperType(kUsesAesParent), |
| 474 "x-org.example is not a known concrete system"); | 486 "x-org.example is not a known concrete system"); |
| 475 EXPECT_TRUE(type.empty()); | 487 EXPECT_TRUE(type.empty()); |
| 476 #endif | 488 #endif |
| 477 } | 489 } |
| 478 | 490 |
| 479 TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) { | 491 TEST_F(KeySystemsTest, IsSupportedKeySystem_InvalidVariants) { |
| 480 // Case sensitive. | 492 // Case sensitive. |
| 481 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.ClEaR")); | 493 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.ClEaR")); |
| 482 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(kVideoWebM, no_codecs(), | |
| 483 "x-org.example.ClEaR")); | |
| 484 | 494 |
| 485 // TLDs are not allowed. | 495 // TLDs are not allowed. |
| 486 EXPECT_FALSE(IsSupportedKeySystem("org.")); | 496 EXPECT_FALSE(IsSupportedKeySystem("org.")); |
| 487 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 488 kVideoWebM, no_codecs(), "org.")); | |
| 489 EXPECT_FALSE(IsSupportedKeySystem("com")); | 497 EXPECT_FALSE(IsSupportedKeySystem("com")); |
| 490 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 491 kVideoWebM, no_codecs(), "com")); | |
| 492 | 498 |
| 493 // Extra period. | 499 // Extra period. |
| 494 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.")); | 500 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.")); |
| 495 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(kVideoWebM, no_codecs(), | |
| 496 "x-org.example.clear.")); | |
| 497 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.")); | 501 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.")); |
| 498 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(kVideoWebM, no_codecs(), | |
| 499 "x-org.example.")); | |
| 500 | 502 |
| 501 // Incomplete. | 503 // Incomplete. |
| 502 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clea")); | 504 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clea")); |
| 503 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(kVideoWebM, no_codecs(), | |
| 504 "x-org.example.clea")); | |
| 505 | 505 |
| 506 // Extra character. | 506 // Extra character. |
| 507 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clearz")); | 507 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clearz")); |
| 508 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(kVideoWebM, no_codecs(), | |
| 509 "x-org.example.clearz")); | |
| 510 | 508 |
| 511 // There are no child key systems for UsesAes. | 509 // There are no child key systems for UsesAes. |
| 512 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.foo")); | 510 EXPECT_FALSE(IsSupportedKeySystem("x-org.example.clear.foo")); |
| 513 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 514 kVideoWebM, no_codecs(), "x-org.example.clear.foo")); | |
| 515 } | 511 } |
| 516 | 512 |
| 517 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { | 513 TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_NoType) { |
| 518 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 514 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 519 std::string(), no_codecs(), kUsesAes)); | 515 std::string(), no_codecs(), kUsesAes)); |
| 520 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 516 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 521 std::string(), no_codecs(), kUsesAesParent)); | 517 std::string(), no_codecs(), kUsesAesParent)); |
| 522 | 518 |
| 523 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(std::string(), no_codecs(), | 519 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(std::string(), no_codecs(), |
| 524 "x-org.example.foo")); | 520 "x-org.example.foo")); |
| 525 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 521 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 526 std::string(), no_codecs(), "x-org.example.clear.foo")); | 522 std::string(), no_codecs(), "x-org.example.clear.foo")); |
| 527 } | 523 } |
| 528 | 524 |
| 529 // Tests the second registered container type. | 525 // Tests the second registered container type. |
| 530 // TODO(ddorwin): Combined with TypesContainer1 in a future CL. | 526 // TODO(ddorwin): Combined with TypesContainer1 in a future CL. |
| 531 TEST_F(KeySystemsTest, | 527 TEST_F(KeySystemsTest, |
| 532 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer2) { | 528 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer2) { |
| 533 // Valid video types. | 529 // Valid video types. |
| 534 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 530 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 535 kVideoFoo, no_codecs(), kUsesAes)); | 531 kVideoFoo, no_codecs(), kUsesAes)); |
| 536 // The parent should be supported but is not. See http://crbug.com/164303. | |
| 537 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 538 kVideoFoo, no_codecs(), kUsesAesParent)); | |
| 539 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 532 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 540 kVideoFoo, foovideo_codec(), kUsesAes)); | 533 kVideoFoo, foovideo_codec(), kUsesAes)); |
| 541 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 534 |
| 535 // Audio in a video container. | |
| 536 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 542 kVideoFoo, foovideo_and_fooaudio_codecs(), kUsesAes)); | 537 kVideoFoo, foovideo_and_fooaudio_codecs(), kUsesAes)); |
| 543 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 538 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 544 kVideoFoo, fooaudio_codec(), kUsesAes)); | 539 kVideoFoo, fooaudio_codec(), kUsesAes)); |
| 545 | 540 |
| 546 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | 541 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
| 547 // They should really pass canPlayType(). | 542 // They should really pass canPlayType(). |
| 548 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 543 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 549 kVideoFoo, foovideo_extended_codec(), kUsesAes)); | 544 kVideoFoo, foovideo_extended_codec(), kUsesAes)); |
| 550 | 545 |
| 551 // Invalid codec format. | 546 // Invalid codec format. |
| 552 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 547 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 553 kVideoFoo, foovideo_dot_codec(), kUsesAes)); | 548 kVideoFoo, foovideo_dot_codec(), kUsesAes)); |
| 554 | 549 |
| 555 // Non-container2 codec. | 550 // Non-container2 codec. |
| 556 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 551 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 557 kVideoFoo, vp8_codec(), kUsesAes)); | 552 kVideoFoo, vp8_codec(), kUsesAes)); |
| 558 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 553 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 559 kVideoFoo, unknown_codec(), kUsesAes)); | 554 kVideoFoo, unknown_codec(), kUsesAes)); |
| 560 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 555 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 561 kVideoFoo, mixed_codecs(), kUsesAes)); | 556 kVideoFoo, mixed_codecs(), kUsesAes)); |
| 562 | 557 |
| 563 // Valid audio types. | 558 // Valid audio types. |
| 564 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 559 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 565 kAudioFoo, no_codecs(), kUsesAes)); | 560 kAudioFoo, no_codecs(), kUsesAes)); |
| 566 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 561 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 567 kAudioFoo, fooaudio_codec(), kUsesAes)); | 562 kAudioFoo, fooaudio_codec(), kUsesAes)); |
| 568 | 563 |
| 569 // Non-audio codecs. | 564 // Non-audio codecs. |
| 570 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 565 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 571 kAudioFoo, foovideo_codec(), kUsesAes)); | 566 kAudioFoo, foovideo_codec(), kUsesAes)); |
| 572 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 567 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 573 kAudioFoo, foovideo_and_fooaudio_codecs(), kUsesAes)); | 568 kAudioFoo, foovideo_and_fooaudio_codecs(), kUsesAes)); |
| 574 | 569 |
| 575 // Non-container2 codec. | 570 // Non-container2 codec. |
| 576 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 571 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 577 kAudioFoo, vorbis_codec(), kUsesAes)); | 572 kAudioFoo, vorbis_codec(), kUsesAes)); |
| 578 } | 573 } |
| 579 | 574 |
| 580 // | 575 // |
| 581 // Non-AesDecryptor-based key system. | 576 // Non-AesDecryptor-based key system. |
| 582 // | 577 // |
| 583 | 578 |
| 584 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { | 579 TEST_F(KeySystemsTest, Basic_ExternalDecryptor) { |
| 585 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); | 580 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); |
| 586 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 581 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 587 kVideoWebM, no_codecs(), kExternal)); | 582 kVideoWebM, no_codecs(), kExternal)); |
| 588 | 583 |
| 589 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); | 584 EXPECT_FALSE(CanUseAesDecryptor(kExternal)); |
| 590 #if defined(ENABLE_PEPPER_CDMS) | 585 #if defined(ENABLE_PEPPER_CDMS) |
| 591 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); | 586 EXPECT_EQ("application/x-ppapi-external-cdm", GetPepperType(kExternal)); |
| 592 #endif // defined(ENABLE_PEPPER_CDMS) | 587 #endif // defined(ENABLE_PEPPER_CDMS) |
| 593 } | 588 } |
| 594 | 589 |
| 595 TEST_F(KeySystemsTest, Parent_ParentRegistered) { | 590 TEST_F(KeySystemsTest, Parent_ParentRegistered) { |
| 596 // The parent system is not a concrete system but is supported. | 591 // Unprefixed has no parent key system support. |
| 597 EXPECT_FALSE(IsSupportedKeySystem(kExternalParent)); | 592 EXPECT_FALSE(IsSupportedKeySystem(kExternalParent)); |
| 598 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 599 kVideoWebM, no_codecs(), kExternalParent)); | |
| 600 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 593 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 601 kVideoWebM, no_codecs(), kExternalParent)); | 594 kVideoWebM, no_codecs(), kExternalParent)); |
| 602 | 595 |
| 603 // The parent is not supported for most things. | 596 // The parent is not supported for most things. |
| 604 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kExternalParent)); | 597 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kExternalParent)); |
| 605 bool result = false; | 598 bool result = false; |
| 606 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kExternalParent), | 599 EXPECT_DEBUG_DEATH_PORTABLE(result = CanUseAesDecryptor(kExternalParent), |
| 607 "x-com.example is not a known concrete system"); | 600 "x-com.example is not a known concrete system"); |
| 608 EXPECT_FALSE(result); | 601 EXPECT_FALSE(result); |
| 609 #if defined(ENABLE_PEPPER_CDMS) | 602 #if defined(ENABLE_PEPPER_CDMS) |
| 610 std::string type; | 603 std::string type; |
| 611 EXPECT_DEBUG_DEATH(type = GetPepperType(kExternalParent), | 604 EXPECT_DEBUG_DEATH(type = GetPepperType(kExternalParent), |
| 612 "x-com.example is not a known concrete system"); | 605 "x-com.example is not a known concrete system"); |
| 613 EXPECT_TRUE(type.empty()); | 606 EXPECT_TRUE(type.empty()); |
| 614 #endif | 607 #endif |
| 615 } | 608 } |
| 616 | 609 |
| 617 TEST_F( | 610 TEST_F( |
| 618 KeySystemsTest, | 611 KeySystemsTest, |
| 619 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { | 612 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer1) { |
| 620 // Valid video types. | 613 // Valid video types. |
| 621 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 614 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 622 kVideoWebM, no_codecs(), kExternal)); | 615 kVideoWebM, no_codecs(), kExternal)); |
| 623 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 616 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 624 kVideoWebM, vp8_codec(), kExternal)); | 617 kVideoWebM, vp8_codec(), kExternal)); |
| 625 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 618 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 626 kVideoWebM, vp80_codec(), kExternal)); | 619 kVideoWebM, vp80_codec(), kExternal)); |
| 627 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 620 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 628 kVideoWebM, vp8_and_vorbis_codecs(), kExternal)); | |
| 629 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 630 kVideoWebM, vp9_codec(), kExternal)); | 621 kVideoWebM, vp9_codec(), kExternal)); |
| 631 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 622 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 632 kVideoWebM, vp90_codec(), kExternal)); | 623 kVideoWebM, vp90_codec(), kExternal)); |
| 633 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 624 |
| 625 // Audio in a video container. | |
| 626 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 627 kVideoWebM, vp8_and_vorbis_codecs(), kExternal)); | |
| 628 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 634 kVideoWebM, vp9_and_vorbis_codecs(), kExternal)); | 629 kVideoWebM, vp9_and_vorbis_codecs(), kExternal)); |
| 635 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 630 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 636 kVideoWebM, vorbis_codec(), kExternal)); | 631 kVideoWebM, vorbis_codec(), kExternal)); |
| 637 | 632 |
| 638 // Valid video types - parent key system. | 633 // Valid video types - parent key system. |
| 639 // Unprefixed has no parent key system support. | |
| 640 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 641 kVideoWebM, no_codecs(), kExternalParent)); | |
| 642 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 643 kVideoWebM, vp8_codec(), kExternalParent)); | |
| 644 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 645 kVideoWebM, vp80_codec(), kExternalParent)); | |
| 646 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 647 kVideoWebM, vp8_and_vorbis_codecs(), kExternalParent)); | |
| 648 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 649 kVideoWebM, vp9_codec(), kExternalParent)); | |
| 650 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 651 kVideoWebM, vp90_codec(), kExternalParent)); | |
| 652 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 653 kVideoWebM, vp9_and_vorbis_codecs(), kExternalParent)); | |
| 654 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 655 kVideoWebM, vorbis_codec(), kExternalParent)); | |
| 656 // Prefixed has parent key system support. | 634 // Prefixed has parent key system support. |
| 657 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 635 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 658 kVideoWebM, no_codecs(), kExternalParent)); | 636 kVideoWebM, no_codecs(), kExternalParent)); |
| 659 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 637 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 660 kVideoWebM, vp8_codec(), kExternalParent)); | 638 kVideoWebM, vp8_codec(), kExternalParent)); |
| 661 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 639 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 662 kVideoWebM, vp80_codec(), kExternalParent)); | 640 kVideoWebM, vp80_codec(), kExternalParent)); |
| 663 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 641 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 664 kVideoWebM, vp8_and_vorbis_codecs(), kExternalParent)); | 642 kVideoWebM, vp8_and_vorbis_codecs(), kExternalParent)); |
| 665 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 643 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 666 kVideoWebM, vp9_codec(), kExternalParent)); | 644 kVideoWebM, vp9_codec(), kExternalParent)); |
| 667 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 645 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 668 kVideoWebM, vp90_codec(), kExternalParent)); | 646 kVideoWebM, vp90_codec(), kExternalParent)); |
| 669 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 647 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 670 kVideoWebM, vp9_and_vorbis_codecs(), kExternalParent)); | 648 kVideoWebM, vp9_and_vorbis_codecs(), kExternalParent)); |
| 671 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 649 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 672 kVideoWebM, vorbis_codec(), kExternalParent)); | 650 kVideoWebM, vorbis_codec(), kExternalParent)); |
| 673 | 651 |
| 674 // Non-Webm codecs. | 652 // Non-Webm codecs. |
| 675 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 653 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 676 kVideoWebM, foovideo_codec(), kExternal)); | 654 kVideoWebM, foovideo_codec(), kExternal)); |
| 677 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 655 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 678 kVideoWebM, unknown_codec(), kExternal)); | 656 kVideoWebM, unknown_codec(), kExternal)); |
| 679 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 657 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 680 kVideoWebM, mixed_codecs(), kExternal)); | 658 kVideoWebM, mixed_codecs(), kExternal)); |
| 681 | 659 |
| 682 // Valid audio types. | 660 // Valid audio types. |
| 683 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 661 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 684 kAudioWebM, no_codecs(), kExternal)); | 662 kAudioWebM, no_codecs(), kExternal)); |
| 685 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 663 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 686 kAudioWebM, vorbis_codec(), kExternal)); | 664 kAudioWebM, vorbis_codec(), kExternal)); |
| 687 | 665 |
| 688 // Valid audio types - parent key system. | 666 // Valid audio types - parent key system. |
| 689 // Unprefixed has no parent key system support. | |
| 690 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 691 kAudioWebM, no_codecs(), kExternalParent)); | |
| 692 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 693 kAudioWebM, vorbis_codec(), kExternalParent)); | |
| 694 // Prefixed has parent key system support. | 667 // Prefixed has parent key system support. |
| 695 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 668 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 696 kAudioWebM, no_codecs(), kExternalParent)); | 669 kAudioWebM, no_codecs(), kExternalParent)); |
| 697 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 670 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 698 kAudioWebM, vorbis_codec(), kExternalParent)); | 671 kAudioWebM, vorbis_codec(), kExternalParent)); |
| 699 | 672 |
| 700 // Non-audio codecs. | 673 // Non-audio codecs. |
| 701 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 674 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 702 kAudioWebM, vp8_codec(), kExternal)); | 675 kAudioWebM, vp8_codec(), kExternal)); |
| 703 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 676 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 704 kAudioWebM, vp8_and_vorbis_codecs(), kExternal)); | 677 kAudioWebM, vp8_and_vorbis_codecs(), kExternal)); |
| 705 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 678 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 706 kAudioWebM, vp9_codec(), kExternal)); | 679 kAudioWebM, vp9_codec(), kExternal)); |
| 707 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 680 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 708 kAudioWebM, vp9_and_vorbis_codecs(), kExternal)); | 681 kAudioWebM, vp9_and_vorbis_codecs(), kExternal)); |
| 709 | 682 |
| 710 // Non-Webm codec. | 683 // Non-Webm codec. |
| 711 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 684 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 712 kAudioWebM, fooaudio_codec(), kExternal)); | 685 kAudioWebM, fooaudio_codec(), kExternal)); |
| 713 } | 686 } |
| 714 | 687 |
| 715 TEST_F( | 688 TEST_F( |
| 716 KeySystemsTest, | 689 KeySystemsTest, |
| 717 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { | 690 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { |
| 718 // Valid video types. | 691 // Valid video types. |
| 719 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 692 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 720 kVideoFoo, no_codecs(), kExternal)); | 693 kVideoFoo, no_codecs(), kExternal)); |
| 721 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 694 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 722 kVideoFoo, foovideo_codec(), kExternal)); | 695 kVideoFoo, foovideo_codec(), kExternal)); |
| 723 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 696 |
| 697 // Audio in a video container. | |
| 698 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 724 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternal)); | 699 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternal)); |
| 725 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 700 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 726 kVideoFoo, fooaudio_codec(), kExternal)); | 701 kVideoFoo, fooaudio_codec(), kExternal)); |
| 727 | 702 |
| 728 // Valid video types - parent key system. | 703 // Valid video types - parent key system. |
| 729 // Unprefixed has no parent key system support. | |
| 730 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 731 kVideoFoo, no_codecs(), kExternalParent)); | |
| 732 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 733 kVideoFoo, foovideo_codec(), kExternalParent)); | |
| 734 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 735 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternalParent)); | |
| 736 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 737 kVideoFoo, fooaudio_codec(), kExternalParent)); | |
| 738 // Prefixed has parent key system support. | 704 // Prefixed has parent key system support. |
| 739 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 705 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 740 kVideoFoo, no_codecs(), kExternalParent)); | 706 kVideoFoo, no_codecs(), kExternalParent)); |
| 741 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 707 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 742 kVideoFoo, foovideo_codec(), kExternalParent)); | 708 kVideoFoo, foovideo_codec(), kExternalParent)); |
| 743 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 709 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 744 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternalParent)); | 710 kVideoFoo, foovideo_and_fooaudio_codecs(), kExternalParent)); |
| 745 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 711 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 746 kVideoFoo, fooaudio_codec(), kExternalParent)); | 712 kVideoFoo, fooaudio_codec(), kExternalParent)); |
| 747 | 713 |
| 748 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. | 714 // Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl. |
| 749 // They should really pass canPlayType(). | 715 // They should really pass canPlayType(). |
| 750 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 716 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 751 kVideoFoo, foovideo_extended_codec(), kExternal)); | 717 kVideoFoo, foovideo_extended_codec(), kExternal)); |
| 752 | 718 |
| 753 // Invalid codec format. | 719 // Invalid codec format. |
| 754 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 720 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 755 kVideoFoo, foovideo_dot_codec(), kExternal)); | 721 kVideoFoo, foovideo_dot_codec(), kExternal)); |
| 756 | 722 |
| 757 // Non-container2 codecs. | 723 // Non-container2 codecs. |
| 758 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 724 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 759 kVideoFoo, vp8_codec(), kExternal)); | 725 kVideoFoo, vp8_codec(), kExternal)); |
| 760 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 726 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 761 kVideoFoo, unknown_codec(), kExternal)); | 727 kVideoFoo, unknown_codec(), kExternal)); |
| 762 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 728 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 763 kVideoFoo, mixed_codecs(), kExternal)); | 729 kVideoFoo, mixed_codecs(), kExternal)); |
| 764 | 730 |
| 765 // Valid audio types. | 731 // Valid audio types. |
| 766 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 732 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 767 kAudioFoo, no_codecs(), kExternal)); | 733 kAudioFoo, no_codecs(), kExternal)); |
| 768 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 734 EXPECT_TRUE(IsSupportedKeySystemWithAudioMimeType( |
| 769 kAudioFoo, fooaudio_codec(), kExternal)); | 735 kAudioFoo, fooaudio_codec(), kExternal)); |
| 770 | 736 |
| 771 // Valid audio types - parent key system. | 737 // Valid audio types - parent key system. |
| 772 // Unprefixed has no parent key system support. | 738 // Unprefixed has no parent key system support. |
|
ddorwin
2015/03/24 23:48:04
Not removed
sandersd (OOO until July 31)
2015/03/24 23:57:21
Done.
| |
| 773 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 774 kAudioFoo, no_codecs(), kExternalParent)); | |
| 775 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 776 kAudioFoo, fooaudio_codec(), kExternalParent)); | |
| 777 // Prefixed has parent key system support. | 739 // Prefixed has parent key system support. |
| 778 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 740 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 779 kAudioFoo, no_codecs(), kExternalParent)); | 741 kAudioFoo, no_codecs(), kExternalParent)); |
| 780 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 742 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 781 kAudioFoo, fooaudio_codec(), kExternalParent)); | 743 kAudioFoo, fooaudio_codec(), kExternalParent)); |
| 782 | 744 |
| 783 // Non-audio codecs. | 745 // Non-audio codecs. |
| 784 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 746 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 785 kAudioFoo, foovideo_codec(), kExternal)); | 747 kAudioFoo, foovideo_codec(), kExternal)); |
| 786 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 748 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 787 kAudioFoo, foovideo_and_fooaudio_codecs(), kExternal)); | 749 kAudioFoo, foovideo_and_fooaudio_codecs(), kExternal)); |
| 788 | 750 |
| 789 // Non-container2 codec. | 751 // Non-container2 codec. |
| 790 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 752 EXPECT_FALSE(IsSupportedKeySystemWithAudioMimeType( |
| 791 kAudioFoo, vorbis_codec(), kExternal)); | 753 kAudioFoo, vorbis_codec(), kExternal)); |
| 792 } | 754 } |
| 793 | 755 |
| 794 TEST_F(KeySystemsTest, KeySystemNameForUMA) { | 756 TEST_F(KeySystemsTest, KeySystemNameForUMA) { |
| 795 EXPECT_EQ("ClearKey", GetKeySystemNameForUMA(kClearKey)); | 757 EXPECT_EQ("ClearKey", GetKeySystemNameForUMA(kClearKey)); |
| 796 // Prefixed is not supported internally. | 758 // Prefixed is not supported internally. |
| 797 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kPrefixedClearKey)); | 759 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kPrefixedClearKey)); |
| 798 | 760 |
| 799 // External Clear Key never has a UMA name. | 761 // External Clear Key never has a UMA name. |
| 800 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kExternalClearKey)); | 762 EXPECT_EQ("Unknown", GetKeySystemNameForUMA(kExternalClearKey)); |
| 801 } | 763 } |
| 802 | 764 |
| 803 TEST_F(KeySystemsTest, KeySystemsUpdate) { | 765 TEST_F(KeySystemsTest, KeySystemsUpdate) { |
| 804 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); | 766 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); |
| 805 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 767 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 806 kVideoWebM, no_codecs(), kUsesAes)); | 768 kVideoWebM, no_codecs(), kUsesAes)); |
| 807 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); | 769 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); |
| 808 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 770 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 809 kVideoWebM, no_codecs(), kExternal)); | 771 kVideoWebM, no_codecs(), kExternal)); |
| 810 | 772 |
| 811 UpdateClientKeySystems(); | 773 UpdateClientKeySystems(); |
| 812 | 774 |
| 813 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); | 775 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); |
| 814 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 776 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 815 kVideoWebM, no_codecs(), kUsesAes)); | 777 kVideoWebM, no_codecs(), kUsesAes)); |
| 816 EXPECT_FALSE(IsSupportedKeySystem(kExternal)); | 778 EXPECT_FALSE(IsSupportedKeySystem(kExternal)); |
| 817 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 818 kVideoWebM, no_codecs(), kExternal)); | |
| 819 } | 779 } |
| 820 | 780 |
| 821 TEST_F(KeySystemsTest, PrefixedKeySystemsUpdate) { | 781 TEST_F(KeySystemsTest, PrefixedKeySystemsUpdate) { |
| 822 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); | 782 EXPECT_TRUE(IsSupportedKeySystem(kUsesAes)); |
| 823 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 783 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 824 kVideoWebM, no_codecs(), kUsesAes)); | 784 kVideoWebM, no_codecs(), kUsesAes)); |
| 825 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); | 785 EXPECT_TRUE(IsSupportedKeySystem(kExternal)); |
| 826 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( | 786 EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 827 kVideoWebM, no_codecs(), kExternal)); | 787 kVideoWebM, no_codecs(), kExternal)); |
| 828 | 788 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); | 829 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.something.else")); |
| 870 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); | 830 EXPECT_FALSE(IsSupportedKeySystem("com.chromecast.other")); |
| 871 | 831 |
| 872 EXPECT_FALSE(IsSupportedKeySystem("x-")); | 832 EXPECT_FALSE(IsSupportedKeySystem("x-")); |
| 873 EXPECT_TRUE(IsSupportedKeySystem("x-something")); | 833 EXPECT_TRUE(IsSupportedKeySystem("x-something")); |
| 874 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); | 834 EXPECT_FALSE(IsSupportedKeySystem("x-something.else")); |
| 875 EXPECT_FALSE(IsSupportedKeySystem("x-other")); | 835 EXPECT_FALSE(IsSupportedKeySystem("x-other")); |
| 876 } | 836 } |
| 877 | 837 |
| 878 } // namespace media | 838 } // namespace media |
| OLD | NEW |