| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" |
| 8 #include "chrome/browser/sync_file_system/local_sync_operation_resolver.h" | 10 #include "chrome/browser/sync_file_system/local_sync_operation_resolver.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "webkit/fileapi/syncable/file_change.h" | 12 #include "webkit/fileapi/syncable/file_change.h" |
| 11 #include "webkit/fileapi/syncable/sync_file_type.h" | 13 #include "webkit/fileapi/syncable/sync_file_type.h" |
| 12 | 14 |
| 13 namespace sync_file_system { | 15 namespace sync_file_system { |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 struct Input { | 19 struct Input { |
| 18 bool has_remote_change; | 20 scoped_ptr<FileChange> remote_file_change; |
| 19 FileChange remote_file_change; | 21 SyncFileType remote_file_type_in_metadata; |
| 20 | 22 |
| 21 std::string DebugString() { | 23 std::string DebugString() const { |
| 24 std::string change_type = |
| 25 (remote_file_change == NULL) ? "none" |
| 26 : remote_file_change->DebugString(); |
| 22 std::ostringstream ss; | 27 std::ostringstream ss; |
| 23 ss << "has_remote_change: " << (has_remote_change ? "true" : "false") | 28 ss << "RemoteFileChange: " << change_type |
| 24 << ", RemoteFileChange: " << remote_file_change.DebugString(); | 29 << ", RemoteFileTypeInMetadata: " << remote_file_type_in_metadata; |
| 25 return ss.str(); | 30 return ss.str(); |
| 26 } | 31 } |
| 32 |
| 33 Input(FileChange* remote_file_change, |
| 34 SyncFileType remote_file_type_in_metadata) |
| 35 : remote_file_change(remote_file_change), |
| 36 remote_file_type_in_metadata(remote_file_type_in_metadata) { |
| 37 } |
| 27 }; | 38 }; |
| 28 | 39 |
| 29 template <typename type, size_t array_size> | 40 template <typename type, size_t array_size> |
| 30 std::vector<type> CreateList(const type (&inputs)[array_size]) { | 41 std::vector<type> CreateList(const type (&inputs)[array_size]) { |
| 31 return std::vector<type>(inputs, inputs + array_size); | 42 return std::vector<type>(inputs, inputs + array_size); |
| 32 } | 43 } |
| 33 | 44 |
| 34 FileChange CreateDummyFileChange() { | 45 ScopedVector<Input> CreateInput() { |
| 35 return FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 46 SyncFileType dummy_file_type = SYNC_FILE_TYPE_UNKNOWN; |
| 36 SYNC_FILE_TYPE_UNKNOWN); | 47 |
| 48 ScopedVector<Input> vector; |
| 49 vector.push_back(new Input(NULL, SYNC_FILE_TYPE_UNKNOWN)); |
| 50 vector.push_back(new Input(NULL, SYNC_FILE_TYPE_FILE)); |
| 51 vector.push_back(new Input(NULL, SYNC_FILE_TYPE_DIRECTORY)); |
| 52 |
| 53 // When remote_file_change exists, the resolver does not take care of |
| 54 // remote_file_type_in_metadata. |
| 55 vector.push_back(new Input( |
| 56 new FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 57 SYNC_FILE_TYPE_FILE), |
| 58 dummy_file_type)); |
| 59 vector.push_back(new Input( |
| 60 new FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 61 SYNC_FILE_TYPE_DIRECTORY), |
| 62 dummy_file_type)); |
| 63 vector.push_back(new Input( |
| 64 new FileChange(FileChange::FILE_CHANGE_DELETE, |
| 65 SYNC_FILE_TYPE_FILE), |
| 66 dummy_file_type)); |
| 67 vector.push_back(new Input( |
| 68 new FileChange(FileChange::FILE_CHANGE_DELETE, |
| 69 SYNC_FILE_TYPE_DIRECTORY), |
| 70 dummy_file_type)); |
| 71 |
| 72 return vector.Pass(); |
| 37 } | 73 } |
| 38 | 74 |
| 39 std::vector<Input> CreateInput() { | 75 std::string DebugString(const ScopedVector<Input>& inputs, int number) { |
| 40 const Input inputs[] = { | 76 std::ostringstream ss; |
| 41 { false, CreateDummyFileChange() }, | 77 ss << "Case " << number << ": (" << inputs[number]->DebugString() << ")"; |
| 42 { true, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 78 return ss.str(); |
| 43 SYNC_FILE_TYPE_FILE) }, | |
| 44 { true, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | |
| 45 SYNC_FILE_TYPE_DIRECTORY) }, | |
| 46 { true, FileChange(FileChange::FILE_CHANGE_DELETE, | |
| 47 SYNC_FILE_TYPE_FILE) }, | |
| 48 { true, FileChange(FileChange::FILE_CHANGE_DELETE, | |
| 49 SYNC_FILE_TYPE_DIRECTORY) }, | |
| 50 }; | |
| 51 return CreateList(inputs); | |
| 52 } | 79 } |
| 53 | 80 |
| 54 } // namespace | 81 } // namespace |
| 55 | 82 |
| 56 class LocalSyncOperationResolverTest : public testing::Test { | 83 class LocalSyncOperationResolverTest : public testing::Test { |
| 57 public: | 84 public: |
| 58 LocalSyncOperationResolverTest() {} | 85 LocalSyncOperationResolverTest() {} |
| 59 | 86 |
| 60 protected: | 87 protected: |
| 61 typedef LocalSyncOperationResolver Resolver; | 88 typedef LocalSyncOperationResolver Resolver; |
| 62 typedef std::vector<LocalSyncOperationType> ExpectedTypes; | 89 typedef std::vector<LocalSyncOperationType> ExpectedTypes; |
| 63 | 90 |
| 64 DISALLOW_COPY_AND_ASSIGN(LocalSyncOperationResolverTest); | 91 DISALLOW_COPY_AND_ASSIGN(LocalSyncOperationResolverTest); |
| 65 }; | 92 }; |
| 66 | 93 |
| 67 TEST_F(LocalSyncOperationResolverTest, ResolveForAddOrUpdateFile) { | 94 TEST_F(LocalSyncOperationResolverTest, ResolveForAddOrUpdateFile) { |
| 68 const LocalSyncOperationType kExpectedTypes[] = { | 95 const LocalSyncOperationType kExpectedTypes[] = { |
| 69 LOCAL_SYNC_OPERATION_ADD_FILE, | 96 LOCAL_SYNC_OPERATION_ADD_FILE, |
| 97 LOCAL_SYNC_OPERATION_UPDATE_FILE, |
| 98 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 99 |
| 70 LOCAL_SYNC_OPERATION_CONFLICT, | 100 LOCAL_SYNC_OPERATION_CONFLICT, |
| 71 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 101 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 72 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 102 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 73 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 103 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 74 }; | 104 }; |
| 75 | 105 |
| 76 ExpectedTypes expected_types = CreateList(kExpectedTypes); | 106 ExpectedTypes expected_types = CreateList(kExpectedTypes); |
| 77 std::vector<Input> inputs = CreateInput(); | 107 ScopedVector<Input> inputs = CreateInput(); |
| 78 | 108 |
| 79 ASSERT_EQ(expected_types.size(), inputs.size()); | 109 ASSERT_EQ(expected_types.size(), inputs.size()); |
| 80 // TODO(nhiroki): Fix inputs so that these tests can cover all cases. | 110 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) { |
| 81 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | |
| 82 EXPECT_EQ(expected_types[i], | 111 EXPECT_EQ(expected_types[i], |
| 83 Resolver::ResolveForAddOrUpdateFile( | 112 Resolver::ResolveForAddOrUpdateFile( |
| 84 inputs[i].has_remote_change, inputs[i].remote_file_change, | 113 inputs[i]->remote_file_change.get(), |
| 85 SYNC_FILE_TYPE_UNKNOWN)) | 114 inputs[i]->remote_file_type_in_metadata)) |
| 86 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | 115 << DebugString(inputs, i); |
| 116 } |
| 87 } | 117 } |
| 88 | 118 |
| 89 TEST_F(LocalSyncOperationResolverTest, ResolveForAddOrUpdateFileInConflict) { | 119 TEST_F(LocalSyncOperationResolverTest, ResolveForAddOrUpdateFileInConflict) { |
| 90 const LocalSyncOperationType kExpectedTypes[] = { | 120 const LocalSyncOperationType kExpectedTypes[] = { |
| 91 LOCAL_SYNC_OPERATION_CONFLICT, | 121 LOCAL_SYNC_OPERATION_CONFLICT, |
| 92 LOCAL_SYNC_OPERATION_CONFLICT, | 122 LOCAL_SYNC_OPERATION_CONFLICT, |
| 123 LOCAL_SYNC_OPERATION_CONFLICT, |
| 124 |
| 125 LOCAL_SYNC_OPERATION_CONFLICT, |
| 93 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 126 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 94 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 127 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 95 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 128 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 96 }; | 129 }; |
| 97 | 130 |
| 98 ExpectedTypes expected_types = CreateList(kExpectedTypes); | 131 ExpectedTypes expected_types = CreateList(kExpectedTypes); |
| 99 std::vector<Input> inputs = CreateInput(); | 132 ScopedVector<Input> inputs = CreateInput(); |
| 100 | 133 |
| 101 ASSERT_EQ(expected_types.size(), inputs.size()); | 134 ASSERT_EQ(expected_types.size(), inputs.size()); |
| 102 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | 135 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) { |
| 103 EXPECT_EQ(expected_types[i], | 136 EXPECT_EQ(expected_types[i], |
| 104 Resolver::ResolveForAddOrUpdateFileInConflict( | 137 Resolver::ResolveForAddOrUpdateFileInConflict( |
| 105 inputs[i].has_remote_change, inputs[i].remote_file_change)) | 138 inputs[i]->remote_file_change.get())) |
| 106 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | 139 << DebugString(inputs, i); |
| 140 } |
| 107 } | 141 } |
| 108 | 142 |
| 109 TEST_F(LocalSyncOperationResolverTest, ResolveForAddDirectory) { | 143 TEST_F(LocalSyncOperationResolverTest, ResolveForAddDirectory) { |
| 110 const LocalSyncOperationType kExpectedTypes[] = { | 144 const LocalSyncOperationType kExpectedTypes[] = { |
| 111 LOCAL_SYNC_OPERATION_ADD_DIRECTORY, | 145 LOCAL_SYNC_OPERATION_ADD_DIRECTORY, |
| 112 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 146 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 113 LOCAL_SYNC_OPERATION_NONE, | 147 LOCAL_SYNC_OPERATION_NONE, |
| 148 |
| 149 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 150 LOCAL_SYNC_OPERATION_NONE, |
| 114 LOCAL_SYNC_OPERATION_ADD_DIRECTORY, | 151 LOCAL_SYNC_OPERATION_ADD_DIRECTORY, |
| 115 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 152 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 116 }; | 153 }; |
| 117 | 154 |
| 118 ExpectedTypes expected_types = CreateList(kExpectedTypes); | 155 ExpectedTypes expected_types = CreateList(kExpectedTypes); |
| 119 std::vector<Input> inputs = CreateInput(); | 156 ScopedVector<Input> inputs = CreateInput(); |
| 120 | 157 |
| 121 ASSERT_EQ(expected_types.size(), inputs.size()); | 158 ASSERT_EQ(expected_types.size(), inputs.size()); |
| 122 // TODO(nhiroki): Fix inputs so that these tests can cover all cases. | 159 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) { |
| 123 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | |
| 124 EXPECT_EQ(expected_types[i], | 160 EXPECT_EQ(expected_types[i], |
| 125 Resolver::ResolveForAddDirectory( | 161 Resolver::ResolveForAddDirectory( |
| 126 inputs[i].has_remote_change, inputs[i].remote_file_change, | 162 inputs[i]->remote_file_change.get(), |
| 127 SYNC_FILE_TYPE_UNKNOWN)) | 163 inputs[i]->remote_file_type_in_metadata)) |
| 128 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | 164 << DebugString(inputs, i); |
| 165 } |
| 129 } | 166 } |
| 130 | 167 |
| 131 TEST_F(LocalSyncOperationResolverTest, ResolveForAddDirectoryInConflict) { | 168 TEST_F(LocalSyncOperationResolverTest, ResolveForAddDirectoryInConflict) { |
| 132 const LocalSyncOperationType kExpectedTypes[] = { | 169 EXPECT_EQ(LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 133 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 170 Resolver::ResolveForAddDirectoryInConflict()); |
| 134 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | |
| 135 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | |
| 136 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | |
| 137 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | |
| 138 }; | |
| 139 | |
| 140 ExpectedTypes expected_types = CreateList(kExpectedTypes); | |
| 141 std::vector<Input> inputs = CreateInput(); | |
| 142 | |
| 143 ASSERT_EQ(expected_types.size(), inputs.size()); | |
| 144 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | |
| 145 EXPECT_EQ(expected_types[i], | |
| 146 Resolver::ResolveForAddDirectoryInConflict( | |
| 147 inputs[i].has_remote_change, inputs[i].remote_file_change)) | |
| 148 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | |
| 149 } | 171 } |
| 150 | 172 |
| 151 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteFile) { | 173 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteFile) { |
| 152 const LocalSyncOperationType kExpectedTypes[] = { | 174 const LocalSyncOperationType kExpectedTypes[] = { |
| 153 LOCAL_SYNC_OPERATION_NONE, | 175 LOCAL_SYNC_OPERATION_NONE, |
| 176 LOCAL_SYNC_OPERATION_DELETE_FILE, |
| 177 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 178 |
| 154 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 179 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 155 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 180 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 156 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 181 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 157 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 182 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 158 }; | 183 }; |
| 159 | 184 |
| 160 ExpectedTypes expected_types = CreateList(kExpectedTypes); | 185 ExpectedTypes expected_types = CreateList(kExpectedTypes); |
| 161 std::vector<Input> inputs = CreateInput(); | 186 ScopedVector<Input> inputs = CreateInput(); |
| 162 | 187 |
| 163 ASSERT_EQ(expected_types.size(), inputs.size()); | 188 ASSERT_EQ(expected_types.size(), inputs.size()); |
| 164 // TODO(nhiroki): Fix inputs so that these tests can cover all cases. | 189 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) { |
| 165 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | |
| 166 EXPECT_EQ(expected_types[i], | 190 EXPECT_EQ(expected_types[i], |
| 167 Resolver::ResolveForDeleteFile( | 191 Resolver::ResolveForDeleteFile( |
| 168 inputs[i].has_remote_change, inputs[i].remote_file_change, | 192 inputs[i]->remote_file_change.get(), |
| 169 SYNC_FILE_TYPE_UNKNOWN)) | 193 inputs[i]->remote_file_type_in_metadata)) |
| 170 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | 194 << DebugString(inputs, i); |
| 195 } |
| 171 } | 196 } |
| 172 | 197 |
| 173 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteFileInConflict) { | 198 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteFileInConflict) { |
| 174 const LocalSyncOperationType kExpectedTypes[] = { | 199 const LocalSyncOperationType kExpectedTypes[] = { |
| 175 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 200 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 176 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 201 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 177 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 202 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 203 |
| 204 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 205 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 178 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 206 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 179 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 207 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 180 }; | 208 }; |
| 181 | 209 |
| 182 ExpectedTypes expected_types = CreateList(kExpectedTypes); | 210 ExpectedTypes expected_types = CreateList(kExpectedTypes); |
| 183 std::vector<Input> inputs = CreateInput(); | 211 ScopedVector<Input> inputs = CreateInput(); |
| 184 | 212 |
| 185 ASSERT_EQ(expected_types.size(), inputs.size()); | 213 ASSERT_EQ(expected_types.size(), inputs.size()); |
| 186 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | 214 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) { |
| 187 EXPECT_EQ(expected_types[i], | 215 EXPECT_EQ(expected_types[i], |
| 188 Resolver::ResolveForDeleteFileInConflict( | 216 Resolver::ResolveForDeleteFileInConflict( |
| 189 inputs[i].has_remote_change, inputs[i].remote_file_change)) | 217 inputs[i]->remote_file_change.get())) |
| 190 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | 218 << DebugString(inputs, i); |
| 219 } |
| 191 } | 220 } |
| 192 | 221 |
| 193 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteDirectory) { | 222 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteDirectory) { |
| 194 const LocalSyncOperationType kExpectedTypes[] = { | 223 const LocalSyncOperationType kExpectedTypes[] = { |
| 195 LOCAL_SYNC_OPERATION_NONE, | 224 LOCAL_SYNC_OPERATION_NONE, |
| 196 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 225 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 226 LOCAL_SYNC_OPERATION_DELETE_DIRECTORY, |
| 227 |
| 228 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 197 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 229 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 198 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 230 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 199 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 231 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 200 }; | 232 }; |
| 201 | 233 |
| 202 ExpectedTypes expected_types = CreateList(kExpectedTypes); | 234 ExpectedTypes expected_types = CreateList(kExpectedTypes); |
| 203 std::vector<Input> inputs = CreateInput(); | 235 ScopedVector<Input> inputs = CreateInput(); |
| 204 | 236 |
| 205 ASSERT_EQ(expected_types.size(), inputs.size()); | 237 ASSERT_EQ(expected_types.size(), inputs.size()); |
| 206 // TODO(nhiroki): Fix inputs so that these tests can cover all cases. | 238 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) { |
| 207 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | |
| 208 EXPECT_EQ(expected_types[i], | 239 EXPECT_EQ(expected_types[i], |
| 209 Resolver::ResolveForDeleteDirectory( | 240 Resolver::ResolveForDeleteDirectory( |
| 210 inputs[i].has_remote_change, inputs[i].remote_file_change, | 241 inputs[i]->remote_file_change.get(), |
| 211 SYNC_FILE_TYPE_UNKNOWN)) | 242 inputs[i]->remote_file_type_in_metadata)) |
| 212 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | 243 << DebugString(inputs, i); |
| 244 } |
| 213 } | 245 } |
| 214 | 246 |
| 215 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteDirectoryInConflict) { | 247 TEST_F(LocalSyncOperationResolverTest, ResolveForDeleteDirectoryInConflict) { |
| 216 const LocalSyncOperationType kExpectedTypes[] = { | 248 const LocalSyncOperationType kExpectedTypes[] = { |
| 217 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 249 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 218 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 250 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 219 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 251 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 252 |
| 253 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 254 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 220 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 255 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 221 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 256 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 222 }; | 257 }; |
| 223 | 258 |
| 224 ExpectedTypes expected_types = CreateList(kExpectedTypes); | 259 ExpectedTypes expected_types = CreateList(kExpectedTypes); |
| 225 std::vector<Input> inputs = CreateInput(); | 260 ScopedVector<Input> inputs = CreateInput(); |
| 226 | 261 |
| 227 ASSERT_EQ(expected_types.size(), inputs.size()); | 262 ASSERT_EQ(expected_types.size(), inputs.size()); |
| 228 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) | 263 for (ExpectedTypes::size_type i = 0; i < expected_types.size(); ++i) { |
| 229 EXPECT_EQ(expected_types[i], | 264 EXPECT_EQ(expected_types[i], |
| 230 Resolver::ResolveForDeleteDirectoryInConflict( | 265 Resolver::ResolveForDeleteDirectoryInConflict( |
| 231 inputs[i].has_remote_change, inputs[i].remote_file_change)) | 266 inputs[i]->remote_file_change.get())) |
| 232 << "Case " << i << ": (" << inputs[i].DebugString() << ")"; | 267 << DebugString(inputs, i); |
| 268 } |
| 233 } | 269 } |
| 234 | 270 |
| 235 } // namespace sync_file_system | 271 } // namespace sync_file_system |
| OLD | NEW |