OLD | NEW |
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 "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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 NULL, NULL, NULL, NULL, 0)); | 678 NULL, NULL, NULL, NULL, 0)); |
679 std::wstring resolved_name = link_file.value(); | 679 std::wstring resolved_name = link_file.value(); |
680 EXPECT_TRUE(file_util::ResolveShortcut(&resolved_name)); | 680 EXPECT_TRUE(file_util::ResolveShortcut(&resolved_name)); |
681 std::wstring read_contents = ReadTextFile(FilePath(resolved_name)); | 681 std::wstring read_contents = ReadTextFile(FilePath(resolved_name)); |
682 EXPECT_EQ(file_contents, read_contents); | 682 EXPECT_EQ(file_contents, read_contents); |
683 | 683 |
684 DeleteFile(target_file.value().c_str()); | 684 DeleteFile(target_file.value().c_str()); |
685 DeleteFile(link_file.value().c_str()); | 685 DeleteFile(link_file.value().c_str()); |
686 CoUninitialize(); | 686 CoUninitialize(); |
687 } | 687 } |
| 688 |
| 689 TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) { |
| 690 // Create a directory |
| 691 FilePath dir_name_from = |
| 692 test_dir_.Append(FILE_PATH_LITERAL("CopyAndDelete_From_Subdir")); |
| 693 file_util::CreateDirectory(dir_name_from); |
| 694 ASSERT_TRUE(file_util::PathExists(dir_name_from)); |
| 695 |
| 696 // Create a file under the directory |
| 697 FilePath file_name_from = |
| 698 dir_name_from.Append(FILE_PATH_LITERAL("CopyAndDelete_Test_File.txt")); |
| 699 CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); |
| 700 ASSERT_TRUE(file_util::PathExists(file_name_from)); |
| 701 |
| 702 // Move the directory by using CopyAndDeleteDirectory |
| 703 FilePath dir_name_to = test_dir_.Append( |
| 704 FILE_PATH_LITERAL("CopyAndDelete_To_Subdir")); |
| 705 FilePath file_name_to = |
| 706 dir_name_to.Append(FILE_PATH_LITERAL("CopyAndDelete_Test_File.txt")); |
| 707 |
| 708 ASSERT_FALSE(file_util::PathExists(dir_name_to)); |
| 709 |
| 710 EXPECT_TRUE(file_util::CopyAndDeleteDirectory(dir_name_from, dir_name_to)); |
| 711 |
| 712 // Check everything has been moved. |
| 713 EXPECT_FALSE(file_util::PathExists(dir_name_from)); |
| 714 EXPECT_FALSE(file_util::PathExists(file_name_from)); |
| 715 EXPECT_TRUE(file_util::PathExists(dir_name_to)); |
| 716 EXPECT_TRUE(file_util::PathExists(file_name_to)); |
| 717 } |
688 #endif | 718 #endif |
689 | 719 |
690 TEST_F(FileUtilTest, CreateTemporaryFileNameTest) { | 720 TEST_F(FileUtilTest, CreateTemporaryFileNameTest) { |
691 std::wstring temp_files[3]; | 721 std::wstring temp_files[3]; |
692 for (int i = 0; i < 3; i++) { | 722 for (int i = 0; i < 3; i++) { |
693 ASSERT_TRUE(file_util::CreateTemporaryFileName(&(temp_files[i]))); | 723 ASSERT_TRUE(file_util::CreateTemporaryFileName(&(temp_files[i]))); |
694 EXPECT_TRUE(file_util::PathExists(temp_files[i])); | 724 EXPECT_TRUE(file_util::PathExists(temp_files[i])); |
695 EXPECT_FALSE(file_util::DirectoryExists(temp_files[i])); | 725 EXPECT_FALSE(file_util::DirectoryExists(temp_files[i])); |
696 } | 726 } |
697 for (int i = 0; i < 3; i++) | 727 for (int i = 0; i < 3; i++) |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 #elif defined(OS_LINUX) | 1086 #elif defined(OS_LINUX) |
1057 EXPECT_FALSE(file_util::ContainsPath(foo, | 1087 EXPECT_FALSE(file_util::ContainsPath(foo, |
1058 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); | 1088 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); |
1059 #else | 1089 #else |
1060 // We can't really do this test on osx since the case-sensitivity of the | 1090 // We can't really do this test on osx since the case-sensitivity of the |
1061 // filesystem is configurable. | 1091 // filesystem is configurable. |
1062 #endif | 1092 #endif |
1063 } | 1093 } |
1064 | 1094 |
1065 } // namespace | 1095 } // namespace |
OLD | NEW |