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

Side by Side Diff: chrome/browser/chromeos/drive/file_system/move_operation_unittest.cc

Issue 408143014: Rename OperationObserver to OperationDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
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/file_system/move_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/move_operation.h"
6 6
7 #include "chrome/browser/chromeos/drive/file_change.h" 7 #include "chrome/browser/chromeos/drive/file_change.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 "content/public/test/test_utils.h" 9 #include "content/public/test/test_utils.h"
10 #include "google_apis/drive/test_util.h" 10 #include "google_apis/drive/test_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace drive { 13 namespace drive {
14 namespace file_system { 14 namespace file_system {
15 15
16 class MoveOperationTest : public OperationTestBase { 16 class MoveOperationTest : public OperationTestBase {
17 protected: 17 protected:
18 virtual void SetUp() OVERRIDE { 18 virtual void SetUp() OVERRIDE {
19 OperationTestBase::SetUp(); 19 OperationTestBase::SetUp();
20 operation_.reset(new MoveOperation(blocking_task_runner(), 20 operation_.reset(new MoveOperation(blocking_task_runner(),
21 observer(), 21 delegate(),
22 metadata())); 22 metadata()));
23 } 23 }
24 24
25 scoped_ptr<MoveOperation> operation_; 25 scoped_ptr<MoveOperation> operation_;
26 }; 26 };
27 27
28 TEST_F(MoveOperationTest, MoveFileInSameDirectory) { 28 TEST_F(MoveOperationTest, MoveFileInSameDirectory) {
29 const base::FilePath src_path( 29 const base::FilePath src_path(
30 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); 30 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
31 const base::FilePath dest_path( 31 const base::FilePath dest_path(
32 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); 32 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log"));
33 33
34 ResourceEntry src_entry, dest_entry; 34 ResourceEntry src_entry, dest_entry;
35 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry)); 35 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry));
36 ASSERT_EQ(FILE_ERROR_NOT_FOUND, 36 ASSERT_EQ(FILE_ERROR_NOT_FOUND,
37 GetLocalResourceEntry(dest_path, &dest_entry)); 37 GetLocalResourceEntry(dest_path, &dest_entry));
38 38
39 FileError error = FILE_ERROR_FAILED; 39 FileError error = FILE_ERROR_FAILED;
40 operation_->Move(src_path, 40 operation_->Move(src_path,
41 dest_path, 41 dest_path,
42 google_apis::test_util::CreateCopyResultCallback(&error)); 42 google_apis::test_util::CreateCopyResultCallback(&error));
43 content::RunAllBlockingPoolTasksUntilIdle(); 43 content::RunAllBlockingPoolTasksUntilIdle();
44 EXPECT_EQ(FILE_ERROR_OK, error); 44 EXPECT_EQ(FILE_ERROR_OK, error);
45 45
46 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 46 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
47 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id()); 47 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id());
48 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 48 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
49 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry)); 49 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry));
50 50
51 EXPECT_EQ(2U, observer()->get_changed_files().size()); 51 EXPECT_EQ(2U, delegate()->get_changed_files().size());
52 EXPECT_TRUE(observer()->get_changed_files().count(src_path)); 52 EXPECT_TRUE(delegate()->get_changed_files().count(src_path));
53 EXPECT_TRUE(observer()->get_changed_files().count(dest_path)); 53 EXPECT_TRUE(delegate()->get_changed_files().count(dest_path));
54 54
55 EXPECT_EQ(1U, observer()->updated_local_ids().size()); 55 EXPECT_EQ(1U, delegate()->updated_local_ids().size());
56 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id())); 56 EXPECT_TRUE(delegate()->updated_local_ids().count(src_entry.local_id()));
57 } 57 }
58 58
59 TEST_F(MoveOperationTest, MoveFileFromRootToSubDirectory) { 59 TEST_F(MoveOperationTest, MoveFileFromRootToSubDirectory) {
60 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); 60 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt"));
61 base::FilePath dest_path( 61 base::FilePath dest_path(
62 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); 62 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log"));
63 63
64 ResourceEntry src_entry, dest_entry; 64 ResourceEntry src_entry, dest_entry;
65 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry)); 65 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry));
66 ASSERT_EQ(FILE_ERROR_NOT_FOUND, 66 ASSERT_EQ(FILE_ERROR_NOT_FOUND,
67 GetLocalResourceEntry(dest_path, &dest_entry)); 67 GetLocalResourceEntry(dest_path, &dest_entry));
68 68
69 FileError error = FILE_ERROR_FAILED; 69 FileError error = FILE_ERROR_FAILED;
70 operation_->Move(src_path, 70 operation_->Move(src_path,
71 dest_path, 71 dest_path,
72 google_apis::test_util::CreateCopyResultCallback(&error)); 72 google_apis::test_util::CreateCopyResultCallback(&error));
73 content::RunAllBlockingPoolTasksUntilIdle(); 73 content::RunAllBlockingPoolTasksUntilIdle();
74 EXPECT_EQ(FILE_ERROR_OK, error); 74 EXPECT_EQ(FILE_ERROR_OK, error);
75 75
76 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 76 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
77 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id()); 77 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id());
78 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 78 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
79 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry)); 79 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry));
80 80
81 EXPECT_EQ(2U, observer()->get_changed_files().size()); 81 EXPECT_EQ(2U, delegate()->get_changed_files().size());
82 EXPECT_TRUE(observer()->get_changed_files().count(src_path)); 82 EXPECT_TRUE(delegate()->get_changed_files().count(src_path));
83 EXPECT_TRUE(observer()->get_changed_files().count(dest_path)); 83 EXPECT_TRUE(delegate()->get_changed_files().count(dest_path));
84 84
85 EXPECT_EQ(1U, observer()->updated_local_ids().size()); 85 EXPECT_EQ(1U, delegate()->updated_local_ids().size());
86 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id())); 86 EXPECT_TRUE(delegate()->updated_local_ids().count(src_entry.local_id()));
87 } 87 }
88 88
89 TEST_F(MoveOperationTest, MoveNotExistingFile) { 89 TEST_F(MoveOperationTest, MoveNotExistingFile) {
90 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); 90 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt"));
91 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log")); 91 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log"));
92 92
93 FileError error = FILE_ERROR_OK; 93 FileError error = FILE_ERROR_OK;
94 operation_->Move(src_path, 94 operation_->Move(src_path,
95 dest_path, 95 dest_path,
96 google_apis::test_util::CreateCopyResultCallback(&error)); 96 google_apis::test_util::CreateCopyResultCallback(&error));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 content::RunAllBlockingPoolTasksUntilIdle(); 132 content::RunAllBlockingPoolTasksUntilIdle();
133 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); 133 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error);
134 134
135 ResourceEntry entry; 135 ResourceEntry entry;
136 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); 136 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry));
137 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); 137 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry));
138 } 138 }
139 139
140 } // namespace file_system 140 } // namespace file_system
141 } // namespace drive 141 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698