Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: base/files/file_util_proxy_unittest.cc

Issue 15078003: Cleanup: Remove unneeded base/file_util.h includes in base. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/files/file_util_proxy.h ('k') | base/i18n/icu_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file_util_proxy.h" 5 #include "base/files/file_util_proxy.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "base/platform_file.h" 15 #include "base/platform_file.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace base { 19 namespace base {
19 20
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 FileUtilProxy::CreateTemporary( 188 FileUtilProxy::CreateTemporary(
188 file_task_runner(), 0 /* additional_file_flags */, 189 file_task_runner(), 0 /* additional_file_flags */,
189 Bind(&FileUtilProxyTest::DidCreateTemporary, weak_factory_.GetWeakPtr())); 190 Bind(&FileUtilProxyTest::DidCreateTemporary, weak_factory_.GetWeakPtr()));
190 MessageLoop::current()->Run(); 191 MessageLoop::current()->Run();
191 EXPECT_EQ(PLATFORM_FILE_OK, error_); 192 EXPECT_EQ(PLATFORM_FILE_OK, error_);
192 EXPECT_TRUE(file_util::PathExists(path_)); 193 EXPECT_TRUE(file_util::PathExists(path_));
193 EXPECT_NE(kInvalidPlatformFileValue, file_); 194 EXPECT_NE(kInvalidPlatformFileValue, file_);
194 195
195 // The file should be writable. 196 // The file should be writable.
196 #if defined(OS_WIN) 197 #if defined(OS_WIN)
197 HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); 198 HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
198 OVERLAPPED overlapped = {0}; 199 OVERLAPPED overlapped = {0};
199 overlapped.hEvent = hEvent; 200 overlapped.hEvent = hEvent;
200 DWORD bytes_written; 201 DWORD bytes_written;
201 if (!::WriteFile(file_, "test", 4, &bytes_written, &overlapped)) { 202 if (!::WriteFile(file_, "test", 4, &bytes_written, &overlapped)) {
202 // Temporary file is created with ASYNC flag, so WriteFile may return 0 203 // Temporary file is created with ASYNC flag, so WriteFile may return 0
203 // with ERROR_IO_PENDING. 204 // with ERROR_IO_PENDING.
204 EXPECT_EQ(ERROR_IO_PENDING, GetLastError()); 205 EXPECT_EQ(ERROR_IO_PENDING, GetLastError());
205 GetOverlappedResult(file_, &overlapped, &bytes_written, TRUE); 206 GetOverlappedResult(file_, &overlapped, &bytes_written, TRUE);
206 } 207 }
207 EXPECT_EQ(4, bytes_written); 208 EXPECT_EQ(4, bytes_written);
208 #else 209 #else
209 // On POSIX ASYNC flag does not affect synchronous read/write behavior. 210 // On POSIX ASYNC flag does not affect synchronous read/write behavior.
210 EXPECT_EQ(4, WritePlatformFile(file_, 0, "test", 4)); 211 EXPECT_EQ(4, WritePlatformFile(file_, 0, "test", 4));
211 #endif 212 #endif
212 EXPECT_TRUE(ClosePlatformFile(file_)); 213 EXPECT_TRUE(ClosePlatformFile(file_));
213 file_ = kInvalidPlatformFileValue; 214 file_ = kInvalidPlatformFileValue;
214 215
215 // Make sure the written data can be read from the returned path. 216 // Make sure the written data can be read from the returned path.
216 std::string data; 217 std::string data;
217 EXPECT_TRUE(file_util::ReadFileToString(path_, &data)); 218 EXPECT_TRUE(file_util::ReadFileToString(path_, &data));
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 char buffer[53]; 402 char buffer[53];
402 EXPECT_EQ(53, file_util::ReadFile(test_path(), buffer, 53)); 403 EXPECT_EQ(53, file_util::ReadFile(test_path(), buffer, 53));
403 int i = 0; 404 int i = 0;
404 for (; i < 10; ++i) 405 for (; i < 10; ++i)
405 EXPECT_EQ(kTestData[i], buffer[i]); 406 EXPECT_EQ(kTestData[i], buffer[i]);
406 for (; i < 53; ++i) 407 for (; i < 53; ++i)
407 EXPECT_EQ(0, buffer[i]); 408 EXPECT_EQ(0, buffer[i]);
408 } 409 }
409 410
410 } // namespace base 411 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_proxy.h ('k') | base/i18n/icu_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698