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

Side by Side Diff: chrome/browser/chromeos/drive/sync/entry_update_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 | « no previous file | chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc » ('j') | 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/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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 scoped_ptr<google_apis::FileResource> server_entry; 544 scoped_ptr<google_apis::FileResource> server_entry;
545 fake_service()->GetFileResource( 545 fake_service()->GetFileResource(
546 entry.resource_id(), 546 entry.resource_id(),
547 google_apis::test_util::CreateCopyResultCallback(&status, &server_entry)); 547 google_apis::test_util::CreateCopyResultCallback(&status, &server_entry));
548 content::RunAllBlockingPoolTasksUntilIdle(); 548 content::RunAllBlockingPoolTasksUntilIdle();
549 EXPECT_EQ(google_apis::HTTP_SUCCESS, status); 549 EXPECT_EQ(google_apis::HTTP_SUCCESS, status);
550 ASSERT_TRUE(server_entry); 550 ASSERT_TRUE(server_entry);
551 EXPECT_TRUE(server_entry->IsDirectory()); 551 EXPECT_TRUE(server_entry->IsDirectory());
552 } 552 }
553 553
554 TEST_F(EntryUpdatePerformerTest, UpdateEntry_InsufficientPermission) {
555 base::FilePath src_path(
556 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
557
558 ResourceEntry src_entry;
559 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry));
560
561 // Update local entry.
562 ResourceEntry updated_entry(src_entry);
563 updated_entry.set_title("Moved" + src_entry.title());
564 updated_entry.set_metadata_edit_state(ResourceEntry::DIRTY);
565
566 FileError error = FILE_ERROR_FAILED;
567 base::PostTaskAndReplyWithResult(
568 blocking_task_runner(),
569 FROM_HERE,
570 base::Bind(&ResourceMetadata::RefreshEntry,
571 base::Unretained(metadata()),
572 updated_entry),
573 google_apis::test_util::CreateCopyResultCallback(&error));
574 content::RunAllBlockingPoolTasksUntilIdle();
575 EXPECT_EQ(FILE_ERROR_OK, error);
576
577 // Set user permission to forbid server side update.
578 EXPECT_EQ(google_apis::HTTP_SUCCESS, fake_service()->SetUserPermission(
579 src_entry.resource_id(), google_apis::drive::PERMISSION_ROLE_READER));
580
581 // Try to perform update.
582 error = FILE_ERROR_FAILED;
583 performer_->UpdateEntry(
584 src_entry.local_id(),
585 ClientContext(USER_INITIATED),
586 google_apis::test_util::CreateCopyResultCallback(&error));
587 content::RunAllBlockingPoolTasksUntilIdle();
588 EXPECT_EQ(FILE_ERROR_OK, error);
589
590 // This should result in reverting the local change.
591 ResourceEntry result_entry;
592 EXPECT_EQ(FILE_ERROR_OK,
593 GetLocalResourceEntryById(src_entry.local_id(), &result_entry));
594 EXPECT_EQ(src_entry.title(), result_entry.title());
595 }
596
554 } // namespace internal 597 } // namespace internal
555 } // namespace drive 598 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/sync/remove_performer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698