Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/browser/net/url_fixer_upper_unittest.cc

Issue 149796: Bug fix for 10876, file extension handling refactoring (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/download_util.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (url.length() <= 8) 189 if (url.length() <= 8)
190 return false; 190 return false;
191 if (std::string("file:///") != url.substr(0, 8)) 191 if (std::string("file:///") != url.substr(0, 8))
192 return false; // no file:/// prefix 192 return false; // no file:/// prefix
193 if (url.find('\\') != std::string::npos) 193 if (url.find('\\') != std::string::npos)
194 return false; // contains backslashes 194 return false; // contains backslashes
195 195
196 FilePath derived_path; 196 FilePath derived_path;
197 net::FileURLToFilePath(GURL(url), &derived_path); 197 net::FileURLToFilePath(GURL(url), &derived_path);
198 198
199 FilePath::StringType derived_path_str = derived_path.value(); 199 return FilePath::CompareEqualIgnoreCase(derived_path.value(),
200 return (derived_path_str.length() == full_file_path.value().length()) && 200 full_file_path.value());
201 std::equal(derived_path_str.begin(),
202 derived_path_str.end(),
203 full_file_path.value().begin(),
204 CaseInsensitiveCompare<FilePath::CharType>());
205 } 201 }
206 202
207 struct fixup_case { 203 struct fixup_case {
208 const std::string input; 204 const std::string input;
209 const std::string desired_tld; 205 const std::string desired_tld;
210 const std::string output; 206 const std::string output;
211 } fixup_cases[] = { 207 } fixup_cases[] = {
212 {"www.google.com", "", "http://www.google.com/"}, 208 {"www.google.com", "", "http://www.google.com/"},
213 {" www.google.com ", "", "http://www.google.com/"}, 209 {" www.google.com ", "", "http://www.google.com/"},
214 {" foo.com/asdf bar", "", "http://foo.com/asdf bar"}, 210 {" foo.com/asdf bar", "", "http://foo.com/asdf bar"},
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // (should resolve to the same file as above) 455 // (should resolve to the same file as above)
460 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + 456 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") +
461 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); 457 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value();
462 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str)); 458 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str));
463 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path)); 459 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path));
464 460
465 // done with the subdir 461 // done with the subdir
466 EXPECT_TRUE(file_util::Delete(full_path, false)); 462 EXPECT_TRUE(file_util::Delete(full_path, false));
467 EXPECT_TRUE(file_util::Delete(new_dir, true)); 463 EXPECT_TRUE(file_util::Delete(new_dir, true));
468 } 464 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_util.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698