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 "content/public/common/content_client.h" | 8 #include "content/public/common/content_client.h" |
| 9 #include "content/public/renderer/content_renderer_client.h" | 9 #include "content/public/renderer/content_renderer_client.h" |
| 10 #include "content/public/renderer/key_system_info.h" | 10 #include "content/public/renderer/key_system_info.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 key_systems->push_back(ext); | 113 key_systems->push_back(ext); |
| 114 } | 114 } |
| 115 | 115 |
| 116 class KeySystemsTest : public testing::Test { | 116 class KeySystemsTest : public testing::Test { |
| 117 protected: | 117 protected: |
| 118 KeySystemsTest() { | 118 KeySystemsTest() { |
| 119 vp8_codec_.push_back("vp8"); | 119 vp8_codec_.push_back("vp8"); |
| 120 | 120 |
| 121 vp80_codec_.push_back("vp8.0"); | 121 vp80_codec_.push_back("vp8.0"); |
| 122 | 122 |
| 123 vp9_codec_.push_back("vp9"); | |
| 124 | |
| 125 vp90_codec_.push_back("vp9.0"); | |
| 126 | |
| 123 vorbis_codec_.push_back("vorbis"); | 127 vorbis_codec_.push_back("vorbis"); |
| 124 | 128 |
| 125 vp8_and_vorbis_codecs_.push_back("vp8"); | 129 vp8_and_vorbis_codecs_.push_back("vp8"); |
| 126 vp8_and_vorbis_codecs_.push_back("vorbis"); | 130 vp8_and_vorbis_codecs_.push_back("vorbis"); |
| 127 | 131 |
| 132 vp9_and_vorbis_codecs_.push_back("vp9"); | |
| 133 vp9_and_vorbis_codecs_.push_back("vorbis"); | |
| 134 | |
| 128 foovideo_codec_.push_back("foovideo"); | 135 foovideo_codec_.push_back("foovideo"); |
| 129 | 136 |
| 130 foovideo_extended_codec_.push_back("foovideo.4D400C"); | 137 foovideo_extended_codec_.push_back("foovideo.4D400C"); |
| 131 | 138 |
| 132 foovideo_dot_codec_.push_back("foovideo."); | 139 foovideo_dot_codec_.push_back("foovideo."); |
| 133 | 140 |
| 134 fooaudio_codec_.push_back("fooaudio"); | 141 fooaudio_codec_.push_back("fooaudio"); |
| 135 | 142 |
| 136 foovideo_and_fooaudio_codecs_.push_back("foovideo"); | 143 foovideo_and_fooaudio_codecs_.push_back("foovideo"); |
| 137 foovideo_and_fooaudio_codecs_.push_back("fooaudio"); | 144 foovideo_and_fooaudio_codecs_.push_back("fooaudio"); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 160 // Clear the use of content_client_, which was set in SetUp(). | 167 // Clear the use of content_client_, which was set in SetUp(). |
| 161 SetContentClient(NULL); | 168 SetContentClient(NULL); |
| 162 } | 169 } |
| 163 | 170 |
| 164 typedef std::vector<std::string> CodecVector; | 171 typedef std::vector<std::string> CodecVector; |
| 165 | 172 |
| 166 const CodecVector& no_codecs() const { return no_codecs_; } | 173 const CodecVector& no_codecs() const { return no_codecs_; } |
| 167 | 174 |
| 168 const CodecVector& vp8_codec() const { return vp8_codec_; } | 175 const CodecVector& vp8_codec() const { return vp8_codec_; } |
| 169 const CodecVector& vp80_codec() const { return vp80_codec_; } | 176 const CodecVector& vp80_codec() const { return vp80_codec_; } |
| 177 const CodecVector& vp9_codec() const { return vp9_codec_; } | |
| 178 const CodecVector& vp90_codec() const { return vp90_codec_; } | |
| 179 | |
| 170 const CodecVector& vorbis_codec() const { return vorbis_codec_; } | 180 const CodecVector& vorbis_codec() const { return vorbis_codec_; } |
| 181 | |
| 171 const CodecVector& vp8_and_vorbis_codecs() const { | 182 const CodecVector& vp8_and_vorbis_codecs() const { |
| 172 return vp8_and_vorbis_codecs_; | 183 return vp8_and_vorbis_codecs_; |
| 173 } | 184 } |
| 185 const CodecVector& vp9_and_vorbis_codecs() const { | |
| 186 return vp9_and_vorbis_codecs_; | |
| 187 } | |
| 174 | 188 |
| 175 const CodecVector& foovideo_codec() const { return foovideo_codec_; } | 189 const CodecVector& foovideo_codec() const { return foovideo_codec_; } |
| 176 const CodecVector& foovideo_extended_codec() const { | 190 const CodecVector& foovideo_extended_codec() const { |
| 177 return foovideo_extended_codec_; | 191 return foovideo_extended_codec_; |
| 178 } | 192 } |
| 179 const CodecVector& foovideo_dot_codec() const { return foovideo_dot_codec_; } | 193 const CodecVector& foovideo_dot_codec() const { return foovideo_dot_codec_; } |
| 180 const CodecVector& fooaudio_codec() const { return fooaudio_codec_; } | 194 const CodecVector& fooaudio_codec() const { return fooaudio_codec_; } |
| 181 const CodecVector& foovideo_and_fooaudio_codecs() const { | 195 const CodecVector& foovideo_and_fooaudio_codecs() const { |
| 182 return foovideo_and_fooaudio_codecs_; | 196 return foovideo_and_fooaudio_codecs_; |
| 183 } | 197 } |
| 184 | 198 |
| 185 const CodecVector& unknown_codec() const { return unknown_codec_; } | 199 const CodecVector& unknown_codec() const { return unknown_codec_; } |
| 186 | 200 |
| 187 const CodecVector& mixed_codecs() const { return mixed_codecs_; } | 201 const CodecVector& mixed_codecs() const { return mixed_codecs_; } |
| 188 | 202 |
| 189 private: | 203 private: |
| 190 const CodecVector no_codecs_; | 204 const CodecVector no_codecs_; |
| 191 | |
| 192 CodecVector vp8_codec_; | 205 CodecVector vp8_codec_; |
| 193 CodecVector vp80_codec_; | 206 CodecVector vp80_codec_; |
| 207 CodecVector vp9_codec_; | |
| 208 CodecVector vp90_codec_; | |
| 194 CodecVector vorbis_codec_; | 209 CodecVector vorbis_codec_; |
| 195 CodecVector vp8_and_vorbis_codecs_; | 210 CodecVector vp8_and_vorbis_codecs_; |
| 211 CodecVector vp9_and_vorbis_codecs_; | |
| 196 | 212 |
| 197 CodecVector foovideo_codec_; | 213 CodecVector foovideo_codec_; |
| 198 CodecVector foovideo_extended_codec_; | 214 CodecVector foovideo_extended_codec_; |
| 199 CodecVector foovideo_dot_codec_; | 215 CodecVector foovideo_dot_codec_; |
| 200 CodecVector fooaudio_codec_; | 216 CodecVector fooaudio_codec_; |
| 201 CodecVector foovideo_and_fooaudio_codecs_; | 217 CodecVector foovideo_and_fooaudio_codecs_; |
| 202 | 218 |
| 203 CodecVector unknown_codec_; | 219 CodecVector unknown_codec_; |
| 204 | 220 |
| 205 CodecVector mixed_codecs_; | 221 CodecVector mixed_codecs_; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 TEST_F(KeySystemsTest, | 292 TEST_F(KeySystemsTest, |
| 277 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) { | 293 IsSupportedKeySystemWithMediaMimeType_UsesAesDecryptor_TypesContainer1) { |
| 278 // Valid video types. | 294 // Valid video types. |
| 279 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 295 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 280 kVideoWebM, vp8_codec(), kUsesAes)); | 296 kVideoWebM, vp8_codec(), kUsesAes)); |
| 281 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 297 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 282 kVideoWebM, vp80_codec(), kUsesAes)); | 298 kVideoWebM, vp80_codec(), kUsesAes)); |
| 283 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 299 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 284 kVideoWebM, vp8_and_vorbis_codecs(), kUsesAes)); | 300 kVideoWebM, vp8_and_vorbis_codecs(), kUsesAes)); |
| 285 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 301 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 302 kVideoWebM, vp9_codec(), kUsesAes)); | |
| 303 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 304 kVideoWebM, vp90_codec(), kUsesAes)); | |
| 305 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 306 kVideoWebM, vp9_and_vorbis_codecs(), kUsesAes)); | |
| 307 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 286 kVideoWebM, vorbis_codec(), kUsesAes)); | 308 kVideoWebM, vorbis_codec(), kUsesAes)); |
| 287 | 309 |
| 288 // Non-Webm codecs. | 310 // Non-Webm codecs. |
| 289 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 311 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 290 kVideoWebM, foovideo_codec(), kUsesAes)); | 312 kVideoWebM, foovideo_codec(), kUsesAes)); |
| 291 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 313 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 292 kVideoWebM, unknown_codec(), kUsesAes)); | 314 kVideoWebM, unknown_codec(), kUsesAes)); |
| 293 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 315 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 294 kVideoWebM, mixed_codecs(), kUsesAes)); | 316 kVideoWebM, mixed_codecs(), kUsesAes)); |
| 295 | 317 |
| 296 // Valid audio types. | 318 // Valid audio types. |
| 297 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 319 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 298 kAudioWebM, no_codecs(), kUsesAes)); | 320 kAudioWebM, no_codecs(), kUsesAes)); |
| 299 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 321 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 300 kAudioWebM, vorbis_codec(), kUsesAes)); | 322 kAudioWebM, vorbis_codec(), kUsesAes)); |
| 301 | 323 |
| 302 // Non-audio codecs. | 324 // Non-audio codecs. |
| 303 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 325 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 304 kAudioWebM, vp8_codec(), kUsesAes)); | 326 kAudioWebM, vp8_codec(), kUsesAes)); |
| 305 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 327 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 306 kAudioWebM, vp8_and_vorbis_codecs(), kUsesAes)); | 328 kAudioWebM, vp8_and_vorbis_codecs(), kUsesAes)); |
| 329 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 330 kAudioWebM, vp9_codec(), kUsesAes)); | |
| 331 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 332 kAudioWebM, vp9_and_vorbis_codecs(), kUsesAes)); | |
| 307 | 333 |
| 308 // Non-Webm codec. | 334 // Non-Webm codec. |
| 309 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 335 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 310 kAudioWebM, fooaudio_codec(), kUsesAes)); | 336 kAudioWebM, fooaudio_codec(), kUsesAes)); |
| 311 } | 337 } |
| 312 | 338 |
| 313 // No parent is registered for UsesAes. | 339 // No parent is registered for UsesAes. |
| 314 TEST_F(KeySystemsTest, Parent_NoParentRegistered) { | 340 TEST_F(KeySystemsTest, Parent_NoParentRegistered) { |
| 315 EXPECT_FALSE(IsConcreteSupportedKeySystem(kUsesAesParent)); | 341 EXPECT_FALSE(IsConcreteSupportedKeySystem(kUsesAesParent)); |
| 316 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 342 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 // Valid video types. | 496 // Valid video types. |
| 471 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 497 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 472 kVideoWebM, no_codecs(), kExternal)); | 498 kVideoWebM, no_codecs(), kExternal)); |
| 473 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 499 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 474 kVideoWebM, vp8_codec(), kExternal)); | 500 kVideoWebM, vp8_codec(), kExternal)); |
| 475 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 501 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 476 kVideoWebM, vp80_codec(), kExternal)); | 502 kVideoWebM, vp80_codec(), kExternal)); |
| 477 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 503 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 478 kVideoWebM, vp8_and_vorbis_codecs(), kExternal)); | 504 kVideoWebM, vp8_and_vorbis_codecs(), kExternal)); |
| 479 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 505 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 506 kVideoWebM, vp9_codec(), kExternal)); | |
| 507 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 508 kVideoWebM, vp90_codec(), kExternal)); | |
| 509 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 510 kVideoWebM, vp9_and_vorbis_codecs(), kExternal)); | |
| 511 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
|
ddorwin
2014/04/24 23:00:23
indentation
xhwang
2014/04/25 16:49:08
Done.
| |
| 480 kVideoWebM, vorbis_codec(), kExternal)); | 512 kVideoWebM, vorbis_codec(), kExternal)); |
| 481 | 513 |
| 482 // Valid video types - parent key system. | 514 // Valid video types - parent key system. |
| 483 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 515 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 484 kVideoWebM, no_codecs(), kExternalParent)); | 516 kVideoWebM, no_codecs(), kExternalParent)); |
| 485 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 517 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 486 kVideoWebM, vp8_codec(), kExternalParent)); | 518 kVideoWebM, vp8_codec(), kExternalParent)); |
| 487 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 519 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 488 kVideoWebM, vp80_codec(), kExternalParent)); | 520 kVideoWebM, vp80_codec(), kExternalParent)); |
| 489 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 521 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 490 kVideoWebM, vp8_and_vorbis_codecs(), kExternalParent)); | 522 kVideoWebM, vp8_and_vorbis_codecs(), kExternalParent)); |
| 491 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 523 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 524 kVideoWebM, vp9_codec(), kExternalParent)); | |
| 525 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 526 kVideoWebM, vp90_codec(), kExternalParent)); | |
| 527 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 528 kVideoWebM, vp9_and_vorbis_codecs(), kExternalParent)); | |
| 529 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | |
| 492 kVideoWebM, vorbis_codec(), kExternalParent)); | 530 kVideoWebM, vorbis_codec(), kExternalParent)); |
| 493 | 531 |
| 494 // Non-Webm codecs. | 532 // Non-Webm codecs. |
| 495 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 533 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 496 kVideoWebM, foovideo_codec(), kExternal)); | 534 kVideoWebM, foovideo_codec(), kExternal)); |
| 497 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 535 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 498 kVideoWebM, unknown_codec(), kExternal)); | 536 kVideoWebM, unknown_codec(), kExternal)); |
| 499 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 537 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 500 kVideoWebM, mixed_codecs(), kExternal)); | 538 kVideoWebM, mixed_codecs(), kExternal)); |
| 501 | 539 |
| 502 // Valid audio types. | 540 // Valid audio types. |
| 503 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 541 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 504 kAudioWebM, no_codecs(), kExternal)); | 542 kAudioWebM, no_codecs(), kExternal)); |
| 505 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 543 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 506 kAudioWebM, vorbis_codec(), kExternal)); | 544 kAudioWebM, vorbis_codec(), kExternal)); |
| 507 | 545 |
| 508 // Valid audio types - parent key system. | 546 // Valid audio types - parent key system. |
| 509 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 547 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 510 kAudioWebM, no_codecs(), kExternalParent)); | 548 kAudioWebM, no_codecs(), kExternalParent)); |
| 511 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( | 549 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( |
| 512 kAudioWebM, vorbis_codec(), kExternalParent)); | 550 kAudioWebM, vorbis_codec(), kExternalParent)); |
| 513 | 551 |
| 514 // Non-audio codecs. | 552 // Non-audio codecs. |
| 515 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 553 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 516 kAudioWebM, vp8_codec(), kExternal)); | 554 kAudioWebM, vp8_codec(), kExternal)); |
| 517 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 555 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 518 kAudioWebM, vp8_and_vorbis_codecs(), kExternal)); | 556 kAudioWebM, vp8_and_vorbis_codecs(), kExternal)); |
| 557 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 558 kAudioWebM, vp9_codec(), kExternal)); | |
| 559 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | |
| 560 kAudioWebM, vp9_and_vorbis_codecs(), kExternal)); | |
| 519 | 561 |
| 520 // Non-Webm codec. | 562 // Non-Webm codec. |
| 521 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( | 563 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( |
| 522 kAudioWebM, fooaudio_codec(), kExternal)); | 564 kAudioWebM, fooaudio_codec(), kExternal)); |
| 523 } | 565 } |
| 524 | 566 |
| 525 TEST_F( | 567 TEST_F( |
| 526 KeySystemsTest, | 568 KeySystemsTest, |
| 527 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { | 569 IsSupportedKeySystemWithMediaMimeType_ExternalDecryptor_TypesContainer2) { |
| 528 // Valid video types. | 570 // Valid video types. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 | 637 |
| 596 #if defined(WIDEVINE_CDM_AVAILABLE) | 638 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 597 const char* const kTestWidevineUmaName = "Widevine"; | 639 const char* const kTestWidevineUmaName = "Widevine"; |
| 598 #else | 640 #else |
| 599 const char* const kTestWidevineUmaName = "Unknown"; | 641 const char* const kTestWidevineUmaName = "Unknown"; |
| 600 #endif | 642 #endif |
| 601 EXPECT_EQ(kTestWidevineUmaName, KeySystemNameForUMA("com.widevine.alpha")); | 643 EXPECT_EQ(kTestWidevineUmaName, KeySystemNameForUMA("com.widevine.alpha")); |
| 602 } | 644 } |
| 603 | 645 |
| 604 } // namespace content | 646 } // namespace content |
| OLD | NEW |