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 "base/file_util_proxy.h" | 5 #include "base/file_util_proxy.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // On POSIX ASYNC flag does not affect synchronous read/write behavior. | 209 // On POSIX ASYNC flag does not affect synchronous read/write behavior. |
210 EXPECT_EQ(4, WritePlatformFile(file_, 0, "test", 4)); | 210 EXPECT_EQ(4, WritePlatformFile(file_, 0, "test", 4)); |
211 #endif | 211 #endif |
212 EXPECT_TRUE(ClosePlatformFile(file_)); | 212 EXPECT_TRUE(ClosePlatformFile(file_)); |
213 file_ = kInvalidPlatformFileValue; | 213 file_ = kInvalidPlatformFileValue; |
214 | 214 |
215 // Make sure the written data can be read from the returned path. | 215 // Make sure the written data can be read from the returned path. |
216 std::string data; | 216 std::string data; |
217 EXPECT_TRUE(file_util::ReadFileToString(path_, &data)); | 217 EXPECT_TRUE(file_util::ReadFileToString(path_, &data)); |
218 EXPECT_EQ("test", data); | 218 EXPECT_EQ("test", data); |
| 219 |
| 220 // Make sure we can & do delete the created file to prevent leaks on the bots. |
| 221 EXPECT_TRUE(file_util::Delete(path_, false)); |
219 } | 222 } |
220 | 223 |
221 TEST_F(FileUtilProxyTest, GetFileInfo_File) { | 224 TEST_F(FileUtilProxyTest, GetFileInfo_File) { |
222 // Setup. | 225 // Setup. |
223 ASSERT_EQ(4, file_util::WriteFile(test_path(), "test", 4)); | 226 ASSERT_EQ(4, file_util::WriteFile(test_path(), "test", 4)); |
224 PlatformFileInfo expected_info; | 227 PlatformFileInfo expected_info; |
225 file_util::GetFileInfo(test_path(), &expected_info); | 228 file_util::GetFileInfo(test_path(), &expected_info); |
226 | 229 |
227 // Run. | 230 // Run. |
228 FileUtilProxy::GetFileInfo( | 231 FileUtilProxy::GetFileInfo( |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 char buffer[53]; | 401 char buffer[53]; |
399 EXPECT_EQ(53, file_util::ReadFile(test_path(), buffer, 53)); | 402 EXPECT_EQ(53, file_util::ReadFile(test_path(), buffer, 53)); |
400 int i = 0; | 403 int i = 0; |
401 for (; i < 10; ++i) | 404 for (; i < 10; ++i) |
402 EXPECT_EQ(kTestData[i], buffer[i]); | 405 EXPECT_EQ(kTestData[i], buffer[i]); |
403 for (; i < 53; ++i) | 406 for (; i < 53; ++i) |
404 EXPECT_EQ(0, buffer[i]); | 407 EXPECT_EQ(0, buffer[i]); |
405 } | 408 } |
406 | 409 |
407 } // namespace base | 410 } // namespace base |
OLD | NEW |