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

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

Issue 100373004: drive: Check OperationObserver::OnEntryUpdatedByOperation is called by MoveOperation in tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | 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/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_system/copy_operation.h" 7 #include "chrome/browser/chromeos/drive/file_system/copy_operation.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/drive/fake_drive_service.h" 9 #include "chrome/browser/drive/fake_drive_service.h"
10 #include "google_apis/drive/test_util.h" 10 #include "google_apis/drive/test_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 test_util::RunBlockingPoolTask(); 52 test_util::RunBlockingPoolTask();
53 EXPECT_EQ(FILE_ERROR_OK, error); 53 EXPECT_EQ(FILE_ERROR_OK, error);
54 54
55 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 55 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
56 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id()); 56 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id());
57 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 57 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
58 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry)); 58 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry));
59 59
60 EXPECT_EQ(1U, observer()->get_changed_paths().size()); 60 EXPECT_EQ(1U, observer()->get_changed_paths().size());
61 EXPECT_TRUE(observer()->get_changed_paths().count(src_path.DirName())); 61 EXPECT_TRUE(observer()->get_changed_paths().count(src_path.DirName()));
62
63 EXPECT_EQ(1U, observer()->updated_local_ids().size());
64 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id()));
62 } 65 }
63 66
64 TEST_F(MoveOperationTest, MoveFileFromRootToSubDirectory) { 67 TEST_F(MoveOperationTest, MoveFileFromRootToSubDirectory) {
65 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); 68 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt"));
66 base::FilePath dest_path( 69 base::FilePath dest_path(
67 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); 70 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log"));
68 71
69 ResourceEntry src_entry, dest_entry; 72 ResourceEntry src_entry, dest_entry;
70 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry)); 73 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry));
71 ASSERT_EQ(FILE_ERROR_NOT_FOUND, 74 ASSERT_EQ(FILE_ERROR_NOT_FOUND,
72 GetLocalResourceEntry(dest_path, &dest_entry)); 75 GetLocalResourceEntry(dest_path, &dest_entry));
73 76
74 FileError error = FILE_ERROR_FAILED; 77 FileError error = FILE_ERROR_FAILED;
75 operation_->Move(src_path, 78 operation_->Move(src_path,
76 dest_path, 79 dest_path,
77 false, 80 false,
78 google_apis::test_util::CreateCopyResultCallback(&error)); 81 google_apis::test_util::CreateCopyResultCallback(&error));
79 test_util::RunBlockingPoolTask(); 82 test_util::RunBlockingPoolTask();
80 EXPECT_EQ(FILE_ERROR_OK, error); 83 EXPECT_EQ(FILE_ERROR_OK, error);
81 84
82 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 85 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
83 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id()); 86 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id());
84 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 87 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
85 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry)); 88 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry));
86 89
87 EXPECT_EQ(2U, observer()->get_changed_paths().size()); 90 EXPECT_EQ(2U, observer()->get_changed_paths().size());
88 EXPECT_TRUE(observer()->get_changed_paths().count(src_path.DirName())); 91 EXPECT_TRUE(observer()->get_changed_paths().count(src_path.DirName()));
89 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName())); 92 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName()));
93
94 EXPECT_EQ(1U, observer()->updated_local_ids().size());
95 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id()));
90 } 96 }
91 97
92 TEST_F(MoveOperationTest, MoveFileBetweenSubDirectoriesRenameWithTitle) { 98 TEST_F(MoveOperationTest, MoveFileBetweenSubDirectoriesRenameWithTitle) {
93 base::FilePath src_path( 99 base::FilePath src_path(
94 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); 100 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
95 base::FilePath dest_path(FILE_PATH_LITERAL( 101 base::FilePath dest_path(FILE_PATH_LITERAL(
96 "drive/root/Directory 1/Sub Directory Folder/" 102 "drive/root/Directory 1/Sub Directory Folder/"
97 "SubDirectory File 1 (1).txt")); 103 "SubDirectory File 1 (1).txt"));
98 104
99 ResourceEntry src_entry, dest_entry; 105 ResourceEntry src_entry, dest_entry;
(...skipping 28 matching lines...) Expand all
128 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 134 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
129 EXPECT_EQ("SubDirectory File 1 (1).txt", dest_entry.title()); 135 EXPECT_EQ("SubDirectory File 1 (1).txt", dest_entry.title());
130 EXPECT_EQ(copied_entry.local_id(), dest_entry.local_id()); 136 EXPECT_EQ(copied_entry.local_id(), dest_entry.local_id());
131 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 137 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
132 EXPECT_EQ(FILE_ERROR_NOT_FOUND, 138 EXPECT_EQ(FILE_ERROR_NOT_FOUND,
133 GetLocalResourceEntry(copied_path, &copied_entry)); 139 GetLocalResourceEntry(copied_path, &copied_entry));
134 140
135 EXPECT_EQ(2U, observer()->get_changed_paths().size()); 141 EXPECT_EQ(2U, observer()->get_changed_paths().size());
136 EXPECT_TRUE(observer()->get_changed_paths().count(copied_path.DirName())); 142 EXPECT_TRUE(observer()->get_changed_paths().count(copied_path.DirName()));
137 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName())); 143 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName()));
144
145 EXPECT_EQ(1U, observer()->updated_local_ids().size());
146 EXPECT_TRUE(observer()->updated_local_ids().count(copied_entry.local_id()));
138 } 147 }
139 148
140 TEST_F(MoveOperationTest, MoveNotExistingFile) { 149 TEST_F(MoveOperationTest, MoveNotExistingFile) {
141 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); 150 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt"));
142 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log")); 151 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log"));
143 152
144 FileError error = FILE_ERROR_OK; 153 FileError error = FILE_ERROR_OK;
145 operation_->Move(src_path, 154 operation_->Move(src_path,
146 dest_path, 155 dest_path,
147 false, 156 false,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id()); 223 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id());
215 EXPECT_EQ(src_entry.file_info().last_modified(), 224 EXPECT_EQ(src_entry.file_info().last_modified(),
216 dest_entry.file_info().last_modified()); 225 dest_entry.file_info().last_modified());
217 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 226 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
218 EXPECT_EQ(FILE_ERROR_NOT_FOUND, 227 EXPECT_EQ(FILE_ERROR_NOT_FOUND,
219 GetLocalResourceEntry(src_path, &src_entry)); 228 GetLocalResourceEntry(src_path, &src_entry));
220 } 229 }
221 230
222 } // namespace file_system 231 } // namespace file_system
223 } // namespace drive 232 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698