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

Side by Side Diff: content/browser/fileapi/file_system_operation_impl_unittest.cc

Issue 105293002: Move more file_util functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webkit/browser/fileapi/file_system_operation_impl.h" 5 #include "webkit/browser/fileapi/file_system_operation_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 FileSystemURL CreateDirectory(const std::string& path) { 152 FileSystemURL CreateDirectory(const std::string& path) {
153 FileSystemURL url = URLForPath(path); 153 FileSystemURL url = URLForPath(path);
154 EXPECT_EQ(base::PLATFORM_FILE_OK, 154 EXPECT_EQ(base::PLATFORM_FILE_OK,
155 file_util()->CreateDirectory(NewContext().get(), url, 155 file_util()->CreateDirectory(NewContext().get(), url,
156 false /* exclusive */, true)); 156 false /* exclusive */, true));
157 return url; 157 return url;
158 } 158 }
159 159
160 int64 GetFileSize(const std::string& path) { 160 int64 GetFileSize(const std::string& path) {
161 base::PlatformFileInfo info; 161 base::PlatformFileInfo info;
162 EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(path), &info)); 162 EXPECT_TRUE(base::GetFileInfo(PlatformPath(path), &info));
163 return info.size; 163 return info.size;
164 } 164 }
165 165
166 // Callbacks for recording test results. 166 // Callbacks for recording test results.
167 FileSystemOperation::StatusCallback RecordStatusCallback() { 167 FileSystemOperation::StatusCallback RecordStatusCallback() {
168 return base::Bind(&FileSystemOperationImplTest::DidFinish, 168 return base::Bind(&FileSystemOperationImplTest::DidFinish,
169 weak_factory_.GetWeakPtr()); 169 weak_factory_.GetWeakPtr());
170 } 170 }
171 171
172 FileSystemOperation::ReadDirectoryCallback 172 FileSystemOperation::ReadDirectoryCallback
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 EXPECT_TRUE(change_observer()->HasNoChange()); 1058 EXPECT_TRUE(change_observer()->HasNoChange());
1059 1059
1060 EXPECT_EQ(10, GetFileSize("dir/file")); 1060 EXPECT_EQ(10, GetFileSize("dir/file"));
1061 } 1061 }
1062 1062
1063 TEST_F(FileSystemOperationImplTest, TestTouchFile) { 1063 TEST_F(FileSystemOperationImplTest, TestTouchFile) {
1064 FileSystemURL file(CreateFile("file")); 1064 FileSystemURL file(CreateFile("file"));
1065 base::FilePath platform_path = PlatformPath("file"); 1065 base::FilePath platform_path = PlatformPath("file");
1066 1066
1067 base::PlatformFileInfo info; 1067 base::PlatformFileInfo info;
1068 EXPECT_TRUE(file_util::GetFileInfo(platform_path, &info)); 1068 EXPECT_TRUE(base::GetFileInfo(platform_path, &info));
1069 EXPECT_FALSE(info.is_directory); 1069 EXPECT_FALSE(info.is_directory);
1070 EXPECT_EQ(0, info.size); 1070 EXPECT_EQ(0, info.size);
1071 const base::Time last_modified = info.last_modified; 1071 const base::Time last_modified = info.last_modified;
1072 const base::Time last_accessed = info.last_accessed; 1072 const base::Time last_accessed = info.last_accessed;
1073 1073
1074 const base::Time new_modified_time = base::Time::UnixEpoch(); 1074 const base::Time new_modified_time = base::Time::UnixEpoch();
1075 const base::Time new_accessed_time = new_modified_time + 1075 const base::Time new_accessed_time = new_modified_time +
1076 base::TimeDelta::FromHours(77); 1076 base::TimeDelta::FromHours(77);
1077 ASSERT_NE(last_modified, new_modified_time); 1077 ASSERT_NE(last_modified, new_modified_time);
1078 ASSERT_NE(last_accessed, new_accessed_time); 1078 ASSERT_NE(last_accessed, new_accessed_time);
1079 1079
1080 operation_runner()->TouchFile(file, new_accessed_time, new_modified_time, 1080 operation_runner()->TouchFile(file, new_accessed_time, new_modified_time,
1081 RecordStatusCallback()); 1081 RecordStatusCallback());
1082 base::RunLoop().RunUntilIdle(); 1082 base::RunLoop().RunUntilIdle();
1083 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); 1083 EXPECT_EQ(base::PLATFORM_FILE_OK, status());
1084 EXPECT_TRUE(change_observer()->HasNoChange()); 1084 EXPECT_TRUE(change_observer()->HasNoChange());
1085 1085
1086 EXPECT_TRUE(file_util::GetFileInfo(platform_path, &info)); 1086 EXPECT_TRUE(base::GetFileInfo(platform_path, &info));
1087 // We compare as time_t here to lower our resolution, to avoid false 1087 // We compare as time_t here to lower our resolution, to avoid false
1088 // negatives caused by conversion to the local filesystem's native 1088 // negatives caused by conversion to the local filesystem's native
1089 // representation and back. 1089 // representation and back.
1090 EXPECT_EQ(new_modified_time.ToTimeT(), info.last_modified.ToTimeT()); 1090 EXPECT_EQ(new_modified_time.ToTimeT(), info.last_modified.ToTimeT());
1091 EXPECT_EQ(new_accessed_time.ToTimeT(), info.last_accessed.ToTimeT()); 1091 EXPECT_EQ(new_accessed_time.ToTimeT(), info.last_accessed.ToTimeT());
1092 } 1092 }
1093 1093
1094 TEST_F(FileSystemOperationImplTest, TestCreateSnapshotFile) { 1094 TEST_F(FileSystemOperationImplTest, TestCreateSnapshotFile) {
1095 FileSystemURL dir(CreateDirectory("dir")); 1095 FileSystemURL dir(CreateDirectory("dir"));
1096 1096
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 base::RunLoop().RunUntilIdle(); 1232 base::RunLoop().RunUntilIdle();
1233 1233
1234 expected_usage += grandchild_file_size + grandchild_path_cost; 1234 expected_usage += grandchild_file_size + grandchild_path_cost;
1235 usage = GetUsage(); 1235 usage = GetUsage();
1236 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, 1236 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size,
1237 GetDataSizeOnDisk()); 1237 GetDataSizeOnDisk());
1238 EXPECT_EQ(expected_usage, usage); 1238 EXPECT_EQ(expected_usage, usage);
1239 } 1239 }
1240 1240
1241 } // namespace fileapi 1241 } // namespace fileapi
OLDNEW
« no previous file with comments | « content/browser/fileapi/dragged_file_util_unittest.cc ('k') | content/browser/fileapi/local_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698