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

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

Issue 230413003: Adding platform specific checks for VP9 codecs and HLS mime types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding comments Created 6 years, 7 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
11 #if defined(OS_ANDROID)
12 #include "base/android/build_info.h"
13 #endif
14
11 namespace net { 15 namespace net {
12 16
13 TEST(MimeUtilTest, ExtensionTest) { 17 TEST(MimeUtilTest, ExtensionTest) {
14 const struct { 18 const struct {
15 const base::FilePath::CharType* extension; 19 const base::FilePath::CharType* extension;
16 const char* mime_type; 20 const char* mime_type;
17 bool valid; 21 bool valid;
18 } tests[] = { 22 } tests[] = {
19 { FILE_PATH_LITERAL("png"), "image/png", true }, 23 { FILE_PATH_LITERAL("png"), "image/png", true },
20 { FILE_PATH_LITERAL("css"), "text/css", true }, 24 { FILE_PATH_LITERAL("css"), "text/css", true },
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 EXPECT_FALSE(MatchesMimeType("video/*", "*/*")); 186 EXPECT_FALSE(MatchesMimeType("video/*", "*/*"));
183 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/*")); 187 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/*"));
184 EXPECT_TRUE(MatchesMimeType("video/*;param=val", "video/*;param=val")); 188 EXPECT_TRUE(MatchesMimeType("video/*;param=val", "video/*;param=val"));
185 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/*;param=val2")); 189 EXPECT_FALSE(MatchesMimeType("video/*;param=val", "video/*;param=val2"));
186 190
187 EXPECT_TRUE(MatchesMimeType("ab*cd", "abxxxcd")); 191 EXPECT_TRUE(MatchesMimeType("ab*cd", "abxxxcd"));
188 EXPECT_TRUE(MatchesMimeType("ab*cd", "abx/xcd")); 192 EXPECT_TRUE(MatchesMimeType("ab*cd", "abx/xcd"));
189 EXPECT_TRUE(MatchesMimeType("ab/*cd", "ab/xxxcd")); 193 EXPECT_TRUE(MatchesMimeType("ab/*cd", "ab/xxxcd"));
190 } 194 }
191 195
196 TEST(MimeUtilTest, CommonMediaMimeType) {
197 #if defined(OS_ANDROID)
198 bool HLSSupported;
199 if (base::android::BuildInfo::GetInstance()->sdk_int() < 14)
200 HLSSupported = false;
201 else
202 HLSSupported = true;
203 #endif
204
205 EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm"));
206 EXPECT_TRUE(IsSupportedMediaMimeType("video/webm"));
207
208 EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav"));
209 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav"));
210
211 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg"));
212 EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg"));
213 #if defined(OS_ANDROID)
214 EXPECT_FALSE(IsSupportedMediaMimeType("video/ogg"));
215 EXPECT_EQ(HLSSupported, IsSupportedMediaMimeType("application/x-mpegurl"));
216 EXPECT_EQ(HLSSupported,
217 IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
218 #else
219 EXPECT_TRUE(IsSupportedMediaMimeType("video/ogg"));
220 EXPECT_FALSE(IsSupportedMediaMimeType("application/x-mpegurl"));
221 EXPECT_FALSE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
222 #endif // OS_ANDROID
223
224 #if defined(USE_PROPRIETARY_CODECS)
225 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp4"));
226 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-m4a"));
227 EXPECT_TRUE(IsSupportedMediaMimeType("video/mp4"));
228 EXPECT_TRUE(IsSupportedMediaMimeType("video/x-m4v"));
229
230 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp3"));
231 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-mp3"));
232 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mpeg"));
233 #else
234 EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp4"));
235 EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-m4a"));
236 EXPECT_FALSE(IsSupportedMediaMimeType("video/mp4"));
237 EXPECT_FALSE(IsSupportedMediaMimeType("video/x-m4v"));
238
239 EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp3"));
240 EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-mp3"));
241 EXPECT_FALSE(IsSupportedMediaMimeType("audio/mpeg"));
242 #endif // USE_PROPRIETARY_CODECS
243 EXPECT_FALSE(IsSupportedMediaMimeType("video/mp3"));
244
245 EXPECT_FALSE(IsSupportedMediaMimeType("video/unknown"));
246 EXPECT_FALSE(IsSupportedMediaMimeType("audio/unknown"));
247 EXPECT_FALSE(IsSupportedMediaMimeType("unknown/unknown"));
248 }
249
192 // Note: codecs should only be a list of 2 or fewer; hence the restriction of 250 // Note: codecs should only be a list of 2 or fewer; hence the restriction of
193 // results' length to 2. 251 // results' length to 2.
194 TEST(MimeUtilTest, ParseCodecString) { 252 TEST(MimeUtilTest, ParseCodecString) {
195 const struct { 253 const struct {
196 const char* original; 254 const char* original;
197 size_t expected_size; 255 size_t expected_size;
198 const char* results[2]; 256 const char* results[2];
199 } tests[] = { 257 } tests[] = {
200 { "\"bogus\"", 1, { "bogus" } }, 258 { "\"bogus\"", 1, { "bogus" } },
201 { "0", 1, { "0" } }, 259 { "0", 1, { "0" } },
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 std::string post_data; 410 std::string post_data;
353 AddMultipartValueForUpload("value name", "value", "boundary", 411 AddMultipartValueForUpload("value name", "value", "boundary",
354 "content type", &post_data); 412 "content type", &post_data);
355 AddMultipartValueForUpload("value name", "value", "boundary", 413 AddMultipartValueForUpload("value name", "value", "boundary",
356 "", &post_data); 414 "", &post_data);
357 AddMultipartFinalDelimiterForUpload("boundary", &post_data); 415 AddMultipartFinalDelimiterForUpload("boundary", &post_data);
358 EXPECT_STREQ(ref_output, post_data.c_str()); 416 EXPECT_STREQ(ref_output, post_data.c_str());
359 } 417 }
360 418
361 } // namespace net 419 } // 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