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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // It would be better if this next case got treated as http, but I don't see | 170 // It would be better if this next case got treated as http, but I don't see |
171 // a clean way to guess this isn't the new-and-exciting "user" scheme. | 171 // a clean way to guess this isn't the new-and-exciting "user" scheme. |
172 {"user:passwd@www.google.com:8080/", "", "user:passwd@www.google.com:8080/"}, | 172 {"user:passwd@www.google.com:8080/", "", "user:passwd@www.google.com:8080/"}, |
173 //{"file:///c:/foo/bar%20baz.txt", "", "file:///C:/foo/bar%20baz.txt"}, | 173 //{"file:///c:/foo/bar%20baz.txt", "", "file:///C:/foo/bar%20baz.txt"}, |
174 {"ftp.google.com", "", "ftp://ftp.google.com/"}, | 174 {"ftp.google.com", "", "ftp://ftp.google.com/"}, |
175 {" ftp.google.com", "", "ftp://ftp.google.com/"}, | 175 {" ftp.google.com", "", "ftp://ftp.google.com/"}, |
176 {"FTP.GooGle.com", "", "ftp://FTP.GooGle.com/"}, | 176 {"FTP.GooGle.com", "", "ftp://FTP.GooGle.com/"}, |
177 {"ftpblah.google.com", "", "http://ftpblah.google.com/"}, | 177 {"ftpblah.google.com", "", "http://ftpblah.google.com/"}, |
178 {"ftp", "", "http://ftp/"}, | 178 {"ftp", "", "http://ftp/"}, |
179 {"google.ftp.com", "", "http://google.ftp.com/"}, | 179 {"google.ftp.com", "", "http://google.ftp.com/"}, |
180 // URLs which end with an ISO-8859 next-line (0x85). | |
181 { "http://google.com/search?q=\xd0\x85", "", | |
182 "http://google.com/search?q=\xd0\x85" | |
183 }, | |
184 { "http://google.com/search?q=\xec\x97\x85", "", | |
185 "http://google.com/search?q=\xec\x97\x85" | |
186 }, | |
187 { "http://google.com/search?q=\xf0\x90\x80\x85", "", | |
188 "http://google.com/search?q=\xf0\x90\x80\x85" | |
189 }, | |
190 // URLs which end with a non-break space (0xA0). | |
191 { "http://google.com/search?q=\xd0\xa0", "", | |
192 "http://google.com/search?q=\xd0\xa0" | |
193 }, | |
194 { "http://google.com/search?q=\xec\x97\xa0", "", | |
195 "http://google.com/search?q=\xec\x97\xa0" | |
196 }, | |
197 { "http://google.com/search?q=\xf0\x90\x80\xa0", "", | |
198 "http://google.com/search?q=\xf0\x90\x80\xa0" | |
199 }, | |
200 }; | 180 }; |
201 | 181 |
202 TEST(URLFixerUpperTest, FixupURL) { | 182 TEST(URLFixerUpperTest, FixupURL) { |
203 std::string output; | 183 std::string output; |
204 | 184 |
205 for (size_t i = 0; i < arraysize(fixup_cases); ++i) { | 185 for (size_t i = 0; i < arraysize(fixup_cases); ++i) { |
206 fixup_case value = fixup_cases[i]; | 186 fixup_case value = fixup_cases[i]; |
207 output = URLFixerUpper::FixupURL(value.input, value.desired_tld); | 187 output = URLFixerUpper::FixupURL(value.input, value.desired_tld); |
208 EXPECT_EQ(value.output, output); | 188 EXPECT_EQ(value.output, output); |
209 } | 189 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // (should resolve to the same file as above) | 337 // (should resolve to the same file as above) |
358 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + | 338 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + |
359 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); | 339 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); |
360 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str)); | 340 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str)); |
361 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path)); | 341 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path)); |
362 | 342 |
363 // done with the subdir | 343 // done with the subdir |
364 EXPECT_TRUE(file_util::Delete(full_path, false)); | 344 EXPECT_TRUE(file_util::Delete(full_path, false)); |
365 EXPECT_TRUE(file_util::Delete(new_dir, true)); | 345 EXPECT_TRUE(file_util::Delete(new_dir, true)); |
366 } | 346 } |
OLD | NEW |