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

Side by Side Diff: chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc

Issue 453843002: Add tests for sync performes about HTTP_FORBIDDEN handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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
« no previous file with comments | « chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/task_runner_util.h"
8 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" 8 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h"
9 #include "chrome/browser/chromeos/drive/file_system_util.h" 9 #include "chrome/browser/chromeos/drive/file_system_util.h"
10 #include "chrome/browser/chromeos/drive/job_scheduler.h" 10 #include "chrome/browser/chromeos/drive/job_scheduler.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 EXPECT_EQ(FILE_ERROR_OK, error); 141 EXPECT_EQ(FILE_ERROR_OK, error);
142 142
143 // Remove the entry. 143 // Remove the entry.
144 performer.Remove(local_id, ClientContext(USER_INITIATED), 144 performer.Remove(local_id, ClientContext(USER_INITIATED),
145 google_apis::test_util::CreateCopyResultCallback(&error)); 145 google_apis::test_util::CreateCopyResultCallback(&error));
146 content::RunAllBlockingPoolTasksUntilIdle(); 146 content::RunAllBlockingPoolTasksUntilIdle();
147 EXPECT_EQ(FILE_ERROR_OK, error); 147 EXPECT_EQ(FILE_ERROR_OK, error);
148 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntryById(local_id, &entry)); 148 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntryById(local_id, &entry));
149 } 149 }
150 150
151 TEST_F(RemovePerformerTest, Remove_InsufficientPermission) {
152 RemovePerformer performer(blocking_task_runner(), delegate(), scheduler(),
153 metadata());
154
155 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt"));
156
157 ResourceEntry src_entry;
158 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry));
159
160 // Remove locally.
161 ResourceEntry updated_entry(src_entry);
162 updated_entry.set_parent_local_id(util::kDriveTrashDirLocalId);
163
164 FileError error = FILE_ERROR_FAILED;
165 base::PostTaskAndReplyWithResult(
166 blocking_task_runner(),
167 FROM_HERE,
168 base::Bind(&ResourceMetadata::RefreshEntry,
169 base::Unretained(metadata()),
170 updated_entry),
171 google_apis::test_util::CreateCopyResultCallback(&error));
172 content::RunAllBlockingPoolTasksUntilIdle();
173 EXPECT_EQ(FILE_ERROR_OK, error);
174
175 // Set user permission to forbid server side update.
176 EXPECT_EQ(google_apis::HTTP_SUCCESS, fake_service()->SetUserPermission(
177 src_entry.resource_id(), google_apis::drive::PERMISSION_ROLE_READER));
178
179 // Try to perform remove.
180 error = FILE_ERROR_FAILED;
181 performer.Remove(src_entry.local_id(),
182 ClientContext(USER_INITIATED),
183 google_apis::test_util::CreateCopyResultCallback(&error));
184 content::RunAllBlockingPoolTasksUntilIdle();
185 EXPECT_EQ(FILE_ERROR_OK, error);
186
187 // This should result in reverting the local change.
188 ResourceEntry result_entry;
189 EXPECT_EQ(FILE_ERROR_OK,
190 GetLocalResourceEntryById(src_entry.local_id(), &result_entry));
191 EXPECT_EQ(src_entry.parent_local_id(), result_entry.parent_local_id());
192
193 ASSERT_EQ(1U, delegate()->drive_sync_errors().size());
194 EXPECT_EQ(file_system::DRIVE_SYNC_ERROR_DELETE_WITHOUT_PERMISSION,
195 delegate()->drive_sync_errors()[0]);
196 }
197
151 } // namespace internal 198 } // namespace internal
152 } // namespace drive 199 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/sync/entry_update_performer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698