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

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

Issue 9317018: referrer_charset is a lie. It's really the user's default_charset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/base/net_util.cc ('k') | net/http/http_content_disposition.h » ('j') | 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 "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 27 matching lines...) Expand all
38 }; 38 };
39 39
40 struct HeaderParamCase { 40 struct HeaderParamCase {
41 const char* header_name; 41 const char* header_name;
42 const char* param_name; 42 const char* param_name;
43 const char* expected; 43 const char* expected;
44 }; 44 };
45 45
46 struct FileNameCDCase { 46 struct FileNameCDCase {
47 const char* header_field; 47 const char* header_field;
48 const char* referrer_charset; 48 const char* default_charset;
49 const wchar_t* expected; 49 const wchar_t* expected;
50 }; 50 };
51 51
52 const char* kLanguages[] = { 52 const char* kLanguages[] = {
53 "", "en", "zh-CN", "ja", "ko", 53 "", "en", "zh-CN", "ja", "ko",
54 "he", "ar", "ru", "el", "fr", 54 "he", "ar", "ru", "el", "fr",
55 "de", "pt", "sv", "th", "hi", 55 "de", "pt", "sv", "th", "hi",
56 "de,en", "el,en", "zh-TW,en", "ko,ja", "he,ru,en", 56 "de,en", "el,en", "zh-TW,en", "ko,ja", "he,ru,en",
57 "zh,ru,en" 57 "zh,ru,en"
58 }; 58 };
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 struct CompliantHostCase { 381 struct CompliantHostCase {
382 const char* host; 382 const char* host;
383 const char* desired_tld; 383 const char* desired_tld;
384 bool expected_output; 384 bool expected_output;
385 }; 385 };
386 386
387 struct GenerateFilenameCase { 387 struct GenerateFilenameCase {
388 const char* url; 388 const char* url;
389 const char* content_disp_header; 389 const char* content_disp_header;
390 const char* referrer_charset; 390 const char* default_charset;
391 const char* suggested_filename; 391 const char* suggested_filename;
392 const char* mime_type; 392 const char* mime_type;
393 const wchar_t* default_filename; 393 const wchar_t* default_filename;
394 const wchar_t* expected_filename; 394 const wchar_t* expected_filename;
395 }; 395 };
396 396
397 struct UrlTestData { 397 struct UrlTestData {
398 const char* description; 398 const char* description;
399 const char* input; 399 const char* input;
400 const char* languages; 400 const char* languages;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } 509 }
510 return out; 510 return out;
511 } 511 }
512 512
513 void RunGenerateFileNameTestCase(const GenerateFilenameCase* test_case, 513 void RunGenerateFileNameTestCase(const GenerateFilenameCase* test_case,
514 size_t iteration, 514 size_t iteration,
515 const char* suite) { 515 const char* suite) {
516 std::string default_filename(WideToUTF8(test_case->default_filename)); 516 std::string default_filename(WideToUTF8(test_case->default_filename));
517 FilePath file_path = GenerateFileName( 517 FilePath file_path = GenerateFileName(
518 GURL(test_case->url), test_case->content_disp_header, 518 GURL(test_case->url), test_case->content_disp_header,
519 test_case->referrer_charset, test_case->suggested_filename, 519 test_case->default_charset, test_case->suggested_filename,
520 test_case->mime_type, default_filename); 520 test_case->mime_type, default_filename);
521 EXPECT_EQ(test_case->expected_filename, 521 EXPECT_EQ(test_case->expected_filename,
522 file_util::FilePathAsWString(file_path)) 522 file_util::FilePathAsWString(file_path))
523 << "Iteration " << iteration << " of " << suite << ": " << test_case->url; 523 << "Iteration " << iteration << " of " << suite << ": " << test_case->url;
524 } 524 }
525 525
526 } // anonymous namespace 526 } // anonymous namespace
527 527
528 TEST(NetUtilTest, FileURLConversion) { 528 TEST(NetUtilTest, FileURLConversion) {
529 // a list of test file names and the corresponding URLs 529 // a list of test file names and the corresponding URLs
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 }; 2084 };
2085 2085
2086 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(selection_tests); ++i) 2086 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(selection_tests); ++i)
2087 RunGenerateFileNameTestCase(&selection_tests[i], i, "selection"); 2087 RunGenerateFileNameTestCase(&selection_tests[i], i, "selection");
2088 2088
2089 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i) 2089 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i)
2090 RunGenerateFileNameTestCase(&generation_tests[i], i, "generation"); 2090 RunGenerateFileNameTestCase(&generation_tests[i], i, "generation");
2091 2091
2092 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i) { 2092 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i) {
2093 GenerateFilenameCase test_case = generation_tests[i]; 2093 GenerateFilenameCase test_case = generation_tests[i];
2094 test_case.referrer_charset = "GBK"; 2094 test_case.default_charset = "GBK";
2095 RunGenerateFileNameTestCase(&test_case, i, "generation (referrer=GBK)"); 2095 RunGenerateFileNameTestCase(&test_case, i, "generation (referrer=GBK)");
2096 } 2096 }
2097 } 2097 }
2098 2098
2099 // This is currently a windows specific function. 2099 // This is currently a windows specific function.
2100 #if defined(OS_WIN) 2100 #if defined(OS_WIN)
2101 namespace { 2101 namespace {
2102 2102
2103 struct GetDirectoryListingEntryCase { 2103 struct GetDirectoryListingEntryCase {
2104 const wchar_t* name; 2104 const wchar_t* name;
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 if (it->address[i] != 0) { 3204 if (it->address[i] != 0) {
3205 all_zeroes = false; 3205 all_zeroes = false;
3206 break; 3206 break;
3207 } 3207 }
3208 } 3208 }
3209 EXPECT_FALSE(all_zeroes); 3209 EXPECT_FALSE(all_zeroes);
3210 } 3210 }
3211 } 3211 }
3212 3212
3213 } // namespace net 3213 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.cc ('k') | net/http/http_content_disposition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698