Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/browser/sync/engine/apply_updates_command.h" | 10 #include "chrome/browser/sync/engine/apply_updates_command.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 if (item_id.ServerKnows()) { | 136 if (item_id.ServerKnows()) { |
| 137 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); | 137 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); |
| 138 entry.Put(syncable::SERVER_IS_DIR, is_folder); | 138 entry.Put(syncable::SERVER_IS_DIR, is_folder); |
| 139 entry.Put(syncable::SERVER_PARENT_ID, parent_id); | 139 entry.Put(syncable::SERVER_PARENT_ID, parent_id); |
| 140 entry.Put(syncable::SERVER_IS_DEL, false); | 140 entry.Put(syncable::SERVER_IS_DEL, false); |
| 141 } | 141 } |
| 142 if (metahandle_out) | 142 if (metahandle_out) |
| 143 *metahandle_out = entry.Get(syncable::META_HANDLE); | 143 *metahandle_out = entry.Get(syncable::META_HANDLE); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void CreateUnappliedAndUnsyncedItem(const Id& item_id, | |
|
akalin
2012/02/01 01:10:24
comment that metahandle_out can be NULL
| |
| 147 const Id& parent_id, | |
| 148 const string& name, | |
| 149 bool is_folder, | |
| 150 syncable::ModelType model_type, | |
| 151 int64* metahandle_out) { | |
| 152 ASSERT_TRUE(item_id.ServerKnows()) << "CreateUnappliedAndUnsyncedItem()" | |
|
akalin
2012/02/01 01:10:24
just to make sure you know, ASSERT_TRUE just does,
rlarocque
2012/02/02 00:32:56
The idea of this assert was to catch logic errors.
| |
| 153 << " requires an 'item_id' argument that passes ServerKnows()."; | |
| 154 | |
| 155 // If our caller did not specify a location to store the returned | |
| 156 // metahandle, then use our own temporary storage. | |
| 157 int64 local_metahandle_out; | |
|
akalin
2012/02/01 01:10:24
initialize this int64 (just paranoia)
rlarocque
2012/02/02 00:32:56
Done.
| |
| 158 if (!metahandle_out) | |
| 159 metahandle_out = &local_metahandle_out; | |
| 160 | |
| 161 CreateUnsyncedItem(item_id, parent_id, name, is_folder, | |
| 162 model_type, metahandle_out); | |
| 163 | |
| 164 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
| 165 ASSERT_TRUE(dir.good()); | |
| 166 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
| 167 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, *metahandle_out); | |
| 168 ASSERT_TRUE(entry.good()); | |
| 169 | |
| 170 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); | |
| 171 entry.Put(syncable::SERVER_VERSION, next_revision_++); | |
| 172 } | |
| 173 | |
| 174 int64 GetNextRevision() { | |
| 175 return next_revision_++; | |
| 176 } | |
| 177 | |
| 146 ApplyUpdatesCommand apply_updates_command_; | 178 ApplyUpdatesCommand apply_updates_command_; |
| 147 TestIdFactory id_factory_; | 179 TestIdFactory id_factory_; |
| 148 private: | 180 private: |
| 149 int64 next_revision_; | 181 int64 next_revision_; |
| 150 DISALLOW_COPY_AND_ASSIGN(ApplyUpdatesCommandTest); | 182 DISALLOW_COPY_AND_ASSIGN(ApplyUpdatesCommandTest); |
| 151 }; | 183 }; |
| 152 | 184 |
| 153 TEST_F(ApplyUpdatesCommandTest, Simple) { | 185 TEST_F(ApplyUpdatesCommandTest, Simple) { |
| 154 string root_server_id = syncable::GetNullId().GetServerId(); | 186 string root_server_id = syncable::GetNullId().GetServerId(); |
| 155 CreateUnappliedNewItemWithParent("parent", | 187 CreateUnappliedNewItemWithParent("parent", |
| 156 DefaultBookmarkSpecifics(), | 188 DefaultBookmarkSpecifics(), |
| 157 root_server_id); | 189 root_server_id); |
| 158 CreateUnappliedNewItemWithParent("child", | 190 CreateUnappliedNewItemWithParent("child", |
| 159 DefaultBookmarkSpecifics(), | 191 DefaultBookmarkSpecifics(), |
| 160 "parent"); | 192 "parent"); |
| 161 | 193 |
| 162 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 194 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 163 apply_updates_command_.ExecuteImpl(session()); | 195 apply_updates_command_.ExecuteImpl(session()); |
| 164 | 196 |
| 165 sessions::StatusController* status = session()->mutable_status_controller(); | 197 sessions::StatusController* status = session()->mutable_status_controller(); |
| 166 | 198 |
| 167 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 199 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 168 ASSERT_TRUE(status->update_progress()); | 200 ASSERT_TRUE(status->update_progress()); |
| 169 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 201 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
| 170 << "All updates should have been attempted"; | 202 << "All updates should have been attempted"; |
| 171 ASSERT_TRUE(status->conflict_progress()); | 203 ASSERT_TRUE(status->conflict_progress()); |
| 172 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 204 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 173 << "Simple update shouldn't result in conflicts"; | 205 << "Simple update shouldn't result in conflicts"; |
| 206 EXPECT_EQ(0, status->conflict_progress()->NonblockingConflictingItemsSize()) | |
| 207 << "Simple update shouldn't result in conflicts"; | |
| 208 EXPECT_EQ(0, status->conflict_progress()->HierarchyConflictingItemsSize()) | |
| 209 << "Simple update shouldn't result in conflicts"; | |
| 174 EXPECT_EQ(2, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 210 EXPECT_EQ(2, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
| 175 << "All items should have been successfully applied"; | 211 << "All items should have been successfully applied"; |
| 176 } | 212 } |
| 177 | 213 |
| 178 TEST_F(ApplyUpdatesCommandTest, UpdateWithChildrenBeforeParents) { | 214 TEST_F(ApplyUpdatesCommandTest, UpdateWithChildrenBeforeParents) { |
| 179 // Set a bunch of updates which are difficult to apply in the order | 215 // Set a bunch of updates which are difficult to apply in the order |
| 180 // they're received due to dependencies on other unseen items. | 216 // they're received due to dependencies on other unseen items. |
| 181 string root_server_id = syncable::GetNullId().GetServerId(); | 217 string root_server_id = syncable::GetNullId().GetServerId(); |
| 182 CreateUnappliedNewItemWithParent("a_child_created_first", | 218 CreateUnappliedNewItemWithParent("a_child_created_first", |
| 183 DefaultBookmarkSpecifics(), | 219 DefaultBookmarkSpecifics(), |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 203 ASSERT_TRUE(status->update_progress()); | 239 ASSERT_TRUE(status->update_progress()); |
| 204 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) | 240 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) |
| 205 << "All updates should have been attempted"; | 241 << "All updates should have been attempted"; |
| 206 ASSERT_TRUE(status->conflict_progress()); | 242 ASSERT_TRUE(status->conflict_progress()); |
| 207 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 243 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 208 << "Simple update shouldn't result in conflicts, even if out-of-order"; | 244 << "Simple update shouldn't result in conflicts, even if out-of-order"; |
| 209 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 245 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
| 210 << "All updates should have been successfully applied"; | 246 << "All updates should have been successfully applied"; |
| 211 } | 247 } |
| 212 | 248 |
| 213 TEST_F(ApplyUpdatesCommandTest, NestedItemsWithUnknownParent) { | 249 TEST_F(ApplyUpdatesCommandTest, SimpleConflict) { |
|
akalin
2012/02/01 01:10:24
Please describe what the test does in a comment ab
| |
| 250 string root_server_id = syncable::GetNullId().GetServerId(); | |
| 251 CreateUnappliedAndUnsyncedItem(id_factory_.MakeServer("item"), | |
| 252 id_factory_.root(), "item", false, | |
| 253 syncable::BOOKMARKS, NULL); | |
| 254 | |
| 255 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
| 256 apply_updates_command_.ExecuteImpl(session()); | |
| 257 | |
| 258 sessions::StatusController* status = session()->mutable_status_controller(); | |
| 259 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
| 260 ASSERT_TRUE(status->conflict_progress()); | |
| 261 EXPECT_EQ(1, status->conflict_progress()->ConflictingItemsSize()) | |
| 262 << "Unsynced and unapplied item should be a simple conflict"; | |
| 263 } | |
| 264 | |
| 265 TEST_F(ApplyUpdatesCommandTest, HierarchyAndSimpleConflict) { | |
|
akalin
2012/02/01 01:10:24
here too
| |
| 266 int64 handle; | |
|
akalin
2012/02/01 01:10:24
initialize (paranoia, although if CreateUnapplied.
rlarocque
2012/02/02 00:32:56
Done.
| |
| 267 // Create a simply-conflicting item. It will start with valid parent ids. | |
| 268 CreateUnappliedAndUnsyncedItem(id_factory_.MakeServer("orphaned_by_server"), | |
| 269 id_factory_.root(), "orphaned_by_server", | |
| 270 false, syncable::BOOKMARKS, &handle); | |
| 271 { | |
| 272 // Manually set the SERVER_PARENT_ID to bad value. | |
| 273 // A bad parent indicates a hierarchy conflict. | |
| 274 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
| 275 ASSERT_TRUE(dir.good()); | |
| 276 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
| 277 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, handle); | |
| 278 ASSERT_TRUE(entry.good()); | |
| 279 | |
| 280 entry.Put(syncable::SERVER_PARENT_ID, | |
| 281 id_factory_.MakeServer("bogus_parent")); | |
| 282 } | |
| 283 | |
| 284 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
| 285 apply_updates_command_.ExecuteImpl(session()); | |
| 286 | |
| 287 sessions::StatusController* status = session()->mutable_status_controller(); | |
| 288 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
| 289 | |
| 290 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()); | |
| 291 | |
| 292 // An update that is both a simple conflict and a hierarchy conflict should be | |
| 293 // treated as a hierarchy conflict. | |
| 294 ASSERT_TRUE(status->conflict_progress()); | |
| 295 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
| 296 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()); | |
| 297 } | |
| 298 | |
| 299 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDirectoryLoop) { | |
|
akalin
2012/02/01 01:10:24
describe test
| |
| 300 // Item 'X' locally has parent of 'root'. Server is updating it to have | |
| 301 // parent of 'Y'. | |
| 302 { | |
| 303 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
| 304 ASSERT_TRUE(dir.good()); | |
| 305 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
| 306 | |
| 307 syncable::Id parent_id(id_factory_.root()); | |
| 308 MutableEntry entry(&trans, syncable::CREATE, parent_id, "X"); | |
| 309 ASSERT_TRUE(entry.good()); | |
| 310 | |
| 311 entry.Put(syncable::ID, id_factory_.MakeServer("X")); | |
| 312 entry.Put(syncable::BASE_VERSION, GetNextRevision()); | |
| 313 entry.Put(syncable::IS_UNSYNCED, false); | |
| 314 entry.Put(syncable::NON_UNIQUE_NAME, "X"); | |
| 315 entry.Put(syncable::IS_DIR, true); | |
| 316 entry.Put(syncable::IS_DEL, false); | |
| 317 entry.Put(syncable::PARENT_ID, parent_id); | |
| 318 | |
| 319 CHECK(entry.PutPredecessor(id_factory_.root())); | |
| 320 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | |
| 321 | |
| 322 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); | |
| 323 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); | |
| 324 entry.Put(syncable::SERVER_NON_UNIQUE_NAME, "X"); | |
| 325 entry.Put(syncable::SERVER_PARENT_ID, id_factory_.MakeServer("Y")); | |
| 326 entry.Put(syncable::SERVER_IS_DIR, true); | |
| 327 entry.Put(syncable::SERVER_SPECIFICS, DefaultBookmarkSpecifics()); | |
| 328 } | |
| 329 | |
| 330 // Item 'Y' is child of 'X'. | |
| 331 CreateUnsyncedItem(id_factory_.MakeServer("Y"), id_factory_.MakeServer("X"), | |
| 332 "Y", true, syncable::BOOKMARKS, NULL); | |
| 333 | |
| 334 // If the server's update were applied, we would have X be a child of Y, and Y | |
| 335 // as a child of X. That's a directory loop. The UpdateApplicator should | |
| 336 // prevent the update from being applied and note that this is a hierarchy | |
| 337 // conflict. | |
| 338 | |
| 339 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
| 340 apply_updates_command_.ExecuteImpl(session()); | |
| 341 | |
| 342 sessions::StatusController* status = session()->mutable_status_controller(); | |
| 343 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
| 344 | |
| 345 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()); | |
| 346 | |
| 347 // This should count as a hierarchy conflict. | |
| 348 ASSERT_TRUE(status->conflict_progress()); | |
| 349 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
| 350 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()); | |
| 351 } | |
| 352 | |
| 353 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeletedParent) { | |
|
akalin
2012/02/01 01:10:24
here too
| |
| 354 // Create a locally deleted parent item. | |
| 355 int64 parent_handle; | |
| 356 CreateUnsyncedItem(Id::CreateFromServerId("parent"), id_factory_.root(), | |
| 357 "parent", true, syncable::BOOKMARKS, &parent_handle); | |
| 358 { | |
| 359 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
| 360 ASSERT_TRUE(dir.good()); | |
| 361 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
| 362 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, parent_handle); | |
| 363 entry.Put(syncable::IS_DEL, true); | |
| 364 } | |
| 365 | |
| 366 // Create an incoming child from the server. | |
| 367 CreateUnappliedNewItemWithParent("child", DefaultBookmarkSpecifics(), | |
| 368 "parent"); | |
| 369 | |
| 370 // The server's update may seem valid to some other client, but on this client | |
| 371 // that new item's parent no longer exists. The update should not be applied | |
| 372 // and the update applicator should indicate this is a hierarchy conflict. | |
| 373 | |
| 374 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
| 375 apply_updates_command_.ExecuteImpl(session()); | |
| 376 | |
| 377 sessions::StatusController* status = session()->mutable_status_controller(); | |
| 378 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
| 379 | |
| 380 // This should count as a hierarchy conflict. | |
| 381 ASSERT_TRUE(status->conflict_progress()); | |
| 382 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
| 383 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()); | |
| 384 } | |
| 385 | |
| 386 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeleteNonEmptyDirectory) { | |
|
akalin
2012/02/01 01:10:24
here too
| |
| 387 // Create a server-deleted directory. | |
| 388 { | |
| 389 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
| 390 ASSERT_TRUE(dir.good()); | |
| 391 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
| 392 | |
| 393 syncable::Id parent_id(id_factory_.root()); | |
| 394 MutableEntry entry(&trans, syncable::CREATE, parent_id, "parent"); | |
| 395 ASSERT_TRUE(entry.good()); | |
| 396 | |
| 397 entry.Put(syncable::ID, id_factory_.MakeServer("parent")); | |
| 398 entry.Put(syncable::BASE_VERSION, GetNextRevision()); | |
| 399 entry.Put(syncable::IS_UNSYNCED, false); | |
| 400 entry.Put(syncable::NON_UNIQUE_NAME, "parent"); | |
| 401 entry.Put(syncable::IS_DIR, true); | |
| 402 entry.Put(syncable::IS_DEL, false); | |
| 403 entry.Put(syncable::PARENT_ID, parent_id); | |
| 404 | |
| 405 CHECK(entry.PutPredecessor(id_factory_.root())); | |
| 406 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | |
| 407 | |
| 408 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); | |
| 409 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); | |
| 410 entry.Put(syncable::SERVER_NON_UNIQUE_NAME, "parent"); | |
| 411 entry.Put(syncable::SERVER_PARENT_ID, parent_id); | |
| 412 entry.Put(syncable::SERVER_IS_DIR, true); | |
| 413 entry.Put(syncable::SERVER_IS_DEL, true); | |
| 414 entry.Put(syncable::SERVER_SPECIFICS, DefaultBookmarkSpecifics()); | |
| 415 } | |
| 416 | |
| 417 // Create a local child of the server-deleted directory. | |
| 418 CreateUnsyncedItem(id_factory_.MakeServer("child"), | |
| 419 id_factory_.MakeServer("parent"), "child", false, | |
| 420 syncable::BOOKMARKS, NULL); | |
| 421 | |
| 422 // The server's request to delete the directory must be ignored, otherwise our | |
| 423 // unsynced new child would be orphaned. This is a hierarchy conflict. | |
| 424 | |
| 425 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
| 426 apply_updates_command_.ExecuteImpl(session()); | |
| 427 | |
| 428 sessions::StatusController* status = session()->mutable_status_controller(); | |
| 429 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
| 430 | |
| 431 // This should count as a hierarchy conflict. | |
| 432 ASSERT_TRUE(status->conflict_progress()); | |
| 433 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
| 434 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()); | |
| 435 } | |
| 436 | |
| 437 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictUnknownParent) { | |
|
akalin
2012/02/01 01:10:24
here too (since you're touching it)
| |
| 214 // We shouldn't be able to do anything with either of these items. | 438 // We shouldn't be able to do anything with either of these items. |
| 215 CreateUnappliedNewItemWithParent("some_item", | 439 CreateUnappliedNewItemWithParent("some_item", |
| 216 DefaultBookmarkSpecifics(), | 440 DefaultBookmarkSpecifics(), |
| 217 "unknown_parent"); | 441 "unknown_parent"); |
| 218 CreateUnappliedNewItemWithParent("some_other_item", | 442 CreateUnappliedNewItemWithParent("some_other_item", |
| 219 DefaultBookmarkSpecifics(), | 443 DefaultBookmarkSpecifics(), |
| 220 "some_item"); | 444 "some_item"); |
| 221 | 445 |
| 222 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 446 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 223 apply_updates_command_.ExecuteImpl(session()); | 447 apply_updates_command_.ExecuteImpl(session()); |
| 224 | 448 |
| 225 sessions::StatusController* status = session()->mutable_status_controller(); | 449 sessions::StatusController* status = session()->mutable_status_controller(); |
| 226 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 450 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 227 ASSERT_TRUE(status->update_progress()); | 451 ASSERT_TRUE(status->update_progress()); |
| 228 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 452 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
| 229 << "All updates should have been attempted"; | 453 << "All updates should have been attempted"; |
| 230 ASSERT_TRUE(status->conflict_progress()); | 454 ASSERT_TRUE(status->conflict_progress()); |
| 231 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 455 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 456 << "Updates with unknown parent should not be treated as 'simple'" | |
| 457 << " conflicts"; | |
| 458 EXPECT_EQ(2, status->conflict_progress()->HierarchyConflictingItemsSize()) | |
| 232 << "All updates with an unknown ancestors should be in conflict"; | 459 << "All updates with an unknown ancestors should be in conflict"; |
| 233 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 460 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
| 234 << "No item with an unknown ancestor should be applied"; | 461 << "No item with an unknown ancestor should be applied"; |
| 235 } | 462 } |
| 236 | 463 |
| 237 TEST_F(ApplyUpdatesCommandTest, ItemsBothKnownAndUnknown) { | 464 TEST_F(ApplyUpdatesCommandTest, ItemsBothKnownAndUnknown) { |
| 238 // See what happens when there's a mixture of good and bad updates. | 465 // See what happens when there's a mixture of good and bad updates. |
| 239 string root_server_id = syncable::GetNullId().GetServerId(); | 466 string root_server_id = syncable::GetNullId().GetServerId(); |
| 240 CreateUnappliedNewItemWithParent("first_unknown_item", | 467 CreateUnappliedNewItemWithParent("first_unknown_item", |
| 241 DefaultBookmarkSpecifics(), | 468 DefaultBookmarkSpecifics(), |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 258 | 485 |
| 259 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 486 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 260 apply_updates_command_.ExecuteImpl(session()); | 487 apply_updates_command_.ExecuteImpl(session()); |
| 261 | 488 |
| 262 sessions::StatusController* status = session()->mutable_status_controller(); | 489 sessions::StatusController* status = session()->mutable_status_controller(); |
| 263 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 490 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 264 ASSERT_TRUE(status->update_progress()); | 491 ASSERT_TRUE(status->update_progress()); |
| 265 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) | 492 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) |
| 266 << "All updates should have been attempted"; | 493 << "All updates should have been attempted"; |
| 267 ASSERT_TRUE(status->conflict_progress()); | 494 ASSERT_TRUE(status->conflict_progress()); |
| 268 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 495 EXPECT_EQ(2, status->conflict_progress()->HierarchyConflictingItemsSize()) |
| 269 << "The updates with unknown ancestors should be in conflict"; | 496 << "The updates with unknown ancestors should be in conflict"; |
| 270 EXPECT_EQ(4, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 497 EXPECT_EQ(4, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
| 271 << "The updates with known ancestors should be successfully applied"; | 498 << "The updates with known ancestors should be successfully applied"; |
| 272 } | 499 } |
| 273 | 500 |
| 274 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { | 501 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { |
| 275 // Decryptable password updates should be applied. | 502 // Decryptable password updates should be applied. |
| 276 Cryptographer* cryptographer; | 503 Cryptographer* cryptographer; |
| 277 { | 504 { |
| 278 // Storing the cryptographer separately is bad, but for this test we | 505 // Storing the cryptographer separately is bad, but for this test we |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 EXPECT_FALSE(cryptographer->is_ready()); | 960 EXPECT_FALSE(cryptographer->is_ready()); |
| 734 EXPECT_TRUE(cryptographer->has_pending_keys()); | 961 EXPECT_TRUE(cryptographer->has_pending_keys()); |
| 735 | 962 |
| 736 Syncer::UnsyncedMetaHandles handles; | 963 Syncer::UnsyncedMetaHandles handles; |
| 737 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 964 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
| 738 EXPECT_EQ(2*batch_s+1, handles.size()); | 965 EXPECT_EQ(2*batch_s+1, handles.size()); |
| 739 } | 966 } |
| 740 } | 967 } |
| 741 | 968 |
| 742 } // namespace browser_sync | 969 } // namespace browser_sync |
| OLD | NEW |