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

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

Issue 11266008: Fix certificate and keychain installation on Android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rename CertificateType to CertificateMimeType Created 8 years 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
« net/base/mime_util.cc ('K') | « net/base/mime_util.cc ('k') | no next file » | 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/string_split.h" 6 #include "base/string_split.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 TEST(MimeUtilTest, LookupTypes) { 63 TEST(MimeUtilTest, LookupTypes) {
64 EXPECT_FALSE(IsUnsupportedTextMimeType("text/banana")); 64 EXPECT_FALSE(IsUnsupportedTextMimeType("text/banana"));
65 EXPECT_TRUE(IsUnsupportedTextMimeType("text/vcard")); 65 EXPECT_TRUE(IsUnsupportedTextMimeType("text/vcard"));
66 66
67 EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg")); 67 EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg"));
68 EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat")); 68 EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat"));
69 EXPECT_TRUE(IsSupportedNonImageMimeType("text/html")); 69 EXPECT_TRUE(IsSupportedNonImageMimeType("text/html"));
70 EXPECT_TRUE(IsSupportedNonImageMimeType("text/banana")); 70 EXPECT_TRUE(IsSupportedNonImageMimeType("text/banana"));
71 EXPECT_FALSE(IsSupportedNonImageMimeType("text/vcard")); 71 EXPECT_FALSE(IsSupportedNonImageMimeType("text/vcard"));
72 EXPECT_FALSE(IsSupportedNonImageMimeType("application/virus")); 72 EXPECT_FALSE(IsSupportedNonImageMimeType("application/virus"));
73 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-user-cert"));
74 #if defined(OS_ANDROID)
75 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-ca-cert"));
76 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-pkcs12"));
77 #endif
73 78
74 EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); 79 EXPECT_TRUE(IsSupportedMimeType("image/jpeg"));
75 EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); 80 EXPECT_FALSE(IsSupportedMimeType("image/lolcat"));
76 EXPECT_TRUE(IsSupportedMimeType("text/html")); 81 EXPECT_TRUE(IsSupportedMimeType("text/html"));
77 EXPECT_TRUE(IsSupportedMimeType("text/banana")); 82 EXPECT_TRUE(IsSupportedMimeType("text/banana"));
78 EXPECT_FALSE(IsSupportedMimeType("text/vcard")); 83 EXPECT_FALSE(IsSupportedMimeType("text/vcard"));
79 EXPECT_FALSE(IsSupportedMimeType("application/virus")); 84 EXPECT_FALSE(IsSupportedMimeType("application/virus"));
80 } 85 }
81 86
82 TEST(MimeUtilTest, MatchesMimeType) { 87 TEST(MimeUtilTest, MatchesMimeType) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 #else 270 #else
266 if (extensions[j] == tests[i].contained_result) 271 if (extensions[j] == tests[i].contained_result)
267 found = true; 272 found = true;
268 #endif 273 #endif
269 } 274 }
270 ASSERT_TRUE(found) << "Must find at least the contained result within " 275 ASSERT_TRUE(found) << "Must find at least the contained result within "
271 << tests[i].mime_type; 276 << tests[i].mime_type;
272 } 277 }
273 } 278 }
274 279
280 TEST(MimeUtilTest, TestGetCertificateMimeTypeForMimeType) {
281 EXPECT_EQ(CERTIFICATE_MIME_TYPE_X509_USER_CERT,
282 GetCertificateMimeTypeForMimeType("application/x-x509-user-cert"));
283 #if defined(OS_ANDROID)
284 // Only Android supports CA Certs and PKCS12 archives.
285 EXPECT_EQ(CERTIFICATE_MIME_TYPE_X509_CA_CERT,
286 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert"));
287 EXPECT_EQ(CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE,
288 GetCertificateMimeTypeForMimeType("application/x-pkcs12"));
289 #else
290 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN,
291 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert"));
292 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN,
293 GetCertificateMimeTypeForMimeType("application/x-pkcs12"));
294 #endif
295 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN,
296 GetCertificateMimeTypeForMimeType("text/plain"));
297 }
298
275 } // namespace net 299 } // namespace net
OLDNEW
« net/base/mime_util.cc ('K') | « net/base/mime_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698