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