 Chromium Code Reviews
 Chromium Code Reviews Issue 174053:
  Set OS X cache directory to ~/Library/Caches/[app name]/[profile name]  (Closed)
    
  
    Issue 174053:
  Set OS X cache directory to ~/Library/Caches/[app name]/[profile name]  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/basictypes.h" | 5 #include "base/basictypes.h" | 
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" | 
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" | 
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" | 
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" | 
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" | 
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 for (size_t i = 0; i < arraysize(cases); ++i) { | 478 for (size_t i = 0; i < arraysize(cases); ++i) { | 
| 479 FilePath parent(cases[i].inputs[0]); | 479 FilePath parent(cases[i].inputs[0]); | 
| 480 FilePath child(cases[i].inputs[1]); | 480 FilePath child(cases[i].inputs[1]); | 
| 481 | 481 | 
| 482 EXPECT_EQ(parent.IsParent(child), cases[i].expected) << | 482 EXPECT_EQ(parent.IsParent(child), cases[i].expected) << | 
| 483 "i: " << i << ", parent: " << parent.value() << ", child: " << | 483 "i: " << i << ", parent: " << parent.value() << ", child: " << | 
| 484 child.value(); | 484 child.value(); | 
| 485 } | 485 } | 
| 486 } | 486 } | 
| 487 | 487 | 
| 488 TEST_F(FilePathTest, AppendRelativePathTest) { | |
| 489 const struct BinaryTestData cases[] = { | |
| 490 { { FPL("/"), FPL("/foo/bar/baz") }, FPL("foo/bar/baz")}, | |
| 491 { { FPL("/foo/bar"), FPL("/foo/bar/baz") }, FPL("baz")}, | |
| 492 { { FPL("/foo/bar/"), FPL("/foo/bar/baz") }, FPL("baz")}, | |
| 493 { { FPL("//foo/bar/"), FPL("//foo/bar/baz") }, FPL("baz")}, | |
| 494 { { FPL("/foo/bar"), FPL("/foo2/bar/baz") }, FPL("")}, | |
| 495 { { FPL("/foo/bar.txt"), FPL("/foo/bar/baz") }, FPL("")}, | |
| 496 { { FPL("/foo/bar"), FPL("/foo/bar2/baz") }, FPL("")}, | |
| 497 { { FPL("/foo/bar"), FPL("/foo/bar") }, FPL("")}, | |
| 498 { { FPL("/foo/bar/baz"), FPL("/foo/bar") }, FPL("")}, | |
| 499 { { FPL("foo/bar"), FPL("foo/bar/baz") }, FPL("baz")}, | |
| 500 { { FPL("foo/bar"), FPL("foo2/bar/baz") }, FPL("")}, | |
| 501 { { FPL("foo/bar"), FPL("foo/bar2/baz") }, FPL("")}, | |
| 502 { { FPL(""), FPL("foo") }, FPL("")}, | |
| 503 #if defined(FILE_PATH_USES_DRIVE_LETTERS) | |
| 504 { { FPL("c:/foo/bar"), FPL("c:/foo/bar/baz") }, FPL("baz")}, | |
| 505 { { FPL("E:/foo/bar"), FPL("e:/foo/bar/baz") }, FPL("baz")}, | |
| 506 { { FPL("f:/foo/bar"), FPL("F:/foo/bar/baz") }, FPL("baz")}, | |
| 507 { { FPL("E:/Foo/bar"), FPL("e:/foo/bar/baz") }, FPL("")}, | |
| 508 { { FPL("f:/foo/bar"), FPL("F:/foo/Bar/baz") }, FPL("")}, | |
| 509 { { FPL("c:/"), FPL("c:/foo/bar/baz") }, FPL("foo/bar/baz")}, | |
| 510 { { FPL("c:"), FPL("c:/foo/bar/baz") }, FPL("foo/bar/baz")}, | |
| 511 { { FPL("c:/foo/bar"), FPL("d:/foo/bar/baz") }, FPL("")}, | |
| 512 { { FPL("c:/foo/bar"), FPL("D:/foo/bar/baz") }, FPL("")}, | |
| 513 { { FPL("C:/foo/bar"), FPL("d:/foo/bar/baz") }, FPL("")}, | |
| 514 { { FPL("c:/foo/bar"), FPL("c:/foo2/bar/baz") }, FPL("")}, | |
| 515 { { FPL("e:/foo/bar"), FPL("E:/foo2/bar/baz") }, FPL("")}, | |
| 516 { { FPL("F:/foo/bar"), FPL("f:/foo2/bar/baz") }, FPL("")}, | |
| 517 { { FPL("c:/foo/bar"), FPL("c:/foo/bar2/baz") }, FPL("")}, | |
| 518 #endif // FILE_PATH_USES_DRIVE_LETTERS | |
| 519 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | |
| 520 { { FPL("\\foo\\bar"), FPL("\\foo\\bar\\baz") }, FPL("baz")}, | |
| 521 { { FPL("\\foo/bar"), FPL("\\foo\\bar\\baz") }, FPL("baz")}, | |
| 522 { { FPL("\\foo/bar"), FPL("\\foo/bar/baz") }, FPL("baz")}, | |
| 523 { { FPL("\\"), FPL("\\foo\\bar\\baz") }, FPL("foo\\bar\\baz")}, | |
| 524 { { FPL(""), FPL("\\foo\\bar\\baz") }, FPL("")}, | |
| 525 { { FPL("\\foo\\bar"), FPL("\\foo2\\bar\\baz") }, FPL("")}, | |
| 526 { { FPL("\\foo\\bar"), FPL("\\foo\\bar2\\baz") }, FPL("")}, | |
| 527 #endif // FILE_PATH_USES_WIN_SEPARATORS | |
| 528 }; | |
| 529 | |
| 530 const FilePath base("blah"); | |
| 
Mark Mentovai
2009/09/16 18:55:20
On Windows:
C:\b\slave\win\build\src\base\file_pa
 | |
| 531 | |
| 532 for (size_t i = 0; i < arraysize(cases); ++i) { | |
| 533 FilePath parent(cases[i].inputs[0]); | |
| 534 FilePath child(cases[i].inputs[1]); | |
| 535 { | |
| 536 FilePath result(""); | |
| 
Mark Mentovai
2009/09/16 18:55:20
Same error, I've changed this to:
      FilePath
 | |
| 537 bool success = parent.AppendRelativePath(child, &result); | |
| 538 EXPECT_EQ(cases[i].expected[0] != '\0', success) << | |
| 539 "i: " << i << ", parent: " << parent.value() << ", child: " << | |
| 540 child.value(); | |
| 541 EXPECT_STREQ(cases[i].expected, result.value().c_str()) << | |
| 542 "i: " << i << ", parent: " << parent.value() << ", child: " << | |
| 543 child.value(); | |
| 544 } | |
| 545 { | |
| 546 FilePath result(base); | |
| 547 bool success = parent.AppendRelativePath(child, &result); | |
| 548 EXPECT_EQ(cases[i].expected[0] != '\0', success) << | |
| 549 "i: " << i << ", parent: " << parent.value() << ", child: " << | |
| 550 child.value(); | |
| 551 EXPECT_EQ(base.Append(cases[i].expected).value(), result.value()) << | |
| 552 "i: " << i << ", parent: " << parent.value() << ", child: " << | |
| 553 child.value(); | |
| 554 } | |
| 555 } | |
| 556 } | |
| 557 | |
| 488 TEST_F(FilePathTest, EqualityTest) { | 558 TEST_F(FilePathTest, EqualityTest) { | 
| 489 const struct BinaryBooleanTestData cases[] = { | 559 const struct BinaryBooleanTestData cases[] = { | 
| 490 { { FPL("/foo/bar/baz"), FPL("/foo/bar/baz") }, true}, | 560 { { FPL("/foo/bar/baz"), FPL("/foo/bar/baz") }, true}, | 
| 491 { { FPL("/foo/bar"), FPL("/foo/bar/baz") }, false}, | 561 { { FPL("/foo/bar"), FPL("/foo/bar/baz") }, false}, | 
| 492 { { FPL("/foo/bar/baz"), FPL("/foo/bar") }, false}, | 562 { { FPL("/foo/bar/baz"), FPL("/foo/bar") }, false}, | 
| 493 { { FPL("//foo/bar/"), FPL("//foo/bar/") }, true}, | 563 { { FPL("//foo/bar/"), FPL("//foo/bar/") }, true}, | 
| 494 { { FPL("/foo/bar"), FPL("/foo2/bar") }, false}, | 564 { { FPL("/foo/bar"), FPL("/foo2/bar") }, false}, | 
| 495 { { FPL("/foo/bar.txt"), FPL("/foo/bar") }, false}, | 565 { { FPL("/foo/bar.txt"), FPL("/foo/bar") }, false}, | 
| 496 { { FPL("foo/bar"), FPL("foo/bar") }, true}, | 566 { { FPL("foo/bar"), FPL("foo/bar") }, true}, | 
| 497 { { FPL("foo/bar"), FPL("foo/bar/baz") }, false}, | 567 { { FPL("foo/bar"), FPL("foo/bar/baz") }, false}, | 
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 }; | 828 }; | 
| 759 | 829 | 
| 760 for (size_t i = 0; i < arraysize(cases); ++i) { | 830 for (size_t i = 0; i < arraysize(cases); ++i) { | 
| 761 FilePath input(cases[i].input); | 831 FilePath input(cases[i].input); | 
| 762 bool observed = input.ReferencesParent(); | 832 bool observed = input.ReferencesParent(); | 
| 763 EXPECT_EQ(cases[i].expected, observed) << | 833 EXPECT_EQ(cases[i].expected, observed) << | 
| 764 "i: " << i << ", input: " << input.value(); | 834 "i: " << i << ", input: " << input.value(); | 
| 765 } | 835 } | 
| 766 } | 836 } | 
| 767 | 837 | 
| OLD | NEW |