| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 true}}, | 337 true}}, |
| 338 {"xn--fiqs8s.cn", L"\x4e2d\x56fd\x3002" L"cn", | 338 {"xn--fiqs8s.cn", L"\x4e2d\x56fd\x3002" L"cn", |
| 339 {false, false, true, false, false, | 339 {false, false, true, false, false, |
| 340 false, false, false, false, false, | 340 false, false, false, false, false, |
| 341 false, false, false, false, false, | 341 false, false, false, false, false, |
| 342 false, false, true, false, false, | 342 false, false, true, false, false, |
| 343 true}}, | 343 true}}, |
| 344 #endif | 344 #endif |
| 345 }; | 345 }; |
| 346 | 346 |
| 347 struct RFC1738Case { |
| 348 const char* host; |
| 349 bool expected_output; |
| 350 }; |
| 351 |
| 347 struct SuggestedFilenameCase { | 352 struct SuggestedFilenameCase { |
| 348 const char* url; | 353 const char* url; |
| 349 const char* content_disp_header; | 354 const char* content_disp_header; |
| 350 const char* referrer_charset; | 355 const char* referrer_charset; |
| 351 const wchar_t* default_filename; | 356 const wchar_t* default_filename; |
| 352 const wchar_t* expected_filename; | 357 const wchar_t* expected_filename; |
| 353 }; | 358 }; |
| 354 | 359 |
| 355 struct UrlTestData { | 360 struct UrlTestData { |
| 356 const char* description; | 361 const char* description; |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 &output); | 808 &output); |
| 804 std::wstring expected(idn_cases[i].unicode_allowed[j] ? | 809 std::wstring expected(idn_cases[i].unicode_allowed[j] ? |
| 805 idn_cases[i].unicode_output : | 810 idn_cases[i].unicode_output : |
| 806 ASCIIToWide(idn_cases[i].input)); | 811 ASCIIToWide(idn_cases[i].input)); |
| 807 AppendLanguagesToOutputs(kLanguages[j], &expected, &output); | 812 AppendLanguagesToOutputs(kLanguages[j], &expected, &output); |
| 808 EXPECT_EQ(expected, output); | 813 EXPECT_EQ(expected, output); |
| 809 } | 814 } |
| 810 } | 815 } |
| 811 } | 816 } |
| 812 | 817 |
| 818 TEST(NetUtilTest, RFC1738) { |
| 819 const RFC1738Case rfc1738_cases[] = { |
| 820 {"", false}, |
| 821 {"a", true}, |
| 822 {"-", false}, |
| 823 {".", false}, |
| 824 {"a.", false}, |
| 825 {"a.a", true}, |
| 826 {"9.a", true}, |
| 827 {"a.9", false}, |
| 828 {"a.a9", true}, |
| 829 {"a.9a", false}, |
| 830 {"a+9a", false}, |
| 831 {"1-.a-b", false}, |
| 832 {"1-2.a-b", true}, |
| 833 {"a.b.c.d.e", true}, |
| 834 {"1.2.3.4.e", true}, |
| 835 {"a.b.c.d.5", false}, |
| 836 }; |
| 837 |
| 838 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(rfc1738_cases); ++i) { |
| 839 EXPECT_EQ(rfc1738_cases[i].expected_output, |
| 840 net::IsCanonicalizedHostRFC1738Compliant(rfc1738_cases[i].host)); |
| 841 } |
| 842 } |
| 843 |
| 813 TEST(NetUtilTest, StripWWW) { | 844 TEST(NetUtilTest, StripWWW) { |
| 814 EXPECT_EQ(L"", net::StripWWW(L"")); | 845 EXPECT_EQ(L"", net::StripWWW(L"")); |
| 815 EXPECT_EQ(L"", net::StripWWW(L"www.")); | 846 EXPECT_EQ(L"", net::StripWWW(L"www.")); |
| 816 EXPECT_EQ(L"blah", net::StripWWW(L"www.blah")); | 847 EXPECT_EQ(L"blah", net::StripWWW(L"www.blah")); |
| 817 EXPECT_EQ(L"blah", net::StripWWW(L"blah")); | 848 EXPECT_EQ(L"blah", net::StripWWW(L"blah")); |
| 818 } | 849 } |
| 819 | 850 |
| 820 TEST(NetUtilTest, GetSuggestedFilename) { | 851 TEST(NetUtilTest, GetSuggestedFilename) { |
| 821 const SuggestedFilenameCase test_cases[] = { | 852 const SuggestedFilenameCase test_cases[] = { |
| 822 {"http://www.google.com/", | 853 {"http://www.google.com/", |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 net::SetExplicitlyAllowedPorts(invalid[i]); | 1418 net::SetExplicitlyAllowedPorts(invalid[i]); |
| 1388 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); | 1419 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); |
| 1389 } | 1420 } |
| 1390 | 1421 |
| 1391 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { | 1422 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { |
| 1392 net::SetExplicitlyAllowedPorts(valid[i]); | 1423 net::SetExplicitlyAllowedPorts(valid[i]); |
| 1393 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); | 1424 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); |
| 1394 } | 1425 } |
| 1395 } | 1426 } |
| 1396 | 1427 |
| OLD | NEW |