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

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

Issue 417943002: Revert of android tests: don't override DIR_MODULE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « chrome/common/chrome_paths.cc ('k') | no next file » | 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 347 }
348 } 348 }
349 349
350 // Test different types of file inputs to URIFixerUpper::FixupURL. This 350 // 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 351 // doesn't go into the nice array of fixups above since the file input
352 // has to exist. 352 // has to exist.
353 TEST(URLFixerTest, FixupFile) { 353 TEST(URLFixerTest, FixupFile) {
354 // this "original" filename is the one we tweak to get all the variations 354 // this "original" filename is the one we tweak to get all the variations
355 base::FilePath dir; 355 base::FilePath dir;
356 base::FilePath original; 356 base::FilePath original;
357 ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &dir)); 357 ASSERT_TRUE(PathService::Get(base::DIR_MODULE, &dir));
358 ASSERT_TRUE(MakeTempFile( 358 ASSERT_TRUE(MakeTempFile(
359 dir, 359 dir,
360 base::FilePath(FILE_PATH_LITERAL("url fixer upper existing file.txt")), 360 base::FilePath(FILE_PATH_LITERAL("url fixer upper existing file.txt")),
361 &original)); 361 &original));
362 362
363 // reference path 363 // reference path
364 GURL golden(net::FilePathToFileURL(original)); 364 GURL golden(net::FilePathToFileURL(original));
365 365
366 // c:\foo\bar.txt -> file:///c:/foo/bar.txt (basic) 366 // c:\foo\bar.txt -> file:///c:/foo/bar.txt (basic)
367 GURL fixedup(url_fixer::FixupURL(original.AsUTF8Unsafe(), std::string())); 367 GURL fixedup(url_fixer::FixupURL(original.AsUTF8Unsafe(), std::string()));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 url_fixer::FixupURL(cases[i].input, "").possibly_invalid_spec()); 431 url_fixer::FixupURL(cases[i].input, "").possibly_invalid_spec());
432 } 432 }
433 433
434 EXPECT_TRUE(base::DeleteFile(original, false)); 434 EXPECT_TRUE(base::DeleteFile(original, false));
435 } 435 }
436 436
437 TEST(URLFixerTest, FixupRelativeFile) { 437 TEST(URLFixerTest, FixupRelativeFile) {
438 base::FilePath full_path, dir; 438 base::FilePath full_path, dir;
439 base::FilePath file_part( 439 base::FilePath file_part(
440 FILE_PATH_LITERAL("url_fixer_upper_existing_file.txt")); 440 FILE_PATH_LITERAL("url_fixer_upper_existing_file.txt"));
441 ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &dir)); 441 ASSERT_TRUE(PathService::Get(base::DIR_MODULE, &dir));
442 ASSERT_TRUE(MakeTempFile(dir, file_part, &full_path)); 442 ASSERT_TRUE(MakeTempFile(dir, file_part, &full_path));
443 full_path = base::MakeAbsoluteFilePath(full_path); 443 full_path = base::MakeAbsoluteFilePath(full_path);
444 ASSERT_FALSE(full_path.empty()); 444 ASSERT_FALSE(full_path.empty());
445 445
446 // make sure we pass through good URLs 446 // make sure we pass through good URLs
447 for (size_t i = 0; i < arraysize(fixup_cases); ++i) { 447 for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
448 FixupCase value = fixup_cases[i]; 448 FixupCase value = fixup_cases[i];
449 base::FilePath input = base::FilePath::FromUTF8Unsafe(value.input); 449 base::FilePath input = base::FilePath::FromUTF8Unsafe(value.input);
450 EXPECT_EQ(value.output, 450 EXPECT_EQ(value.output,
451 url_fixer::FixupRelativeFile(dir, input).possibly_invalid_spec()); 451 url_fixer::FixupRelativeFile(dir, input).possibly_invalid_spec());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 EXPECT_TRUE(base::DeleteFile(full_path, false)); 508 EXPECT_TRUE(base::DeleteFile(full_path, false));
509 EXPECT_TRUE(base::DeleteFile(new_dir, true)); 509 EXPECT_TRUE(base::DeleteFile(new_dir, true));
510 510
511 // Test that an obvious HTTP URL isn't accidentally treated as an absolute 511 // Test that an obvious HTTP URL isn't accidentally treated as an absolute
512 // file path (on account of system-specific craziness). 512 // file path (on account of system-specific craziness).
513 base::FilePath empty_path; 513 base::FilePath empty_path;
514 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../")); 514 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../"));
515 EXPECT_TRUE( 515 EXPECT_TRUE(
516 url_fixer::FixupRelativeFile(empty_path, http_url_path).SchemeIs("http")); 516 url_fixer::FixupRelativeFile(empty_path, http_url_path).SchemeIs("http"));
517 } 517 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698