| 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 |
| 11 #if defined(OS_ANDROID) | 11 #if defined(OS_ANDROID) |
| 12 #include "base/android/build_info.h" | 12 #include "base/android/build_info.h" |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 TEST(MimeUtilTest, ExtensionTest) { | 17 TEST(MimeUtilTest, ExtensionTest) { |
| 18 const struct { | 18 const struct { |
| 19 const base::FilePath::CharType* extension; | 19 const base::FilePath::CharType* extension; |
| 20 const char* mime_type; | 20 const char* mime_type; |
| 21 bool valid; | 21 bool valid; |
| 22 } tests[] = { | 22 } tests[] = { |
| 23 { FILE_PATH_LITERAL("png"), "image/png", true }, | 23 { FILE_PATH_LITERAL("png"), "image/png", true }, |
| 24 { FILE_PATH_LITERAL("css"), "text/css", true }, | 24 { FILE_PATH_LITERAL("css"), "text/css", true }, |
| 25 { FILE_PATH_LITERAL("pjp"), "image/jpeg", true }, | 25 { FILE_PATH_LITERAL("pjp"), "image/jpeg", true }, |
| 26 { FILE_PATH_LITERAL("pjpeg"), "image/jpeg", true }, | 26 { FILE_PATH_LITERAL("pjpeg"), "image/jpeg", true }, |
| 27 #if defined(OS_ANDROID) |
| 28 { FILE_PATH_LITERAL("m3u8"), "application/x-mpegurl", true }, |
| 29 #endif |
| 27 { FILE_PATH_LITERAL("not an extension / for sure"), "", false }, | 30 { FILE_PATH_LITERAL("not an extension / for sure"), "", false }, |
| 28 }; | 31 }; |
| 29 | 32 |
| 30 std::string mime_type; | 33 std::string mime_type; |
| 31 bool rv; | 34 bool rv; |
| 32 | 35 |
| 33 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 36 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 34 rv = GetMimeTypeFromExtension(tests[i].extension, &mime_type); | 37 rv = GetMimeTypeFromExtension(tests[i].extension, &mime_type); |
| 35 EXPECT_EQ(tests[i].valid, rv); | 38 EXPECT_EQ(tests[i].valid, rv); |
| 36 if (rv) | 39 if (rv) |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 std::string post_data; | 447 std::string post_data; |
| 445 AddMultipartValueForUpload("value name", "value", "boundary", | 448 AddMultipartValueForUpload("value name", "value", "boundary", |
| 446 "content type", &post_data); | 449 "content type", &post_data); |
| 447 AddMultipartValueForUpload("value name", "value", "boundary", | 450 AddMultipartValueForUpload("value name", "value", "boundary", |
| 448 "", &post_data); | 451 "", &post_data); |
| 449 AddMultipartFinalDelimiterForUpload("boundary", &post_data); | 452 AddMultipartFinalDelimiterForUpload("boundary", &post_data); |
| 450 EXPECT_STREQ(ref_output, post_data.c_str()); | 453 EXPECT_STREQ(ref_output, post_data.c_str()); |
| 451 } | 454 } |
| 452 | 455 |
| 453 } // namespace net | 456 } // namespace net |
| OLD | NEW |