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

Side by Side Diff: chrome/browser/chromeos/drive/change_list_loader_unittest.cc

Issue 23670006: Use DriveService for proper resource id resolution in ChangeListLoader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 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 "chrome/browser/chromeos/drive/change_list_loader.h" 5 #include "chrome/browser/chromeos/drive/change_list_loader.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 cache_.reset(new FileCache(metadata_storage_.get(), 125 cache_.reset(new FileCache(metadata_storage_.get(),
126 temp_dir_.path(), 126 temp_dir_.path(),
127 base::MessageLoopProxy::current().get(), 127 base::MessageLoopProxy::current().get(),
128 NULL /* free_disk_space_getter */)); 128 NULL /* free_disk_space_getter */));
129 ASSERT_TRUE(cache_->Initialize()); 129 ASSERT_TRUE(cache_->Initialize());
130 130
131 change_list_loader_.reset( 131 change_list_loader_.reset(
132 new ChangeListLoader(base::MessageLoopProxy::current().get(), 132 new ChangeListLoader(base::MessageLoopProxy::current().get(),
133 metadata_.get(), 133 metadata_.get(),
134 scheduler_.get())); 134 scheduler_.get(),
135 drive_service_.get()));
135 } 136 }
136 137
137 // Adds a new file to the root directory of the service. 138 // Adds a new file to the root directory of the service.
138 scoped_ptr<google_apis::ResourceEntry> AddNewFile(const std::string& title) { 139 scoped_ptr<google_apis::ResourceEntry> AddNewFile(const std::string& title) {
139 google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR; 140 google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR;
140 scoped_ptr<google_apis::ResourceEntry> entry; 141 scoped_ptr<google_apis::ResourceEntry> entry;
141 drive_service_->AddNewFile( 142 drive_service_->AddNewFile(
142 "text/plain", 143 "text/plain",
143 "content text", 144 "content text",
144 drive_service_->GetRootResourceId(), 145 drive_service_->GetRootResourceId(),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 change_list_loader_->LoadIfNeeded( 213 change_list_loader_->LoadIfNeeded(
213 DirectoryFetchInfo(), 214 DirectoryFetchInfo(),
214 google_apis::test_util::CreateCopyResultCallback(&error)); 215 google_apis::test_util::CreateCopyResultCallback(&error));
215 base::RunLoop().RunUntilIdle(); 216 base::RunLoop().RunUntilIdle();
216 EXPECT_EQ(FILE_ERROR_OK, error); 217 EXPECT_EQ(FILE_ERROR_OK, error);
217 218
218 // Reset loader. 219 // Reset loader.
219 change_list_loader_.reset( 220 change_list_loader_.reset(
220 new ChangeListLoader(base::MessageLoopProxy::current().get(), 221 new ChangeListLoader(base::MessageLoopProxy::current().get(),
221 metadata_.get(), 222 metadata_.get(),
222 scheduler_.get())); 223 scheduler_.get(),
224 drive_service_.get()));
223 225
224 // Add a file to the service. 226 // Add a file to the service.
225 scoped_ptr<google_apis::ResourceEntry> gdata_entry = AddNewFile("New File"); 227 scoped_ptr<google_apis::ResourceEntry> gdata_entry = AddNewFile("New File");
226 ASSERT_TRUE(gdata_entry); 228 ASSERT_TRUE(gdata_entry);
227 229
228 // Start loading. Because local metadata is available, the load results in 230 // Start loading. Because local metadata is available, the load results in
229 // returning FILE_ERROR_OK without fetching full list of resources. 231 // returning FILE_ERROR_OK without fetching full list of resources.
230 const int previous_resource_list_load_count = 232 const int previous_resource_list_load_count =
231 drive_service_->resource_list_load_count(); 233 drive_service_->resource_list_load_count();
232 TestChangeListLoaderObserver observer(change_list_loader_.get()); 234 TestChangeListLoaderObserver observer(change_list_loader_.get());
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // The new file is found in the local metadata. 436 // The new file is found in the local metadata.
435 base::FilePath new_file_path = 437 base::FilePath new_file_path =
436 util::GetDriveMyDriveRootPath().AppendASCII(gdata_entry->title()); 438 util::GetDriveMyDriveRootPath().AppendASCII(gdata_entry->title());
437 ResourceEntry entry; 439 ResourceEntry entry;
438 EXPECT_EQ(FILE_ERROR_OK, 440 EXPECT_EQ(FILE_ERROR_OK,
439 metadata_->GetResourceEntryByPath(new_file_path, &entry)); 441 metadata_->GetResourceEntryByPath(new_file_path, &entry));
440 } 442 }
441 443
442 } // namespace internal 444 } // namespace internal
443 } // namespace drive 445 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_loader.cc ('k') | chrome/browser/chromeos/drive/file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698