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 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 EXPECT_FALSE(names[i] == names[(i+1)%3]); | 1678 EXPECT_FALSE(names[i] == names[(i+1)%3]); |
1679 } | 1679 } |
1680 | 1680 |
1681 // Close and delete. | 1681 // Close and delete. |
1682 for (i = 0; i < 3; ++i) { | 1682 for (i = 0; i < 3; ++i) { |
1683 EXPECT_TRUE(CloseFile(fps[i])); | 1683 EXPECT_TRUE(CloseFile(fps[i])); |
1684 EXPECT_TRUE(DeleteFile(names[i], false)); | 1684 EXPECT_TRUE(DeleteFile(names[i], false)); |
1685 } | 1685 } |
1686 } | 1686 } |
1687 | 1687 |
| 1688 TEST_F(FileUtilTest, FileToFILE) { |
| 1689 File file; |
| 1690 FILE* stream = FileToFILE(file.Pass(), "w"); |
| 1691 EXPECT_FALSE(stream); |
| 1692 |
| 1693 FilePath file_name = temp_dir_.path().Append(FPL("The file.txt")); |
| 1694 file = File(file_name, File::FLAG_CREATE | File::FLAG_WRITE); |
| 1695 EXPECT_TRUE(file.IsValid()); |
| 1696 |
| 1697 stream = FileToFILE(file.Pass(), "w"); |
| 1698 EXPECT_TRUE(stream); |
| 1699 EXPECT_FALSE(file.IsValid()); |
| 1700 EXPECT_TRUE(CloseFile(stream)); |
| 1701 } |
| 1702 |
1688 TEST_F(FileUtilTest, CreateNewTempDirectoryTest) { | 1703 TEST_F(FileUtilTest, CreateNewTempDirectoryTest) { |
1689 FilePath temp_dir; | 1704 FilePath temp_dir; |
1690 ASSERT_TRUE(CreateNewTempDirectory(FilePath::StringType(), &temp_dir)); | 1705 ASSERT_TRUE(CreateNewTempDirectory(FilePath::StringType(), &temp_dir)); |
1691 EXPECT_TRUE(PathExists(temp_dir)); | 1706 EXPECT_TRUE(PathExists(temp_dir)); |
1692 EXPECT_TRUE(DeleteFile(temp_dir, false)); | 1707 EXPECT_TRUE(DeleteFile(temp_dir, false)); |
1693 } | 1708 } |
1694 | 1709 |
1695 TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { | 1710 TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { |
1696 FilePath new_dir; | 1711 FilePath new_dir; |
1697 ASSERT_TRUE(CreateTemporaryDirInDir( | 1712 ASSERT_TRUE(CreateTemporaryDirInDir( |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 // Trying to close it should crash. This is important for security. | 2587 // Trying to close it should crash. This is important for security. |
2573 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); | 2588 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); |
2574 #endif | 2589 #endif |
2575 } | 2590 } |
2576 | 2591 |
2577 #endif // defined(OS_POSIX) | 2592 #endif // defined(OS_POSIX) |
2578 | 2593 |
2579 } // namespace | 2594 } // namespace |
2580 | 2595 |
2581 } // namespace base | 2596 } // namespace base |
OLD | NEW |