| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 std::wstring ReadTextFile(const FilePath& filename) { | 237 std::wstring ReadTextFile(const FilePath& filename) { |
| 238 wchar_t contents[64]; | 238 wchar_t contents[64]; |
| 239 std::wifstream file; | 239 std::wifstream file; |
| 240 file.open(filename.value().c_str()); | 240 file.open(filename.value().c_str()); |
| 241 EXPECT_TRUE(file.is_open()); | 241 EXPECT_TRUE(file.is_open()); |
| 242 file.getline(contents, arraysize(contents)); | 242 file.getline(contents, arraysize(contents)); |
| 243 file.close(); | 243 file.close(); |
| 244 return std::wstring(contents); | 244 return std::wstring(contents); |
| 245 } | 245 } |
| 246 | 246 |
| 247 #if defined(OS_WIN) | |
| 248 uint64 FileTimeAsUint64(const FILETIME& ft) { | |
| 249 ULARGE_INTEGER u; | |
| 250 u.LowPart = ft.dwLowDateTime; | |
| 251 u.HighPart = ft.dwHighDateTime; | |
| 252 return u.QuadPart; | |
| 253 } | |
| 254 #endif | |
| 255 | |
| 256 TEST_F(FileUtilTest, FileAndDirectorySize) { | 247 TEST_F(FileUtilTest, FileAndDirectorySize) { |
| 257 // Create three files of 20, 30 and 3 chars (utf8). ComputeDirectorySize | 248 // Create three files of 20, 30 and 3 chars (utf8). ComputeDirectorySize |
| 258 // should return 53 bytes. | 249 // should return 53 bytes. |
| 259 FilePath file_01 = temp_dir_.path().Append(FPL("The file 01.txt")); | 250 FilePath file_01 = temp_dir_.path().Append(FPL("The file 01.txt")); |
| 260 CreateTextFile(file_01, L"12345678901234567890"); | 251 CreateTextFile(file_01, L"12345678901234567890"); |
| 261 int64 size_f1 = 0; | 252 int64 size_f1 = 0; |
| 262 ASSERT_TRUE(GetFileSize(file_01, &size_f1)); | 253 ASSERT_TRUE(GetFileSize(file_01, &size_f1)); |
| 263 EXPECT_EQ(20ll, size_f1); | 254 EXPECT_EQ(20ll, size_f1); |
| 264 | 255 |
| 265 FilePath subdir_path = temp_dir_.path().Append(FPL("Level2")); | 256 FilePath subdir_path = temp_dir_.path().Append(FPL("Level2")); |
| (...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2527 // Trying to close it should crash. This is important for security. | 2518 // Trying to close it should crash. This is important for security. |
| 2528 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); | 2519 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); |
| 2529 #endif | 2520 #endif |
| 2530 } | 2521 } |
| 2531 | 2522 |
| 2532 #endif // defined(OS_POSIX) | 2523 #endif // defined(OS_POSIX) |
| 2533 | 2524 |
| 2534 } // namespace | 2525 } // namespace |
| 2535 | 2526 |
| 2536 } // namespace base | 2527 } // namespace base |
| OLD | NEW |