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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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/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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 EXPECT_FALSE(IsValidTopLevelMimeType("")); 356 EXPECT_FALSE(IsValidTopLevelMimeType(""));
357 EXPECT_FALSE(IsValidTopLevelMimeType("/")); 357 EXPECT_FALSE(IsValidTopLevelMimeType("/"));
358 EXPECT_FALSE(IsValidTopLevelMimeType(" ")); 358 EXPECT_FALSE(IsValidTopLevelMimeType(" "));
359 359
360 EXPECT_TRUE(IsValidTopLevelMimeType("x-video")); 360 EXPECT_TRUE(IsValidTopLevelMimeType("x-video"));
361 EXPECT_TRUE(IsValidTopLevelMimeType("X-video")); 361 EXPECT_TRUE(IsValidTopLevelMimeType("X-video"));
362 362
363 EXPECT_FALSE(IsValidTopLevelMimeType("x-")); 363 EXPECT_FALSE(IsValidTopLevelMimeType("x-"));
364 } 364 }
365 365
366 TEST(MimeUtilTest, TestToIANAMediaType) {
367 EXPECT_EQ("", GetIANAMediaType("texting/driving"));
368 EXPECT_EQ("", GetIANAMediaType("ham/sandwich"));
369 EXPECT_EQ("", GetIANAMediaType(std::string()));
370 EXPECT_EQ("", GetIANAMediaType("/application/hamsandwich"));
371
372 EXPECT_EQ("application", GetIANAMediaType("application/poodle-wrestler"));
373 EXPECT_EQ("audio", GetIANAMediaType("audio/mpeg"));
374 EXPECT_EQ("example", GetIANAMediaType("example/yomomma"));
375 EXPECT_EQ("image", GetIANAMediaType("image/png"));
376 EXPECT_EQ("message", GetIANAMediaType("message/sipfrag"));
377 EXPECT_EQ("model", GetIANAMediaType("model/vrml"));
378 EXPECT_EQ("multipart", GetIANAMediaType("multipart/mixed"));
379 EXPECT_EQ("text", GetIANAMediaType("text/plain"));
380 EXPECT_EQ("video", GetIANAMediaType("video/H261"));
381 }
382
383 TEST(MimeUtilTest, TestGetExtensionsForMimeType) { 366 TEST(MimeUtilTest, TestGetExtensionsForMimeType) {
384 const struct { 367 const struct {
385 const char* mime_type; 368 const char* mime_type;
386 size_t min_expected_size; 369 size_t min_expected_size;
387 const char* contained_result; 370 const char* contained_result;
388 } tests[] = { 371 } tests[] = {
389 { "text/plain", 2, "txt" }, 372 { "text/plain", 2, "txt" },
390 { "*", 0, NULL }, 373 { "*", 0, NULL },
391 { "message/*", 1, "eml" }, 374 { "message/*", 1, "eml" },
392 { "MeSsAge/*", 1, "eml" }, 375 { "MeSsAge/*", 1, "eml" },
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 std::string post_data; 436 std::string post_data;
454 AddMultipartValueForUpload("value name", "value", "boundary", 437 AddMultipartValueForUpload("value name", "value", "boundary",
455 "content type", &post_data); 438 "content type", &post_data);
456 AddMultipartValueForUpload("value name", "value", "boundary", 439 AddMultipartValueForUpload("value name", "value", "boundary",
457 "", &post_data); 440 "", &post_data);
458 AddMultipartFinalDelimiterForUpload("boundary", &post_data); 441 AddMultipartFinalDelimiterForUpload("boundary", &post_data);
459 EXPECT_STREQ(ref_output, post_data.c_str()); 442 EXPECT_STREQ(ref_output, post_data.c_str());
460 } 443 }
461 444
462 } // namespace net 445 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mime_util.cc ('k') | net/base/network_change_notifier.cc » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698