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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Create a file that exists. | 71 // Create a file that exists. |
72 File file(file_path, base::File::FLAG_CREATE | base::File::FLAG_READ); | 72 File file(file_path, base::File::FLAG_CREATE | base::File::FLAG_READ); |
73 EXPECT_FALSE(file.IsValid()); | 73 EXPECT_FALSE(file.IsValid()); |
74 EXPECT_FALSE(file.created()); | 74 EXPECT_FALSE(file.created()); |
75 EXPECT_EQ(base::File::FILE_ERROR_EXISTS, file.error_details()); | 75 EXPECT_EQ(base::File::FILE_ERROR_EXISTS, file.error_details()); |
76 } | 76 } |
77 | 77 |
78 { | 78 { |
79 // Create or overwrite a file. | 79 // Create or overwrite a file. |
80 File file(file_path, | 80 File file(file_path, |
81 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_READ); | 81 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
82 EXPECT_TRUE(file.IsValid()); | 82 EXPECT_TRUE(file.IsValid()); |
83 EXPECT_TRUE(file.created()); | 83 EXPECT_TRUE(file.created()); |
84 EXPECT_EQ(base::File::FILE_OK, file.error_details()); | 84 EXPECT_EQ(base::File::FILE_OK, file.error_details()); |
85 } | 85 } |
86 | 86 |
87 { | 87 { |
88 // Create a delete-on-close file. | 88 // Create a delete-on-close file. |
89 file_path = temp_dir.path().AppendASCII("create_file_2"); | 89 file_path = temp_dir.path().AppendASCII("create_file_2"); |
90 File file(file_path, | 90 File file(file_path, |
91 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ | | 91 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ | |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 NULL)); | 442 NULL)); |
443 ASSERT_TRUE(dir.IsValid()); | 443 ASSERT_TRUE(dir.IsValid()); |
444 | 444 |
445 base::File::Info info; | 445 base::File::Info info; |
446 EXPECT_TRUE(dir.GetInfo(&info)); | 446 EXPECT_TRUE(dir.GetInfo(&info)); |
447 EXPECT_TRUE(info.is_directory); | 447 EXPECT_TRUE(info.is_directory); |
448 EXPECT_FALSE(info.is_symbolic_link); | 448 EXPECT_FALSE(info.is_symbolic_link); |
449 EXPECT_EQ(0, info.size); | 449 EXPECT_EQ(0, info.size); |
450 } | 450 } |
451 #endif // defined(OS_WIN) | 451 #endif // defined(OS_WIN) |
OLD | NEW |