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 "base/strings/string_split.h" | 6 #include "base/strings/string_split.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); | 189 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); |
190 ASSERT_EQ(2u, codecs_out.size()); | 190 ASSERT_EQ(2u, codecs_out.size()); |
191 EXPECT_EQ("avc1.42E01E", codecs_out[0]); | 191 EXPECT_EQ("avc1.42E01E", codecs_out[0]); |
192 EXPECT_EQ("mp4a.40.2", codecs_out[1]); | 192 EXPECT_EQ("mp4a.40.2", codecs_out[1]); |
193 } | 193 } |
194 | 194 |
195 TEST(MimeUtilTest, TestIsMimeType) { | 195 TEST(MimeUtilTest, TestIsMimeType) { |
196 std::string nonAscii("application/nonutf8"); | 196 std::string nonAscii("application/nonutf8"); |
197 EXPECT_TRUE(IsMimeType(nonAscii)); | 197 EXPECT_TRUE(IsMimeType(nonAscii)); |
198 #if defined(OS_WIN) | 198 #if defined(OS_WIN) |
199 nonAscii.append(WideToUTF8(std::wstring(L"\u2603"))); | 199 nonAscii.append(base::WideToUTF8(std::wstring(L"\u2603"))); |
200 #else | 200 #else |
201 nonAscii.append("\u2603"); // unicode snowman | 201 nonAscii.append("\u2603"); // unicode snowman |
202 #endif | 202 #endif |
203 EXPECT_FALSE(IsMimeType(nonAscii)); | 203 EXPECT_FALSE(IsMimeType(nonAscii)); |
204 | 204 |
205 EXPECT_TRUE(IsMimeType("application/mime")); | 205 EXPECT_TRUE(IsMimeType("application/mime")); |
206 EXPECT_TRUE(IsMimeType("application/json")); | 206 EXPECT_TRUE(IsMimeType("application/json")); |
207 EXPECT_TRUE(IsMimeType("application/x-suggestions+json")); | 207 EXPECT_TRUE(IsMimeType("application/x-suggestions+json")); |
208 EXPECT_TRUE(IsMimeType("application/+json")); | 208 EXPECT_TRUE(IsMimeType("application/+json")); |
209 EXPECT_TRUE(IsMimeType("audio/mime")); | 209 EXPECT_TRUE(IsMimeType("audio/mime")); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 std::vector<base::FilePath::StringType> extensions; | 271 std::vector<base::FilePath::StringType> extensions; |
272 GetExtensionsForMimeType(tests[i].mime_type, &extensions); | 272 GetExtensionsForMimeType(tests[i].mime_type, &extensions); |
273 ASSERT_TRUE(tests[i].min_expected_size <= extensions.size()); | 273 ASSERT_TRUE(tests[i].min_expected_size <= extensions.size()); |
274 | 274 |
275 if (!tests[i].contained_result) | 275 if (!tests[i].contained_result) |
276 continue; | 276 continue; |
277 | 277 |
278 bool found = false; | 278 bool found = false; |
279 for (size_t j = 0; !found && j < extensions.size(); ++j) { | 279 for (size_t j = 0; !found && j < extensions.size(); ++j) { |
280 #if defined(OS_WIN) | 280 #if defined(OS_WIN) |
281 if (extensions[j] == UTF8ToWide(tests[i].contained_result)) | 281 if (extensions[j] == base::UTF8ToWide(tests[i].contained_result)) |
282 found = true; | 282 found = true; |
283 #else | 283 #else |
284 if (extensions[j] == tests[i].contained_result) | 284 if (extensions[j] == tests[i].contained_result) |
285 found = true; | 285 found = true; |
286 #endif | 286 #endif |
287 } | 287 } |
288 ASSERT_TRUE(found) << "Must find at least the contained result within " | 288 ASSERT_TRUE(found) << "Must find at least the contained result within " |
289 << tests[i].mime_type; | 289 << tests[i].mime_type; |
290 } | 290 } |
291 } | 291 } |
(...skipping 27 matching lines...) Expand all Loading... |
319 std::string post_data; | 319 std::string post_data; |
320 AddMultipartValueForUpload("value name", "value", "boundary", | 320 AddMultipartValueForUpload("value name", "value", "boundary", |
321 "content type", &post_data); | 321 "content type", &post_data); |
322 AddMultipartValueForUpload("value name", "value", "boundary", | 322 AddMultipartValueForUpload("value name", "value", "boundary", |
323 "", &post_data); | 323 "", &post_data); |
324 AddMultipartFinalDelimiterForUpload("boundary", &post_data); | 324 AddMultipartFinalDelimiterForUpload("boundary", &post_data); |
325 EXPECT_STREQ(ref_output, post_data.c_str()); | 325 EXPECT_STREQ(ref_output, post_data.c_str()); |
326 } | 326 } |
327 | 327 |
328 } // namespace net | 328 } // namespace net |
OLD | NEW |