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

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

Issue 10834383: Chrome OS "open with" picker allowing Web Intents (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed mime matching code, asserts that the mime-pattern "*" matches a blank mime-type (i.e. "*" mat… Created 8 years, 4 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 unified diff | Download patch
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/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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); 73 EXPECT_TRUE(IsSupportedMimeType("image/jpeg"));
74 EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); 74 EXPECT_FALSE(IsSupportedMimeType("image/lolcat"));
75 EXPECT_TRUE(IsSupportedMimeType("text/html")); 75 EXPECT_TRUE(IsSupportedMimeType("text/html"));
76 EXPECT_TRUE(IsSupportedMimeType("text/banana")); 76 EXPECT_TRUE(IsSupportedMimeType("text/banana"));
77 EXPECT_FALSE(IsSupportedMimeType("text/vcard")); 77 EXPECT_FALSE(IsSupportedMimeType("text/vcard"));
78 EXPECT_FALSE(IsSupportedMimeType("application/virus")); 78 EXPECT_FALSE(IsSupportedMimeType("application/virus"));
79 } 79 }
80 80
81 TEST(MimeUtilTest, MatchesMimeType) { 81 TEST(MimeUtilTest, MatchesMimeType) {
82 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); 82 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg"));
83 EXPECT_TRUE(MatchesMimeType("*", ""));
benwells 2012/08/27 08:02:59 Is there a reason to add this test?
thorogood 2012/08/28 00:04:04 The reason for this is that it demonstrates that i
83 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); 84 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg"));
84 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); 85 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg"));
85 EXPECT_TRUE(MatchesMimeType("application/*+xml", 86 EXPECT_TRUE(MatchesMimeType("application/*+xml",
86 "application/html+xml")); 87 "application/html+xml"));
87 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); 88 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml"));
88 EXPECT_TRUE(MatchesMimeType("aaa*aaa", "aaaaaa")); 89 EXPECT_TRUE(MatchesMimeType("aaa*aaa", "aaaaaa"));
89 EXPECT_FALSE(MatchesMimeType("video/", "video/x-mpeg")); 90 EXPECT_FALSE(MatchesMimeType("video/", "video/x-mpeg"));
90 EXPECT_FALSE(MatchesMimeType("", "video/x-mpeg")); 91 EXPECT_FALSE(MatchesMimeType("", "video/x-mpeg"));
91 EXPECT_FALSE(MatchesMimeType("", "")); 92 EXPECT_FALSE(MatchesMimeType("", ""));
92 EXPECT_FALSE(MatchesMimeType("video/x-mpeg", "")); 93 EXPECT_FALSE(MatchesMimeType("video/x-mpeg", ""));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 163
163 EXPECT_TRUE(IsMimeType("x-video/mime")); 164 EXPECT_TRUE(IsMimeType("x-video/mime"));
164 EXPECT_TRUE(IsMimeType("X-Video/mime")); 165 EXPECT_TRUE(IsMimeType("X-Video/mime"));
165 EXPECT_FALSE(IsMimeType("x-video/")); 166 EXPECT_FALSE(IsMimeType("x-video/"));
166 EXPECT_FALSE(IsMimeType("x-/mime")); 167 EXPECT_FALSE(IsMimeType("x-/mime"));
167 EXPECT_FALSE(IsMimeType("mime/looking")); 168 EXPECT_FALSE(IsMimeType("mime/looking"));
168 EXPECT_FALSE(IsMimeType("text/")); 169 EXPECT_FALSE(IsMimeType("text/"));
169 } 170 }
170 171
171 } // namespace net 172 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698