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/files/file_util.h" | 7 #include "base/files/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 L"\u206B.\u206C.\u206D.\u206F.\uFEFF)", | 71 L"\u206B.\u206C.\u206D.\u206F.\uFEFF)", |
72 L"(-.-.-.-.-.-.-.-.-.-.-.-.-.-.-)"}, | 72 L"(-.-.-.-.-.-.-.-.-.-.-.-.-.-.-)"}, |
73 {L"config~1", L"config-1"}, | 73 {L"config~1", L"config-1"}, |
74 {L" _ ", L"-_-"}, | 74 {L" _ ", L"-_-"}, |
75 {L" ", L"-"}, | 75 {L" ", L"-"}, |
76 {L"\u2008.(\u2007).\u3000", L"-.(\u2007).-"}, | 76 {L"\u2008.(\u2007).\u3000", L"-.(\u2007).-"}, |
77 {L" ", L"- -"}, | 77 {L" ", L"- -"}, |
78 {L". ", L"- -"} | 78 {L". ", L"- -"} |
79 }; | 79 }; |
80 | 80 |
81 #if defined(OS_WIN) || defined(OS_MACOSX) | 81 #if defined(OS_MACOSX) |
82 | 82 |
83 TEST_F(FileUtilICUTest, ReplaceIllegalCharactersInPathTest) { | 83 TEST_F(FileUtilICUTest, ReplaceIllegalCharactersInPathTest) { |
84 for (size_t i = 0; i < arraysize(kIllegalCharacterCases); ++i) { | 84 for (size_t i = 0; i < arraysize(kIllegalCharacterCases); ++i) { |
85 #if defined(OS_WIN) | |
86 std::wstring bad_name(kIllegalCharacterCases[i].bad_name); | |
87 ReplaceIllegalCharactersInPath(&bad_name, '-'); | |
88 EXPECT_EQ(kIllegalCharacterCases[i].good_name, bad_name); | |
89 #elif defined(OS_MACOSX) | |
90 std::string bad_name(WideToUTF8(kIllegalCharacterCases[i].bad_name)); | 85 std::string bad_name(WideToUTF8(kIllegalCharacterCases[i].bad_name)); |
91 ReplaceIllegalCharactersInPath(&bad_name, '-'); | 86 ReplaceIllegalCharactersInPath(&bad_name, '-'); |
92 EXPECT_EQ(WideToUTF8(kIllegalCharacterCases[i].good_name), bad_name); | 87 EXPECT_EQ(WideToUTF8(kIllegalCharacterCases[i].good_name), bad_name); |
93 #endif | |
94 } | 88 } |
95 } | 89 } |
96 | 90 |
97 #endif | 91 #endif |
98 | 92 |
99 TEST_F(FileUtilICUTest, IsFilenameLegalTest) { | 93 TEST_F(FileUtilICUTest, IsFilenameLegalTest) { |
100 EXPECT_TRUE(IsFilenameLegal(string16())); | 94 EXPECT_TRUE(IsFilenameLegal(string16())); |
101 | 95 |
102 for (const auto& test_case : kIllegalCharacterCases) { | 96 for (const auto& test_case : kIllegalCharacterCases) { |
103 string16 bad_name = WideToUTF16(test_case.bad_name); | 97 string16 bad_name = WideToUTF16(test_case.bad_name); |
(...skipping 23 matching lines...) Expand all Loading... |
127 NormalizeFileNameEncoding(&path); | 121 NormalizeFileNameEncoding(&path); |
128 EXPECT_EQ(FilePath(kNormalizeFileNameEncodingTestCases[i].normalized_path), | 122 EXPECT_EQ(FilePath(kNormalizeFileNameEncodingTestCases[i].normalized_path), |
129 path); | 123 path); |
130 } | 124 } |
131 } | 125 } |
132 | 126 |
133 #endif | 127 #endif |
134 | 128 |
135 } // namespace i18n | 129 } // namespace i18n |
136 } // namespace base | 130 } // namespace base |
OLD | NEW |