OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/filename_util.h" | 5 #include "net/base/filename_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 << "Iteration " << i; | 401 << "Iteration " << i; |
402 } | 402 } |
403 } | 403 } |
404 | 404 |
405 TEST(FilenameUtilTest, GenerateFileName) { | 405 TEST(FilenameUtilTest, GenerateFileName) { |
406 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 406 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
407 // This test doesn't run when the locale is not UTF-8 because some of the | 407 // This test doesn't run when the locale is not UTF-8 because some of the |
408 // string conversions fail. This is OK (we have the default value) but they | 408 // string conversions fail. This is OK (we have the default value) but they |
409 // don't match our expectations. | 409 // don't match our expectations. |
410 std::string locale = setlocale(LC_CTYPE, NULL); | 410 std::string locale = setlocale(LC_CTYPE, NULL); |
411 StringToLowerASCII(&locale); | 411 base::StringToLowerASCII(&locale); |
412 EXPECT_TRUE(locale.find("utf-8") != std::string::npos || | 412 EXPECT_TRUE(locale.find("utf-8") != std::string::npos || |
413 locale.find("utf8") != std::string::npos) | 413 locale.find("utf8") != std::string::npos) |
414 << "Your locale (" << locale << ") must be set to UTF-8 " | 414 << "Your locale (" << locale << ") must be set to UTF-8 " |
415 << "for this test to pass!"; | 415 << "for this test to pass!"; |
416 #endif | 416 #endif |
417 | 417 |
418 // Tests whether the correct filename is selected from the the given | 418 // Tests whether the correct filename is selected from the the given |
419 // parameters and that Content-Disposition headers are properly | 419 // parameters and that Content-Disposition headers are properly |
420 // handled including failovers when the header is malformed. | 420 // handled including failovers when the header is malformed. |
421 const GenerateFilenameCase selection_tests[] = { | 421 const GenerateFilenameCase selection_tests[] = { |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 RunGenerateFileNameTestCase(&generation_tests[i]); | 1643 RunGenerateFileNameTestCase(&generation_tests[i]); |
1644 | 1644 |
1645 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i) { | 1645 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i) { |
1646 GenerateFilenameCase test_case = generation_tests[i]; | 1646 GenerateFilenameCase test_case = generation_tests[i]; |
1647 test_case.referrer_charset = "GBK"; | 1647 test_case.referrer_charset = "GBK"; |
1648 RunGenerateFileNameTestCase(&test_case); | 1648 RunGenerateFileNameTestCase(&test_case); |
1649 } | 1649 } |
1650 } | 1650 } |
1651 | 1651 |
1652 } // namespace net | 1652 } // namespace net |
OLD | NEW |