OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 Pathname path; | 63 Pathname path; |
64 EXPECT_TRUE(Filesystem::GetTemporaryFolder(path, true, NULL)); | 64 EXPECT_TRUE(Filesystem::GetTemporaryFolder(path, true, NULL)); |
65 path.SetFilename("not an actual file"); | 65 path.SetFilename("not an actual file"); |
66 | 66 |
67 EXPECT_FALSE(Filesystem::IsFile(path)); | 67 EXPECT_FALSE(Filesystem::IsFile(path)); |
68 | 68 |
69 FileStream* fs = Filesystem::OpenFile(path, "rb"); | 69 FileStream* fs = Filesystem::OpenFile(path, "rb"); |
70 EXPECT_FALSE(fs != NULL); | 70 EXPECT_FALSE(fs != NULL); |
71 } | 71 } |
72 | 72 |
73 // Test that CreatePrivateFile fails for existing files and succeeds for | |
74 // non-existent ones. | |
75 TEST(MAYBE_FilesystemTest, TestCreatePrivateFile) { | |
76 Pathname path; | |
77 EXPECT_TRUE(Filesystem::GetTemporaryFolder(path, true, NULL)); | |
78 path.SetFilename("private_file_test"); | |
79 | |
80 // First call should succeed because the file doesn't exist yet. | |
81 EXPECT_TRUE(Filesystem::CreatePrivateFile(path)); | |
82 // Next call should fail, because now it exists. | |
83 EXPECT_FALSE(Filesystem::CreatePrivateFile(path)); | |
84 | |
85 // Verify that we have permission to open the file for reading and writing. | |
86 std::unique_ptr<FileStream> fs(Filesystem::OpenFile(path, "wb")); | |
87 EXPECT_TRUE(fs.get() != NULL); | |
88 // Have to close the file on Windows before it will let us delete it. | |
89 fs.reset(); | |
90 | |
91 // Verify that we have permission to delete the file. | |
92 EXPECT_TRUE(Filesystem::DeleteFile(path)); | |
93 } | |
94 | |
95 // Test checking for free disk space. | 73 // Test checking for free disk space. |
96 TEST(MAYBE_FilesystemTest, TestGetDiskFreeSpace) { | 74 TEST(MAYBE_FilesystemTest, TestGetDiskFreeSpace) { |
97 // Note that we should avoid picking any file/folder which could be located | 75 // Note that we should avoid picking any file/folder which could be located |
98 // at the remotely mounted drive/device. | 76 // at the remotely mounted drive/device. |
99 Pathname path; | 77 Pathname path; |
100 ASSERT_TRUE(Filesystem::GetAppDataFolder(&path, true)); | 78 ASSERT_TRUE(Filesystem::GetAppDataFolder(&path, true)); |
101 | 79 |
102 int64_t free1 = 0; | 80 int64_t free1 = 0; |
103 EXPECT_TRUE(Filesystem::IsFolder(path)); | 81 EXPECT_TRUE(Filesystem::IsFolder(path)); |
104 EXPECT_FALSE(Filesystem::IsFile(path)); | 82 EXPECT_FALSE(Filesystem::IsFile(path)); |
(...skipping 13 matching lines...) Expand all Loading... |
118 int64_t free3 = 0; | 96 int64_t free3 = 0; |
119 path.clear(); | 97 path.clear(); |
120 EXPECT_TRUE(path.empty()); | 98 EXPECT_TRUE(path.empty()); |
121 EXPECT_TRUE(Filesystem::GetDiskFreeSpace(path, &free3)); | 99 EXPECT_TRUE(Filesystem::GetDiskFreeSpace(path, &free3)); |
122 // Current working directory may not be where exe is. | 100 // Current working directory may not be where exe is. |
123 // EXPECT_LT(static_cast<int64_t>(free1 * .9), free3); | 101 // EXPECT_LT(static_cast<int64_t>(free1 * .9), free3); |
124 // EXPECT_LT(free3, static_cast<int64_t>(free1 * 1.1)); | 102 // EXPECT_LT(free3, static_cast<int64_t>(free1 * 1.1)); |
125 EXPECT_GT(free3, 0); | 103 EXPECT_GT(free3, 0); |
126 } | 104 } |
127 | 105 |
128 // Tests that GetCurrentDirectory() returns something. | |
129 TEST(MAYBE_FilesystemTest, TestGetCurrentDirectory) { | |
130 EXPECT_FALSE(Filesystem::GetCurrentDirectory().empty()); | |
131 } | |
132 | |
133 // Tests that GetAppPathname returns something. | |
134 TEST(MAYBE_FilesystemTest, TestGetAppPathname) { | |
135 Pathname path; | |
136 EXPECT_TRUE(Filesystem::GetAppPathname(&path)); | |
137 EXPECT_FALSE(path.empty()); | |
138 } | |
139 | |
140 } // namespace rtc | 106 } // namespace rtc |
OLD | NEW |