| 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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 }; | 812 }; |
| 813 | 813 |
| 814 TEST_F(FileUtilTest, ReplaceExtensionTest) { | 814 TEST_F(FileUtilTest, ReplaceExtensionTest) { |
| 815 for (unsigned int i = 0; i < arraysize(kReplaceExtension); ++i) { | 815 for (unsigned int i = 0; i < arraysize(kReplaceExtension); ++i) { |
| 816 std::wstring file_name(kReplaceExtension[i].file_name); | 816 std::wstring file_name(kReplaceExtension[i].file_name); |
| 817 file_util::ReplaceExtension(&file_name, kReplaceExtension[i].extension); | 817 file_util::ReplaceExtension(&file_name, kReplaceExtension[i].extension); |
| 818 EXPECT_EQ(file_name, kReplaceExtension[i].result); | 818 EXPECT_EQ(file_name, kReplaceExtension[i].result); |
| 819 } | 819 } |
| 820 } | 820 } |
| 821 | 821 |
| 822 // Make sure ReplaceExtension doesn't replace an extension that occurs as one of |
| 823 // the directory names of the path. |
| 824 TEST_F(FileUtilTest, ReplaceExtensionTestWithPathSeparators) { |
| 825 std::wstring path; |
| 826 file_util::AppendToPath(&path, L"foo.bar"); |
| 827 file_util::AppendToPath(&path, L"foo"); |
| 828 // '/foo.bar/foo' with extension '.baz' |
| 829 std::wstring result_path = path; |
| 830 file_util::ReplaceExtension(&result_path, L".baz"); |
| 831 EXPECT_EQ(path + L".baz", result_path); |
| 832 } |
| 833 |
| 822 TEST_F(FileUtilTest, FileEnumeratorTest) { | 834 TEST_F(FileUtilTest, FileEnumeratorTest) { |
| 823 // Test an empty directory. | 835 // Test an empty directory. |
| 824 file_util::FileEnumerator f0(test_dir_, true, | 836 file_util::FileEnumerator f0(test_dir_, true, |
| 825 file_util::FileEnumerator::FILES_AND_DIRECTORIES); | 837 file_util::FileEnumerator::FILES_AND_DIRECTORIES); |
| 826 EXPECT_EQ(f0.Next(), L""); | 838 EXPECT_EQ(f0.Next(), L""); |
| 827 EXPECT_EQ(f0.Next(), L""); | 839 EXPECT_EQ(f0.Next(), L""); |
| 828 | 840 |
| 829 // create the directories | 841 // create the directories |
| 830 std::wstring dir1 = test_dir_; | 842 std::wstring dir1 = test_dir_; |
| 831 file_util::AppendToPath(&dir1, L"dir1"); | 843 file_util::AppendToPath(&dir1, L"dir1"); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 | 921 |
| 910 // Make sure the destructor closes the find handle while in the middle of a | 922 // Make sure the destructor closes the find handle while in the middle of a |
| 911 // query to allow TearDown to delete the directory. | 923 // query to allow TearDown to delete the directory. |
| 912 file_util::FileEnumerator f6(test_dir_, true, | 924 file_util::FileEnumerator f6(test_dir_, true, |
| 913 file_util::FileEnumerator::FILES_AND_DIRECTORIES); | 925 file_util::FileEnumerator::FILES_AND_DIRECTORIES); |
| 914 EXPECT_FALSE(f6.Next().empty()); // Should have found something | 926 EXPECT_FALSE(f6.Next().empty()); // Should have found something |
| 915 // (we don't care what). | 927 // (we don't care what). |
| 916 } | 928 } |
| 917 | 929 |
| 918 } // namespace | 930 } // namespace |
| OLD | NEW |