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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10271026: gdata: Add GDataFileSystem::ReadDirectoryByPathAsync() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: polish Created 8 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
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 <errno.h> 5 #include <errno.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 GDataEntry* FindEntryByResourceId(const std::string& resource_id) { 271 GDataEntry* FindEntryByResourceId(const std::string& resource_id) {
272 ReadOnlyFindEntryDelegate search_delegate; 272 ReadOnlyFindEntryDelegate search_delegate;
273 file_system_->FindEntryByResourceIdSync(resource_id, 273 file_system_->FindEntryByResourceIdSync(resource_id,
274 &search_delegate); 274 &search_delegate);
275 return search_delegate.entry(); 275 return search_delegate.entry();
276 } 276 }
277 277
278 // Gets the file info for |file_path| and compares the contents against 278 // Gets the file info for |file_path| and compares the contents against
279 // |entry|. Returns true if the file info matches |entry|. 279 // |file|. Returns true if the file info matches |file|.
280 bool GetFileInfoAndCompare(const FilePath& file_path, 280 bool GetFileInfoAndCompare(const FilePath& file_path,
281 GDataEntry* entry) { 281 GDataFile* file) {
282 file_system_->GetFileInfoByPathAsync( 282 file_system_->GetFileInfoByPathAsync(
283 file_path, 283 file_path,
284 base::Bind(&CallbackHelper::GetFileInfoCallback, 284 base::Bind(&CallbackHelper::GetFileInfoCallback,
285 callback_helper_.get())); 285 callback_helper_.get()));
286 message_loop_.RunAllPending(); 286 message_loop_.RunAllPending();
287 287
288 if (entry == NULL) { 288 if (file == NULL) {
289 // File info is expected not to be found. 289 // File info is expected not to be found.
290 return callback_helper_->file_info_ == NULL; 290 return (callback_helper_->last_error_ ==
291 base::PLATFORM_FILE_ERROR_NOT_FOUND &&
292 callback_helper_->file_proto_ == NULL);
291 } 293 }
292 294
293 scoped_ptr<GDataFileProto> file_info = 295 if (callback_helper_->last_error_ != base::PLATFORM_FILE_OK)
294 callback_helper_->file_info_.Pass(); 296 return false;
295 return (entry->resource_id() == file_info->gdata_entry().resource_id()); 297
298 scoped_ptr<GDataFileProto> file_proto =
299 callback_helper_->file_proto_.Pass();
300 return (file->resource_id() == file_proto->gdata_entry().resource_id());
301 }
302
303 // Reads the directory at |file_path| and compares the contents against
304 // |directory|. Returns true if the file info matches |directory|.
305 bool ReadDirectoryAndCompare(const FilePath& file_path,
306 GDataDirectory* directory) {
307 file_system_->ReadDirectoryByPathAsync(
308 file_path,
309 base::Bind(&CallbackHelper::ReadDirectoryCallback,
310 callback_helper_.get()));
311 message_loop_.RunAllPending();
312
313 if (directory == NULL) {
314 // Directory is expected not to be found.
315 return (callback_helper_->last_error_ ==
316 base::PLATFORM_FILE_ERROR_NOT_FOUND &&
317 callback_helper_->directory_proto_ == NULL);
318 }
319
320 if (callback_helper_->last_error_ != base::PLATFORM_FILE_OK)
321 return false;
322
323 scoped_ptr<GDataDirectoryProto> directory_proto =
324 callback_helper_->directory_proto_.Pass();
325 return (directory->resource_id() ==
326 directory_proto->gdata_entry().resource_id());
296 } 327 }
297 328
298 FilePath GetCacheFilePath( 329 FilePath GetCacheFilePath(
299 const std::string& resource_id, 330 const std::string& resource_id,
300 const std::string& md5, 331 const std::string& md5,
301 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, 332 GDataRootDirectory::CacheSubDirectoryType sub_dir_type,
302 GDataFileSystem::CachedFileOrigin file_origin) { 333 GDataFileSystem::CachedFileOrigin file_origin) {
303 return file_system_->GetCacheFilePath(resource_id, md5, sub_dir_type, 334 return file_system_->GetCacheFilePath(resource_id, md5, sub_dir_type,
304 file_origin); 335 file_origin);
305 } 336 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 // This is used as a helper for registering callbacks that need to be 995 // This is used as a helper for registering callbacks that need to be
965 // RefCountedThreadSafe, and a place where we can fetch results from various 996 // RefCountedThreadSafe, and a place where we can fetch results from various
966 // operations. 997 // operations.
967 class CallbackHelper 998 class CallbackHelper
968 : public base::RefCountedThreadSafe<CallbackHelper> { 999 : public base::RefCountedThreadSafe<CallbackHelper> {
969 public: 1000 public:
970 CallbackHelper() 1001 CallbackHelper()
971 : last_error_(base::PLATFORM_FILE_OK), 1002 : last_error_(base::PLATFORM_FILE_OK),
972 quota_bytes_total_(0), 1003 quota_bytes_total_(0),
973 quota_bytes_used_(0), 1004 quota_bytes_used_(0),
974 file_info_(NULL) {} 1005 file_proto_(NULL) {}
975 virtual ~CallbackHelper() {} 1006 virtual ~CallbackHelper() {}
1007
976 virtual void GetFileCallback(base::PlatformFileError error, 1008 virtual void GetFileCallback(base::PlatformFileError error,
977 const FilePath& file_path, 1009 const FilePath& file_path,
978 const std::string& mime_type, 1010 const std::string& mime_type,
979 GDataFileType file_type) { 1011 GDataFileType file_type) {
980 last_error_ = error; 1012 last_error_ = error;
981 download_path_ = file_path; 1013 download_path_ = file_path;
982 mime_type_ = mime_type; 1014 mime_type_ = mime_type;
983 file_type_ = file_type; 1015 file_type_ = file_type;
984 } 1016 }
1017
985 virtual void FileOperationCallback(base::PlatformFileError error) { 1018 virtual void FileOperationCallback(base::PlatformFileError error) {
986 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 1019 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
987 1020
988 last_error_ = error; 1021 last_error_ = error;
989 } 1022 }
1023
990 virtual void GetAvailableSpaceCallback(base::PlatformFileError error, 1024 virtual void GetAvailableSpaceCallback(base::PlatformFileError error,
991 int64 bytes_total, 1025 int64 bytes_total,
992 int64 bytes_used) { 1026 int64 bytes_used) {
993 last_error_ = error; 1027 last_error_ = error;
994 quota_bytes_total_ = bytes_total; 1028 quota_bytes_total_ = bytes_total;
995 quota_bytes_used_ = bytes_used; 1029 quota_bytes_used_ = bytes_used;
996 } 1030 }
1031
997 virtual void GetFileInfoCallback( 1032 virtual void GetFileInfoCallback(
998 base::PlatformFileError error, 1033 base::PlatformFileError error,
999 scoped_ptr<GDataFileProto> file_info) { 1034 scoped_ptr<GDataFileProto> file_proto) {
1000 last_error_ = error; 1035 last_error_ = error;
1001 file_info_ = file_info.Pass(); 1036 file_proto_ = file_proto.Pass();
1037 }
1038
1039 virtual void ReadDirectoryCallback(
1040 base::PlatformFileError error,
1041 scoped_ptr<GDataDirectoryProto> directory_proto) {
1042 last_error_ = error;
1043 directory_proto_ = directory_proto.Pass();
1002 } 1044 }
1003 1045
1004 base::PlatformFileError last_error_; 1046 base::PlatformFileError last_error_;
1005 FilePath download_path_; 1047 FilePath download_path_;
1006 std::string mime_type_; 1048 std::string mime_type_;
1007 GDataFileType file_type_; 1049 GDataFileType file_type_;
1008 int64 quota_bytes_total_; 1050 int64 quota_bytes_total_;
1009 int64 quota_bytes_used_; 1051 int64 quota_bytes_used_;
1010 scoped_ptr<GDataFileProto> file_info_; 1052 scoped_ptr<GDataFileProto> file_proto_;
1053 scoped_ptr<GDataDirectoryProto> directory_proto_;
1011 }; 1054 };
1012 1055
1013 MessageLoopForUI message_loop_; 1056 MessageLoopForUI message_loop_;
1014 // The order of the test threads is important, do not change the order. 1057 // The order of the test threads is important, do not change the order.
1015 // See also content/browser/browser_thread_imple.cc. 1058 // See also content/browser/browser_thread_imple.cc.
1016 content::TestBrowserThread ui_thread_; 1059 content::TestBrowserThread ui_thread_;
1017 content::TestBrowserThread io_thread_; 1060 content::TestBrowserThread io_thread_;
1018 scoped_ptr<TestingProfile> profile_; 1061 scoped_ptr<TestingProfile> profile_;
1019 scoped_refptr<CallbackHelper> callback_helper_; 1062 scoped_refptr<CallbackHelper> callback_helper_;
1020 GDataFileSystem* file_system_; 1063 GDataFileSystem* file_system_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1106
1064 file_system_->FindEntryByPathAsync( 1107 file_system_->FindEntryByPathAsync(
1065 FilePath(FILE_PATH_LITERAL("gdata")), callback); 1108 FilePath(FILE_PATH_LITERAL("gdata")), callback);
1066 file_system_->FindEntryByPathAsync( 1109 file_system_->FindEntryByPathAsync(
1067 FilePath(FILE_PATH_LITERAL("gdata")), callback); 1110 FilePath(FILE_PATH_LITERAL("gdata")), callback);
1068 message_loop_.Run(); // Wait to get our result 1111 message_loop_.Run(); // Wait to get our result
1069 EXPECT_EQ(2, counter); 1112 EXPECT_EQ(2, counter);
1070 } 1113 }
1071 1114
1072 TEST_F(GDataFileSystemTest, SearchRootDirectory) { 1115 TEST_F(GDataFileSystemTest, SearchRootDirectory) {
1116 LoadRootFeedDocument("root_feed.json");
1117
1073 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("gdata")); 1118 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("gdata"));
1074 GDataEntry* entry = FindEntry(FilePath(FILE_PATH_LITERAL(kFilePath))); 1119 GDataEntry* entry = FindEntry(FilePath(FILE_PATH_LITERAL(kFilePath)));
1075 ASSERT_TRUE(entry); 1120 ASSERT_TRUE(entry);
1076 EXPECT_EQ(kFilePath, entry->GetFilePath()); 1121 EXPECT_EQ(kFilePath, entry->GetFilePath());
1122 EXPECT_TRUE(ReadDirectoryAndCompare(kFilePath, entry->AsGDataDirectory()));
1077 } 1123 }
1078 1124
1079 TEST_F(GDataFileSystemTest, SearchExistingFile) { 1125 TEST_F(GDataFileSystemTest, SearchExistingFile) {
1080 LoadRootFeedDocument("root_feed.json"); 1126 LoadRootFeedDocument("root_feed.json");
1081 1127
1082 const FilePath kFilePath = FilePath( 1128 const FilePath kFilePath = FilePath(
1083 FILE_PATH_LITERAL("gdata/File 1.txt")); 1129 FILE_PATH_LITERAL("gdata/File 1.txt"));
1084 GDataEntry* entry = FindEntry(kFilePath); 1130 GDataEntry* entry = FindEntry(kFilePath);
1085 ASSERT_TRUE(entry); 1131 ASSERT_TRUE(entry);
1086 EXPECT_EQ(kFilePath, entry->GetFilePath()); 1132 EXPECT_EQ(kFilePath, entry->GetFilePath());
1087 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, entry)); 1133 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, entry->AsGDataFile()));
1088 } 1134 }
1089 1135
1090 TEST_F(GDataFileSystemTest, SearchExistingDocument) { 1136 TEST_F(GDataFileSystemTest, SearchExistingDocument) {
1091 LoadRootFeedDocument("root_feed.json"); 1137 LoadRootFeedDocument("root_feed.json");
1092 1138
1093 const FilePath kFilePath = FilePath( 1139 const FilePath kFilePath = FilePath(
1094 FILE_PATH_LITERAL("gdata/Document 1.gdoc")); 1140 FILE_PATH_LITERAL("gdata/Document 1.gdoc"));
1095 GDataEntry* entry = FindEntry(kFilePath); 1141 GDataEntry* entry = FindEntry(kFilePath);
1096 ASSERT_TRUE(entry); 1142 ASSERT_TRUE(entry);
1097 EXPECT_EQ(kFilePath, entry->GetFilePath()); 1143 EXPECT_EQ(kFilePath, entry->GetFilePath());
1098 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, entry)); 1144 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, entry->AsGDataFile()));
1099 } 1145 }
1100 1146
1101 TEST_F(GDataFileSystemTest, SearchNonExistingFile) { 1147 TEST_F(GDataFileSystemTest, SearchNonExistingFile) {
1102 LoadRootFeedDocument("root_feed.json"); 1148 LoadRootFeedDocument("root_feed.json");
1103 1149
1104 const FilePath kFilePath = FilePath( 1150 const FilePath kFilePath = FilePath(
1105 FILE_PATH_LITERAL("gdata/nonexisting.file")); 1151 FILE_PATH_LITERAL("gdata/nonexisting.file"));
1106 GDataEntry* entry = FindEntry(kFilePath); 1152 GDataEntry* entry = FindEntry(kFilePath);
1107 ASSERT_FALSE(entry); 1153 ASSERT_FALSE(entry);
1108 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, NULL)); 1154 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, NULL));
1109 } 1155 }
1110 1156
1111 TEST_F(GDataFileSystemTest, SearchEncodedFileNames) { 1157 TEST_F(GDataFileSystemTest, SearchEncodedFileNames) {
1112 LoadRootFeedDocument("root_feed.json"); 1158 LoadRootFeedDocument("root_feed.json");
1113 1159
1114 const FilePath kFilePath1 = FilePath( 1160 const FilePath kFilePath1 = FilePath(
1115 FILE_PATH_LITERAL("gdata/Slash / in file 1.txt")); 1161 FILE_PATH_LITERAL("gdata/Slash / in file 1.txt"));
1116 GDataEntry* entry = FindEntry(kFilePath1); 1162 GDataEntry* entry = FindEntry(kFilePath1);
1117 ASSERT_FALSE(entry); 1163 ASSERT_FALSE(entry);
1118 1164
1119 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe( 1165 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe(
1120 "gdata/Slash \xE2\x88\x95 in file 1.txt"); 1166 "gdata/Slash \xE2\x88\x95 in file 1.txt");
1121 entry = FindEntry(kFilePath2); 1167 entry = FindEntry(kFilePath2);
1122 ASSERT_TRUE(entry); 1168 ASSERT_TRUE(entry);
1123 EXPECT_EQ(kFilePath2, entry->GetFilePath()); 1169 EXPECT_EQ(kFilePath2, entry->GetFilePath());
1124 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath2, entry)); 1170 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath2, entry->AsGDataFile()));
1125 1171
1126 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe( 1172 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe(
1127 "gdata/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); 1173 "gdata/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt");
1128 entry = FindEntry(kFilePath3); 1174 entry = FindEntry(kFilePath3);
1129 ASSERT_TRUE(entry); 1175 ASSERT_TRUE(entry);
1130 EXPECT_EQ(kFilePath3, entry->GetFilePath()); 1176 EXPECT_EQ(kFilePath3, entry->GetFilePath());
1131 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath3, entry)); 1177 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath3, entry->AsGDataFile()));
1132 } 1178 }
1133 1179
1134 TEST_F(GDataFileSystemTest, SearchEncodedFileNamesLoadingRoot) { 1180 TEST_F(GDataFileSystemTest, SearchEncodedFileNamesLoadingRoot) {
1135 LoadRootFeedDocument("root_feed.json"); 1181 LoadRootFeedDocument("root_feed.json");
1136 1182
1137 const FilePath kFilePath1 = FilePath( 1183 const FilePath kFilePath1 = FilePath(
1138 FILE_PATH_LITERAL("gdata/Slash / in file 1.txt")); 1184 FILE_PATH_LITERAL("gdata/Slash / in file 1.txt"));
1139 GDataEntry* entry = FindEntry(kFilePath1); 1185 GDataEntry* entry = FindEntry(kFilePath1);
1140 ASSERT_FALSE(entry); 1186 ASSERT_FALSE(entry);
1141 1187
1142 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe( 1188 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe(
1143 "gdata/Slash \xE2\x88\x95 in file 1.txt"); 1189 "gdata/Slash \xE2\x88\x95 in file 1.txt");
1144 entry = FindEntry(kFilePath2); 1190 entry = FindEntry(kFilePath2);
1145 ASSERT_TRUE(entry); 1191 ASSERT_TRUE(entry);
1146 EXPECT_EQ(kFilePath2, entry->GetFilePath()); 1192 EXPECT_EQ(kFilePath2, entry->GetFilePath());
1147 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath2, entry)); 1193 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath2, entry->AsGDataFile()));
1148 1194
1149 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe( 1195 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe(
1150 "gdata/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); 1196 "gdata/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt");
1151 entry = FindEntry(kFilePath3); 1197 entry = FindEntry(kFilePath3);
1152 ASSERT_TRUE(entry); 1198 ASSERT_TRUE(entry);
1153 EXPECT_EQ(kFilePath3, entry->GetFilePath()); 1199 EXPECT_EQ(kFilePath3, entry->GetFilePath());
1154 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath3, entry)); 1200 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath3, entry->AsGDataFile()));
1155 } 1201 }
1156 1202
1157 TEST_F(GDataFileSystemTest, SearchDuplicateNames) { 1203 TEST_F(GDataFileSystemTest, SearchDuplicateNames) {
1158 LoadRootFeedDocument("root_feed.json"); 1204 LoadRootFeedDocument("root_feed.json");
1159 1205
1160 const FilePath kFilePath1 = FilePath( 1206 const FilePath kFilePath1 = FilePath(
1161 FILE_PATH_LITERAL("gdata/Duplicate Name.txt")); 1207 FILE_PATH_LITERAL("gdata/Duplicate Name.txt"));
1162 GDataEntry* entry = FindEntry(kFilePath1); 1208 GDataEntry* entry = FindEntry(kFilePath1);
1163 ASSERT_TRUE(entry); 1209 ASSERT_TRUE(entry);
1164 EXPECT_EQ(kFilePath1, entry->GetFilePath()); 1210 EXPECT_EQ(kFilePath1, entry->GetFilePath());
1165 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath1, entry)); 1211 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath1, entry->AsGDataFile()));
1166 1212
1167 const FilePath kFilePath2 = FilePath( 1213 const FilePath kFilePath2 = FilePath(
1168 FILE_PATH_LITERAL("gdata/Duplicate Name (2).txt")); 1214 FILE_PATH_LITERAL("gdata/Duplicate Name (2).txt"));
1169 entry = FindEntry(kFilePath2); 1215 entry = FindEntry(kFilePath2);
1170 ASSERT_TRUE(entry); 1216 ASSERT_TRUE(entry);
1171 EXPECT_EQ(kFilePath2, entry->GetFilePath()); 1217 EXPECT_EQ(kFilePath2, entry->GetFilePath());
1172 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath2, entry)); 1218 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath2, entry->AsGDataFile()));
1173 } 1219 }
1174 1220
1175 TEST_F(GDataFileSystemTest, SearchExistingDirectory) { 1221 TEST_F(GDataFileSystemTest, SearchExistingDirectory) {
1176 LoadRootFeedDocument("root_feed.json"); 1222 LoadRootFeedDocument("root_feed.json");
1177 1223
1178 const FilePath kFilePath = FilePath( 1224 const FilePath kFilePath = FilePath(
1179 FILE_PATH_LITERAL("gdata/Directory 1")); 1225 FILE_PATH_LITERAL("gdata/Directory 1"));
1180 GDataEntry* entry = FindEntry(kFilePath); 1226 GDataEntry* entry = FindEntry(kFilePath);
1181 ASSERT_TRUE(entry); 1227 ASSERT_TRUE(entry);
1182 EXPECT_EQ(kFilePath, entry->GetFilePath()); 1228 EXPECT_EQ(kFilePath, entry->GetFilePath());
1229 EXPECT_TRUE(ReadDirectoryAndCompare(kFilePath, entry->AsGDataDirectory()));
1183 } 1230 }
1184 1231
1185 TEST_F(GDataFileSystemTest, SearchInSubdir) { 1232 TEST_F(GDataFileSystemTest, SearchInSubdir) {
1186 LoadRootFeedDocument("root_feed.json"); 1233 LoadRootFeedDocument("root_feed.json");
1187 1234
1188 const FilePath kFilePath = FilePath( 1235 const FilePath kFilePath = FilePath(
1189 FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt")); 1236 FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt"));
1190 GDataEntry* entry = FindEntry(kFilePath); 1237 GDataEntry* entry = FindEntry(kFilePath);
1191 ASSERT_TRUE(entry); 1238 ASSERT_TRUE(entry);
1192 EXPECT_EQ(kFilePath, entry->GetFilePath()); 1239 EXPECT_EQ(kFilePath, entry->GetFilePath());
1193 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, entry)); 1240 EXPECT_TRUE(GetFileInfoAndCompare(kFilePath, entry->AsGDataFile()));
1194 } 1241 }
1195 1242
1196 // Check the reconstruction of the directory structure from only the root feed. 1243 // Check the reconstruction of the directory structure from only the root feed.
1197 TEST_F(GDataFileSystemTest, SearchInSubSubdir) { 1244 TEST_F(GDataFileSystemTest, SearchInSubSubdir) {
1198 LoadRootFeedDocument("root_feed.json"); 1245 LoadRootFeedDocument("root_feed.json");
1199 1246
1200 const FilePath kFilePath = FilePath( 1247 const FilePath kFilePath = FilePath(
1201 FILE_PATH_LITERAL("gdata/Directory 1/Sub Directory Folder/" 1248 FILE_PATH_LITERAL("gdata/Directory 1/Sub Directory Folder/"
1202 "Sub Sub Directory Folder")); 1249 "Sub Sub Directory Folder"));
1203 GDataEntry* entry = FindEntry(kFilePath); 1250 GDataEntry* entry = FindEntry(kFilePath);
1204 ASSERT_TRUE(entry); 1251 ASSERT_TRUE(entry);
1205 EXPECT_EQ(kFilePath, entry->GetFilePath()); 1252 EXPECT_EQ(kFilePath, entry->GetFilePath());
1253 EXPECT_TRUE(ReadDirectoryAndCompare(kFilePath, entry->AsGDataDirectory()));
1206 } 1254 }
1207 1255
1208 TEST_F(GDataFileSystemTest, FilePathTests) { 1256 TEST_F(GDataFileSystemTest, FilePathTests) {
1209 LoadRootFeedDocument("root_feed.json"); 1257 LoadRootFeedDocument("root_feed.json");
1210 1258
1211 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/File 1.txt"))); 1259 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/File 1.txt")));
1212 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/Directory 1"))); 1260 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")));
1213 FindAndTestFilePath( 1261 FindAndTestFilePath(
1214 FilePath(FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt"))); 1262 FilePath(FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt")));
1215 } 1263 }
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 EXPECT_EQ(1, num_callback_invocations_); 3089 EXPECT_EQ(1, num_callback_invocations_);
3042 EXPECT_TRUE(CacheEntryExists(resource_id, md5)); 3090 EXPECT_TRUE(CacheEntryExists(resource_id, md5));
3043 3091
3044 // Try to remove the file. 3092 // Try to remove the file.
3045 num_callback_invocations_ = 0; 3093 num_callback_invocations_ = 0;
3046 TestRemoveFromCache(resource_id, base::PLATFORM_FILE_OK); 3094 TestRemoveFromCache(resource_id, base::PLATFORM_FILE_OK);
3047 EXPECT_EQ(1, num_callback_invocations_); 3095 EXPECT_EQ(1, num_callback_invocations_);
3048 } 3096 }
3049 3097
3050 } // namespace gdata 3098 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | chrome/browser/chromeos/gdata/mock_gdata_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698