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