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

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc

Issue 11665029: Sync FileSystem: Mark empty batch sync origin as incremental sync origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: +comment Created 7 years, 11 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/sync_file_system/drive_file_sync_service.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/sync_file_system/drive_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 typedef DriveFileSyncService::ChangeQueueItem ChangeQueueItem; 180 typedef DriveFileSyncService::ChangeQueueItem ChangeQueueItem;
181 typedef DriveFileSyncService::RemoteSyncType RemoteSyncType; 181 typedef DriveFileSyncService::RemoteSyncType RemoteSyncType;
182 sync_service_->pending_changes_.clear(); 182 sync_service_->pending_changes_.clear();
183 183
184 RemoteSyncType sync_type = DriveFileSyncService::REMOTE_SYNC_TYPE_BATCH; 184 RemoteSyncType sync_type = DriveFileSyncService::REMOTE_SYNC_TYPE_BATCH;
185 std::pair<iterator, bool> inserted_to_queue = 185 std::pair<iterator, bool> inserted_to_queue =
186 sync_service_->pending_changes_.insert( 186 sync_service_->pending_changes_.insert(
187 ChangeQueueItem(changestamp, sync_type, url)); 187 ChangeQueueItem(changestamp, sync_type, url));
188 DCHECK(inserted_to_queue.second); 188 DCHECK(inserted_to_queue.second);
189 189
190 DriveFileSyncService::PathToChange* path_to_change = 190 DriveFileSyncService::PathToChangeMap* path_to_change =
191 &sync_service_->url_to_change_[url.origin()]; 191 &sync_service_->origin_to_changes_map_[url.origin()];
192 (*path_to_change)[url.path()] = DriveFileSyncService::RemoteChange( 192 (*path_to_change)[url.path()] = DriveFileSyncService::RemoteChange(
193 changestamp, resource_id, sync_type, url, file_change, 193 changestamp, resource_id, sync_type, url, file_change,
194 inserted_to_queue.first); 194 inserted_to_queue.first);
195 } 195 }
196 196
197 DriveFileSyncClient* sync_client() { 197 DriveFileSyncClient* sync_client() {
198 if (sync_client_) 198 if (sync_client_)
199 return sync_client_.get(); 199 return sync_client_.get();
200 return sync_service_->sync_client_.get(); 200 return sync_service_->sync_client_.get();
201 } 201 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 google_apis::HTTP_SUCCESS, 541 google_apis::HTTP_SUCCESS,
542 base::Passed(&listing_files_in_empty_directory))); 542 base::Passed(&listing_files_in_empty_directory)));
543 543
544 SetUpDriveSyncService(); 544 SetUpDriveSyncService();
545 bool done = false; 545 bool done = false;
546 sync_service()->RegisterOriginForTrackingChanges( 546 sync_service()->RegisterOriginForTrackingChanges(
547 kOrigin, base::Bind(&ExpectEqStatus, &done, fileapi::SYNC_STATUS_OK)); 547 kOrigin, base::Bind(&ExpectEqStatus, &done, fileapi::SYNC_STATUS_OK));
548 message_loop()->RunUntilIdle(); 548 message_loop()->RunUntilIdle();
549 EXPECT_TRUE(done); 549 EXPECT_TRUE(done);
550 550
551 EXPECT_EQ(1u, metadata_store()->batch_sync_origins().size()); 551 EXPECT_TRUE(metadata_store()->batch_sync_origins().empty());
552 EXPECT_TRUE(metadata_store()->incremental_sync_origins().empty()); 552 EXPECT_EQ(1u, metadata_store()->incremental_sync_origins().size());
553 EXPECT_TRUE(pending_changes().empty()); 553 EXPECT_TRUE(pending_changes().empty());
554 } 554 }
555 555
556 TEST_F(DriveFileSyncServiceTest, RegisterExistingOrigin) { 556 TEST_F(DriveFileSyncServiceTest, RegisterExistingOrigin) {
557 const GURL kOrigin("chrome-extension://example"); 557 const GURL kOrigin("chrome-extension://example");
558 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 558 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
559 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 559 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
560 560
561 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId); 561 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId);
562 562
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 *LoadJSONFile("gdata/file_entry.json"))); 935 *LoadJSONFile("gdata/file_entry.json")));
936 AppendIncrementalRemoteChange(kOrigin, *entry, 12345); 936 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
937 ProcessRemoteChange(fileapi::SYNC_STATUS_OK, 937 ProcessRemoteChange(fileapi::SYNC_STATUS_OK,
938 CreateURL(kOrigin, kFileName), 938 CreateURL(kOrigin, kFileName),
939 fileapi::SYNC_OPERATION_UPDATED); 939 fileapi::SYNC_OPERATION_UPDATED);
940 } 940 }
941 941
942 #endif // !defined(OS_ANDROID) 942 #endif // !defined(OS_ANDROID)
943 943
944 } // namespace sync_file_system 944 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698