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