Chromium Code Reviews| Index: media/formats/webm/webm_tracks_parser_unittest.cc |
| diff --git a/media/formats/webm/webm_tracks_parser_unittest.cc b/media/formats/webm/webm_tracks_parser_unittest.cc |
| index 0f8e3515c3828f5599bc0ce6d685f84a0de54d4d..db3626360251643bcc518e9b30340a52beb561ea 100644 |
| --- a/media/formats/webm/webm_tracks_parser_unittest.cc |
| +++ b/media/formats/webm/webm_tracks_parser_unittest.cc |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include "base/logging.h" |
| +#include "media/base/channel_layout.h" |
| #include "media/formats/webm/tracks_builder.h" |
| #include "media/formats/webm/webm_constants.h" |
| #include "media/formats/webm/webm_tracks_parser.h" |
| @@ -48,7 +49,7 @@ TEST_F(WebMTracksParserTest, SubtitleNoNameNoLang) { |
| TracksBuilder tb; |
| tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, 1, |
| - kWebMCodecSubtitles, "", ""); |
| + kWebMCodecSubtitles, "", "", -1, -1, -1, -1, -1); |
| const std::vector<uint8> buf = tb.Finish(); |
| VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", ""); |
| @@ -59,7 +60,7 @@ TEST_F(WebMTracksParserTest, SubtitleYesNameNoLang) { |
| TracksBuilder tb; |
| tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, 1, |
| - kWebMCodecSubtitles, "Spock", ""); |
| + kWebMCodecSubtitles, "Spock", "", -1, -1, -1, -1, -1); |
| const std::vector<uint8> buf = tb.Finish(); |
| VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Spock", ""); |
| @@ -70,7 +71,7 @@ TEST_F(WebMTracksParserTest, SubtitleNoNameYesLang) { |
| TracksBuilder tb; |
| tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, 1, |
| - kWebMCodecSubtitles, "", "eng"); |
| + kWebMCodecSubtitles, "", "eng", -1, -1, -1, -1, -1); |
| const std::vector<uint8> buf = tb.Finish(); |
| VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", "eng"); |
| @@ -81,7 +82,7 @@ TEST_F(WebMTracksParserTest, SubtitleYesNameYesLang) { |
| TracksBuilder tb; |
| tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, 1, |
| - kWebMCodecSubtitles, "Picard", "fre"); |
| + kWebMCodecSubtitles, "Picard", "fre", -1, -1, -1, -1, -1); |
| const std::vector<uint8> buf = tb.Finish(); |
| VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Picard", "fre"); |
| @@ -92,9 +93,9 @@ TEST_F(WebMTracksParserTest, IgnoringTextTracks) { |
| TracksBuilder tb; |
| tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, 1, |
| - kWebMCodecSubtitles, "Subtitles", "fre"); |
| + kWebMCodecSubtitles, "Subtitles", "fre", -1, -1, -1, -1, -1); |
| tb.AddTrack(2, kWebMTrackTypeSubtitlesOrCaptions, 2, |
| - kWebMCodecSubtitles, "Commentary", "fre"); |
| + kWebMCodecSubtitles, "Commentary", "fre", -1, -1, -1, -1, -1); |
| const std::vector<uint8> buf = tb.Finish(); |
| scoped_ptr<WebMTracksParser> parser(new WebMTracksParser(LogCB(), true)); |
| @@ -119,4 +120,60 @@ TEST_F(WebMTracksParserTest, IgnoringTextTracks) { |
| EXPECT_EQ(parser->text_tracks().size(), 2u); |
| } |
| +TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationUnset) { |
| + // Other audio/video decoder config fields are necessary in the test |
| + // audio/video TrackEntry configurations. This method does only very minimal |
| + // verification of their inclusion and parsing; the goal is to confirm |
| + // TrackEntry DefaultDuration defaults to -1 if not included in audio or |
| + // video TrackEntry. |
| + TracksBuilder tb; |
| + tb.AddTrack(1, kWebMTrackTypeAudio, 1, "A_VORBIS", "audio", "", -1, -1, -1, |
|
acolwell GONE FROM CHROMIUM
2014/03/26 22:25:32
nit: Should we have AddVideoTrack(), AddAudioTrack
wolenetz
2014/03/27 01:21:43
Done.
|
| + 2, 8000); |
| + tb.AddTrack(2, kWebMTrackTypeVideo, 2, "V_VP8", "video", "", -1, 320, 240, |
| + -1, -1); |
| + const std::vector<uint8> buf = tb.Finish(); |
| + |
| + scoped_ptr<WebMTracksParser> parser(new WebMTracksParser(LogCB(), true)); |
| + int result = parser->Parse(&buf[0], buf.size()); |
| + EXPECT_LE(0, result); |
| + EXPECT_EQ(static_cast<int>(buf.size()), result); |
| + |
| + EXPECT_EQ(kNoTimestamp(), parser->GetAudioDefaultDuration(1000.0)); |
|
acolwell GONE FROM CHROMIUM
2014/03/26 22:25:32
nit: make this a constant so it's a little clearer
wolenetz
2014/03/27 01:21:43
Done.
|
| + EXPECT_EQ(kNoTimestamp(), parser->GetVideoDefaultDuration(1000.0)); |
| + |
| + const VideoDecoderConfig& video_config = parser->video_decoder_config(); |
| + EXPECT_TRUE(video_config.IsValidConfig()); |
| + EXPECT_EQ(320, video_config.coded_size().width()); |
| + EXPECT_EQ(240, video_config.coded_size().height()); |
| + |
| + const AudioDecoderConfig& audio_config = parser->audio_decoder_config(); |
| + EXPECT_TRUE(audio_config.IsValidConfig()); |
| + EXPECT_EQ(CHANNEL_LAYOUT_STEREO, audio_config.channel_layout()); |
| + EXPECT_EQ(8000, audio_config.samples_per_second()); |
| +} |
| + |
| +TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationSet) { |
| + // Confirm audio or video TrackEntry DefaultDuration values are parsed, if |
| + // present. |
| + TracksBuilder tb; |
| + tb.AddTrack(1, kWebMTrackTypeAudio, 1, "A_VORBIS", "audio", "", 12345678, |
| + -1, -1, 2, 8000); |
| + tb.AddTrack(2, kWebMTrackTypeVideo, 2, "V_VP8", "video", "", 987654321, |
| + 320, 240, -1, -1); |
| + const std::vector<uint8> buf = tb.Finish(); |
| + |
| + scoped_ptr<WebMTracksParser> parser(new WebMTracksParser(LogCB(), true)); |
| + int result = parser->Parse(&buf[0], buf.size()); |
| + EXPECT_LE(0, result); |
| + EXPECT_EQ(static_cast<int>(buf.size()), result); |
| + |
| + EXPECT_EQ(base::TimeDelta::FromMicroseconds(12000), |
| + parser->GetAudioDefaultDuration(1000.0)); // 1 ms resolution |
| + EXPECT_EQ(base::TimeDelta::FromMicroseconds(985000), |
| + parser->GetVideoDefaultDuration(5000.0)); // 5 ms resolution |
| + EXPECT_EQ(kNoTimestamp(), parser->GetAudioDefaultDuration(12346.0)); |
| + EXPECT_EQ(base::TimeDelta::FromMicroseconds(12345), |
| + parser->GetAudioDefaultDuration(12345.0)); |
| +} |
| + |
| } // namespace media |