| 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 "net/base/mime_util.h" | 7 #include "net/base/mime_util.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 namespace net { | 10 namespace net { |
| 10 | 11 |
| 11 TEST(MimeUtilTest, ExtensionTest) { | 12 TEST(MimeUtilTest, ExtensionTest) { |
| 12 const struct { | 13 const struct { |
| 13 const FilePath::CharType* extension; | 14 const FilePath::CharType* extension; |
| 14 const char* mime_type; | 15 const char* mime_type; |
| 15 bool valid; | 16 bool valid; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 120 } |
| 120 | 121 |
| 121 // Test without stripping the codec type. | 122 // Test without stripping the codec type. |
| 122 std::vector<std::string> codecs_out; | 123 std::vector<std::string> codecs_out; |
| 123 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); | 124 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); |
| 124 ASSERT_EQ(2u, codecs_out.size()); | 125 ASSERT_EQ(2u, codecs_out.size()); |
| 125 EXPECT_EQ("avc1.42E01E", codecs_out[0]); | 126 EXPECT_EQ("avc1.42E01E", codecs_out[0]); |
| 126 EXPECT_EQ("mp4a.40.2", codecs_out[1]); | 127 EXPECT_EQ("mp4a.40.2", codecs_out[1]); |
| 127 } | 128 } |
| 128 | 129 |
| 130 TEST(MimeUtilTest, TestIsMimeType) { |
| 131 std::string nonAscii("application/nonutf8"); |
| 132 EXPECT_TRUE(IsMimeType(nonAscii)); |
| 133 #if defined(OS_WIN) |
| 134 nonAscii.append(WideToUTF8(std::wstring(L"\u2603"))); |
| 135 #else |
| 136 nonAscii.append("\u2603"); // unicode snowman |
| 137 #endif |
| 138 EXPECT_FALSE(IsMimeType(nonAscii)); |
| 139 |
| 140 EXPECT_TRUE(IsMimeType("application/mime")); |
| 141 EXPECT_TRUE(IsMimeType("audio/mime")); |
| 142 EXPECT_TRUE(IsMimeType("example/mime")); |
| 143 EXPECT_TRUE(IsMimeType("image/mime")); |
| 144 EXPECT_TRUE(IsMimeType("message/mime")); |
| 145 EXPECT_TRUE(IsMimeType("model/mime")); |
| 146 EXPECT_TRUE(IsMimeType("multipart/mime")); |
| 147 EXPECT_TRUE(IsMimeType("text/mime")); |
| 148 EXPECT_TRUE(IsMimeType("TEXT/mime")); |
| 149 EXPECT_TRUE(IsMimeType("Text/mime")); |
| 150 EXPECT_TRUE(IsMimeType("TeXt/mime")); |
| 151 EXPECT_TRUE(IsMimeType("video/mime")); |
| 152 EXPECT_TRUE(IsMimeType("video/mime;parameter")); |
| 153 EXPECT_TRUE(IsMimeType("*/*")); |
| 154 EXPECT_TRUE(IsMimeType("*")); |
| 155 |
| 156 EXPECT_TRUE(IsMimeType("x-video/mime")); |
| 157 EXPECT_TRUE(IsMimeType("X-Video/mime")); |
| 158 EXPECT_FALSE(IsMimeType("x-video/")); |
| 159 EXPECT_FALSE(IsMimeType("x-/mime")); |
| 160 EXPECT_FALSE(IsMimeType("mime/looking")); |
| 161 EXPECT_FALSE(IsMimeType("text/")); |
| 162 } |
| 163 |
| 129 } // namespace net | 164 } // namespace net |
| OLD | NEW |