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

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

Issue 9836086: Added logic that will return the result of the first chunk of root feed and continue fetching the r… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed asserts in browser_tests Created 8 years, 9 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 GDataRootDirectory::CACHE_TYPE_TMP, 183 GDataRootDirectory::CACHE_TYPE_TMP,
184 GDataFileSystem::CACHED_FILE_FROM_SERVER); 184 GDataFileSystem::CACHED_FILE_FROM_SERVER);
185 } 185 }
186 186
187 GDataFileBase* FindFile(const FilePath& file_path) { 187 GDataFileBase* FindFile(const FilePath& file_path) {
188 ReadOnlyFindFileDelegate search_delegate; 188 ReadOnlyFindFileDelegate search_delegate;
189 file_system_->FindFileByPathSync(file_path, &search_delegate); 189 file_system_->FindFileByPathSync(file_path, &search_delegate);
190 return search_delegate.file(); 190 return search_delegate.file();
191 } 191 }
192 192
193 GDataFileBase* FindFileElementByResourceId(const std::string& resource_id) {
194 ReadOnlyFindFileDelegate search_delegate;
195 file_system_->FindFileByPathSync(FilePath(FILE_PATH_LITERAL("gdata")),
196 &search_delegate);
197 return search_delegate.file()->AsGDataRootDirectory()->GetFileByResourceId(
198 resource_id);
199 }
200
193 void FindAndTestFilePath(const FilePath& file_path) { 201 void FindAndTestFilePath(const FilePath& file_path) {
194 GDataFileBase* file = FindFile(file_path); 202 GDataFileBase* file = FindFile(file_path);
195 ASSERT_TRUE(file) << "File can't be found " << file_path.value(); 203 ASSERT_TRUE(file) << "File can't be found " << file_path.value();
196 EXPECT_EQ(file->GetFilePath(), file_path); 204 EXPECT_EQ(file->GetFilePath(), file_path);
197 } 205 }
198 206
199 GDataFileBase* FindFileByResourceId(const std::string& resource) { 207 GDataFileBase* FindFileByResourceId(const std::string& resource) {
200 return file_system_->root_->GetFileByResourceId(resource); 208 return file_system_->root_->GetFileByResourceId(resource);
201 } 209 }
202 210
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/Feed 1 File.txt"))); 930 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/Feed 1 File.txt")));
923 FindAndTestFilePath( 931 FindAndTestFilePath(
924 FilePath(FILE_PATH_LITERAL( 932 FilePath(FILE_PATH_LITERAL(
925 "gdata/Directory 1/Feed 1 SubDirectory File.txt"))); 933 "gdata/Directory 1/Feed 1 SubDirectory File.txt")));
926 934
927 // Test second feed elements. 935 // Test second feed elements.
928 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/Feed 2 File.txt"))); 936 FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/Feed 2 File.txt")));
929 FindAndTestFilePath( 937 FindAndTestFilePath(
930 FilePath(FILE_PATH_LITERAL( 938 FilePath(FILE_PATH_LITERAL(
931 "gdata/Directory 1/Sub Directory Folder/Feed 2 Directory"))); 939 "gdata/Directory 1/Sub Directory Folder/Feed 2 Directory")));
940
941 // Make sure orphaned files didn't make into the file system.
942 ASSERT_FALSE(FindFileElementByResourceId(
943 "file:orphan_file_resource_id"));
944 ASSERT_FALSE(FindFileElementByResourceId(
945 "folder:orphan_feed_folder_resouce_id"));
946 ASSERT_FALSE(FindFileElementByResourceId(
947 "file:orphan_subfolder_file_resource_id"));
932 } 948 }
933 949
934 TEST_F(GDataFileSystemTest, CopyNotExistingFile) { 950 TEST_F(GDataFileSystemTest, CopyNotExistingFile) {
935 FilePath src_file_path(FILE_PATH_LITERAL("gdata/Dummy file.txt")); 951 FilePath src_file_path(FILE_PATH_LITERAL("gdata/Dummy file.txt"));
936 FilePath dest_file_path(FILE_PATH_LITERAL("gdata/Test.log")); 952 FilePath dest_file_path(FILE_PATH_LITERAL("gdata/Test.log"));
937 953
938 LoadRootFeedDocument("root_feed.json"); 954 LoadRootFeedDocument("root_feed.json");
939 955
940 GDataFileBase* src_file = NULL; 956 GDataFileBase* src_file = NULL;
941 EXPECT_TRUE((src_file = FindFile(src_file_path)) == NULL); 957 EXPECT_TRUE((src_file = FindFile(src_file_path)) == NULL);
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 2263
2248 // Verify account meta feed is saved to cache. 2264 // Verify account meta feed is saved to cache.
2249 RunAllPendingForIO(); 2265 RunAllPendingForIO();
2250 FilePath path = file_system_->cache_paths_[ 2266 FilePath path = file_system_->cache_paths_[
2251 GDataRootDirectory::CACHE_TYPE_META].Append( 2267 GDataRootDirectory::CACHE_TYPE_META].Append(
2252 FILE_PATH_LITERAL("account_metadata.json")); 2268 FILE_PATH_LITERAL("account_metadata.json"));
2253 EXPECT_TRUE(file_util::PathExists(path)); 2269 EXPECT_TRUE(file_util::PathExists(path));
2254 } 2270 }
2255 2271
2256 } // namespace gdata 2272 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | chrome/browser/chromeos/gdata/gdata_files.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698