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.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file.h" | 6 #include "base/files/file.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 367 |
368 char buffer[kDataSize]; | 368 char buffer[kDataSize]; |
369 int first_chunk_size = kDataSize / 2; | 369 int first_chunk_size = kDataSize / 2; |
370 EXPECT_EQ(first_chunk_size, file.ReadAtCurrentPos(buffer, first_chunk_size)); | 370 EXPECT_EQ(first_chunk_size, file.ReadAtCurrentPos(buffer, first_chunk_size)); |
371 EXPECT_EQ(kDataSize - first_chunk_size, | 371 EXPECT_EQ(kDataSize - first_chunk_size, |
372 file.ReadAtCurrentPos(buffer + first_chunk_size, | 372 file.ReadAtCurrentPos(buffer + first_chunk_size, |
373 kDataSize - first_chunk_size)); | 373 kDataSize - first_chunk_size)); |
374 EXPECT_EQ(std::string(buffer, buffer + kDataSize), | 374 EXPECT_EQ(std::string(buffer, buffer + kDataSize), |
375 std::string(kData)); | 375 std::string(kData)); |
376 } | 376 } |
| 377 |
| 378 #if defined(OS_WIN) |
| 379 TEST(File, GetInfoForDirectory) { |
| 380 base::ScopedTempDir temp_dir; |
| 381 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 382 FilePath empty_dir = temp_dir.path().Append(FILE_PATH_LITERAL("gpfi_test")); |
| 383 ASSERT_TRUE(CreateDirectory(empty_dir)); |
| 384 |
| 385 base::File dir( |
| 386 ::CreateFile(empty_dir.value().c_str(), |
| 387 FILE_ALL_ACCESS, |
| 388 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
| 389 NULL, |
| 390 OPEN_EXISTING, |
| 391 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. |
| 392 NULL)); |
| 393 ASSERT_TRUE(dir.IsValid()); |
| 394 |
| 395 base::File::Info info; |
| 396 EXPECT_TRUE(dir.GetInfo(&info)); |
| 397 EXPECT_TRUE(info.is_directory); |
| 398 EXPECT_FALSE(info.is_symbolic_link); |
| 399 EXPECT_EQ(0, info.size); |
| 400 } |
| 401 #endif // defined(OS_WIN) |
OLD | NEW |