Chromium Code Reviews| 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/strings/string_split.h" | 6 #include "base/strings/string_split.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); | 87 EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); |
| 88 EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); | 88 EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); |
| 89 EXPECT_TRUE(IsSupportedMimeType("text/html")); | 89 EXPECT_TRUE(IsSupportedMimeType("text/html")); |
| 90 EXPECT_TRUE(IsSupportedMimeType("text/banana")); | 90 EXPECT_TRUE(IsSupportedMimeType("text/banana")); |
| 91 EXPECT_FALSE(IsSupportedMimeType("text/vcard")); | 91 EXPECT_FALSE(IsSupportedMimeType("text/vcard")); |
| 92 EXPECT_FALSE(IsSupportedMimeType("application/virus")); | 92 EXPECT_FALSE(IsSupportedMimeType("application/virus")); |
| 93 EXPECT_FALSE(IsSupportedMimeType("application/x-json")); | 93 EXPECT_FALSE(IsSupportedMimeType("application/x-json")); |
| 94 EXPECT_FALSE(IsSupportedNonImageMimeType("application/vnd.doc;x=y+json")); | 94 EXPECT_FALSE(IsSupportedNonImageMimeType("application/vnd.doc;x=y+json")); |
| 95 } | 95 } |
| 96 | 96 |
| 97 TEST(MimeUtilTest, StrictMediaMimeType) { | |
| 98 EXPECT_TRUE(IsStrictMediaMimeType("video/webm")); | |
| 99 EXPECT_TRUE(IsStrictMediaMimeType("audio/webm")); | |
| 100 | |
| 101 EXPECT_TRUE(IsStrictMediaMimeType("audio/wav")); | |
| 102 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav")); | |
| 103 | |
| 104 #if defined(OS_ANDROID) | |
| 105 EXPECT_FALSE(IsStrictMediaMimeType("video/ogg")); | |
| 106 #else | |
| 107 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg")); | |
| 108 #endif // OS_ANDROID | |
| 109 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg")); | |
| 110 EXPECT_TRUE(IsStrictMediaMimeType("application/ogg")); | |
| 111 | |
| 112 // TODO(amogh.bihani): Fix these test when bug 53193 is fixed. | |
|
Ryan Sleevi
2014/04/07 16:47:47
nit: Rather than "fix these", which is somewhat am
amogh.bihani
2014/04/08 03:29:14
Done.
| |
| 113 // http://crbug.com/53193 ---------------------------------------------------- | |
| 114 EXPECT_FALSE(IsStrictMediaMimeType("audio/mpeg")); | |
| 115 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp3")); | |
| 116 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-mp3")); | |
| 117 | |
| 118 EXPECT_FALSE(IsStrictMediaMimeType("video/mp4")); | |
| 119 EXPECT_FALSE(IsStrictMediaMimeType("video/x-mp4v")); | |
| 120 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp4")); | |
| 121 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-mp4a")); | |
| 122 | |
| 123 EXPECT_FALSE(IsStrictMediaMimeType("application/x-mpegurl")); | |
| 124 EXPECT_FALSE(IsStrictMediaMimeType("application/vnd.apple.mpegurl")); | |
| 125 // --------------------------------------------------------------------------- | |
| 126 | |
| 127 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown")); | |
| 128 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown")); | |
| 129 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown")); | |
| 130 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown")); | |
| 131 } | |
| 132 | |
| 97 TEST(MimeUtilTest, MatchesMimeType) { | 133 TEST(MimeUtilTest, MatchesMimeType) { |
| 98 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); | 134 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); |
| 99 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); | 135 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); |
| 100 EXPECT_TRUE(MatchesMimeType("video/*", "video/*")); | 136 EXPECT_TRUE(MatchesMimeType("video/*", "video/*")); |
| 101 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); | 137 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); |
| 102 EXPECT_TRUE(MatchesMimeType("application/*+xml", | 138 EXPECT_TRUE(MatchesMimeType("application/*+xml", |
| 103 "application/html+xml")); | 139 "application/html+xml")); |
| 104 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); | 140 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); |
| 105 EXPECT_TRUE(MatchesMimeType("application/*+json", | 141 EXPECT_TRUE(MatchesMimeType("application/*+json", |
| 106 "application/x-myformat+json")); | 142 "application/x-myformat+json")); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 std::string post_data; | 357 std::string post_data; |
| 322 AddMultipartValueForUpload("value name", "value", "boundary", | 358 AddMultipartValueForUpload("value name", "value", "boundary", |
| 323 "content type", &post_data); | 359 "content type", &post_data); |
| 324 AddMultipartValueForUpload("value name", "value", "boundary", | 360 AddMultipartValueForUpload("value name", "value", "boundary", |
| 325 "", &post_data); | 361 "", &post_data); |
| 326 AddMultipartFinalDelimiterForUpload("boundary", &post_data); | 362 AddMultipartFinalDelimiterForUpload("boundary", &post_data); |
| 327 EXPECT_STREQ(ref_output, post_data.c_str()); | 363 EXPECT_STREQ(ref_output, post_data.c_str()); |
| 328 } | 364 } |
| 329 | 365 |
| 330 } // namespace net | 366 } // namespace net |
| OLD | NEW |