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

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: Addressing comments 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 #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
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
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