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

Unified Diff: net/base/mime_util_unittest.cc

Issue 10448109: Move function for classifying a string as a mime type into MimeUtil (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adapt for windows unicode strings. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/mime_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mime_util_unittest.cc
diff --git a/net/base/mime_util_unittest.cc b/net/base/mime_util_unittest.cc
index c647294a9c9c3db3662c111b26b888cbb7523381..1ee286252d0988327cfcfc4b724180dea70e0907 100644
--- a/net/base/mime_util_unittest.cc
+++ b/net/base/mime_util_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/basictypes.h"
+#include "base/utf_string_conversions.h"
#include "net/base/mime_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -126,4 +127,38 @@ TEST(MimeUtilTest, ParseCodecString) {
EXPECT_EQ("mp4a.40.2", codecs_out[1]);
}
+TEST(MimeUtilTest, TestIsMimeType) {
+ std::string nonAscii("application/nonutf8");
+ EXPECT_TRUE(IsMimeType(nonAscii));
+#if defined(OS_WIN)
+ nonAscii.append(WideToUTF8(std::wstring(L"\u2603")));
+#else
+ nonAscii.append("\u2603"); // unicode snowman
+#endif
+ EXPECT_FALSE(IsMimeType(nonAscii));
+
+ EXPECT_TRUE(IsMimeType("application/mime"));
+ EXPECT_TRUE(IsMimeType("audio/mime"));
+ EXPECT_TRUE(IsMimeType("example/mime"));
+ EXPECT_TRUE(IsMimeType("image/mime"));
+ EXPECT_TRUE(IsMimeType("message/mime"));
+ EXPECT_TRUE(IsMimeType("model/mime"));
+ EXPECT_TRUE(IsMimeType("multipart/mime"));
+ EXPECT_TRUE(IsMimeType("text/mime"));
+ EXPECT_TRUE(IsMimeType("TEXT/mime"));
+ EXPECT_TRUE(IsMimeType("Text/mime"));
+ EXPECT_TRUE(IsMimeType("TeXt/mime"));
+ EXPECT_TRUE(IsMimeType("video/mime"));
+ EXPECT_TRUE(IsMimeType("video/mime;parameter"));
+ EXPECT_TRUE(IsMimeType("*/*"));
+ EXPECT_TRUE(IsMimeType("*"));
+
+ EXPECT_TRUE(IsMimeType("x-video/mime"));
+ EXPECT_TRUE(IsMimeType("X-Video/mime"));
+ EXPECT_FALSE(IsMimeType("x-video/"));
+ EXPECT_FALSE(IsMimeType("x-/mime"));
+ EXPECT_FALSE(IsMimeType("mime/looking"));
+ EXPECT_FALSE(IsMimeType("text/"));
+}
+
} // namespace net
« no previous file with comments | « net/base/mime_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698