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

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

Issue 337042: Revert 30168 - Commit patch set from http://codereview.chromium.org/149796... (Closed) Base URL: svn://chrome-svn/chrome/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 return FilePath::CompareEqualIgnoreCase(derived_path.value(), 199 FilePath::StringType derived_path_str = derived_path.value();
200 full_file_path.value()); 200 return (derived_path_str.length() == full_file_path.value().length()) &&
201 std::equal(derived_path_str.begin(),
202 derived_path_str.end(),
203 full_file_path.value().begin(),
204 CaseInsensitiveCompare<FilePath::CharType>());
201 } 205 }
202 206
203 struct fixup_case { 207 struct fixup_case {
204 const std::string input; 208 const std::string input;
205 const std::string desired_tld; 209 const std::string desired_tld;
206 const std::string output; 210 const std::string output;
207 } fixup_cases[] = { 211 } fixup_cases[] = {
208 {"www.google.com", "", "http://www.google.com/"}, 212 {"www.google.com", "", "http://www.google.com/"},
209 {" www.google.com ", "", "http://www.google.com/"}, 213 {" www.google.com ", "", "http://www.google.com/"},
210 {" foo.com/asdf bar", "", "http://foo.com/asdf bar"}, 214 {" foo.com/asdf bar", "", "http://foo.com/asdf bar"},
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // (should resolve to the same file as above) 459 // (should resolve to the same file as above)
456 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + 460 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") +
457 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); 461 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value();
458 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str)); 462 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str));
459 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path)); 463 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path));
460 464
461 // done with the subdir 465 // done with the subdir
462 EXPECT_TRUE(file_util::Delete(full_path, false)); 466 EXPECT_TRUE(file_util::Delete(full_path, false));
463 EXPECT_TRUE(file_util::Delete(new_dir, true)); 467 EXPECT_TRUE(file_util::Delete(new_dir, true));
464 } 468 }
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