OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_proxy.h" | 5 #include "base/files/file_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 ThreadRestrictions::SetIOAllowed(prev); | 153 ThreadRestrictions::SetIOAllowed(prev); |
154 | 154 |
155 EXPECT_TRUE(PathExists(test_path())); | 155 EXPECT_TRUE(PathExists(test_path())); |
156 } | 156 } |
157 | 157 |
158 TEST_F(FileProxyTest, Close) { | 158 TEST_F(FileProxyTest, Close) { |
159 // Creates a file. | 159 // Creates a file. |
160 FileProxy proxy(file_task_runner()); | 160 FileProxy proxy(file_task_runner()); |
161 CreateProxy(File::FLAG_CREATE | File::FLAG_WRITE, &proxy); | 161 CreateProxy(File::FLAG_CREATE | File::FLAG_WRITE, &proxy); |
162 | 162 |
163 #if defined(OS_WIN) | |
164 // This fails on Windows if the file is not closed. | |
165 EXPECT_FALSE(base::Move(test_path(), test_dir_path().AppendASCII("new"))); | |
166 #endif | |
167 | |
168 proxy.Close(Bind(&FileProxyTest::DidFinish, weak_factory_.GetWeakPtr())); | 163 proxy.Close(Bind(&FileProxyTest::DidFinish, weak_factory_.GetWeakPtr())); |
169 MessageLoop::current()->Run(); | 164 MessageLoop::current()->Run(); |
170 EXPECT_EQ(File::FILE_OK, error_); | 165 EXPECT_EQ(File::FILE_OK, error_); |
171 EXPECT_FALSE(proxy.IsValid()); | 166 EXPECT_FALSE(proxy.IsValid()); |
172 | 167 |
173 // Now it should pass on all platforms. | 168 // Now it should pass on all platforms. |
174 EXPECT_TRUE(base::Move(test_path(), test_dir_path().AppendASCII("new"))); | 169 EXPECT_TRUE(base::Move(test_path(), test_dir_path().AppendASCII("new"))); |
175 } | 170 } |
176 | 171 |
177 TEST_F(FileProxyTest, CreateTemporary) { | 172 TEST_F(FileProxyTest, CreateTemporary) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 char buffer[53]; | 355 char buffer[53]; |
361 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); | 356 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); |
362 int i = 0; | 357 int i = 0; |
363 for (; i < 10; ++i) | 358 for (; i < 10; ++i) |
364 EXPECT_EQ(kTestData[i], buffer[i]); | 359 EXPECT_EQ(kTestData[i], buffer[i]); |
365 for (; i < 53; ++i) | 360 for (; i < 53; ++i) |
366 EXPECT_EQ(0, buffer[i]); | 361 EXPECT_EQ(0, buffer[i]); |
367 } | 362 } |
368 | 363 |
369 } // namespace base | 364 } // namespace base |
OLD | NEW |