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

Side by Side Diff: components/url_fixer/url_fixer_unittest.cc

Issue 464143002: Merge 288965 "Refresh Public Suffix List to the latest version" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 4 months 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 | « no previous file | net/base/registry_controlled_domains/OWNERS » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 TEST(URLFixerTest, FixupURL) { 314 TEST(URLFixerTest, FixupURL) {
315 for (size_t i = 0; i < arraysize(fixup_cases); ++i) { 315 for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
316 FixupCase value = fixup_cases[i]; 316 FixupCase value = fixup_cases[i];
317 EXPECT_EQ(value.output, 317 EXPECT_EQ(value.output,
318 url_fixer::FixupURL(value.input, "").possibly_invalid_spec()) 318 url_fixer::FixupURL(value.input, "").possibly_invalid_spec())
319 << "input: " << value.input; 319 << "input: " << value.input;
320 } 320 }
321 321
322 // Check the TLD-appending functionality. 322 // Check the TLD-appending functionality.
323 FixupCase tld_cases[] = { 323 FixupCase tld_cases[] = {
324 {"google", "http://www.google.com/"}, 324 {"somedomainthatwillnotbeagtld",
325 {"google.", "http://www.google.com/"}, 325 "http://www.somedomainthatwillnotbeagtld.com/"},
326 {"google..", "http://www.google.com/"}, 326 {"somedomainthatwillnotbeagtld.",
327 {".google", "http://www.google.com/"}, 327 "http://www.somedomainthatwillnotbeagtld.com/"},
328 {"www.google", "http://www.google.com/"}, 328 {"somedomainthatwillnotbeagtld..",
329 {"google.com", "http://google.com/"}, 329 "http://www.somedomainthatwillnotbeagtld.com/"},
330 {"http://google", "http://www.google.com/"}, 330 {".somedomainthatwillnotbeagtld",
331 {"..google..", "http://www.google.com/"}, 331 "http://www.somedomainthatwillnotbeagtld.com/"},
332 {"http://www.google", "http://www.google.com/"}, 332 {"www.somedomainthatwillnotbeagtld",
333 {"9999999999999999", "http://www.9999999999999999.com/"}, 333 "http://www.somedomainthatwillnotbeagtld.com/"},
334 {"google/foo", "http://www.google.com/foo"}, 334 {"somedomainthatwillnotbeagtld.com",
335 {"google.com/foo", "http://google.com/foo"}, 335 "http://somedomainthatwillnotbeagtld.com/"},
336 {"google/?foo=.com", "http://www.google.com/?foo=.com"}, 336 {"http://somedomainthatwillnotbeagtld",
337 {"www.google/?foo=www.", "http://www.google.com/?foo=www."}, 337 "http://www.somedomainthatwillnotbeagtld.com/"},
338 {"google.com/?foo=.com", "http://google.com/?foo=.com"}, 338 {"..somedomainthatwillnotbeagtld..",
339 {"http://www.google.com", "http://www.google.com/"}, 339 "http://www.somedomainthatwillnotbeagtld.com/"},
340 {"google:123", "http://www.google.com:123/"}, 340 {"http://www.somedomainthatwillnotbeagtld",
341 {"http://google:123", "http://www.google.com:123/"}, 341 "http://www.somedomainthatwillnotbeagtld.com/"},
342 {"9999999999999999", "http://www.9999999999999999.com/"},
343 {"somedomainthatwillnotbeagtld/foo",
344 "http://www.somedomainthatwillnotbeagtld.com/foo"},
345 {"somedomainthatwillnotbeagtld.com/foo",
346 "http://somedomainthatwillnotbeagtld.com/foo"},
347 {"somedomainthatwillnotbeagtld/?foo=.com",
348 "http://www.somedomainthatwillnotbeagtld.com/?foo=.com"},
349 {"www.somedomainthatwillnotbeagtld/?foo=www.",
350 "http://www.somedomainthatwillnotbeagtld.com/?foo=www."},
351 {"somedomainthatwillnotbeagtld.com/?foo=.com",
352 "http://somedomainthatwillnotbeagtld.com/?foo=.com"},
353 {"http://www.somedomainthatwillnotbeagtld.com",
354 "http://www.somedomainthatwillnotbeagtld.com/"},
355 {"somedomainthatwillnotbeagtld:123",
356 "http://www.somedomainthatwillnotbeagtld.com:123/"},
357 {"http://somedomainthatwillnotbeagtld:123",
358 "http://www.somedomainthatwillnotbeagtld.com:123/"},
342 }; 359 };
343 for (size_t i = 0; i < arraysize(tld_cases); ++i) { 360 for (size_t i = 0; i < arraysize(tld_cases); ++i) {
344 FixupCase value = tld_cases[i]; 361 FixupCase value = tld_cases[i];
345 EXPECT_EQ(value.output, 362 EXPECT_EQ(value.output,
346 url_fixer::FixupURL(value.input, "com").possibly_invalid_spec()); 363 url_fixer::FixupURL(value.input, "com").possibly_invalid_spec());
347 } 364 }
348 } 365 }
349 366
350 // Test different types of file inputs to URIFixerUpper::FixupURL. This 367 // Test different types of file inputs to URIFixerUpper::FixupURL. This
351 // doesn't go into the nice array of fixups above since the file input 368 // doesn't go into the nice array of fixups above since the file input
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 EXPECT_TRUE(base::DeleteFile(full_path, false)); 525 EXPECT_TRUE(base::DeleteFile(full_path, false));
509 EXPECT_TRUE(base::DeleteFile(new_dir, true)); 526 EXPECT_TRUE(base::DeleteFile(new_dir, true));
510 527
511 // Test that an obvious HTTP URL isn't accidentally treated as an absolute 528 // Test that an obvious HTTP URL isn't accidentally treated as an absolute
512 // file path (on account of system-specific craziness). 529 // file path (on account of system-specific craziness).
513 base::FilePath empty_path; 530 base::FilePath empty_path;
514 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../")); 531 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../"));
515 EXPECT_TRUE( 532 EXPECT_TRUE(
516 url_fixer::FixupRelativeFile(empty_path, http_url_path).SchemeIs("http")); 533 url_fixer::FixupRelativeFile(empty_path, http_url_path).SchemeIs("http"));
517 } 534 }
OLDNEW
« no previous file with comments | « no previous file | net/base/registry_controlled_domains/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698