| 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/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "net/base/mime_util.h" | 7 #include "net/base/mime_util.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 TEST(MimeUtilTest, LookupTypes) { | 62 TEST(MimeUtilTest, LookupTypes) { |
| 63 EXPECT_FALSE(IsUnsupportedTextMimeType("text/banana")); | 63 EXPECT_FALSE(IsUnsupportedTextMimeType("text/banana")); |
| 64 EXPECT_TRUE(IsUnsupportedTextMimeType("text/vcard")); | 64 EXPECT_TRUE(IsUnsupportedTextMimeType("text/vcard")); |
| 65 | 65 |
| 66 EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg")); | 66 EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg")); |
| 67 EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat")); | 67 EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat")); |
| 68 EXPECT_TRUE(IsSupportedNonImageMimeType("text/html")); | 68 EXPECT_TRUE(IsSupportedNonImageMimeType("text/html")); |
| 69 EXPECT_TRUE(IsSupportedNonImageMimeType("text/banana")); | 69 EXPECT_TRUE(IsSupportedNonImageMimeType("text/banana")); |
| 70 EXPECT_FALSE(IsSupportedNonImageMimeType("text/vcard")); | 70 EXPECT_FALSE(IsSupportedNonImageMimeType("text/vcard")); |
| 71 EXPECT_FALSE(IsSupportedNonImageMimeType("application/virus")); | 71 EXPECT_FALSE(IsSupportedNonImageMimeType("application/virus")); |
| 72 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-user-cert")); |
| 73 #if defined(OS_ANDROID) |
| 74 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-ca-cert")); |
| 75 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-pkcs12")); |
| 76 #endif |
| 72 | 77 |
| 73 EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); | 78 EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); |
| 74 EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); | 79 EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); |
| 75 EXPECT_TRUE(IsSupportedMimeType("text/html")); | 80 EXPECT_TRUE(IsSupportedMimeType("text/html")); |
| 76 EXPECT_TRUE(IsSupportedMimeType("text/banana")); | 81 EXPECT_TRUE(IsSupportedMimeType("text/banana")); |
| 77 EXPECT_FALSE(IsSupportedMimeType("text/vcard")); | 82 EXPECT_FALSE(IsSupportedMimeType("text/vcard")); |
| 78 EXPECT_FALSE(IsSupportedMimeType("application/virus")); | 83 EXPECT_FALSE(IsSupportedMimeType("application/virus")); |
| 79 } | 84 } |
| 80 | 85 |
| 81 TEST(MimeUtilTest, MatchesMimeType) { | 86 TEST(MimeUtilTest, MatchesMimeType) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 #else | 224 #else |
| 220 if (extensions[j] == tests[i].contained_result) | 225 if (extensions[j] == tests[i].contained_result) |
| 221 found = true; | 226 found = true; |
| 222 #endif | 227 #endif |
| 223 } | 228 } |
| 224 ASSERT_TRUE(found) << "Must find at least the contained result within " | 229 ASSERT_TRUE(found) << "Must find at least the contained result within " |
| 225 << tests[i].mime_type; | 230 << tests[i].mime_type; |
| 226 } | 231 } |
| 227 } | 232 } |
| 228 | 233 |
| 234 TEST(MimeUtilTest, TestGetCryptoFileTypeForMimeType) { |
| 235 EXPECT_EQ(CRYPTO_FILE_TYPE_X509_USER_CERT, |
| 236 GetCryptoFileTypeForMimeType("application/x-x509-user-cert")); |
| 237 #if defined(OS_ANDROID) |
| 238 // Only Android supports CA Certs and PKCS12 keychains. |
| 239 EXPECT_EQ(CRYPTO_FILE_TYPE_X509_CA_CERT, |
| 240 GetCryptoFileTypeForMimeType("application/x-x509-ca-cert")); |
| 241 EXPECT_EQ(CRYPTO_FILE_TYPE_PKCS12_KEYCHAIN, |
| 242 GetCryptoFileTypeForMimeType("application/x-pkcs12")); |
| 243 #else |
| 244 EXPECT_EQ(CRYPTO_FILE_TYPE_UNKNOWN, |
| 245 GetCryptoFileTypeForMimeType("application/x-x509-ca-cert")); |
| 246 EXPECT_EQ(CRYPTO_FILE_TYPE_UNKNOWN, |
| 247 GetCryptoFileTypeForMimeType("application/x-pkcs12")); |
| 248 #endif |
| 249 EXPECT_EQ(CRYPTO_FILE_TYPE_UNKNOWN, |
| 250 GetCryptoFileTypeForMimeType("text/plain")); |
| 251 } |
| 252 |
| 229 } // namespace net | 253 } // namespace net |
| OLD | NEW |