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

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

Issue 11421125: Implement polling part of DriveFileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for optional changestamp field Created 8 years 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 "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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 fileapi::SyncOperationType* operation_out, 251 fileapi::SyncOperationType* operation_out,
252 fileapi::SyncStatusCode status, 252 fileapi::SyncStatusCode status,
253 const fileapi::FileSystemURL& url, 253 const fileapi::FileSystemURL& url,
254 fileapi::SyncOperationType operation) { 254 fileapi::SyncOperationType operation) {
255 *status_out = status; 255 *status_out = status;
256 *url_out = url; 256 *url_out = url;
257 *operation_out = operation; 257 *operation_out = operation;
258 } 258 }
259 259
260 void AppendIncrementalRemoteChange(const GURL& origin, 260 void AppendIncrementalRemoteChange(const GURL& origin,
261 google_apis::DocumentEntry* entry, 261 const google_apis::DocumentEntry& entry,
262 int64 changestamp) { 262 int64 changestamp) {
263 sync_service_->AppendNewRemoteChange( 263 sync_service_->AppendNewRemoteChange(
264 origin, entry, changestamp, 264 origin, entry, changestamp,
265 DriveFileSyncService::REMOTE_SYNC_TYPE_INCREMENTAL); 265 DriveFileSyncService::REMOTE_SYNC_TYPE_INCREMENTAL);
266 } 266 }
267 267
268 private: 268 private:
269 MessageLoop message_loop_; 269 MessageLoop message_loop_;
270 content::TestBrowserThread file_thread_; 270 content::TestBrowserThread file_thread_;
271 271
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 .Times(AnyNumber()); 750 .Times(AnyNumber());
751 751
752 EXPECT_CALL(*mock_remote_processor(), 752 EXPECT_CALL(*mock_remote_processor(),
753 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _)) 753 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _))
754 .WillOnce(PrepareForRemoteChange_Busy()); 754 .WillOnce(PrepareForRemoteChange_Busy());
755 755
756 SetUpDriveSyncService(); 756 SetUpDriveSyncService();
757 757
758 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( 758 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse(
759 *LoadJSONFile("gdata/file_entry.json"))); 759 *LoadJSONFile("gdata/file_entry.json")));
760 AppendIncrementalRemoteChange(kOrigin, entry.get(), 12345); 760 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
761 761
762 ProcessRemoteChange(fileapi::SYNC_STATUS_FILE_BUSY, 762 ProcessRemoteChange(fileapi::SYNC_STATUS_FILE_BUSY,
763 CreateURL(kOrigin, kFileName), 763 CreateURL(kOrigin, kFileName),
764 fileapi::SYNC_OPERATION_NONE); 764 fileapi::SYNC_OPERATION_NONE);
765 } 765 }
766 766
767 TEST_F(DriveFileSyncServiceTest, RemoteChange_NewFile) { 767 TEST_F(DriveFileSyncServiceTest, RemoteChange_NewFile) {
768 const GURL kOrigin("chrome-extension://example.com"); 768 const GURL kOrigin("chrome-extension://example.com");
769 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 769 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
770 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 770 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
(...skipping 25 matching lines...) Expand all
796 .WillOnce(InvokeDidDownloadFile()); 796 .WillOnce(InvokeDidDownloadFile());
797 797
798 EXPECT_CALL(*mock_remote_processor(), 798 EXPECT_CALL(*mock_remote_processor(),
799 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _)) 799 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _))
800 .WillOnce(InvokeDidApplyRemoteChange()); 800 .WillOnce(InvokeDidApplyRemoteChange());
801 801
802 SetUpDriveSyncService(); 802 SetUpDriveSyncService();
803 803
804 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( 804 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse(
805 *LoadJSONFile("gdata/file_entry.json"))); 805 *LoadJSONFile("gdata/file_entry.json")));
806 AppendIncrementalRemoteChange(kOrigin, entry.get(), 12345); 806 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
807 807
808 ProcessRemoteChange(fileapi::SYNC_STATUS_OK, 808 ProcessRemoteChange(fileapi::SYNC_STATUS_OK,
809 CreateURL(kOrigin, kFileName), 809 CreateURL(kOrigin, kFileName),
810 fileapi::SYNC_OPERATION_ADD); 810 fileapi::SYNC_OPERATION_ADD);
811 } 811 }
812 812
813 TEST_F(DriveFileSyncServiceTest, RemoteChange_UpdateFile) { 813 TEST_F(DriveFileSyncServiceTest, RemoteChange_UpdateFile) {
814 const GURL kOrigin("chrome-extension://example.com"); 814 const GURL kOrigin("chrome-extension://example.com");
815 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 815 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
816 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 816 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
(...skipping 25 matching lines...) Expand all
842 .WillOnce(InvokeDidDownloadFile()); 842 .WillOnce(InvokeDidDownloadFile());
843 843
844 EXPECT_CALL(*mock_remote_processor(), 844 EXPECT_CALL(*mock_remote_processor(),
845 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _)) 845 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _))
846 .WillOnce(InvokeDidApplyRemoteChange()); 846 .WillOnce(InvokeDidApplyRemoteChange());
847 847
848 SetUpDriveSyncService(); 848 SetUpDriveSyncService();
849 849
850 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( 850 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse(
851 *LoadJSONFile("gdata/file_entry.json"))); 851 *LoadJSONFile("gdata/file_entry.json")));
852 AppendIncrementalRemoteChange(kOrigin, entry.get(), 12345); 852 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
853 ProcessRemoteChange(fileapi::SYNC_STATUS_OK, 853 ProcessRemoteChange(fileapi::SYNC_STATUS_OK,
854 CreateURL(kOrigin, kFileName), 854 CreateURL(kOrigin, kFileName),
855 fileapi::SYNC_OPERATION_UPDATE); 855 fileapi::SYNC_OPERATION_UPDATE);
856 } 856 }
857 857
858 #endif // !defined(OS_ANDROID) 858 #endif // !defined(OS_ANDROID)
859 859
860 } // namespace sync_file_system 860 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698