| 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 "base/i18n/file_util_icu.h" | 5 #include "base/i18n/file_util_icu.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 {L"bad\uFDD0file\uFDEFname.jpg ", L"bad-file-name.jpg"}, | 66 {L"bad\uFDD0file\uFDEFname.jpg ", L"bad-file-name.jpg"}, |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 TEST_F(FileUtilICUTest, ReplaceIllegalCharactersInPathTest) { | 69 TEST_F(FileUtilICUTest, ReplaceIllegalCharactersInPathTest) { |
| 70 for (size_t i = 0; i < arraysize(kIllegalCharacterCases); ++i) { | 70 for (size_t i = 0; i < arraysize(kIllegalCharacterCases); ++i) { |
| 71 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
| 72 std::wstring bad_name(kIllegalCharacterCases[i].bad_name); | 72 std::wstring bad_name(kIllegalCharacterCases[i].bad_name); |
| 73 file_util::ReplaceIllegalCharactersInPath(&bad_name, '-'); | 73 file_util::ReplaceIllegalCharactersInPath(&bad_name, '-'); |
| 74 EXPECT_EQ(kIllegalCharacterCases[i].good_name, bad_name); | 74 EXPECT_EQ(kIllegalCharacterCases[i].good_name, bad_name); |
| 75 #elif defined(OS_MACOSX) | 75 #elif defined(OS_MACOSX) |
| 76 std::string bad_name(WideToUTF8(kIllegalCharacterCases[i].bad_name)); | 76 std::string bad_name(base::WideToUTF8(kIllegalCharacterCases[i].bad_name)); |
| 77 file_util::ReplaceIllegalCharactersInPath(&bad_name, '-'); | 77 file_util::ReplaceIllegalCharactersInPath(&bad_name, '-'); |
| 78 EXPECT_EQ(WideToUTF8(kIllegalCharacterCases[i].good_name), bad_name); | 78 EXPECT_EQ(base::WideToUTF8(kIllegalCharacterCases[i].good_name), bad_name); |
| 79 #endif | 79 #endif |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 #endif | 83 #endif |
| 84 | 84 |
| 85 #if defined(OS_CHROMEOS) | 85 #if defined(OS_CHROMEOS) |
| 86 static const struct normalize_name_encoding_test_cases { | 86 static const struct normalize_name_encoding_test_cases { |
| 87 const char* original_path; | 87 const char* original_path; |
| 88 const char* normalized_path; | 88 const char* normalized_path; |
| 89 } kNormalizeFileNameEncodingTestCases[] = { | 89 } kNormalizeFileNameEncodingTestCases[] = { |
| 90 { "foo_na\xcc\x88me.foo", "foo_n\xc3\xa4me.foo"}, | 90 { "foo_na\xcc\x88me.foo", "foo_n\xc3\xa4me.foo"}, |
| 91 { "foo_dir_na\xcc\x88me/foo_na\xcc\x88me.foo", | 91 { "foo_dir_na\xcc\x88me/foo_na\xcc\x88me.foo", |
| 92 "foo_dir_na\xcc\x88me/foo_n\xc3\xa4me.foo"}, | 92 "foo_dir_na\xcc\x88me/foo_n\xc3\xa4me.foo"}, |
| 93 { "", ""}, | 93 { "", ""}, |
| 94 { "foo_dir_na\xcc\x88me/", "foo_dir_n\xc3\xa4me"} | 94 { "foo_dir_na\xcc\x88me/", "foo_dir_n\xc3\xa4me"} |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 TEST_F(FileUtilICUTest, NormalizeFileNameEncoding) { | 97 TEST_F(FileUtilICUTest, NormalizeFileNameEncoding) { |
| 98 for (size_t i = 0; i < arraysize(kNormalizeFileNameEncodingTestCases); i++) { | 98 for (size_t i = 0; i < arraysize(kNormalizeFileNameEncodingTestCases); i++) { |
| 99 base::FilePath path(kNormalizeFileNameEncodingTestCases[i].original_path); | 99 base::FilePath path(kNormalizeFileNameEncodingTestCases[i].original_path); |
| 100 file_util::NormalizeFileNameEncoding(&path); | 100 file_util::NormalizeFileNameEncoding(&path); |
| 101 EXPECT_EQ( | 101 EXPECT_EQ( |
| 102 base::FilePath(kNormalizeFileNameEncodingTestCases[i].normalized_path), | 102 base::FilePath(kNormalizeFileNameEncodingTestCases[i].normalized_path), |
| 103 path); | 103 path); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 #endif | 107 #endif |
| OLD | NEW |