Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: net/base/mime_util_unittest.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/mime_util.cc ('k') | net/base/net_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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* const mime_type; 20 const char* const 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("PNG"), "image/png", true},
25 { FILE_PATH_LITERAL("pjp"), "image/jpeg", true }, 25 {FILE_PATH_LITERAL("css"), "text/css", true},
26 { FILE_PATH_LITERAL("pjpeg"), "image/jpeg", true }, 26 {FILE_PATH_LITERAL("pjp"), "image/jpeg", true},
27 {FILE_PATH_LITERAL("pjpeg"), "image/jpeg", true},
27 #if defined(OS_ANDROID) 28 #if defined(OS_ANDROID)
28 { FILE_PATH_LITERAL("m3u8"), "application/x-mpegurl", true }, 29 {FILE_PATH_LITERAL("m3u8"), "application/x-mpegurl", true},
29 #endif 30 #endif
30 { FILE_PATH_LITERAL("not an extension / for sure"), "", false }, 31 {FILE_PATH_LITERAL("not an extension / for sure"), "", false},
31 }; 32 };
32 33
33 std::string mime_type; 34 std::string mime_type;
34 bool rv; 35 bool rv;
35 36
36 for (size_t i = 0; i < arraysize(tests); ++i) { 37 for (size_t i = 0; i < arraysize(tests); ++i) {
37 rv = GetMimeTypeFromExtension(tests[i].extension, &mime_type); 38 rv = GetMimeTypeFromExtension(tests[i].extension, &mime_type);
38 EXPECT_EQ(tests[i].valid, rv); 39 EXPECT_EQ(tests[i].valid, rv);
39 if (rv) 40 if (rv)
40 EXPECT_EQ(tests[i].mime_type, mime_type); 41 EXPECT_EQ(tests[i].mime_type, mime_type);
41 } 42 }
42 } 43 }
43 44
44 TEST(MimeUtilTest, FileTest) { 45 TEST(MimeUtilTest, FileTest) {
45 const struct { 46 const struct {
46 const base::FilePath::CharType* file_path; 47 const base::FilePath::CharType* file_path;
47 const char* const mime_type; 48 const char* const mime_type;
48 bool valid; 49 bool valid;
49 } tests[] = { 50 } tests[] = {
50 { FILE_PATH_LITERAL("c:\\foo\\bar.css"), "text/css", true }, 51 {FILE_PATH_LITERAL("c:\\foo\\bar.css"), "text/css", true},
51 { FILE_PATH_LITERAL("c:\\blah"), "", false }, 52 {FILE_PATH_LITERAL("c:\\foo\\bar.CSS"), "text/css", true},
52 { FILE_PATH_LITERAL("/usr/local/bin/mplayer"), "", false }, 53 {FILE_PATH_LITERAL("c:\\blah"), "", false},
53 { FILE_PATH_LITERAL("/home/foo/bar.css"), "text/css", true }, 54 {FILE_PATH_LITERAL("/usr/local/bin/mplayer"), "", false},
54 { FILE_PATH_LITERAL("/blah."), "", false }, 55 {FILE_PATH_LITERAL("/home/foo/bar.css"), "text/css", true},
55 { FILE_PATH_LITERAL("c:\\blah."), "", false }, 56 {FILE_PATH_LITERAL("/blah."), "", false},
57 {FILE_PATH_LITERAL("c:\\blah."), "", false},
56 }; 58 };
57 59
58 std::string mime_type; 60 std::string mime_type;
59 bool rv; 61 bool rv;
60 62
61 for (size_t i = 0; i < arraysize(tests); ++i) { 63 for (size_t i = 0; i < arraysize(tests); ++i) {
62 rv = GetMimeTypeFromFile(base::FilePath(tests[i].file_path), 64 rv = GetMimeTypeFromFile(base::FilePath(tests[i].file_path),
63 &mime_type); 65 &mime_type);
64 EXPECT_EQ(tests[i].valid, rv); 66 EXPECT_EQ(tests[i].valid, rv);
65 if (rv) 67 if (rv)
66 EXPECT_EQ(tests[i].mime_type, mime_type); 68 EXPECT_EQ(tests[i].mime_type, mime_type);
67 } 69 }
68 } 70 }
69 71
70 TEST(MimeUtilTest, LookupTypes) { 72 TEST(MimeUtilTest, LookupTypes) {
71 EXPECT_FALSE(IsUnsupportedTextMimeType("text/banana")); 73 EXPECT_FALSE(IsUnsupportedTextMimeType("text/banana"));
72 EXPECT_TRUE(IsUnsupportedTextMimeType("text/vcard")); 74 EXPECT_TRUE(IsUnsupportedTextMimeType("text/vcard"));
73 75
74 EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg")); 76 EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg"));
77 EXPECT_TRUE(IsSupportedImageMimeType("Image/JPEG"));
75 EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat")); 78 EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat"));
79 EXPECT_FALSE(IsSupportedImageMimeType("Image/LolCat"));
76 EXPECT_TRUE(IsSupportedNonImageMimeType("text/html")); 80 EXPECT_TRUE(IsSupportedNonImageMimeType("text/html"));
77 EXPECT_TRUE(IsSupportedNonImageMimeType("text/css")); 81 EXPECT_TRUE(IsSupportedNonImageMimeType("text/css"));
78 EXPECT_TRUE(IsSupportedNonImageMimeType("text/")); 82 EXPECT_TRUE(IsSupportedNonImageMimeType("text/"));
79 EXPECT_TRUE(IsSupportedNonImageMimeType("text/banana")); 83 EXPECT_TRUE(IsSupportedNonImageMimeType("text/banana"));
84 EXPECT_TRUE(IsSupportedNonImageMimeType("Text/Banana"));
80 EXPECT_FALSE(IsSupportedNonImageMimeType("text/vcard")); 85 EXPECT_FALSE(IsSupportedNonImageMimeType("text/vcard"));
81 EXPECT_FALSE(IsSupportedNonImageMimeType("application/virus")); 86 EXPECT_FALSE(IsSupportedNonImageMimeType("application/virus"));
87 EXPECT_FALSE(IsSupportedNonImageMimeType("Application/VIRUS"));
82 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-user-cert")); 88 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-user-cert"));
83 EXPECT_TRUE(IsSupportedNonImageMimeType("application/json")); 89 EXPECT_TRUE(IsSupportedNonImageMimeType("application/json"));
84 EXPECT_TRUE(IsSupportedNonImageMimeType("application/+json")); 90 EXPECT_TRUE(IsSupportedNonImageMimeType("application/+json"));
85 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-suggestions+json")); 91 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-suggestions+json"));
86 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-s+json;x=2")); 92 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-s+json;x=2"));
87 #if defined(OS_ANDROID) 93 #if defined(OS_ANDROID)
88 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-ca-cert")); 94 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-ca-cert"));
89 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-pkcs12")); 95 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-pkcs12"));
90 EXPECT_TRUE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl")); 96 EXPECT_TRUE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
91 EXPECT_TRUE(IsSupportedMediaMimeType("application/x-mpegurl")); 97 EXPECT_TRUE(IsSupportedMediaMimeType("application/x-mpegurl"));
98 EXPECT_TRUE(IsSupportedMediaMimeType("Application/X-MPEGURL"));
92 #endif 99 #endif
93 100
94 EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); 101 EXPECT_TRUE(IsSupportedMimeType("image/jpeg"));
95 EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); 102 EXPECT_FALSE(IsSupportedMimeType("image/lolcat"));
103 EXPECT_FALSE(IsSupportedMimeType("Image/LOLCAT"));
96 EXPECT_TRUE(IsSupportedMimeType("text/html")); 104 EXPECT_TRUE(IsSupportedMimeType("text/html"));
97 EXPECT_TRUE(IsSupportedMimeType("text/banana")); 105 EXPECT_TRUE(IsSupportedMimeType("text/banana"));
106 EXPECT_TRUE(IsSupportedMimeType("Text/BANANA"));
98 EXPECT_FALSE(IsSupportedMimeType("text/vcard")); 107 EXPECT_FALSE(IsSupportedMimeType("text/vcard"));
99 EXPECT_FALSE(IsSupportedMimeType("application/virus")); 108 EXPECT_FALSE(IsSupportedMimeType("application/virus"));
100 EXPECT_FALSE(IsSupportedMimeType("application/x-json")); 109 EXPECT_FALSE(IsSupportedMimeType("application/x-json"));
110 EXPECT_FALSE(IsSupportedMimeType("Application/X-JSON"));
101 EXPECT_FALSE(IsSupportedNonImageMimeType("application/vnd.doc;x=y+json")); 111 EXPECT_FALSE(IsSupportedNonImageMimeType("application/vnd.doc;x=y+json"));
112 EXPECT_FALSE(IsSupportedNonImageMimeType("Application/VND.DOC;X=Y+JSON"));
102 } 113 }
103 114
104 TEST(MimeUtilTest, StrictMediaMimeType) { 115 TEST(MimeUtilTest, StrictMediaMimeType) {
105 EXPECT_TRUE(IsStrictMediaMimeType("video/webm")); 116 EXPECT_TRUE(IsStrictMediaMimeType("video/webm"));
117 EXPECT_TRUE(IsStrictMediaMimeType("Video/WEBM"));
106 EXPECT_TRUE(IsStrictMediaMimeType("audio/webm")); 118 EXPECT_TRUE(IsStrictMediaMimeType("audio/webm"));
107 119
108 EXPECT_TRUE(IsStrictMediaMimeType("audio/wav")); 120 EXPECT_TRUE(IsStrictMediaMimeType("audio/wav"));
109 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav")); 121 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav"));
110 122
111 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg")); 123 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg"));
112 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg")); 124 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg"));
113 EXPECT_TRUE(IsStrictMediaMimeType("application/ogg")); 125 EXPECT_TRUE(IsStrictMediaMimeType("application/ogg"));
114 126
115 EXPECT_TRUE(IsStrictMediaMimeType("audio/mpeg")); 127 EXPECT_TRUE(IsStrictMediaMimeType("audio/mpeg"));
116 EXPECT_TRUE(IsStrictMediaMimeType("audio/mp3")); 128 EXPECT_TRUE(IsStrictMediaMimeType("audio/mp3"));
117 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-mp3")); 129 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-mp3"));
118 130
119 EXPECT_TRUE(IsStrictMediaMimeType("video/mp4")); 131 EXPECT_TRUE(IsStrictMediaMimeType("video/mp4"));
120 EXPECT_TRUE(IsStrictMediaMimeType("video/x-m4v")); 132 EXPECT_TRUE(IsStrictMediaMimeType("video/x-m4v"));
121 EXPECT_TRUE(IsStrictMediaMimeType("audio/mp4")); 133 EXPECT_TRUE(IsStrictMediaMimeType("audio/mp4"));
122 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-m4a")); 134 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-m4a"));
123 135
124 EXPECT_TRUE(IsStrictMediaMimeType("application/x-mpegurl")); 136 EXPECT_TRUE(IsStrictMediaMimeType("application/x-mpegurl"));
125 EXPECT_TRUE(IsStrictMediaMimeType("application/vnd.apple.mpegurl")); 137 EXPECT_TRUE(IsStrictMediaMimeType("application/vnd.apple.mpegurl"));
126 138
127 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown")); 139 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown"));
140 EXPECT_FALSE(IsStrictMediaMimeType("Video/UNKNOWN"));
128 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown")); 141 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown"));
129 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown")); 142 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown"));
130 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown")); 143 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown"));
131 } 144 }
132 145
133 TEST(MimeUtilTest, MatchesMimeType) { 146 TEST(MimeUtilTest, MatchesMimeType) {
147 // MIME types are case insensitive.
148 EXPECT_TRUE(MatchesMimeType("VIDEO/*", "video/x-mpeg"));
149 EXPECT_TRUE(MatchesMimeType("video/*", "VIDEO/X-MPEG"));
150
134 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); 151 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg"));
135 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); 152 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg"));
136 EXPECT_TRUE(MatchesMimeType("video/*", "video/*")); 153 EXPECT_TRUE(MatchesMimeType("video/*", "video/*"));
137 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); 154 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg"));
138 EXPECT_TRUE(MatchesMimeType("application/*+xml", 155 EXPECT_TRUE(MatchesMimeType("application/*+xml",
139 "application/html+xml")); 156 "application/html+xml"));
140 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); 157 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml"));
141 EXPECT_TRUE(MatchesMimeType("application/*+json", 158 EXPECT_TRUE(MatchesMimeType("application/*+json",
142 "application/x-myformat+json")); 159 "application/x-myformat+json"));
143 EXPECT_TRUE(MatchesMimeType("aaa*aaa", "aaaaaa")); 160 EXPECT_TRUE(MatchesMimeType("aaa*aaa", "aaaaaa"));
144 EXPECT_TRUE(MatchesMimeType("*", std::string())); 161 EXPECT_TRUE(MatchesMimeType("*", std::string()));
145 EXPECT_FALSE(MatchesMimeType("video/", "video/x-mpeg")); 162 EXPECT_FALSE(MatchesMimeType("video/", "video/x-mpeg"));
163 EXPECT_FALSE(MatchesMimeType("VIDEO/", "Video/X-MPEG"));
146 EXPECT_FALSE(MatchesMimeType(std::string(), "video/x-mpeg")); 164 EXPECT_FALSE(MatchesMimeType(std::string(), "video/x-mpeg"));
147 EXPECT_FALSE(MatchesMimeType(std::string(), std::string())); 165 EXPECT_FALSE(MatchesMimeType(std::string(), std::string()));
148 EXPECT_FALSE(MatchesMimeType("video/x-mpeg", std::string())); 166 EXPECT_FALSE(MatchesMimeType("video/x-mpeg", std::string()));
149 EXPECT_FALSE(MatchesMimeType("application/*+xml", "application/xml")); 167 EXPECT_FALSE(MatchesMimeType("application/*+xml", "application/xml"));
150 EXPECT_FALSE(MatchesMimeType("application/*+xml", 168 EXPECT_FALSE(MatchesMimeType("application/*+xml",
151 "application/html+xmlz")); 169 "application/html+xmlz"));
152 EXPECT_FALSE(MatchesMimeType("application/*+xml", 170 EXPECT_FALSE(MatchesMimeType("application/*+xml",
153 "applcation/html+xml")); 171 "applcation/html+xml"));
154 EXPECT_FALSE(MatchesMimeType("aaa*aaa", "aaaaa")); 172 EXPECT_FALSE(MatchesMimeType("aaa*aaa", "aaaaa"));
155 173
156 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg;param=val")); 174 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg;param=val"));
175 EXPECT_TRUE(MatchesMimeType("*", "Video/X-MPEG;PARAM=VAL"));
157 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg;param=val")); 176 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg;param=val"));
158 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/mpeg")); 177 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/mpeg"));
178 EXPECT_FALSE(MatchesMimeType("Video/*;PARAM=VAL", "VIDEO/Mpeg"));
159 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/mpeg;param=other")); 179 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/mpeg;param=other"));
160 EXPECT_TRUE(MatchesMimeType("video/*;param=val", "video/mpeg;param=val")); 180 EXPECT_TRUE(MatchesMimeType("video/*;param=val", "video/mpeg;param=val"));
181 EXPECT_TRUE(MatchesMimeType("Video/*;PARAM=Val", "VIDEO/Mpeg;Param=Val"));
182 EXPECT_FALSE(MatchesMimeType("Video/*;PARAM=VAL", "VIDEO/Mpeg;Param=Val"));
161 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg;param=val")); 183 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg;param=val"));
162 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param=val", 184 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param=val",
163 "video/x-mpeg;param=val")); 185 "video/x-mpeg;param=val"));
164 EXPECT_FALSE(MatchesMimeType("video/x-mpeg;param2=val2", 186 EXPECT_FALSE(MatchesMimeType("video/x-mpeg;param2=val2",
165 "video/x-mpeg;param=val")); 187 "video/x-mpeg;param=val"));
166 EXPECT_FALSE(MatchesMimeType("video/x-mpeg;param2=val2", 188 EXPECT_FALSE(MatchesMimeType("video/x-mpeg;param2=val2",
167 "video/x-mpeg;param2=val")); 189 "video/x-mpeg;param2=val"));
168 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param=val", 190 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param=val",
169 "video/x-mpeg;param=val;param2=val2")); 191 "video/x-mpeg;param=val;param2=val2"));
170 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param=val;param2=val2", 192 EXPECT_TRUE(MatchesMimeType("Video/X-Mpeg;Param=Val",
171 "video/x-mpeg;param=val;param2=val2")); 193 "VIDEO/X-MPEG;PARAM=Val;PARAM2=val2"));
194 EXPECT_TRUE(MatchesMimeType("Video/X-Mpeg;Param=VAL",
195 "VIDEO/X-MPEG;PARAM=VAL;PARAM2=val2"));
196 EXPECT_FALSE(MatchesMimeType("Video/X-Mpeg;Param=val",
197 "VIDEO/X-MPEG;PARAM=VAL;PARAM2=val2"));
198 EXPECT_FALSE(MatchesMimeType("video/x-mpeg;param=VAL;param2=val2",
199 "video/x-mpeg;param=val;param2=val2"));
172 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param2=val2;param=val", 200 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param2=val2;param=val",
173 "video/x-mpeg;param=val;param2=val2")); 201 "video/x-mpeg;param=val;param2=val2"));
174 EXPECT_FALSE(MatchesMimeType("video/x-mpeg;param3=val3;param=val", 202 EXPECT_FALSE(MatchesMimeType("video/x-mpeg;param3=val3;param=val",
175 "video/x-mpeg;param=val;param2=val2")); 203 "video/x-mpeg;param=val;param2=val2"));
176 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param=val ;param2=val2 ", 204 EXPECT_TRUE(MatchesMimeType("video/x-mpeg;param=val ;param2=val2 ",
177 "video/x-mpeg;param=val;param2=val2")); 205 "video/x-mpeg;param=val;param2=val2"));
178 206
179 EXPECT_TRUE(MatchesMimeType("*/*;param=val", "video/x-mpeg;param=val")); 207 EXPECT_TRUE(MatchesMimeType("*/*;param=val", "video/x-mpeg;param=val"));
180 EXPECT_FALSE(MatchesMimeType("*/*;param=val", "video/x-mpeg;param=val2")); 208 EXPECT_FALSE(MatchesMimeType("*/*;param=val", "video/x-mpeg;param=val2"));
181 209
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 #endif 433 #endif
406 } 434 }
407 ASSERT_TRUE(found) << "Must find at least the contained result within " 435 ASSERT_TRUE(found) << "Must find at least the contained result within "
408 << tests[i].mime_type; 436 << tests[i].mime_type;
409 } 437 }
410 } 438 }
411 439
412 TEST(MimeUtilTest, TestGetCertificateMimeTypeForMimeType) { 440 TEST(MimeUtilTest, TestGetCertificateMimeTypeForMimeType) {
413 EXPECT_EQ(CERTIFICATE_MIME_TYPE_X509_USER_CERT, 441 EXPECT_EQ(CERTIFICATE_MIME_TYPE_X509_USER_CERT,
414 GetCertificateMimeTypeForMimeType("application/x-x509-user-cert")); 442 GetCertificateMimeTypeForMimeType("application/x-x509-user-cert"));
443 EXPECT_EQ(CERTIFICATE_MIME_TYPE_X509_USER_CERT,
444 GetCertificateMimeTypeForMimeType("Application/X-X509-USER-CERT"));
415 #if defined(OS_ANDROID) 445 #if defined(OS_ANDROID)
416 // Only Android supports CA Certs and PKCS12 archives. 446 // Only Android supports CA Certs and PKCS12 archives.
417 EXPECT_EQ(CERTIFICATE_MIME_TYPE_X509_CA_CERT, 447 EXPECT_EQ(CERTIFICATE_MIME_TYPE_X509_CA_CERT,
418 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert")); 448 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert"));
419 EXPECT_EQ(CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE, 449 EXPECT_EQ(CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE,
420 GetCertificateMimeTypeForMimeType("application/x-pkcs12")); 450 GetCertificateMimeTypeForMimeType("application/x-pkcs12"));
421 #else 451 #else
422 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, 452 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN,
423 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert")); 453 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert"));
424 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, 454 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN,
(...skipping 14 matching lines...) Expand all
439 std::string post_data; 469 std::string post_data;
440 AddMultipartValueForUpload("value name", "value", "boundary", 470 AddMultipartValueForUpload("value name", "value", "boundary",
441 "content type", &post_data); 471 "content type", &post_data);
442 AddMultipartValueForUpload("value name", "value", "boundary", 472 AddMultipartValueForUpload("value name", "value", "boundary",
443 "", &post_data); 473 "", &post_data);
444 AddMultipartFinalDelimiterForUpload("boundary", &post_data); 474 AddMultipartFinalDelimiterForUpload("boundary", &post_data);
445 EXPECT_STREQ(ref_output, post_data.c_str()); 475 EXPECT_STREQ(ref_output, post_data.c_str());
446 } 476 }
447 477
448 } // namespace net 478 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mime_util.cc ('k') | net/base/net_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698