| 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/remove_performer.h" | 5 #include "chrome/browser/chromeos/drive/sync/remove_performer.h" |
| 6 | 6 |
| 7 #include "base/task_runner_util.h" |
| 7 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" | 8 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
| 8 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 9 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 10 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 9 #include "chrome/browser/drive/fake_drive_service.h" | 11 #include "chrome/browser/drive/fake_drive_service.h" |
| 10 #include "google_apis/drive/gdata_wapi_parser.h" | 12 #include "google_apis/drive/gdata_wapi_parser.h" |
| 11 #include "google_apis/drive/test_util.h" | 13 #include "google_apis/drive/test_util.h" |
| 12 | 14 |
| 13 namespace drive { | 15 namespace drive { |
| 14 namespace internal { | 16 namespace internal { |
| 15 | 17 |
| 16 typedef file_system::OperationTestBase RemovePerformerTest; | 18 typedef file_system::OperationTestBase RemovePerformerTest; |
| 17 | 19 |
| 18 TEST_F(RemovePerformerTest, RemoveFile) { | 20 TEST_F(RemovePerformerTest, RemoveFile) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 fake_service()->GetResourceEntry( | 109 fake_service()->GetResourceEntry( |
| 108 resource_id, | 110 resource_id, |
| 109 google_apis::test_util::CreateCopyResultCallback(&gdata_error, | 111 google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
| 110 &gdata_entry)); | 112 &gdata_entry)); |
| 111 test_util::RunBlockingPoolTask(); | 113 test_util::RunBlockingPoolTask(); |
| 112 ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error); | 114 ASSERT_EQ(google_apis::HTTP_SUCCESS, gdata_error); |
| 113 EXPECT_FALSE(gdata_entry->deleted()); // It's not deleted. | 115 EXPECT_FALSE(gdata_entry->deleted()); // It's not deleted. |
| 114 EXPECT_FALSE(gdata_entry->GetLinkByType(google_apis::Link::LINK_PARENT)); | 116 EXPECT_FALSE(gdata_entry->GetLinkByType(google_apis::Link::LINK_PARENT)); |
| 115 } | 117 } |
| 116 | 118 |
| 119 TEST_F(RemovePerformerTest, RemoveLocallyCreatedFile) { |
| 120 RemovePerformer performer(blocking_task_runner(), observer(), scheduler(), |
| 121 metadata()); |
| 122 |
| 123 // Add an entry without resource ID. |
| 124 ResourceEntry entry; |
| 125 entry.set_title("New File.txt"); |
| 126 entry.set_parent_local_id(util::kDriveTrashDirLocalId); |
| 127 |
| 128 FileError error = FILE_ERROR_FAILED; |
| 129 std::string local_id; |
| 130 base::PostTaskAndReplyWithResult( |
| 131 blocking_task_runner(), |
| 132 FROM_HERE, |
| 133 base::Bind(&ResourceMetadata::AddEntry, |
| 134 base::Unretained(metadata()), |
| 135 entry, |
| 136 &local_id), |
| 137 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 138 test_util::RunBlockingPoolTask(); |
| 139 EXPECT_EQ(FILE_ERROR_OK, error); |
| 140 |
| 141 // Remove the entry. |
| 142 performer.Remove(local_id, ClientContext(USER_INITIATED), |
| 143 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 144 test_util::RunBlockingPoolTask(); |
| 145 EXPECT_EQ(FILE_ERROR_OK, error); |
| 146 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntryById(local_id, &entry)); |
| 147 } |
| 148 |
| 117 } // namespace internal | 149 } // namespace internal |
| 118 } // namespace drive | 150 } // namespace drive |
| OLD | NEW |