| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/platform_file.h" | 6 #include "base/platform_file.h" |
| 7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Make sure the file was truncated. | 242 // Make sure the file was truncated. |
| 243 bytes_read = ReadFully(file, 0, data_read, kTestDataSize); | 243 bytes_read = ReadFully(file, 0, data_read, kTestDataSize); |
| 244 EXPECT_EQ(file_size, bytes_read); | 244 EXPECT_EQ(file_size, bytes_read); |
| 245 for (int i = 0; i < file_size; i++) | 245 for (int i = 0; i < file_size; i++) |
| 246 EXPECT_EQ(data_to_write[i], data_read[i]); | 246 EXPECT_EQ(data_to_write[i], data_read[i]); |
| 247 | 247 |
| 248 // Close the file handle to allow the temp directory to be deleted. | 248 // Close the file handle to allow the temp directory to be deleted. |
| 249 base::ClosePlatformFile(file); | 249 base::ClosePlatformFile(file); |
| 250 } | 250 } |
| 251 | 251 |
| 252 TEST(PlatformFile, TouchGetInfoPlatformFile) { | 252 #if defined(OS_MACOSX) |
| 253 // Flakily fails: http://crbug.com/86494 |
| 254 #define MAYBE_TouchGetInfoPlatformFile FLAKY_TouchGetInfoPlatformFile |
| 255 #else |
| 256 #define MAYBE_TouchGetInfoPlatformFile TouchGetInfoPlatformFile |
| 257 #endif |
| 258 TEST(PlatformFile, MAYBE_TouchGetInfoPlatformFile) { |
| 253 ScopedTempDir temp_dir; | 259 ScopedTempDir temp_dir; |
| 254 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 260 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 255 base::PlatformFile file = base::CreatePlatformFile( | 261 base::PlatformFile file = base::CreatePlatformFile( |
| 256 temp_dir.path().AppendASCII("touch_get_info_file"), | 262 temp_dir.path().AppendASCII("touch_get_info_file"), |
| 257 base::PLATFORM_FILE_CREATE | | 263 base::PLATFORM_FILE_CREATE | |
| 258 base::PLATFORM_FILE_WRITE | | 264 base::PLATFORM_FILE_WRITE | |
| 259 base::PLATFORM_FILE_WRITE_ATTRIBUTES, | 265 base::PLATFORM_FILE_WRITE_ATTRIBUTES, |
| 260 NULL, NULL); | 266 NULL, NULL); |
| 261 EXPECT_NE(base::kInvalidPlatformFileValue, file); | 267 EXPECT_NE(base::kInvalidPlatformFileValue, file); |
| 262 | 268 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 EXPECT_EQ(info.last_modified.ToInternalValue(), | 317 EXPECT_EQ(info.last_modified.ToInternalValue(), |
| 312 new_last_modified.ToInternalValue()); | 318 new_last_modified.ToInternalValue()); |
| 313 #endif | 319 #endif |
| 314 | 320 |
| 315 EXPECT_EQ(info.creation_time.ToInternalValue(), | 321 EXPECT_EQ(info.creation_time.ToInternalValue(), |
| 316 creation_time.ToInternalValue()); | 322 creation_time.ToInternalValue()); |
| 317 | 323 |
| 318 // Close the file handle to allow the temp directory to be deleted. | 324 // Close the file handle to allow the temp directory to be deleted. |
| 319 base::ClosePlatformFile(file); | 325 base::ClosePlatformFile(file); |
| 320 } | 326 } |
| OLD | NEW |