OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 TEST_F(FileUtilTest, DeleteNonExistent) { | 625 TEST_F(FileUtilTest, DeleteNonExistent) { |
626 FilePath non_existent = temp_dir_.path().AppendASCII("bogus_file_dne.foobar"); | 626 FilePath non_existent = temp_dir_.path().AppendASCII("bogus_file_dne.foobar"); |
627 ASSERT_FALSE(PathExists(non_existent)); | 627 ASSERT_FALSE(PathExists(non_existent)); |
628 | 628 |
629 EXPECT_TRUE(DeleteFile(non_existent, false)); | 629 EXPECT_TRUE(DeleteFile(non_existent, false)); |
630 ASSERT_FALSE(PathExists(non_existent)); | 630 ASSERT_FALSE(PathExists(non_existent)); |
631 EXPECT_TRUE(DeleteFile(non_existent, true)); | 631 EXPECT_TRUE(DeleteFile(non_existent, true)); |
632 ASSERT_FALSE(PathExists(non_existent)); | 632 ASSERT_FALSE(PathExists(non_existent)); |
633 } | 633 } |
634 | 634 |
| 635 TEST_F(FileUtilTest, DeleteNonExistentWithNonExistentParent) { |
| 636 FilePath non_existent = temp_dir_.path().AppendASCII("bogus_topdir"); |
| 637 non_existent = non_existent.AppendASCII("bogus_subdir"); |
| 638 ASSERT_FALSE(PathExists(non_existent)); |
| 639 |
| 640 EXPECT_TRUE(DeleteFile(non_existent, false)); |
| 641 ASSERT_FALSE(PathExists(non_existent)); |
| 642 EXPECT_TRUE(DeleteFile(non_existent, true)); |
| 643 ASSERT_FALSE(PathExists(non_existent)); |
| 644 } |
| 645 |
635 TEST_F(FileUtilTest, DeleteFile) { | 646 TEST_F(FileUtilTest, DeleteFile) { |
636 // Create a file | 647 // Create a file |
637 FilePath file_name = temp_dir_.path().Append(FPL("Test DeleteFile 1.txt")); | 648 FilePath file_name = temp_dir_.path().Append(FPL("Test DeleteFile 1.txt")); |
638 CreateTextFile(file_name, bogus_content); | 649 CreateTextFile(file_name, bogus_content); |
639 ASSERT_TRUE(PathExists(file_name)); | 650 ASSERT_TRUE(PathExists(file_name)); |
640 | 651 |
641 // Make sure it's deleted | 652 // Make sure it's deleted |
642 EXPECT_TRUE(DeleteFile(file_name, false)); | 653 EXPECT_TRUE(DeleteFile(file_name, false)); |
643 EXPECT_FALSE(PathExists(file_name)); | 654 EXPECT_FALSE(PathExists(file_name)); |
644 | 655 |
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2561 // Trying to close it should crash. This is important for security. | 2572 // Trying to close it should crash. This is important for security. |
2562 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); | 2573 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); |
2563 #endif | 2574 #endif |
2564 } | 2575 } |
2565 | 2576 |
2566 #endif // defined(OS_POSIX) | 2577 #endif // defined(OS_POSIX) |
2567 | 2578 |
2568 } // namespace | 2579 } // namespace |
2569 | 2580 |
2570 } // namespace base | 2581 } // namespace base |
OLD | NEW |