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

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

Issue 218303002: Fix: canPlayType() gives false positive for */ogg and audio/x-wav (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « net/base/mime_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg"));
105 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg"));
106 EXPECT_TRUE(IsStrictMediaMimeType("application/ogg"));
107
108 // TODO(amogh.bihani): These formats should be in stict-format_map_. This will
109 // be fixed with bug 53193 (http://crbug.com/53193)---------------------------
110 EXPECT_FALSE(IsStrictMediaMimeType("audio/mpeg"));
111 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp3"));
112 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-mp3"));
113
114 EXPECT_FALSE(IsStrictMediaMimeType("video/mp4"));
115 EXPECT_FALSE(IsStrictMediaMimeType("video/x-mp4v"));
116 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp4"));
117 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-mp4a"));
118
119 EXPECT_FALSE(IsStrictMediaMimeType("application/x-mpegurl"));
120 EXPECT_FALSE(IsStrictMediaMimeType("application/vnd.apple.mpegurl"));
121 // ---------------------------------------------------------------------------
122
123 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown"));
124 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown"));
125 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown"));
126 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown"));
127 }
128
97 TEST(MimeUtilTest, MatchesMimeType) { 129 TEST(MimeUtilTest, MatchesMimeType) {
98 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); 130 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg"));
99 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); 131 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg"));
100 EXPECT_TRUE(MatchesMimeType("video/*", "video/*")); 132 EXPECT_TRUE(MatchesMimeType("video/*", "video/*"));
101 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); 133 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg"));
102 EXPECT_TRUE(MatchesMimeType("application/*+xml", 134 EXPECT_TRUE(MatchesMimeType("application/*+xml",
103 "application/html+xml")); 135 "application/html+xml"));
104 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); 136 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml"));
105 EXPECT_TRUE(MatchesMimeType("application/*+json", 137 EXPECT_TRUE(MatchesMimeType("application/*+json",
106 "application/x-myformat+json")); 138 "application/x-myformat+json"));
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 std::string post_data; 353 std::string post_data;
322 AddMultipartValueForUpload("value name", "value", "boundary", 354 AddMultipartValueForUpload("value name", "value", "boundary",
323 "content type", &post_data); 355 "content type", &post_data);
324 AddMultipartValueForUpload("value name", "value", "boundary", 356 AddMultipartValueForUpload("value name", "value", "boundary",
325 "", &post_data); 357 "", &post_data);
326 AddMultipartFinalDelimiterForUpload("boundary", &post_data); 358 AddMultipartFinalDelimiterForUpload("boundary", &post_data);
327 EXPECT_STREQ(ref_output, post_data.c_str()); 359 EXPECT_STREQ(ref_output, post_data.c_str());
328 } 360 }
329 361
330 } // namespace net 362 } // namespace net
OLDNEW
« 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