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

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: modify comment 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 379
380 EXPECT_EQ("folder:sync_root_resource_id", 380 EXPECT_EQ("folder:sync_root_resource_id",
381 metadata_store()->sync_root_directory()); 381 metadata_store()->sync_root_directory());
382 382
383 EXPECT_EQ(0u, metadata_store()->batch_sync_origins().size()); 383 EXPECT_EQ(0u, metadata_store()->batch_sync_origins().size());
384 EXPECT_EQ(0u, metadata_store()->incremental_sync_origins().size()); 384 EXPECT_EQ(0u, metadata_store()->incremental_sync_origins().size());
385 EXPECT_EQ(0u, pending_changes().size()); 385 EXPECT_EQ(0u, pending_changes().size());
386 } 386 }
387 387
388 TEST_F(DriveFileSyncServiceTest, BatchSyncOnInitialization) { 388 TEST_F(DriveFileSyncServiceTest, BatchSyncOnInitialization) {
389 const GURL kOrigin1("http://example.com"); 389 const GURL kOrigin1("chrome-extension://example");
390 const GURL kOrigin2("http://hoge.example.com"); 390 const GURL kOrigin2("chrome-extension://example2");
391 const std::string kDirectoryResourceId1( 391 const std::string kDirectoryResourceId1(
392 "folder:origin_directory_resource_id"); 392 "folder:origin_directory_resource_id");
393 const std::string kDirectoryResourceId2( 393 const std::string kDirectoryResourceId2(
394 "folder:origin_directory_resource_id2"); 394 "folder:origin_directory_resource_id2");
395 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 395 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
396 396
397 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId); 397 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId);
398 metadata_store()->AddBatchSyncOrigin(kOrigin1, kDirectoryResourceId1); 398 metadata_store()->AddBatchSyncOrigin(kOrigin1, kDirectoryResourceId1);
399 metadata_store()->AddBatchSyncOrigin(kOrigin2, kDirectoryResourceId2); 399 metadata_store()->AddBatchSyncOrigin(kOrigin2, kDirectoryResourceId2);
400 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin2); 400 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin2);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // kOrigin1 should be a batch sync origin and kOrigin2 should be an 432 // kOrigin1 should be a batch sync origin and kOrigin2 should be an
433 // incremental sync origin. 433 // incremental sync origin.
434 // 4 pending remote changes are from listing_files_in_directory as batch sync 434 // 4 pending remote changes are from listing_files_in_directory as batch sync
435 // changes. 435 // changes.
436 EXPECT_EQ(1u, metadata_store()->batch_sync_origins().size()); 436 EXPECT_EQ(1u, metadata_store()->batch_sync_origins().size());
437 EXPECT_EQ(1u, metadata_store()->incremental_sync_origins().size()); 437 EXPECT_EQ(1u, metadata_store()->incremental_sync_origins().size());
438 EXPECT_EQ(4u, pending_changes().size()); 438 EXPECT_EQ(4u, pending_changes().size());
439 } 439 }
440 440
441 TEST_F(DriveFileSyncServiceTest, RegisterNewOrigin) { 441 TEST_F(DriveFileSyncServiceTest, RegisterNewOrigin) {
442 const GURL kOrigin("http://example.com"); 442 const GURL kOrigin("chrome-extension://example");
443 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 443 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
444 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 444 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
445 const GURL kSyncRootContentURL("https://sync_root_content_url/"); 445 const GURL kSyncRootContentURL("https://sync_root_content_url/");
446 446
447 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId); 447 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId);
448 448
449 EXPECT_CALL(*mock_remote_observer(), 449 EXPECT_CALL(*mock_remote_observer(),
450 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _)) 450 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _))
451 .Times(AtLeast(1)); 451 .Times(AtLeast(1));
452 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeAvailable(0)) 452 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeAvailable(0))
453 .Times(AnyNumber()); 453 .Times(AnyNumber());
454 454
455 InSequence sequence; 455 InSequence sequence;
456 456
457 scoped_ptr<Value> origin_directory_not_found(LoadJSONFile( 457 scoped_ptr<Value> origin_directory_not_found(LoadJSONFile(
458 "sync_file_system/origin_directory_not_found.json")); 458 "sync_file_system/origin_directory_not_found.json"));
459 std::string query = FormatTitleQuery(kOrigin.spec()); 459 std::string query = FormatTitleQuery(
460 DriveFileSyncClient::OriginToDirectoryTitle(kOrigin));
460 461
461 EXPECT_CALL(*mock_drive_service(), 462 EXPECT_CALL(*mock_drive_service(),
462 GetDocuments(GURL(), 0, query, false, kSyncRootResourceId, _)) 463 GetDocuments(GURL(), 0, query, false, kSyncRootResourceId, _))
463 .WillOnce(InvokeGetDataCallback5( 464 .WillOnce(InvokeGetDataCallback5(
464 google_apis::HTTP_SUCCESS, 465 google_apis::HTTP_SUCCESS,
465 base::Passed(&origin_directory_not_found))) 466 base::Passed(&origin_directory_not_found)))
466 .RetiresOnSaturation(); 467 .RetiresOnSaturation();
467 468
468 // If the directory for the origin is missing, DriveFileSyncService should 469 // If the directory for the origin is missing, DriveFileSyncService should
469 // attempt to create it. And as a preparation, it should fetch the content url 470 // attempt to create it. And as a preparation, it should fetch the content url
470 // of the parent directory. 471 // of the parent directory.
471 // 472 //
472 // |sync_root_entry| contains kSyncRootContentURL which is to be added as 473 // |sync_root_entry| contains kSyncRootContentURL which is to be added as
473 // a new origin directory under the root directory. 474 // a new origin directory under the root directory.
474 scoped_ptr<Value> sync_root_entry(LoadJSONFile( 475 scoped_ptr<Value> sync_root_entry(LoadJSONFile(
475 "sync_file_system/sync_root_entry.json")); 476 "sync_file_system/sync_root_entry.json"));
476 EXPECT_CALL(*mock_drive_service(), 477 EXPECT_CALL(*mock_drive_service(),
477 GetDocumentEntry(kSyncRootResourceId, _)) 478 GetDocumentEntry(kSyncRootResourceId, _))
478 .WillOnce(InvokeGetDataCallback1( 479 .WillOnce(InvokeGetDataCallback1(
479 google_apis::HTTP_SUCCESS, 480 google_apis::HTTP_SUCCESS,
480 base::Passed(&sync_root_entry))); 481 base::Passed(&sync_root_entry)));
481 482
482 scoped_ptr<Value> origin_directory_created(LoadJSONFile( 483 scoped_ptr<Value> origin_directory_created(LoadJSONFile(
483 "sync_file_system/origin_directory_created.json")); 484 "sync_file_system/origin_directory_created.json"));
484 FilePath::StringType dirname = 485 FilePath::StringType dirname = FilePath().AppendASCII(
485 FilePath().AppendASCII(kOrigin.spec()).value(); 486 DriveFileSyncClient::OriginToDirectoryTitle(kOrigin)).value();
486 EXPECT_CALL(*mock_drive_service(), 487 EXPECT_CALL(*mock_drive_service(),
487 AddNewDirectory(kSyncRootContentURL, dirname, _)) 488 AddNewDirectory(kSyncRootContentURL, dirname, _))
488 .WillOnce(InvokeGetDataCallback2( 489 .WillOnce(InvokeGetDataCallback2(
489 google_apis::HTTP_SUCCESS, 490 google_apis::HTTP_SUCCESS,
490 base::Passed(&origin_directory_created))); 491 base::Passed(&origin_directory_created)));
491 492
492 // Once the directory is created GetAccountMetadata should be called to get 493 // Once the directory is created GetAccountMetadata should be called to get
493 // the largest changestamp for the origin as a prepariation of the batch sync. 494 // the largest changestamp for the origin as a prepariation of the batch sync.
494 scoped_ptr<Value> account_metadata(LoadJSONFile( 495 scoped_ptr<Value> account_metadata(LoadJSONFile(
495 "gdata/account_metadata.json")); 496 "gdata/account_metadata.json"));
(...skipping 17 matching lines...) Expand all
513 kOrigin, base::Bind(&ExpectEqStatus, &done, fileapi::SYNC_STATUS_OK)); 514 kOrigin, base::Bind(&ExpectEqStatus, &done, fileapi::SYNC_STATUS_OK));
514 message_loop()->RunUntilIdle(); 515 message_loop()->RunUntilIdle();
515 EXPECT_TRUE(done); 516 EXPECT_TRUE(done);
516 517
517 EXPECT_EQ(1u, metadata_store()->batch_sync_origins().size()); 518 EXPECT_EQ(1u, metadata_store()->batch_sync_origins().size());
518 EXPECT_TRUE(metadata_store()->incremental_sync_origins().empty()); 519 EXPECT_TRUE(metadata_store()->incremental_sync_origins().empty());
519 EXPECT_TRUE(pending_changes().empty()); 520 EXPECT_TRUE(pending_changes().empty());
520 } 521 }
521 522
522 TEST_F(DriveFileSyncServiceTest, RegisterExistingOrigin) { 523 TEST_F(DriveFileSyncServiceTest, RegisterExistingOrigin) {
523 const GURL kOrigin("http://example.com"); 524 const GURL kOrigin("chrome-extension://example");
524 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 525 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
525 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 526 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
526 527
527 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId); 528 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId);
528 529
529 EXPECT_CALL(*mock_remote_observer(), 530 EXPECT_CALL(*mock_remote_observer(),
530 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _)) 531 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _))
531 .Times(AtLeast(1)); 532 .Times(AtLeast(1));
532 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeAvailable(4)) 533 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeAvailable(_))
533 .Times(AnyNumber()); 534 .Times(AnyNumber());
534 535
535 InSequence sequence; 536 InSequence sequence;
536 537
537 scoped_ptr<Value> origin_directory_found(LoadJSONFile( 538 scoped_ptr<Value> origin_directory_found(LoadJSONFile(
538 "sync_file_system/origin_directory_found.json")); 539 "sync_file_system/origin_directory_found.json"));
539 std::string query = FormatTitleQuery("http://example.com/"); 540 std::string query = FormatTitleQuery(
541 DriveFileSyncClient::OriginToDirectoryTitle(kOrigin));
540 EXPECT_CALL(*mock_drive_service(), 542 EXPECT_CALL(*mock_drive_service(),
541 GetDocuments(GURL(), 0, query, false, kSyncRootResourceId, _)) 543 GetDocuments(GURL(), 0, query, false, kSyncRootResourceId, _))
542 .WillOnce(InvokeGetDataCallback5( 544 .WillOnce(InvokeGetDataCallback5(
543 google_apis::HTTP_SUCCESS, 545 google_apis::HTTP_SUCCESS,
544 base::Passed(&origin_directory_found))) 546 base::Passed(&origin_directory_found)))
545 .RetiresOnSaturation(); 547 .RetiresOnSaturation();
546 548
547 scoped_ptr<Value> account_metadata(LoadJSONFile( 549 scoped_ptr<Value> account_metadata(LoadJSONFile(
548 "gdata/account_metadata.json")); 550 "gdata/account_metadata.json"));
549 EXPECT_CALL(*mock_drive_service(), GetAccountMetadata(_)) 551 EXPECT_CALL(*mock_drive_service(), GetAccountMetadata(_))
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 message_loop()->RunUntilIdle(); 631 message_loop()->RunUntilIdle();
630 EXPECT_TRUE(done); 632 EXPECT_TRUE(done);
631 633
632 EXPECT_TRUE(metadata_store()->batch_sync_origins().empty()); 634 EXPECT_TRUE(metadata_store()->batch_sync_origins().empty());
633 EXPECT_EQ(1u, metadata_store()->incremental_sync_origins().size()); 635 EXPECT_EQ(1u, metadata_store()->incremental_sync_origins().size());
634 EXPECT_TRUE(pending_changes().empty()); 636 EXPECT_TRUE(pending_changes().empty());
635 } 637 }
636 638
637 TEST_F(DriveFileSyncServiceTest, ResolveSyncOperationType) { 639 TEST_F(DriveFileSyncServiceTest, ResolveSyncOperationType) {
638 const fileapi::FileSystemURL url = fileapi::CreateSyncableFileSystemURL( 640 const fileapi::FileSystemURL url = fileapi::CreateSyncableFileSystemURL(
639 GURL("http://example.com/"), 641 GURL("chrome-extension://example/"),
640 DriveFileSyncService::kServiceName, 642 DriveFileSyncService::kServiceName,
641 FilePath().AppendASCII("path/to/file")); 643 FilePath().AppendASCII("path/to/file"));
642 const std::string kResourceId("123456"); 644 const std::string kResourceId("123456");
643 const int64 kChangestamp = 654321; 645 const int64 kChangestamp = 654321;
644 646
645 scoped_ptr<Value> sync_root_found(LoadJSONFile( 647 scoped_ptr<Value> sync_root_found(LoadJSONFile(
646 "sync_file_system/sync_root_found.json")); 648 "sync_file_system/sync_root_found.json"));
647 std::string query = FormatTitleQuery(kSyncRootDirectoryName); 649 std::string query = FormatTitleQuery(kSyncRootDirectoryName);
648 EXPECT_CALL(*mock_drive_service(), 650 EXPECT_CALL(*mock_drive_service(),
649 GetDocuments(GURL(), 0, query, false, std::string(), _)) 651 GetDocuments(GURL(), 0, query, false, std::string(), _))
650 .WillOnce(InvokeGetDataCallback5( 652 .WillOnce(InvokeGetDataCallback5(
651 google_apis::HTTP_SUCCESS, 653 google_apis::HTTP_SUCCESS,
652 base::Passed(&sync_root_found))); 654 base::Passed(&sync_root_found)));
653 655
654 EXPECT_CALL(*mock_remote_observer(), 656 EXPECT_CALL(*mock_remote_observer(),
655 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _)) 657 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _))
656 .Times(1); 658 .Times(1);
659 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeAvailable(_))
660 .Times(AnyNumber());
657 661
658 SetUpDriveSyncService(); 662 SetUpDriveSyncService();
659 message_loop()->RunUntilIdle(); 663 message_loop()->RunUntilIdle();
660 664
661 const fileapi::FileChange local_add_or_update_change( 665 const fileapi::FileChange local_add_or_update_change(
662 fileapi::FileChange::FILE_CHANGE_ADD_OR_UPDATE, 666 fileapi::FileChange::FILE_CHANGE_ADD_OR_UPDATE,
663 fileapi::SYNC_FILE_TYPE_FILE); 667 fileapi::SYNC_FILE_TYPE_FILE);
664 const fileapi::FileChange local_delete_change( 668 const fileapi::FileChange local_delete_change(
665 fileapi::FileChange::FILE_CHANGE_DELETE, 669 fileapi::FileChange::FILE_CHANGE_DELETE,
666 fileapi::SYNC_FILE_TYPE_FILE); 670 fileapi::SYNC_FILE_TYPE_FILE);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 731
728 ProcessRemoteChange(fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC, 732 ProcessRemoteChange(fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC,
729 fileapi::FileSystemURL(), 733 fileapi::FileSystemURL(),
730 fileapi::SYNC_OPERATION_NONE); 734 fileapi::SYNC_OPERATION_NONE);
731 EXPECT_TRUE(metadata_store()->batch_sync_origins().empty()); 735 EXPECT_TRUE(metadata_store()->batch_sync_origins().empty());
732 EXPECT_TRUE(metadata_store()->incremental_sync_origins().empty()); 736 EXPECT_TRUE(metadata_store()->incremental_sync_origins().empty());
733 EXPECT_TRUE(pending_changes().empty()); 737 EXPECT_TRUE(pending_changes().empty());
734 } 738 }
735 739
736 TEST_F(DriveFileSyncServiceTest, RemoteChange_Busy) { 740 TEST_F(DriveFileSyncServiceTest, RemoteChange_Busy) {
737 const GURL kOrigin("chrome-extension://example.com"); 741 const GURL kOrigin("chrome-extension://example");
738 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 742 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
739 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 743 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
740 const FilePath::StringType kFileName(FPL("File 1.mp3")); 744 const FilePath::StringType kFileName(FPL("File 1.mp3"));
741 745
742 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId); 746 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId);
743 metadata_store()->AddBatchSyncOrigin(kOrigin, kDirectoryResourceId); 747 metadata_store()->AddBatchSyncOrigin(kOrigin, kDirectoryResourceId);
744 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin); 748 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin);
745 749
746 EXPECT_CALL(*mock_remote_observer(), 750 EXPECT_CALL(*mock_remote_observer(),
747 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _)) 751 OnRemoteServiceStateUpdated(REMOTE_SERVICE_OK, _))
748 .Times(AnyNumber()); 752 .Times(AnyNumber());
749 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeAvailable(_)) 753 EXPECT_CALL(*mock_remote_observer(), OnRemoteChangeAvailable(_))
750 .Times(AnyNumber()); 754 .Times(AnyNumber());
751 755
752 EXPECT_CALL(*mock_remote_processor(), 756 EXPECT_CALL(*mock_remote_processor(),
753 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _)) 757 PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _))
754 .WillOnce(PrepareForRemoteChange_Busy()); 758 .WillOnce(PrepareForRemoteChange_Busy());
755 759
756 SetUpDriveSyncService(); 760 SetUpDriveSyncService();
757 761
758 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( 762 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse(
759 *LoadJSONFile("gdata/file_entry.json"))); 763 *LoadJSONFile("gdata/file_entry.json")));
760 AppendIncrementalRemoteChange(kOrigin, entry.get(), 12345); 764 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
761 765
762 ProcessRemoteChange(fileapi::SYNC_STATUS_FILE_BUSY, 766 ProcessRemoteChange(fileapi::SYNC_STATUS_FILE_BUSY,
763 CreateURL(kOrigin, kFileName), 767 CreateURL(kOrigin, kFileName),
764 fileapi::SYNC_OPERATION_NONE); 768 fileapi::SYNC_OPERATION_NONE);
765 } 769 }
766 770
767 TEST_F(DriveFileSyncServiceTest, RemoteChange_NewFile) { 771 TEST_F(DriveFileSyncServiceTest, RemoteChange_NewFile) {
768 const GURL kOrigin("chrome-extension://example.com"); 772 const GURL kOrigin("chrome-extension://example");
769 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 773 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
770 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 774 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
771 const FilePath::StringType kFileName(FPL("File 1.mp3")); 775 const FilePath::StringType kFileName(FPL("File 1.mp3"));
772 const std::string kFileResourceId("file:2_file_resource_id"); 776 const std::string kFileResourceId("file:2_file_resource_id");
773 777
774 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId); 778 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId);
775 metadata_store()->AddBatchSyncOrigin(kOrigin, kDirectoryResourceId); 779 metadata_store()->AddBatchSyncOrigin(kOrigin, kDirectoryResourceId);
776 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin); 780 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin);
777 781
778 EXPECT_CALL(*mock_remote_observer(), 782 EXPECT_CALL(*mock_remote_observer(),
(...skipping 17 matching lines...) Expand all
796 .WillOnce(InvokeDidDownloadFile()); 800 .WillOnce(InvokeDidDownloadFile());
797 801
798 EXPECT_CALL(*mock_remote_processor(), 802 EXPECT_CALL(*mock_remote_processor(),
799 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _)) 803 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _))
800 .WillOnce(InvokeDidApplyRemoteChange()); 804 .WillOnce(InvokeDidApplyRemoteChange());
801 805
802 SetUpDriveSyncService(); 806 SetUpDriveSyncService();
803 807
804 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( 808 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse(
805 *LoadJSONFile("gdata/file_entry.json"))); 809 *LoadJSONFile("gdata/file_entry.json")));
806 AppendIncrementalRemoteChange(kOrigin, entry.get(), 12345); 810 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
807 811
808 ProcessRemoteChange(fileapi::SYNC_STATUS_OK, 812 ProcessRemoteChange(fileapi::SYNC_STATUS_OK,
809 CreateURL(kOrigin, kFileName), 813 CreateURL(kOrigin, kFileName),
810 fileapi::SYNC_OPERATION_ADD); 814 fileapi::SYNC_OPERATION_ADD);
811 } 815 }
812 816
813 TEST_F(DriveFileSyncServiceTest, RemoteChange_UpdateFile) { 817 TEST_F(DriveFileSyncServiceTest, RemoteChange_UpdateFile) {
814 const GURL kOrigin("chrome-extension://example.com"); 818 const GURL kOrigin("chrome-extension://example");
815 const std::string kDirectoryResourceId("folder:origin_directory_resource_id"); 819 const std::string kDirectoryResourceId("folder:origin_directory_resource_id");
816 const std::string kSyncRootResourceId("folder:sync_root_resource_id"); 820 const std::string kSyncRootResourceId("folder:sync_root_resource_id");
817 const FilePath::StringType kFileName(FPL("File 1.mp3")); 821 const FilePath::StringType kFileName(FPL("File 1.mp3"));
818 const std::string kFileResourceId("file:2_file_resource_id"); 822 const std::string kFileResourceId("file:2_file_resource_id");
819 823
820 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId); 824 metadata_store()->SetSyncRootDirectory(kSyncRootResourceId);
821 metadata_store()->AddBatchSyncOrigin(kOrigin, kDirectoryResourceId); 825 metadata_store()->AddBatchSyncOrigin(kOrigin, kDirectoryResourceId);
822 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin); 826 metadata_store()->MoveBatchSyncOriginToIncremental(kOrigin);
823 827
824 EXPECT_CALL(*mock_remote_observer(), 828 EXPECT_CALL(*mock_remote_observer(),
(...skipping 17 matching lines...) Expand all
842 .WillOnce(InvokeDidDownloadFile()); 846 .WillOnce(InvokeDidDownloadFile());
843 847
844 EXPECT_CALL(*mock_remote_processor(), 848 EXPECT_CALL(*mock_remote_processor(),
845 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _)) 849 ApplyRemoteChange(_, _, CreateURL(kOrigin, kFileName), _))
846 .WillOnce(InvokeDidApplyRemoteChange()); 850 .WillOnce(InvokeDidApplyRemoteChange());
847 851
848 SetUpDriveSyncService(); 852 SetUpDriveSyncService();
849 853
850 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( 854 scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse(
851 *LoadJSONFile("gdata/file_entry.json"))); 855 *LoadJSONFile("gdata/file_entry.json")));
852 AppendIncrementalRemoteChange(kOrigin, entry.get(), 12345); 856 AppendIncrementalRemoteChange(kOrigin, *entry, 12345);
853 ProcessRemoteChange(fileapi::SYNC_STATUS_OK, 857 ProcessRemoteChange(fileapi::SYNC_STATUS_OK,
854 CreateURL(kOrigin, kFileName), 858 CreateURL(kOrigin, kFileName),
855 fileapi::SYNC_OPERATION_UPDATE); 859 fileapi::SYNC_OPERATION_UPDATE);
856 } 860 }
857 861
858 #endif // !defined(OS_ANDROID) 862 #endif // !defined(OS_ANDROID)
859 863
860 } // namespace sync_file_system 864 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698