Chromium Code Reviews| Index: media/base/android/media_source_player_unittest.cc |
| diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc |
| index 02ded2d5ff6ee66ce155d2856c90958ca9018d8d..1929cd36069d7335f1797ca565f939348df4edad 100644 |
| --- a/media/base/android/media_source_player_unittest.cc |
| +++ b/media/base/android/media_source_player_unittest.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/strings/stringprintf.h" |
| #include "media/base/android/media_codec_bridge.h" |
| +#include "media/base/android/media_drm_bridge.h" |
| #include "media/base/android/media_player_manager.h" |
| #include "media/base/android/media_source_player.h" |
| #include "media/base/decoder_buffer.h" |
| @@ -174,12 +175,20 @@ class MediaSourcePlayerTest : public testing::Test { |
| ack_params.access_units[0].status = DemuxerStream::kOk; |
| ack_params.access_units[0].end_of_stream = true; |
| return ack_params; |
| - } |
| + } |
| base::TimeTicks StartTimeTicks() { |
| return player_->start_time_ticks_; |
| } |
| + bool IsTypeSupported(const std::vector<uint8>& scheme_uuid, |
| + const std::string& security_level, |
| + const std::string& container, |
| + const std::vector<std::string>& codecs) { |
| + return MediaSourcePlayer::IsTypeSupported( |
|
ddorwin
2013/08/28 18:41:57
Would a using statement avoid the need for this fu
xhwang
2013/08/30 05:32:38
We can only "using foo_namespace::Func1", not "usi
|
| + scheme_uuid, security_level, container, codecs); |
| + } |
| + |
| protected: |
| scoped_ptr<MockMediaPlayerManager> manager_; |
| scoped_ptr<MediaSourcePlayer> player_; |
| @@ -467,4 +476,46 @@ TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterInputEOS) { |
| EXPECT_EQ(2, manager_->num_requests()); |
| } |
| +TEST_F(MediaSourcePlayerTest, CanPlayType_Widevine) { |
| + if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) |
| + return; |
| + |
| + uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
| + 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
| + |
| + std::vector<uint8> widevine_uuid(kWidevineUUID, |
| + kWidevineUUID + arraysize(kWidevineUUID)); |
| + |
| + std::vector<std::string> codec_avc(1, "avc1"); |
| + EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/mp4", codec_avc)); |
| + EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L1", "video/mp4", codec_avc)); |
| + |
| + std::vector<std::string> codec_vp8(1, "vp8"); |
| + EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/webm", codec_vp8)); |
| + EXPECT_FALSE(IsTypeSupported(widevine_uuid, "L1", "video/webm", codec_vp8)); |
| + |
| + std::vector<std::string> codec_vorbis(1, "vorbis"); |
| + EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/webm", codec_vorbis)); |
| + EXPECT_FALSE( |
| + IsTypeSupported(widevine_uuid, "L1", "video/webm", codec_vorbis)); |
| +} |
| + |
| +TEST_F(MediaSourcePlayerTest, CanPlayType_InvalidUUID) { |
| + if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) |
| + return; |
| + |
| + uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, |
| + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; |
| + |
| + std::vector<uint8> invalid_uuid(kInvalidUUID, |
| + kInvalidUUID + arraysize(kInvalidUUID)); |
| + |
| + std::vector<std::string> codec_avc(1, "avc1"); |
| + EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", "video/mp4", codec_avc)); |
| + EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", "video/mp4", codec_avc)); |
| +} |
| + |
| +// TODO(xhwang): Are these IsTypeSupported tests device specific? |
| +// TODO(xhwang): Add more IsTypeSupported tests. |
| + |
| } // namespace media |