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

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

Issue 148233006: drive: Use UploadNewFile from EntryUpdatePerformer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 6 years, 10 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 | « chrome/browser/chromeos/drive/sync_client.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 (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 "chrome/browser/chromeos/drive/sync_client.h" 5 #include "chrome/browser/chromeos/drive/sync_client.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 metadata_.reset(new internal::ResourceMetadata( 128 metadata_.reset(new internal::ResourceMetadata(
129 metadata_storage_.get(), base::MessageLoopProxy::current())); 129 metadata_storage_.get(), base::MessageLoopProxy::current()));
130 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); 130 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize());
131 131
132 cache_.reset(new FileCache(metadata_storage_.get(), 132 cache_.reset(new FileCache(metadata_storage_.get(),
133 temp_dir_.path(), 133 temp_dir_.path(),
134 base::MessageLoopProxy::current().get(), 134 base::MessageLoopProxy::current().get(),
135 NULL /* free_disk_space_getter */)); 135 NULL /* free_disk_space_getter */));
136 ASSERT_TRUE(cache_->Initialize()); 136 ASSERT_TRUE(cache_->Initialize());
137 137
138 change_list_loader_.reset(new ChangeListLoader(
139 base::MessageLoopProxy::current().get(),
140 metadata_.get(),
141 scheduler_.get(),
142 drive_service_.get()));
138 ASSERT_NO_FATAL_FAILURE(SetUpTestData()); 143 ASSERT_NO_FATAL_FAILURE(SetUpTestData());
139 144
140 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(), 145 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(),
141 &observer_, 146 &observer_,
142 scheduler_.get(), 147 scheduler_.get(),
143 metadata_.get(), 148 metadata_.get(),
144 cache_.get(), 149 cache_.get(),
150 change_list_loader_.get(),
145 temp_dir_.path())); 151 temp_dir_.path()));
146 152
147 // Disable delaying so that DoSyncLoop() starts immediately. 153 // Disable delaying so that DoSyncLoop() starts immediately.
148 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); 154 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0));
149 } 155 }
150 156
151 // Adds a file to the service root and |resource_ids_|. 157 // Adds a file to the service root and |resource_ids_|.
152 void AddFileEntry(const std::string& title) { 158 void AddFileEntry(const std::string& title) {
153 google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR; 159 google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR;
154 scoped_ptr<google_apis::ResourceEntry> entry; 160 scoped_ptr<google_apis::ResourceEntry> entry;
(...skipping 22 matching lines...) Expand all
177 ASSERT_NO_FATAL_FAILURE(AddFileEntry("foo")); 183 ASSERT_NO_FATAL_FAILURE(AddFileEntry("foo"));
178 ASSERT_NO_FATAL_FAILURE(AddFileEntry("bar")); 184 ASSERT_NO_FATAL_FAILURE(AddFileEntry("bar"));
179 ASSERT_NO_FATAL_FAILURE(AddFileEntry("baz")); 185 ASSERT_NO_FATAL_FAILURE(AddFileEntry("baz"));
180 ASSERT_NO_FATAL_FAILURE(AddFileEntry("fetched")); 186 ASSERT_NO_FATAL_FAILURE(AddFileEntry("fetched"));
181 ASSERT_NO_FATAL_FAILURE(AddFileEntry("dirty")); 187 ASSERT_NO_FATAL_FAILURE(AddFileEntry("dirty"));
182 ASSERT_NO_FATAL_FAILURE(AddFileEntry("removed")); 188 ASSERT_NO_FATAL_FAILURE(AddFileEntry("removed"));
183 ASSERT_NO_FATAL_FAILURE(AddFileEntry("moved")); 189 ASSERT_NO_FATAL_FAILURE(AddFileEntry("moved"));
184 190
185 // Load data from the service to the metadata. 191 // Load data from the service to the metadata.
186 FileError error = FILE_ERROR_FAILED; 192 FileError error = FILE_ERROR_FAILED;
187 internal::ChangeListLoader change_list_loader( 193 change_list_loader_->LoadForTesting(
188 base::MessageLoopProxy::current().get(),
189 metadata_.get(),
190 scheduler_.get(),
191 drive_service_.get());
192 change_list_loader.LoadForTesting(
193 google_apis::test_util::CreateCopyResultCallback(&error)); 194 google_apis::test_util::CreateCopyResultCallback(&error));
194 base::RunLoop().RunUntilIdle(); 195 base::RunLoop().RunUntilIdle();
195 EXPECT_EQ(FILE_ERROR_OK, error); 196 EXPECT_EQ(FILE_ERROR_OK, error);
196 197
197 // Prepare 3 pinned-but-not-present files. 198 // Prepare 3 pinned-but-not-present files.
198 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("foo"))); 199 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("foo")));
199 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("bar"))); 200 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("bar")));
200 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("baz"))); 201 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("baz")));
201 202
202 // Prepare a pinned-and-fetched file. 203 // Prepare a pinned-and-fetched file.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 scoped_ptr<TestingPrefServiceSimple> pref_service_; 250 scoped_ptr<TestingPrefServiceSimple> pref_service_;
250 scoped_ptr<test_util::FakeNetworkChangeNotifier> 251 scoped_ptr<test_util::FakeNetworkChangeNotifier>
251 fake_network_change_notifier_; 252 fake_network_change_notifier_;
252 scoped_ptr<SyncClientTestDriveService> drive_service_; 253 scoped_ptr<SyncClientTestDriveService> drive_service_;
253 DummyOperationObserver observer_; 254 DummyOperationObserver observer_;
254 scoped_ptr<JobScheduler> scheduler_; 255 scoped_ptr<JobScheduler> scheduler_;
255 scoped_ptr<ResourceMetadataStorage, 256 scoped_ptr<ResourceMetadataStorage,
256 test_util::DestroyHelperForTests> metadata_storage_; 257 test_util::DestroyHelperForTests> metadata_storage_;
257 scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> metadata_; 258 scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> metadata_;
258 scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_; 259 scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_;
260 scoped_ptr<ChangeListLoader> change_list_loader_;
259 scoped_ptr<SyncClient> sync_client_; 261 scoped_ptr<SyncClient> sync_client_;
260 262
261 std::map<std::string, std::string> resource_ids_; // Name-to-id map. 263 std::map<std::string, std::string> resource_ids_; // Name-to-id map.
262 }; 264 };
263 265
264 TEST_F(SyncClientTest, StartProcessingBacklog) { 266 TEST_F(SyncClientTest, StartProcessingBacklog) {
265 sync_client_->StartProcessingBacklog(); 267 sync_client_->StartProcessingBacklog();
266 base::RunLoop().RunUntilIdle(); 268 base::RunLoop().RunUntilIdle();
267 269
268 FileCacheEntry cache_entry; 270 FileCacheEntry cache_entry;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 ASSERT_FALSE(drive_service_->paused_action().is_null()); 424 ASSERT_FALSE(drive_service_->paused_action().is_null());
423 drive_service_->paused_action().Run(); 425 drive_service_->paused_action().Run();
424 base::RunLoop().RunUntilIdle(); 426 base::RunLoop().RunUntilIdle();
425 427
426 // Task should be run twice. 428 // Task should be run twice.
427 EXPECT_EQ(2, drive_service_->download_file_count()); 429 EXPECT_EQ(2, drive_service_->download_file_count());
428 } 430 }
429 431
430 } // namespace internal 432 } // namespace internal
431 } // namespace drive 433 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698