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

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

Issue 203873002: Base: Make file_util and file use the same code to translate from stat to File::Info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TODO Created 6 years, 8 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_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <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/file_util.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 CreateProxy(File::FLAG_OPEN | File::FLAG_READ, &proxy); 202 CreateProxy(File::FLAG_OPEN | File::FLAG_READ, &proxy);
203 proxy.GetInfo( 203 proxy.GetInfo(
204 Bind(&FileProxyTest::DidGetFileInfo, weak_factory_.GetWeakPtr())); 204 Bind(&FileProxyTest::DidGetFileInfo, weak_factory_.GetWeakPtr()));
205 MessageLoop::current()->Run(); 205 MessageLoop::current()->Run();
206 206
207 // Verify. 207 // Verify.
208 EXPECT_EQ(File::FILE_OK, error_); 208 EXPECT_EQ(File::FILE_OK, error_);
209 EXPECT_EQ(expected_info.size, file_info_.size); 209 EXPECT_EQ(expected_info.size, file_info_.size);
210 EXPECT_EQ(expected_info.is_directory, file_info_.is_directory); 210 EXPECT_EQ(expected_info.is_directory, file_info_.is_directory);
211 EXPECT_EQ(expected_info.is_symbolic_link, file_info_.is_symbolic_link); 211 EXPECT_EQ(expected_info.is_symbolic_link, file_info_.is_symbolic_link);
212
213 File file = proxy.TakeFile();
214 EXPECT_TRUE(file.GetInfo(&expected_info));
215 EXPECT_EQ(expected_info.last_modified, file_info_.last_modified); 212 EXPECT_EQ(expected_info.last_modified, file_info_.last_modified);
216 EXPECT_EQ(expected_info.creation_time, file_info_.creation_time); 213 EXPECT_EQ(expected_info.creation_time, file_info_.creation_time);
217 } 214 }
218 215
219 TEST_F(FileProxyTest, Read) { 216 TEST_F(FileProxyTest, Read) {
220 // Setup. 217 // Setup.
221 const char expected_data[] = "bleh"; 218 const char expected_data[] = "bleh";
222 int expected_bytes = arraysize(expected_data); 219 int expected_bytes = arraysize(expected_data);
223 ASSERT_EQ(expected_bytes, 220 ASSERT_EQ(expected_bytes,
224 base::WriteFile(test_path(), expected_data, expected_bytes)); 221 base::WriteFile(test_path(), expected_data, expected_bytes));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 char buffer[53]; 334 char buffer[53];
338 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); 335 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53));
339 int i = 0; 336 int i = 0;
340 for (; i < 10; ++i) 337 for (; i < 10; ++i)
341 EXPECT_EQ(kTestData[i], buffer[i]); 338 EXPECT_EQ(kTestData[i], buffer[i]);
342 for (; i < 53; ++i) 339 for (; i < 53; ++i)
343 EXPECT_EQ(0, buffer[i]); 340 EXPECT_EQ(0, buffer[i]);
344 } 341 }
345 342
346 } // namespace base 343 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698