| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |