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 "media/webm/webm_webvtt_parser.h" | 5 #include "media/webm/webm_webvtt_parser.h" |
6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using ::testing::InSequence; | 9 using ::testing::InSequence; |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 std::string* content) { | 26 std::string* content) { |
27 WebMWebVTTParser::Parse(&cue[0], static_cast<int>(cue.size()), | 27 WebMWebVTTParser::Parse(&cue[0], static_cast<int>(cue.size()), |
28 id, settings, content); | 28 id, settings, content); |
29 } | 29 } |
30 | 30 |
31 class WebMWebVTTParserTest : public testing::Test { | 31 class WebMWebVTTParserTest : public testing::Test { |
32 public: | 32 public: |
33 WebMWebVTTParserTest() {} | 33 WebMWebVTTParserTest() {} |
34 }; | 34 }; |
35 | 35 |
36 TEST_F(WebMWebVTTParserTest, TestBlank) { | 36 TEST_F(WebMWebVTTParserTest, Blank) { |
37 InSequence s; | 37 InSequence s; |
38 | 38 |
39 const Cue cue = EncodeCue("", "", "Subtitle"); | 39 const Cue cue = EncodeCue("", "", "Subtitle"); |
40 std::string id, settings, content; | 40 std::string id, settings, content; |
41 | 41 |
42 DecodeCue(cue, &id, &settings, &content); | 42 DecodeCue(cue, &id, &settings, &content); |
43 EXPECT_EQ(id, ""); | 43 EXPECT_EQ(id, ""); |
44 EXPECT_EQ(settings, ""); | 44 EXPECT_EQ(settings, ""); |
45 EXPECT_EQ(content, "Subtitle"); | 45 EXPECT_EQ(content, "Subtitle"); |
46 } | 46 } |
47 | 47 |
48 TEST_F(WebMWebVTTParserTest, TestId) { | 48 TEST_F(WebMWebVTTParserTest, Id) { |
49 InSequence s; | 49 InSequence s; |
50 | 50 |
51 for (int i = 1; i <= 9; ++i) { | 51 for (int i = 1; i <= 9; ++i) { |
52 const std::string idsrc(1, '0'+i); | 52 const std::string idsrc(1, '0'+i); |
53 const Cue cue = EncodeCue(idsrc, "", "Subtitle"); | 53 const Cue cue = EncodeCue(idsrc, "", "Subtitle"); |
54 std::string id, settings, content; | 54 std::string id, settings, content; |
55 | 55 |
56 DecodeCue(cue, &id, &settings, &content); | 56 DecodeCue(cue, &id, &settings, &content); |
57 EXPECT_EQ(id, idsrc); | 57 EXPECT_EQ(id, idsrc); |
58 EXPECT_EQ(settings, ""); | 58 EXPECT_EQ(settings, ""); |
59 EXPECT_EQ(content, "Subtitle"); | 59 EXPECT_EQ(content, "Subtitle"); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 TEST_F(WebMWebVTTParserTest, TestSettings) { | 63 TEST_F(WebMWebVTTParserTest, Settings) { |
64 InSequence s; | 64 InSequence s; |
65 | 65 |
66 enum { kSettingsCount = 4 }; | 66 enum { kSettingsCount = 4 }; |
67 const char* const settings_str[kSettingsCount] = { | 67 const char* const settings_str[kSettingsCount] = { |
68 "vertical:lr", | 68 "vertical:lr", |
69 "line:50%", | 69 "line:50%", |
70 "position:42%", | 70 "position:42%", |
71 "vertical:rl line:42% position:100%" }; | 71 "vertical:rl line:42% position:100%" }; |
72 | 72 |
73 for (int i = 0; i < kSettingsCount; ++i) { | 73 for (int i = 0; i < kSettingsCount; ++i) { |
74 const Cue cue = EncodeCue("", settings_str[i], "Subtitle"); | 74 const Cue cue = EncodeCue("", settings_str[i], "Subtitle"); |
75 std::string id, settings, content; | 75 std::string id, settings, content; |
76 | 76 |
77 DecodeCue(cue, &id, &settings, &content); | 77 DecodeCue(cue, &id, &settings, &content); |
78 EXPECT_EQ(id, ""); | 78 EXPECT_EQ(id, ""); |
79 EXPECT_EQ(settings, settings_str[i]); | 79 EXPECT_EQ(settings, settings_str[i]); |
80 EXPECT_EQ(content, "Subtitle"); | 80 EXPECT_EQ(content, "Subtitle"); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 TEST_F(WebMWebVTTParserTest, TestContent) { | 84 TEST_F(WebMWebVTTParserTest, Content) { |
85 InSequence s; | 85 InSequence s; |
86 | 86 |
87 enum { kContentCount = 4 }; | 87 enum { kContentCount = 4 }; |
88 const char* const content_str[kContentCount] = { | 88 const char* const content_str[kContentCount] = { |
89 "Subtitle", | 89 "Subtitle", |
90 "Another Subtitle", | 90 "Another Subtitle", |
91 "Yet Another Subtitle", | 91 "Yet Another Subtitle", |
92 "Another Subtitle\nSplit Across Two Lines" }; | 92 "Another Subtitle\nSplit Across Two Lines" }; |
93 | 93 |
94 for (int i = 0; i < kContentCount; ++i) { | 94 for (int i = 0; i < kContentCount; ++i) { |
95 const Cue cue = EncodeCue("", "", content_str[i]); | 95 const Cue cue = EncodeCue("", "", content_str[i]); |
96 std::string id, settings, content; | 96 std::string id, settings, content; |
97 | 97 |
98 DecodeCue(cue, &id, &settings, &content); | 98 DecodeCue(cue, &id, &settings, &content); |
99 EXPECT_EQ(id, ""); | 99 EXPECT_EQ(id, ""); |
100 EXPECT_EQ(settings, ""); | 100 EXPECT_EQ(settings, ""); |
101 EXPECT_EQ(content, content_str[i]); | 101 EXPECT_EQ(content, content_str[i]); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 } // namespace media | 105 } // namespace media |
OLD | NEW |