OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "media/webm/tracks_builder.h" | 6 #include "media/webm/tracks_builder.h" |
7 #include "media/webm/webm_constants.h" | 7 #include "media/webm/webm_constants.h" |
8 #include "media/webm/webm_tracks_parser.h" | 8 #include "media/webm/webm_tracks_parser.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 const WebMTracksParser::TextTracks::const_iterator itr = text_tracks.begin(); | 40 const WebMTracksParser::TextTracks::const_iterator itr = text_tracks.begin(); |
41 EXPECT_EQ(itr->first, 1); // track num | 41 EXPECT_EQ(itr->first, 1); // track num |
42 | 42 |
43 const WebMTracksParser::TextTrackInfo& info = itr->second; | 43 const WebMTracksParser::TextTrackInfo& info = itr->second; |
44 EXPECT_EQ(info.kind, text_kind); | 44 EXPECT_EQ(info.kind, text_kind); |
45 EXPECT_TRUE(info.name == name); | 45 EXPECT_TRUE(info.name == name); |
46 EXPECT_TRUE(info.language == language); | 46 EXPECT_TRUE(info.language == language); |
47 } | 47 } |
48 | 48 |
49 TEST_F(WebMTracksParserTest, TestSubtitleNoNameNoLang) { | 49 TEST_F(WebMTracksParserTest, SubtitleNoNameNoLang) { |
50 InSequence s; | 50 InSequence s; |
51 | 51 |
52 TracksBuilder tb; | 52 TracksBuilder tb; |
53 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, | 53 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, |
54 kWebMCodecSubtitles, "", ""); | 54 kWebMCodecSubtitles, "", ""); |
55 | 55 |
56 const std::vector<uint8> buf = tb.Finish(); | 56 const std::vector<uint8> buf = tb.Finish(); |
57 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", ""); | 57 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", ""); |
58 } | 58 } |
59 | 59 |
60 TEST_F(WebMTracksParserTest, TestSubtitleYesNameNoLang) { | 60 TEST_F(WebMTracksParserTest, SubtitleYesNameNoLang) { |
61 InSequence s; | 61 InSequence s; |
62 | 62 |
63 TracksBuilder tb; | 63 TracksBuilder tb; |
64 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, | 64 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, |
65 kWebMCodecSubtitles, "Spock", ""); | 65 kWebMCodecSubtitles, "Spock", ""); |
66 | 66 |
67 const std::vector<uint8> buf = tb.Finish(); | 67 const std::vector<uint8> buf = tb.Finish(); |
68 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Spock", ""); | 68 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Spock", ""); |
69 } | 69 } |
70 | 70 |
71 TEST_F(WebMTracksParserTest, TestSubtitleNoNameYesLang) { | 71 TEST_F(WebMTracksParserTest, SubtitleNoNameYesLang) { |
72 InSequence s; | 72 InSequence s; |
73 | 73 |
74 TracksBuilder tb; | 74 TracksBuilder tb; |
75 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, | 75 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, |
76 kWebMCodecSubtitles, "", "eng"); | 76 kWebMCodecSubtitles, "", "eng"); |
77 | 77 |
78 const std::vector<uint8> buf = tb.Finish(); | 78 const std::vector<uint8> buf = tb.Finish(); |
79 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", "eng"); | 79 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", "eng"); |
80 } | 80 } |
81 | 81 |
82 TEST_F(WebMTracksParserTest, TestSubtitleYesNameYesLang) { | 82 TEST_F(WebMTracksParserTest, SubtitleYesNameYesLang) { |
83 InSequence s; | 83 InSequence s; |
84 | 84 |
85 TracksBuilder tb; | 85 TracksBuilder tb; |
86 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, | 86 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, |
87 kWebMCodecSubtitles, "Picard", "fre"); | 87 kWebMCodecSubtitles, "Picard", "fre"); |
88 | 88 |
89 const std::vector<uint8> buf = tb.Finish(); | 89 const std::vector<uint8> buf = tb.Finish(); |
90 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Picard", "fre"); | 90 VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Picard", "fre"); |
91 } | 91 } |
92 | 92 |
93 TEST_F(WebMTracksParserTest, TestIgnoringTextTracks) { | 93 TEST_F(WebMTracksParserTest, IgnoringTextTracks) { |
94 InSequence s; | 94 InSequence s; |
95 | 95 |
96 TracksBuilder tb; | 96 TracksBuilder tb; |
97 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, | 97 tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, |
98 kWebMCodecSubtitles, "Subtitles", "fre"); | 98 kWebMCodecSubtitles, "Subtitles", "fre"); |
99 tb.AddTrack(2, kWebMTrackTypeSubtitlesOrCaptions, | 99 tb.AddTrack(2, kWebMTrackTypeSubtitlesOrCaptions, |
100 kWebMCodecSubtitles, "Commentary", "fre"); | 100 kWebMCodecSubtitles, "Commentary", "fre"); |
101 | 101 |
102 const std::vector<uint8> buf = tb.Finish(); | 102 const std::vector<uint8> buf = tb.Finish(); |
103 scoped_ptr<WebMTracksParser> parser(new WebMTracksParser(LogCB(), true)); | 103 scoped_ptr<WebMTracksParser> parser(new WebMTracksParser(LogCB(), true)); |
(...skipping 12 matching lines...) Expand all Loading... |
116 parser.reset(new WebMTracksParser(LogCB(), false)); | 116 parser.reset(new WebMTracksParser(LogCB(), false)); |
117 | 117 |
118 result = parser->Parse(&buf[0], buf.size()); | 118 result = parser->Parse(&buf[0], buf.size()); |
119 EXPECT_GT(result, 0); | 119 EXPECT_GT(result, 0); |
120 | 120 |
121 EXPECT_EQ(parser->ignored_tracks().size(), 0u); | 121 EXPECT_EQ(parser->ignored_tracks().size(), 0u); |
122 EXPECT_EQ(parser->text_tracks().size(), 2u); | 122 EXPECT_EQ(parser->text_tracks().size(), 2u); |
123 } | 123 } |
124 | 124 |
125 } // namespace media | 125 } // namespace media |
OLD | NEW |