OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/drive/sync/entry_update_performer.h" | 5 #include "chrome/browser/chromeos/drive/sync/entry_update_performer.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/md5.h" | 9 #include "base/md5.h" |
10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 scoped_ptr<google_apis::FileResource> server_entry; | 543 scoped_ptr<google_apis::FileResource> server_entry; |
544 fake_service()->GetFileResource( | 544 fake_service()->GetFileResource( |
545 entry.resource_id(), | 545 entry.resource_id(), |
546 google_apis::test_util::CreateCopyResultCallback(&status, &server_entry)); | 546 google_apis::test_util::CreateCopyResultCallback(&status, &server_entry)); |
547 test_util::RunBlockingPoolTask(); | 547 test_util::RunBlockingPoolTask(); |
548 EXPECT_EQ(google_apis::HTTP_SUCCESS, status); | 548 EXPECT_EQ(google_apis::HTTP_SUCCESS, status); |
549 ASSERT_TRUE(server_entry); | 549 ASSERT_TRUE(server_entry); |
550 EXPECT_TRUE(server_entry->IsDirectory()); | 550 EXPECT_TRUE(server_entry->IsDirectory()); |
551 } | 551 } |
552 | 552 |
| 553 TEST_F(EntryUpdatePerformerTest, ParentNeedsToBeSynced) { |
| 554 // Create new directories locally. |
| 555 const base::FilePath kPath(FILE_PATH_LITERAL("drive/root/New Directory")); |
| 556 const base::FilePath kChildPath( |
| 557 FILE_PATH_LITERAL("drive/root/New Directory/Sub Directory")); |
| 558 |
| 559 ResourceEntry parent; |
| 560 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kPath.DirName(), &parent)); |
| 561 |
| 562 ResourceEntry entry; |
| 563 entry.set_parent_local_id(parent.local_id()); |
| 564 entry.set_title(kPath.BaseName().AsUTF8Unsafe()); |
| 565 entry.mutable_file_info()->set_is_directory(true); |
| 566 entry.set_metadata_edit_state(ResourceEntry::DIRTY); |
| 567 |
| 568 FileError error = FILE_ERROR_FAILED; |
| 569 std::string local_id; |
| 570 base::PostTaskAndReplyWithResult( |
| 571 blocking_task_runner(), |
| 572 FROM_HERE, |
| 573 base::Bind(&internal::ResourceMetadata::AddEntry, |
| 574 base::Unretained(metadata()), |
| 575 entry, |
| 576 &local_id), |
| 577 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 578 test_util::RunBlockingPoolTask(); |
| 579 EXPECT_EQ(FILE_ERROR_OK, error); |
| 580 |
| 581 ResourceEntry child; |
| 582 child.set_parent_local_id(local_id); |
| 583 child.set_title(kChildPath.BaseName().AsUTF8Unsafe()); |
| 584 child.mutable_file_info()->set_is_directory(true); |
| 585 child.set_metadata_edit_state(ResourceEntry::DIRTY); |
| 586 |
| 587 error = FILE_ERROR_FAILED; |
| 588 std::string child_local_id; |
| 589 base::PostTaskAndReplyWithResult( |
| 590 blocking_task_runner(), |
| 591 FROM_HERE, |
| 592 base::Bind(&internal::ResourceMetadata::AddEntry, |
| 593 base::Unretained(metadata()), |
| 594 child, |
| 595 &child_local_id), |
| 596 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 597 test_util::RunBlockingPoolTask(); |
| 598 EXPECT_EQ(FILE_ERROR_OK, error); |
| 599 |
| 600 // Update the child. This should return a specific error code. |
| 601 error = FILE_ERROR_FAILED; |
| 602 performer_->UpdateEntry( |
| 603 child_local_id, |
| 604 ClientContext(USER_INITIATED), |
| 605 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 606 test_util::RunBlockingPoolTask(); |
| 607 EXPECT_EQ(FILE_ERROR_PARENT_NEEDS_TO_BE_SYNCED, error); |
| 608 } |
| 609 |
553 } // namespace internal | 610 } // namespace internal |
554 } // namespace drive | 611 } // namespace drive |
OLD | NEW |