| 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 result = shell->SetDescription(L"ResolveShortcutTest"); | 705 result = shell->SetDescription(L"ResolveShortcutTest"); |
| 706 EXPECT_TRUE(SUCCEEDED(result)); | 706 EXPECT_TRUE(SUCCEEDED(result)); |
| 707 result = persist->Save(link_file.value().c_str(), TRUE); | 707 result = persist->Save(link_file.value().c_str(), TRUE); |
| 708 EXPECT_TRUE(SUCCEEDED(result)); | 708 EXPECT_TRUE(SUCCEEDED(result)); |
| 709 if (persist) | 709 if (persist) |
| 710 persist->Release(); | 710 persist->Release(); |
| 711 if (shell) | 711 if (shell) |
| 712 shell->Release(); | 712 shell->Release(); |
| 713 | 713 |
| 714 bool is_solved; | 714 bool is_solved; |
| 715 std::wstring link_file_str = link_file.value(); | 715 is_solved = file_util::ResolveShortcut(&link_file); |
| 716 is_solved = file_util::ResolveShortcut(&link_file_str); | |
| 717 EXPECT_TRUE(is_solved); | 716 EXPECT_TRUE(is_solved); |
| 718 std::wstring contents; | 717 std::wstring contents; |
| 719 contents = ReadTextFile(FilePath(link_file_str)); | 718 contents = ReadTextFile(link_file); |
| 720 EXPECT_EQ(L"This is the target.", contents); | 719 EXPECT_EQ(L"This is the target.", contents); |
| 721 | 720 |
| 722 // Cleaning | 721 // Cleaning |
| 723 DeleteFile(target_file.value().c_str()); | 722 DeleteFile(target_file.value().c_str()); |
| 724 DeleteFile(link_file_str.c_str()); | 723 DeleteFile(link_file.value().c_str()); |
| 725 CoUninitialize(); | 724 CoUninitialize(); |
| 726 } | 725 } |
| 727 | 726 |
| 728 TEST_F(FileUtilTest, CreateShortcutTest) { | 727 TEST_F(FileUtilTest, CreateShortcutTest) { |
| 729 const wchar_t file_contents[] = L"This is another target."; | 728 const wchar_t file_contents[] = L"This is another target."; |
| 730 FilePath target_file = test_dir_.Append(L"Target1.txt"); | 729 FilePath target_file = test_dir_.Append(L"Target1.txt"); |
| 731 CreateTextFile(target_file, file_contents); | 730 CreateTextFile(target_file, file_contents); |
| 732 | 731 |
| 733 FilePath link_file = test_dir_.Append(L"Link1.lnk"); | 732 FilePath link_file = test_dir_.Append(L"Link1.lnk"); |
| 734 | 733 |
| 735 CoInitialize(NULL); | 734 CoInitialize(NULL); |
| 736 EXPECT_TRUE(file_util::CreateShortcutLink(target_file.value().c_str(), | 735 EXPECT_TRUE(file_util::CreateShortcutLink(target_file.value().c_str(), |
| 737 link_file.value().c_str(), | 736 link_file.value().c_str(), |
| 738 NULL, NULL, NULL, NULL, 0)); | 737 NULL, NULL, NULL, NULL, 0)); |
| 739 std::wstring resolved_name = link_file.value(); | 738 FilePath resolved_name = link_file; |
| 740 EXPECT_TRUE(file_util::ResolveShortcut(&resolved_name)); | 739 EXPECT_TRUE(file_util::ResolveShortcut(&resolved_name)); |
| 741 std::wstring read_contents = ReadTextFile(FilePath(resolved_name)); | 740 std::wstring read_contents = ReadTextFile(resolved_name); |
| 742 EXPECT_EQ(file_contents, read_contents); | 741 EXPECT_EQ(file_contents, read_contents); |
| 743 | 742 |
| 744 DeleteFile(target_file.value().c_str()); | 743 DeleteFile(target_file.value().c_str()); |
| 745 DeleteFile(link_file.value().c_str()); | 744 DeleteFile(link_file.value().c_str()); |
| 746 CoUninitialize(); | 745 CoUninitialize(); |
| 747 } | 746 } |
| 748 | 747 |
| 749 TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) { | 748 TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) { |
| 750 // Create a directory | 749 // Create a directory |
| 751 FilePath dir_name_from = | 750 FilePath dir_name_from = |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 #elif defined(OS_LINUX) | 1158 #elif defined(OS_LINUX) |
| 1160 EXPECT_FALSE(file_util::ContainsPath(foo, | 1159 EXPECT_FALSE(file_util::ContainsPath(foo, |
| 1161 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); | 1160 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); |
| 1162 #else | 1161 #else |
| 1163 // We can't really do this test on osx since the case-sensitivity of the | 1162 // We can't really do this test on osx since the case-sensitivity of the |
| 1164 // filesystem is configurable. | 1163 // filesystem is configurable. |
| 1165 #endif | 1164 #endif |
| 1166 } | 1165 } |
| 1167 | 1166 |
| 1168 } // namespace | 1167 } // namespace |
| OLD | NEW |