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

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

Issue 11530004: google_apis: DriveServiceInterface::GetResourceEntry() returns ResourceEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_client_unittest.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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 // Invokes |arg0| as a GetDataCallback. 301 // Invokes |arg0| as a GetDataCallback.
302 ACTION_P2(InvokeGetDataCallback0, error, result) { 302 ACTION_P2(InvokeGetDataCallback0, error, result) {
303 scoped_ptr<base::Value> value(result.Pass()); 303 scoped_ptr<base::Value> value(result.Pass());
304 base::MessageLoopProxy::current()->PostTask( 304 base::MessageLoopProxy::current()->PostTask(
305 FROM_HERE, 305 FROM_HERE,
306 base::Bind(arg0, error, base::Passed(&value))); 306 base::Bind(arg0, error, base::Passed(&value)));
307 } 307 }
308 308
309 // Invokes |arg0| as a GetDataCallback. 309 // Invokes |arg1| as a GetResourceEntryCallback.
310 ACTION_P2(InvokeGetDataCallback1, error, result) { 310 ACTION_P2(InvokeGetResourceEntryCallback1, error, result) {
311 scoped_ptr<base::Value> value(result.Pass()); 311 scoped_ptr<google_apis::ResourceEntry> entry(result.Pass());
312 base::MessageLoopProxy::current()->PostTask( 312 base::MessageLoopProxy::current()->PostTask(
313 FROM_HERE, 313 FROM_HERE,
314 base::Bind(arg1, error, base::Passed(&value))); 314 base::Bind(arg1, error, base::Passed(&entry)));
315 } 315 }
316 316
317 // Invokes |arg2| as a GetDataCallback. 317 // Invokes |arg2| as a GetDataCallback.
318 ACTION_P2(InvokeGetDataCallback2, error, result) { 318 ACTION_P2(InvokeGetDataCallback2, error, result) {
319 scoped_ptr<base::Value> value(result.Pass()); 319 scoped_ptr<base::Value> value(result.Pass());
320 base::MessageLoopProxy::current()->PostTask( 320 base::MessageLoopProxy::current()->PostTask(
321 FROM_HERE, 321 FROM_HERE,
322 base::Bind(arg2, error, base::Passed(&value))); 322 base::Bind(arg2, error, base::Passed(&value)));
323 } 323 }
324 324
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 google_apis::HTTP_SUCCESS, 486 google_apis::HTTP_SUCCESS,
487 base::Passed(&origin_directory_not_found))) 487 base::Passed(&origin_directory_not_found)))
488 .RetiresOnSaturation(); 488 .RetiresOnSaturation();
489 489
490 // If the directory for the origin is missing, DriveFileSyncService should 490 // If the directory for the origin is missing, DriveFileSyncService should
491 // attempt to create it. And as a preparation, it should fetch the content url 491 // attempt to create it. And as a preparation, it should fetch the content url
492 // of the parent directory. 492 // of the parent directory.
493 // 493 //
494 // |sync_root_entry| contains kSyncRootContentURL which is to be added as 494 // |sync_root_entry| contains kSyncRootContentURL which is to be added as
495 // a new origin directory under the root directory. 495 // a new origin directory under the root directory.
496 scoped_ptr<Value> sync_root_entry(LoadJSONFile( 496 scoped_ptr<Value> sync_root_entry_value(LoadJSONFile(
497 "sync_file_system/sync_root_entry.json")); 497 "sync_file_system/sync_root_entry.json"));
498 scoped_ptr<google_apis::ResourceEntry> sync_root_entry
499 = google_apis::ResourceEntry::ExtractAndParse(*sync_root_entry_value);
498 EXPECT_CALL(*mock_drive_service(), 500 EXPECT_CALL(*mock_drive_service(),
499 GetResourceEntry(kSyncRootResourceId, _)) 501 GetResourceEntry(kSyncRootResourceId, _))
500 .WillOnce(InvokeGetDataCallback1( 502 .WillOnce(InvokeGetResourceEntryCallback1(
501 google_apis::HTTP_SUCCESS, 503 google_apis::HTTP_SUCCESS,
502 base::Passed(&sync_root_entry))); 504 base::Passed(&sync_root_entry)));
503 505
504 scoped_ptr<Value> origin_directory_created(LoadJSONFile( 506 scoped_ptr<Value> origin_directory_created(LoadJSONFile(
505 "sync_file_system/origin_directory_created.json")); 507 "sync_file_system/origin_directory_created.json"));
506 FilePath::StringType dirname = FilePath().AppendASCII( 508 FilePath::StringType dirname = FilePath().AppendASCII(
507 DriveFileSyncClient::OriginToDirectoryTitle(kOrigin)).value(); 509 DriveFileSyncClient::OriginToDirectoryTitle(kOrigin)).value();
508 EXPECT_CALL(*mock_drive_service(), 510 EXPECT_CALL(*mock_drive_service(),
509 AddNewDirectory(kSyncRootContentURL, dirname, _)) 511 AddNewDirectory(kSyncRootContentURL, dirname, _))
510 .WillOnce(InvokeGetDataCallback2( 512 .WillOnce(InvokeGetDataCallback2(
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeQueueUpdated(_)) 837 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeQueueUpdated(_))
836 .Times(AnyNumber()); 838 .Times(AnyNumber());
837 839
838 EXPECT_CALL(*mock_remote_processor(), 840 EXPECT_CALL(*mock_remote_processor(),
839 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _)) 841 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _))
840 .WillOnce(PrepareForRemoteChange_NotFound()); 842 .WillOnce(PrepareForRemoteChange_NotFound());
841 EXPECT_CALL(*mock_remote_processor(), 843 EXPECT_CALL(*mock_remote_processor(),
842 ClearLocalChanges(CreateURL(kOrigin, kFileName), _)) 844 ClearLocalChanges(CreateURL(kOrigin, kFileName), _))
843 .WillOnce(InvokeCompletionCallback()); 845 .WillOnce(InvokeCompletionCallback());
844 846
845 scoped_ptr<Value> file_entry(LoadJSONFile("gdata/file_entry.json").Pass()); 847 scoped_ptr<Value> file_entry_value(
848 LoadJSONFile("gdata/file_entry.json").Pass());
849 scoped_ptr<google_apis::ResourceEntry> file_entry
850 = google_apis::ResourceEntry::ExtractAndParse(*file_entry_value);
846 EXPECT_CALL(*mock_drive_service(), 851 EXPECT_CALL(*mock_drive_service(),
847 GetResourceEntry(kFileResourceId, _)) 852 GetResourceEntry(kFileResourceId, _))
848 .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, 853 .WillOnce(InvokeGetResourceEntryCallback1(
849 base::Passed(&file_entry))); 854 google_apis::HTTP_SUCCESS,
855 base::Passed(&file_entry)));
850 856
851 EXPECT_CALL(*mock_drive_service(), 857 EXPECT_CALL(*mock_drive_service(),
852 DownloadFile(_, _, GURL("https://file_content_url"), _, _)) 858 DownloadFile(_, _, GURL("https://file_content_url"), _, _))
853 .WillOnce(InvokeDidDownloadFile()); 859 .WillOnce(InvokeDidDownloadFile());
854 860
855 EXPECT_CALL(*mock_remote_processor(), 861 EXPECT_CALL(*mock_remote_processor(),
856 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _)) 862 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _))
857 .WillOnce(InvokeDidApplyRemoteChange()); 863 .WillOnce(InvokeDidApplyRemoteChange());
858 864
859 SetUpDriveSyncService(); 865 SetUpDriveSyncService();
(...skipping 24 matching lines...) Expand all
884 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeQueueUpdated(_)) 890 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeQueueUpdated(_))
885 .Times(AnyNumber()); 891 .Times(AnyNumber());
886 892
887 EXPECT_CALL(*mock_remote_processor(), 893 EXPECT_CALL(*mock_remote_processor(),
888 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _)) 894 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _))
889 .WillOnce(PrepareForRemoteChange_NotModified()); 895 .WillOnce(PrepareForRemoteChange_NotModified());
890 EXPECT_CALL(*mock_remote_processor(), 896 EXPECT_CALL(*mock_remote_processor(),
891 ClearLocalChanges(CreateURL(kOrigin, kFileName), _)) 897 ClearLocalChanges(CreateURL(kOrigin, kFileName), _))
892 .WillOnce(InvokeCompletionCallback()); 898 .WillOnce(InvokeCompletionCallback());
893 899
894 scoped_ptr<Value> file_entry(LoadJSONFile("gdata/file_entry.json").Pass()); 900 scoped_ptr<Value> file_entry_value(
901 LoadJSONFile("gdata/file_entry.json").Pass());
902 scoped_ptr<google_apis::ResourceEntry> file_entry
903 = google_apis::ResourceEntry::ExtractAndParse(*file_entry_value);
895 EXPECT_CALL(*mock_drive_service(), 904 EXPECT_CALL(*mock_drive_service(),
896 GetResourceEntry(kFileResourceId, _)) 905 GetResourceEntry(kFileResourceId, _))
897 .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, 906 .WillOnce(InvokeGetResourceEntryCallback1(
898 base::Passed(&file_entry))); 907 google_apis::HTTP_SUCCESS,
908 base::Passed(&file_entry)));
899 909
900 EXPECT_CALL(*mock_drive_service(), 910 EXPECT_CALL(*mock_drive_service(),
901 DownloadFile(_, _, GURL("https://file_content_url"), _, _)) 911 DownloadFile(_, _, GURL("https://file_content_url"), _, _))
902 .WillOnce(InvokeDidDownloadFile()); 912 .WillOnce(InvokeDidDownloadFile());
903 913
904 EXPECT_CALL(*mock_remote_processor(), 914 EXPECT_CALL(*mock_remote_processor(),
905 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _)) 915 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _))
906 .WillOnce(InvokeDidApplyRemoteChange()); 916 .WillOnce(InvokeDidApplyRemoteChange());
907 917
908 SetUpDriveSyncService(); 918 SetUpDriveSyncService();
909 919
910 scoped_ptr<ResourceEntry> entry(ResourceEntry::ExtractAndParse( 920 scoped_ptr<ResourceEntry> entry(ResourceEntry::ExtractAndParse(
911 *LoadJSONFile("gdata/file_entry.json"))); 921 *LoadJSONFile("gdata/file_entry.json")));
912 AppendIncrementalRemoteChange(kOrigin, *entry, 12345); 922 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
913 ProcessRemoteChange(fileapi::SYNC_STATUS_OK, 923 ProcessRemoteChange(fileapi::SYNC_STATUS_OK,
914 CreateURL(kOrigin, kFileName), 924 CreateURL(kOrigin, kFileName),
915 fileapi::SYNC_OPERATION_UPDATED); 925 fileapi::SYNC_OPERATION_UPDATED);
916 } 926 }
917 927
918 #endif // !defined(OS_ANDROID) 928 #endif // !defined(OS_ANDROID)
919 929
920 } // namespace sync_file_system 930 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698