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/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/platform_file.h" | 7 #include "base/platform_file.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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 &created, | 94 &created, |
95 &error_code); | 95 &error_code); |
96 EXPECT_EQ(kInvalidPlatformFileValue, file); | 96 EXPECT_EQ(kInvalidPlatformFileValue, file); |
97 EXPECT_FALSE(created); | 97 EXPECT_FALSE(created); |
98 EXPECT_EQ(PLATFORM_FILE_ERROR_EXISTS, error_code); | 98 EXPECT_EQ(PLATFORM_FILE_ERROR_EXISTS, error_code); |
99 | 99 |
100 // Create or overwrite a file. | 100 // Create or overwrite a file. |
101 error_code = PLATFORM_FILE_OK; | 101 error_code = PLATFORM_FILE_OK; |
102 file = CreatePlatformFile( | 102 file = CreatePlatformFile( |
103 file_path, | 103 file_path, |
104 PLATFORM_FILE_CREATE_ALWAYS | PLATFORM_FILE_READ, | 104 PLATFORM_FILE_CREATE_ALWAYS | PLATFORM_FILE_WRITE, |
105 &created, | 105 &created, |
106 &error_code); | 106 &error_code); |
107 EXPECT_NE(kInvalidPlatformFileValue, file); | 107 EXPECT_NE(kInvalidPlatformFileValue, file); |
108 EXPECT_TRUE(created); | 108 EXPECT_TRUE(created); |
109 EXPECT_EQ(PLATFORM_FILE_OK, error_code); | 109 EXPECT_EQ(PLATFORM_FILE_OK, error_code); |
110 ClosePlatformFile(file); | 110 ClosePlatformFile(file); |
111 | 111 |
112 // Create a delete-on-close file. | 112 // Create a delete-on-close file. |
113 created = false; | 113 created = false; |
114 file_path = temp_dir.path().AppendASCII("create_file_2"); | 114 file_path = temp_dir.path().AppendASCII("create_file_2"); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 ReadPlatformFileAtCurrentPos( | 445 ReadPlatformFileAtCurrentPos( |
446 file, buffer + first_chunk_size, | 446 file, buffer + first_chunk_size, |
447 kDataSize - first_chunk_size)); | 447 kDataSize - first_chunk_size)); |
448 EXPECT_EQ(std::string(buffer, buffer + kDataSize), | 448 EXPECT_EQ(std::string(buffer, buffer + kDataSize), |
449 std::string(kData)); | 449 std::string(kData)); |
450 | 450 |
451 ClosePlatformFile(file); | 451 ClosePlatformFile(file); |
452 } | 452 } |
453 | 453 |
454 } // namespace base | 454 } // namespace base |
OLD | NEW |