OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "net/base/mime_util.h" | 6 #include "net/base/mime_util.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 } | 119 } |
120 | 120 |
121 // Test without stripping the codec type. | 121 // Test without stripping the codec type. |
122 std::vector<std::string> codecs_out; | 122 std::vector<std::string> codecs_out; |
123 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); | 123 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); |
124 ASSERT_EQ(2u, codecs_out.size()); | 124 ASSERT_EQ(2u, codecs_out.size()); |
125 EXPECT_EQ("avc1.42E01E", codecs_out[0]); | 125 EXPECT_EQ("avc1.42E01E", codecs_out[0]); |
126 EXPECT_EQ("mp4a.40.2", codecs_out[1]); | 126 EXPECT_EQ("mp4a.40.2", codecs_out[1]); |
127 } | 127 } |
128 | 128 |
129 TEST(MimeUtilTest, TestIsStringMimeType) { | |
130 std::string nonAscii("application/nonutf8"); | |
131 EXPECT_TRUE(IsStringMimeType(nonAscii)); | |
132 nonAscii.append("\u2603"); // unicode snowman | |
133 EXPECT_FALSE(IsStringMimeType(nonAscii)); | |
134 | |
135 EXPECT_TRUE(IsStringMimeType("application/mime")); | |
136 EXPECT_TRUE(IsStringMimeType("audio/mime")); | |
137 EXPECT_TRUE(IsStringMimeType("example/mime")); | |
138 EXPECT_TRUE(IsStringMimeType("image/mime")); | |
139 EXPECT_TRUE(IsStringMimeType("message/mime")); | |
140 EXPECT_TRUE(IsStringMimeType("model/mime")); | |
141 EXPECT_TRUE(IsStringMimeType("multipart/mime")); | |
142 EXPECT_TRUE(IsStringMimeType("text/mime")); | |
143 EXPECT_TRUE(IsStringMimeType("TEXT/mime")); | |
144 EXPECT_TRUE(IsStringMimeType("Text/mime")); | |
145 EXPECT_TRUE(IsStringMimeType("TeXt/mime")); | |
146 EXPECT_TRUE(IsStringMimeType("video/mime")); | |
147 EXPECT_TRUE(IsStringMimeType("video/mime;parameter")); | |
148 EXPECT_TRUE(IsStringMimeType("*/*")); | |
149 EXPECT_TRUE(IsStringMimeType("*")); | |
150 | |
151 EXPECT_TRUE(IsStringMimeType("x-video/mime")); | |
152 EXPECT_TRUE(IsStringMimeType("X-Video/mime")); | |
153 EXPECT_FALSE(IsStringMimeType("x-/mime")); | |
rvargas (doing something else)
2012/06/05 17:54:07
Maybe add one for "x-video/"
Greg Billock
2012/06/05 18:09:53
Done.
| |
154 EXPECT_FALSE(IsStringMimeType("mime/looking")); | |
155 EXPECT_FALSE(IsStringMimeType("text/")); | |
156 } | |
157 | |
129 } // namespace net | 158 } // namespace net |
OLD | NEW |