Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / components / mime_util / mime_util_unittest.cc
blobc44be23b45ee7abe93d79364fb883251bb56ccef
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/mime_util/mime_util.h"
7 #include "build/build_config.h"
8 #include "net/base/mime_util.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace mime_util {
13 TEST(MimeUtilTest, LookupTypes) {
14 EXPECT_FALSE(IsUnsupportedTextMimeType("text/banana"));
15 EXPECT_TRUE(IsUnsupportedTextMimeType("text/vcard"));
17 EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg"));
18 EXPECT_TRUE(IsSupportedImageMimeType("Image/JPEG"));
19 EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat"));
20 EXPECT_FALSE(IsSupportedImageMimeType("Image/LolCat"));
21 EXPECT_TRUE(IsSupportedNonImageMimeType("text/html"));
22 EXPECT_TRUE(IsSupportedNonImageMimeType("text/css"));
23 EXPECT_TRUE(IsSupportedNonImageMimeType("text/"));
24 EXPECT_TRUE(IsSupportedNonImageMimeType("text/banana"));
25 EXPECT_TRUE(IsSupportedNonImageMimeType("Text/Banana"));
26 EXPECT_FALSE(IsSupportedNonImageMimeType("text/vcard"));
27 EXPECT_FALSE(IsSupportedNonImageMimeType("application/virus"));
28 EXPECT_FALSE(IsSupportedNonImageMimeType("Application/VIRUS"));
29 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-user-cert"));
30 EXPECT_TRUE(IsSupportedNonImageMimeType("application/json"));
31 EXPECT_TRUE(IsSupportedNonImageMimeType("application/+json"));
32 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-suggestions+json"));
33 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-s+json;x=2"));
34 #if defined(OS_ANDROID)
35 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-x509-ca-cert"));
36 EXPECT_TRUE(IsSupportedNonImageMimeType("application/x-pkcs12"));
37 #if 0 // Disabled until http://crbug.com/318217 is resolved.
38 EXPECT_TRUE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
39 EXPECT_TRUE(IsSupportedMediaMimeType("application/x-mpegurl"));
40 EXPECT_TRUE(IsSupportedMediaMimeType("Application/X-MPEGURL"));
41 #endif
42 #endif
44 EXPECT_TRUE(IsSupportedMimeType("image/jpeg"));
45 EXPECT_FALSE(IsSupportedMimeType("image/lolcat"));
46 EXPECT_FALSE(IsSupportedMimeType("Image/LOLCAT"));
47 EXPECT_TRUE(IsSupportedMimeType("text/html"));
48 EXPECT_TRUE(IsSupportedMimeType("text/banana"));
49 EXPECT_TRUE(IsSupportedMimeType("Text/BANANA"));
50 EXPECT_FALSE(IsSupportedMimeType("text/vcard"));
51 EXPECT_FALSE(IsSupportedMimeType("application/virus"));
52 EXPECT_FALSE(IsSupportedMimeType("application/x-json"));
53 EXPECT_FALSE(IsSupportedMimeType("Application/X-JSON"));
54 EXPECT_FALSE(IsSupportedNonImageMimeType("application/vnd.doc;x=y+json"));
55 EXPECT_FALSE(IsSupportedNonImageMimeType("Application/VND.DOC;X=Y+JSON"));
58 TEST(MimeUtilTest, TestGetCertificateMimeTypeForMimeType) {
59 EXPECT_EQ(net::CERTIFICATE_MIME_TYPE_X509_USER_CERT,
60 GetCertificateMimeTypeForMimeType("application/x-x509-user-cert"));
61 EXPECT_EQ(net::CERTIFICATE_MIME_TYPE_X509_USER_CERT,
62 GetCertificateMimeTypeForMimeType("Application/X-X509-USER-CERT"));
63 #if defined(OS_ANDROID)
64 // Only Android supports CA Certs and PKCS12 archives.
65 EXPECT_EQ(net::CERTIFICATE_MIME_TYPE_X509_CA_CERT,
66 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert"));
67 EXPECT_EQ(net::CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE,
68 GetCertificateMimeTypeForMimeType("application/x-pkcs12"));
69 #else
70 EXPECT_EQ(net::CERTIFICATE_MIME_TYPE_UNKNOWN,
71 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert"));
72 EXPECT_EQ(net::CERTIFICATE_MIME_TYPE_UNKNOWN,
73 GetCertificateMimeTypeForMimeType("application/x-pkcs12"));
74 #endif
75 EXPECT_EQ(net::CERTIFICATE_MIME_TYPE_UNKNOWN,
76 GetCertificateMimeTypeForMimeType("text/plain"));
79 } // namespace mime_util