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/chromeos/drive/sync_client.h" | 5 #include "chrome/browser/chromeos/drive/sync_client.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 sync_client_->AddUpdateTask(ClientContext(USER_INITIATED), local_id1); | 482 sync_client_->AddUpdateTask(ClientContext(USER_INITIATED), local_id1); |
483 base::RunLoop().RunUntilIdle(); | 483 base::RunLoop().RunUntilIdle(); |
484 | 484 |
485 // Both entries are synced. | 485 // Both entries are synced. |
486 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id1, &entry1)); | 486 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id1, &entry1)); |
487 EXPECT_EQ(ResourceEntry::CLEAN, entry1.metadata_edit_state()); | 487 EXPECT_EQ(ResourceEntry::CLEAN, entry1.metadata_edit_state()); |
488 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id2, &entry2)); | 488 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id2, &entry2)); |
489 EXPECT_EQ(ResourceEntry::CLEAN, entry2.metadata_edit_state()); | 489 EXPECT_EQ(ResourceEntry::CLEAN, entry2.metadata_edit_state()); |
490 } | 490 } |
491 | 491 |
| 492 TEST_F(SyncClientTest, WaitForUpdateTaskToComplete) { |
| 493 // Create a directory locally. |
| 494 const base::FilePath kPath(FILE_PATH_LITERAL("drive/root/dir1")); |
| 495 |
| 496 ResourceEntry parent; |
| 497 EXPECT_EQ(FILE_ERROR_OK, |
| 498 metadata_->GetResourceEntryByPath(kPath.DirName(), &parent)); |
| 499 |
| 500 ResourceEntry entry; |
| 501 entry.set_parent_local_id(parent.local_id()); |
| 502 entry.set_title(kPath.BaseName().AsUTF8Unsafe()); |
| 503 entry.mutable_file_info()->set_is_directory(true); |
| 504 entry.set_metadata_edit_state(ResourceEntry::DIRTY); |
| 505 std::string local_id; |
| 506 EXPECT_EQ(FILE_ERROR_OK, metadata_->AddEntry(entry, &local_id)); |
| 507 |
| 508 // Sync task is not yet avialable. |
| 509 FileError error = FILE_ERROR_FAILED; |
| 510 EXPECT_FALSE(sync_client_->WaitForUpdateTaskToComplete( |
| 511 local_id, google_apis::test_util::CreateCopyResultCallback(&error))); |
| 512 |
| 513 // Start syncing the directory and wait for it to complete. |
| 514 sync_client_->AddUpdateTask(ClientContext(USER_INITIATED), local_id); |
| 515 |
| 516 EXPECT_TRUE(sync_client_->WaitForUpdateTaskToComplete( |
| 517 local_id, google_apis::test_util::CreateCopyResultCallback(&error))); |
| 518 |
| 519 base::RunLoop().RunUntilIdle(); |
| 520 |
| 521 // The callback is called. |
| 522 EXPECT_EQ(FILE_ERROR_OK, error); |
| 523 } |
| 524 |
492 } // namespace internal | 525 } // namespace internal |
493 } // namespace drive | 526 } // namespace drive |
OLD | NEW |