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 // Creates an item that is both unsynced an an unapplied update. Returns the |
| 147 // metahandle of the created item. |
| 148 int64 CreateUnappliedAndUnsyncedItem(const string& name, |
| 149 syncable::ModelType model_type) { |
| 150 int64 metahandle = 0; |
| 151 CreateUnsyncedItem(id_factory_.MakeServer(name), id_factory_.root(), name, |
| 152 false, model_type, &metahandle); |
| 153 |
| 154 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 155 if (!dir.good()) { |
| 156 ADD_FAILURE(); |
| 157 return syncable::kInvalidMetaHandle; |
| 158 } |
| 159 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
| 160 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, metahandle); |
| 161 if (!entry.good()) { |
| 162 ADD_FAILURE(); |
| 163 return syncable::kInvalidMetaHandle; |
| 164 } |
| 165 |
| 166 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); |
| 167 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); |
| 168 |
| 169 return metahandle; |
| 170 } |
| 171 |
| 172 |
| 173 // Creates an item that has neither IS_UNSYNED or IS_UNAPPLIED_UPDATE. The |
| 174 // item is known to both the server and client. Returns the metahandle of |
| 175 // the created item. |
| 176 int64 CreateSyncedItem(const std::string& name, syncable::ModelType |
| 177 model_type, bool is_folder) { |
| 178 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 179 if (!dir.good()) { |
| 180 ADD_FAILURE(); |
| 181 return syncable::kInvalidMetaHandle; |
| 182 } |
| 183 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
| 184 |
| 185 syncable::Id parent_id(id_factory_.root()); |
| 186 syncable::Id item_id(id_factory_.MakeServer(name)); |
| 187 int64 version = GetNextRevision(); |
| 188 |
| 189 sync_pb::EntitySpecifics default_specifics; |
| 190 syncable::AddDefaultExtensionValue(model_type, &default_specifics); |
| 191 |
| 192 MutableEntry entry(&trans, syncable::CREATE, parent_id, name); |
| 193 if (!entry.good()) { |
| 194 ADD_FAILURE(); |
| 195 return syncable::kInvalidMetaHandle; |
| 196 } |
| 197 |
| 198 entry.Put(syncable::ID, item_id); |
| 199 entry.Put(syncable::BASE_VERSION, version); |
| 200 entry.Put(syncable::IS_UNSYNCED, false); |
| 201 entry.Put(syncable::NON_UNIQUE_NAME, name); |
| 202 entry.Put(syncable::IS_DIR, is_folder); |
| 203 entry.Put(syncable::IS_DEL, false); |
| 204 entry.Put(syncable::PARENT_ID, parent_id); |
| 205 |
| 206 if (!entry.PutPredecessor(id_factory_.root())) { |
| 207 ADD_FAILURE(); |
| 208 return syncable::kInvalidMetaHandle; |
| 209 } |
| 210 entry.Put(syncable::SPECIFICS, default_specifics); |
| 211 |
| 212 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); |
| 213 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); |
| 214 entry.Put(syncable::SERVER_NON_UNIQUE_NAME, "X"); |
| 215 entry.Put(syncable::SERVER_PARENT_ID, id_factory_.MakeServer("Y")); |
| 216 entry.Put(syncable::SERVER_IS_DIR, is_folder); |
| 217 entry.Put(syncable::SERVER_IS_DEL, false); |
| 218 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); |
| 219 entry.Put(syncable::SERVER_PARENT_ID, parent_id); |
| 220 |
| 221 return entry.Get(syncable::META_HANDLE); |
| 222 } |
| 223 |
| 224 int64 GetNextRevision() { |
| 225 return next_revision_++; |
| 226 } |
| 227 |
146 ApplyUpdatesCommand apply_updates_command_; | 228 ApplyUpdatesCommand apply_updates_command_; |
147 TestIdFactory id_factory_; | 229 TestIdFactory id_factory_; |
148 private: | 230 private: |
149 int64 next_revision_; | 231 int64 next_revision_; |
150 DISALLOW_COPY_AND_ASSIGN(ApplyUpdatesCommandTest); | 232 DISALLOW_COPY_AND_ASSIGN(ApplyUpdatesCommandTest); |
151 }; | 233 }; |
152 | 234 |
153 TEST_F(ApplyUpdatesCommandTest, Simple) { | 235 TEST_F(ApplyUpdatesCommandTest, Simple) { |
154 string root_server_id = syncable::GetNullId().GetServerId(); | 236 string root_server_id = syncable::GetNullId().GetServerId(); |
155 CreateUnappliedNewItemWithParent("parent", | 237 CreateUnappliedNewItemWithParent("parent", |
156 DefaultBookmarkSpecifics(), | 238 DefaultBookmarkSpecifics(), |
157 root_server_id); | 239 root_server_id); |
158 CreateUnappliedNewItemWithParent("child", | 240 CreateUnappliedNewItemWithParent("child", |
159 DefaultBookmarkSpecifics(), | 241 DefaultBookmarkSpecifics(), |
160 "parent"); | 242 "parent"); |
161 | 243 |
162 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 244 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
163 apply_updates_command_.ExecuteImpl(session()); | 245 apply_updates_command_.ExecuteImpl(session()); |
164 | 246 |
165 sessions::StatusController* status = session()->mutable_status_controller(); | 247 sessions::StatusController* status = session()->mutable_status_controller(); |
166 | 248 |
167 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 249 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
168 ASSERT_TRUE(status->update_progress()); | 250 ASSERT_TRUE(status->update_progress()); |
169 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 251 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
170 << "All updates should have been attempted"; | 252 << "All updates should have been attempted"; |
171 ASSERT_TRUE(status->conflict_progress()); | 253 ASSERT_TRUE(status->conflict_progress()); |
172 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 254 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
| 255 << "Simple update shouldn't result in conflicts"; |
| 256 EXPECT_EQ(0, status->conflict_progress()->EncryptionConflictingItemsSize()) |
| 257 << "Simple update shouldn't result in conflicts"; |
| 258 EXPECT_EQ(0, status->conflict_progress()->HierarchyConflictingItemsSize()) |
173 << "Simple update shouldn't result in conflicts"; | 259 << "Simple update shouldn't result in conflicts"; |
174 EXPECT_EQ(2, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 260 EXPECT_EQ(2, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
175 << "All items should have been successfully applied"; | 261 << "All items should have been successfully applied"; |
176 } | 262 } |
177 | 263 |
178 TEST_F(ApplyUpdatesCommandTest, UpdateWithChildrenBeforeParents) { | 264 TEST_F(ApplyUpdatesCommandTest, UpdateWithChildrenBeforeParents) { |
179 // Set a bunch of updates which are difficult to apply in the order | 265 // Set a bunch of updates which are difficult to apply in the order |
180 // they're received due to dependencies on other unseen items. | 266 // they're received due to dependencies on other unseen items. |
181 string root_server_id = syncable::GetNullId().GetServerId(); | 267 string root_server_id = syncable::GetNullId().GetServerId(); |
182 CreateUnappliedNewItemWithParent("a_child_created_first", | 268 CreateUnappliedNewItemWithParent("a_child_created_first", |
(...skipping 14 matching lines...) Expand all Loading... |
197 | 283 |
198 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 284 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
199 apply_updates_command_.ExecuteImpl(session()); | 285 apply_updates_command_.ExecuteImpl(session()); |
200 | 286 |
201 sessions::StatusController* status = session()->mutable_status_controller(); | 287 sessions::StatusController* status = session()->mutable_status_controller(); |
202 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 288 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
203 ASSERT_TRUE(status->update_progress()); | 289 ASSERT_TRUE(status->update_progress()); |
204 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) | 290 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) |
205 << "All updates should have been attempted"; | 291 << "All updates should have been attempted"; |
206 ASSERT_TRUE(status->conflict_progress()); | 292 ASSERT_TRUE(status->conflict_progress()); |
207 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 293 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
208 << "Simple update shouldn't result in conflicts, even if out-of-order"; | 294 << "Simple update shouldn't result in conflicts, even if out-of-order"; |
209 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 295 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
210 << "All updates should have been successfully applied"; | 296 << "All updates should have been successfully applied"; |
211 } | 297 } |
212 | 298 |
213 TEST_F(ApplyUpdatesCommandTest, NestedItemsWithUnknownParent) { | 299 // Runs the ApplyUpdatesCommand on an item that has both local and remote |
| 300 // modifications (IS_UNSYNCED and IS_UNAPPLIED_UPDATE). We expect the command |
| 301 // to detect that this update can't be applied because it is in a CONFLICT |
| 302 // state. |
| 303 TEST_F(ApplyUpdatesCommandTest, SimpleConflict) { |
| 304 CreateUnappliedAndUnsyncedItem("item", syncable::BOOKMARKS); |
| 305 |
| 306 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 307 apply_updates_command_.ExecuteImpl(session()); |
| 308 |
| 309 sessions::StatusController* status = session()->mutable_status_controller(); |
| 310 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 311 ASSERT_TRUE(status->conflict_progress()); |
| 312 EXPECT_EQ(1, status->conflict_progress()->SimpleConflictingItemsSize()) |
| 313 << "Unsynced and unapplied item should be a simple conflict"; |
| 314 } |
| 315 |
| 316 // Runs the ApplyUpdatesCommand on an item that has both local and remote |
| 317 // modifications *and* the remote modification cannot be applied without |
| 318 // violating the tree constraints. We expect the command to detect that this |
| 319 // update can't be applied and that this situation can't be resolved with the |
| 320 // simple conflict processing logic; it is in a CONFLICT_HIERARCHY state. |
| 321 TEST_F(ApplyUpdatesCommandTest, HierarchyAndSimpleConflict) { |
| 322 // Create a simply-conflicting item. It will start with valid parent ids. |
| 323 int64 handle = CreateUnappliedAndUnsyncedItem("orphaned_by_server", |
| 324 syncable::BOOKMARKS); |
| 325 { |
| 326 // Manually set the SERVER_PARENT_ID to bad value. |
| 327 // A bad parent indicates a hierarchy conflict. |
| 328 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 329 ASSERT_TRUE(dir.good()); |
| 330 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
| 331 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, handle); |
| 332 ASSERT_TRUE(entry.good()); |
| 333 |
| 334 entry.Put(syncable::SERVER_PARENT_ID, |
| 335 id_factory_.MakeServer("bogus_parent")); |
| 336 } |
| 337 |
| 338 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 339 apply_updates_command_.ExecuteImpl(session()); |
| 340 |
| 341 sessions::StatusController* status = session()->mutable_status_controller(); |
| 342 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 343 |
| 344 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()); |
| 345 |
| 346 // An update that is both a simple conflict and a hierarchy conflict should be |
| 347 // treated 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()->SimpleConflictingItemsSize()); |
| 351 } |
| 352 |
| 353 |
| 354 // Runs the ApplyUpdatesCommand on an item with remote modifications that would |
| 355 // create a directory loop if the update were applied. We expect the command to |
| 356 // detect that this update can't be applied because it is in a |
| 357 // CONFLICT_HIERARCHY state. |
| 358 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDirectoryLoop) { |
| 359 // Item 'X' locally has parent of 'root'. Server is updating it to have |
| 360 // parent of 'Y'. |
| 361 { |
| 362 // Create it as a child of root node. |
| 363 int64 handle = CreateSyncedItem("X", syncable::BOOKMARKS, true); |
| 364 |
| 365 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 366 ASSERT_TRUE(dir.good()); |
| 367 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
| 368 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, handle); |
| 369 ASSERT_TRUE(entry.good()); |
| 370 |
| 371 // Re-parent from root to "Y" |
| 372 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); |
| 373 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); |
| 374 entry.Put(syncable::SERVER_PARENT_ID, id_factory_.MakeServer("Y")); |
| 375 } |
| 376 |
| 377 // Item 'Y' is child of 'X'. |
| 378 CreateUnsyncedItem(id_factory_.MakeServer("Y"), id_factory_.MakeServer("X"), |
| 379 "Y", true, syncable::BOOKMARKS, NULL); |
| 380 |
| 381 // If the server's update were applied, we would have X be a child of Y, and Y |
| 382 // as a child of X. That's a directory loop. The UpdateApplicator should |
| 383 // prevent the update from being applied and note that this is a hierarchy |
| 384 // conflict. |
| 385 |
| 386 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 387 apply_updates_command_.ExecuteImpl(session()); |
| 388 |
| 389 sessions::StatusController* status = session()->mutable_status_controller(); |
| 390 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 391 |
| 392 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()); |
| 393 |
| 394 // This should count as a hierarchy conflict. |
| 395 ASSERT_TRUE(status->conflict_progress()); |
| 396 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); |
| 397 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()); |
| 398 } |
| 399 |
| 400 // Runs the ApplyUpdatesCommand on a directory where the server sent us an |
| 401 // update to add a child to a locally deleted (and unsynced) parent. We expect |
| 402 // the command to not apply the update and to indicate the update is in a |
| 403 // CONFLICT_HIERARCHY state. |
| 404 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeletedParent) { |
| 405 // Create a locally deleted parent item. |
| 406 int64 parent_handle; |
| 407 CreateUnsyncedItem(Id::CreateFromServerId("parent"), id_factory_.root(), |
| 408 "parent", true, syncable::BOOKMARKS, &parent_handle); |
| 409 { |
| 410 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 411 ASSERT_TRUE(dir.good()); |
| 412 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
| 413 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, parent_handle); |
| 414 entry.Put(syncable::IS_DEL, true); |
| 415 } |
| 416 |
| 417 // Create an incoming child from the server. |
| 418 CreateUnappliedNewItemWithParent("child", DefaultBookmarkSpecifics(), |
| 419 "parent"); |
| 420 |
| 421 // The server's update may seem valid to some other client, but on this client |
| 422 // that new item's parent no longer exists. The update should not be applied |
| 423 // and the update applicator should indicate 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()->SimpleConflictingItemsSize()); |
| 435 } |
| 436 |
| 437 // Runs the ApplyUpdatesCommand on a directory where the server is trying to |
| 438 // delete a folder that has a recently added (and unsynced) child. We expect |
| 439 // the command to not apply the update because it is in a CONFLICT_HIERARCHY |
| 440 // state. |
| 441 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeleteNonEmptyDirectory) { |
| 442 // Create a server-deleted directory. |
| 443 { |
| 444 // Create it as a child of root node. |
| 445 int64 handle = CreateSyncedItem("parent", syncable::BOOKMARKS, true); |
| 446 |
| 447 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 448 ASSERT_TRUE(dir.good()); |
| 449 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
| 450 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, handle); |
| 451 ASSERT_TRUE(entry.good()); |
| 452 |
| 453 // Delete it on the server. |
| 454 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); |
| 455 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); |
| 456 entry.Put(syncable::SERVER_PARENT_ID, id_factory_.root()); |
| 457 entry.Put(syncable::SERVER_IS_DEL, true); |
| 458 } |
| 459 |
| 460 // Create a local child of the server-deleted directory. |
| 461 CreateUnsyncedItem(id_factory_.MakeServer("child"), |
| 462 id_factory_.MakeServer("parent"), "child", false, |
| 463 syncable::BOOKMARKS, NULL); |
| 464 |
| 465 // The server's request to delete the directory must be ignored, otherwise our |
| 466 // unsynced new child would be orphaned. This is a hierarchy conflict. |
| 467 |
| 468 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 469 apply_updates_command_.ExecuteImpl(session()); |
| 470 |
| 471 sessions::StatusController* status = session()->mutable_status_controller(); |
| 472 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 473 |
| 474 // This should count as a hierarchy conflict. |
| 475 ASSERT_TRUE(status->conflict_progress()); |
| 476 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); |
| 477 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()); |
| 478 } |
| 479 |
| 480 // Runs the ApplyUpdatesCommand on a server-created item that has a locally |
| 481 // unknown parent. We expect the command to not apply the update because the |
| 482 // item is in a CONFLICT_HIERARCHY state. |
| 483 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictUnknownParent) { |
214 // We shouldn't be able to do anything with either of these items. | 484 // We shouldn't be able to do anything with either of these items. |
215 CreateUnappliedNewItemWithParent("some_item", | 485 CreateUnappliedNewItemWithParent("some_item", |
216 DefaultBookmarkSpecifics(), | 486 DefaultBookmarkSpecifics(), |
217 "unknown_parent"); | 487 "unknown_parent"); |
218 CreateUnappliedNewItemWithParent("some_other_item", | 488 CreateUnappliedNewItemWithParent("some_other_item", |
219 DefaultBookmarkSpecifics(), | 489 DefaultBookmarkSpecifics(), |
220 "some_item"); | 490 "some_item"); |
221 | 491 |
222 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 492 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
223 apply_updates_command_.ExecuteImpl(session()); | 493 apply_updates_command_.ExecuteImpl(session()); |
224 | 494 |
225 sessions::StatusController* status = session()->mutable_status_controller(); | 495 sessions::StatusController* status = session()->mutable_status_controller(); |
226 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 496 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
227 ASSERT_TRUE(status->update_progress()); | 497 ASSERT_TRUE(status->update_progress()); |
228 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 498 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
229 << "All updates should have been attempted"; | 499 << "All updates should have been attempted"; |
230 ASSERT_TRUE(status->conflict_progress()); | 500 ASSERT_TRUE(status->conflict_progress()); |
231 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 501 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
| 502 << "Updates with unknown parent should not be treated as 'simple'" |
| 503 << " conflicts"; |
| 504 EXPECT_EQ(2, status->conflict_progress()->HierarchyConflictingItemsSize()) |
232 << "All updates with an unknown ancestors should be in conflict"; | 505 << "All updates with an unknown ancestors should be in conflict"; |
233 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 506 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
234 << "No item with an unknown ancestor should be applied"; | 507 << "No item with an unknown ancestor should be applied"; |
235 } | 508 } |
236 | 509 |
237 TEST_F(ApplyUpdatesCommandTest, ItemsBothKnownAndUnknown) { | 510 TEST_F(ApplyUpdatesCommandTest, ItemsBothKnownAndUnknown) { |
238 // See what happens when there's a mixture of good and bad updates. | 511 // See what happens when there's a mixture of good and bad updates. |
239 string root_server_id = syncable::GetNullId().GetServerId(); | 512 string root_server_id = syncable::GetNullId().GetServerId(); |
240 CreateUnappliedNewItemWithParent("first_unknown_item", | 513 CreateUnappliedNewItemWithParent("first_unknown_item", |
241 DefaultBookmarkSpecifics(), | 514 DefaultBookmarkSpecifics(), |
(...skipping 16 matching lines...) Expand all Loading... |
258 | 531 |
259 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 532 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
260 apply_updates_command_.ExecuteImpl(session()); | 533 apply_updates_command_.ExecuteImpl(session()); |
261 | 534 |
262 sessions::StatusController* status = session()->mutable_status_controller(); | 535 sessions::StatusController* status = session()->mutable_status_controller(); |
263 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 536 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
264 ASSERT_TRUE(status->update_progress()); | 537 ASSERT_TRUE(status->update_progress()); |
265 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) | 538 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) |
266 << "All updates should have been attempted"; | 539 << "All updates should have been attempted"; |
267 ASSERT_TRUE(status->conflict_progress()); | 540 ASSERT_TRUE(status->conflict_progress()); |
268 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 541 EXPECT_EQ(2, status->conflict_progress()->HierarchyConflictingItemsSize()) |
269 << "The updates with unknown ancestors should be in conflict"; | 542 << "The updates with unknown ancestors should be in conflict"; |
270 EXPECT_EQ(4, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 543 EXPECT_EQ(4, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
271 << "The updates with known ancestors should be successfully applied"; | 544 << "The updates with known ancestors should be successfully applied"; |
272 } | 545 } |
273 | 546 |
274 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { | 547 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { |
275 // Decryptable password updates should be applied. | 548 // Decryptable password updates should be applied. |
276 Cryptographer* cryptographer; | 549 Cryptographer* cryptographer; |
277 { | 550 { |
278 // Storing the cryptographer separately is bad, but for this test we | 551 // Storing the cryptographer separately is bad, but for this test we |
(...skipping 18 matching lines...) Expand all Loading... |
297 | 570 |
298 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); | 571 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); |
299 apply_updates_command_.ExecuteImpl(session()); | 572 apply_updates_command_.ExecuteImpl(session()); |
300 | 573 |
301 sessions::StatusController* status = session()->mutable_status_controller(); | 574 sessions::StatusController* status = session()->mutable_status_controller(); |
302 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 575 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
303 ASSERT_TRUE(status->update_progress()); | 576 ASSERT_TRUE(status->update_progress()); |
304 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 577 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
305 << "All updates should have been attempted"; | 578 << "All updates should have been attempted"; |
306 ASSERT_TRUE(status->conflict_progress()); | 579 ASSERT_TRUE(status->conflict_progress()); |
307 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 580 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
308 << "No update should be in conflict because they're all decryptable"; | 581 << "No update should be in conflict because they're all decryptable"; |
309 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 582 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
310 << "The updates that can be decrypted should be applied"; | 583 << "The updates that can be decrypted should be applied"; |
311 } | 584 } |
312 | 585 |
313 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { | 586 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { |
314 // Undecryptable updates should not be applied. | 587 // Undecryptable updates should not be applied. |
315 sync_pb::EntitySpecifics encrypted_bookmark; | 588 sync_pb::EntitySpecifics encrypted_bookmark; |
316 encrypted_bookmark.mutable_encrypted(); | 589 encrypted_bookmark.mutable_encrypted(); |
317 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); | 590 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); |
(...skipping 12 matching lines...) Expand all Loading... |
330 sessions::StatusController* status = session()->mutable_status_controller(); | 603 sessions::StatusController* status = session()->mutable_status_controller(); |
331 EXPECT_TRUE(status->HasConflictingUpdates()) | 604 EXPECT_TRUE(status->HasConflictingUpdates()) |
332 << "Updates that can't be decrypted should trigger the syncer to have " | 605 << "Updates that can't be decrypted should trigger the syncer to have " |
333 << "conflicting updates."; | 606 << "conflicting updates."; |
334 { | 607 { |
335 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 608 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
336 ASSERT_TRUE(status->update_progress()); | 609 ASSERT_TRUE(status->update_progress()); |
337 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 610 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
338 << "All updates should have been attempted"; | 611 << "All updates should have been attempted"; |
339 ASSERT_TRUE(status->conflict_progress()); | 612 ASSERT_TRUE(status->conflict_progress()); |
340 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 613 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
341 << "The updates that can't be decrypted should not be in regular " | 614 << "The updates that can't be decrypted should not be in regular " |
342 << "conflict"; | 615 << "conflict"; |
343 EXPECT_EQ(2, status->conflict_progress()->NonblockingConflictingItemsSize()) | 616 EXPECT_EQ(2, status->conflict_progress()->EncryptionConflictingItemsSize()) |
344 << "The updates that can't be decrypted should be in nonblocking " | 617 << "The updates that can't be decrypted should be in encryption " |
345 << "conflict"; | 618 << "conflict"; |
346 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 619 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
347 << "No update that can't be decrypted should be applied"; | 620 << "No update that can't be decrypted should be applied"; |
348 } | 621 } |
349 { | 622 { |
350 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 623 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
351 ASSERT_TRUE(status->update_progress()); | 624 ASSERT_TRUE(status->update_progress()); |
352 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 625 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
353 << "All updates should have been attempted"; | 626 << "All updates should have been attempted"; |
354 ASSERT_TRUE(status->conflict_progress()); | 627 ASSERT_TRUE(status->conflict_progress()); |
355 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 628 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
356 << "The updates that can't be decrypted should not be in regular " | 629 << "The updates that can't be decrypted should not be in regular " |
357 << "conflict"; | 630 << "conflict"; |
358 EXPECT_EQ(1, status->conflict_progress()->NonblockingConflictingItemsSize()) | 631 EXPECT_EQ(1, status->conflict_progress()->EncryptionConflictingItemsSize()) |
359 << "The updates that can't be decrypted should be in nonblocking " | 632 << "The updates that can't be decrypted should be in encryption " |
360 << "conflict"; | 633 << "conflict"; |
361 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 634 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
362 << "No update that can't be decrypted should be applied"; | 635 << "No update that can't be decrypted should be applied"; |
363 } | 636 } |
364 } | 637 } |
365 | 638 |
366 TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) { | 639 TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) { |
367 // Only decryptable password updates should be applied. | 640 // Only decryptable password updates should be applied. |
368 { | 641 { |
369 sync_pb::EntitySpecifics specifics; | 642 sync_pb::EntitySpecifics specifics; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 sessions::StatusController* status = session()->mutable_status_controller(); | 678 sessions::StatusController* status = session()->mutable_status_controller(); |
406 EXPECT_TRUE(status->HasConflictingUpdates()) | 679 EXPECT_TRUE(status->HasConflictingUpdates()) |
407 << "Updates that can't be decrypted should trigger the syncer to have " | 680 << "Updates that can't be decrypted should trigger the syncer to have " |
408 << "conflicting updates."; | 681 << "conflicting updates."; |
409 { | 682 { |
410 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 683 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
411 ASSERT_TRUE(status->update_progress()); | 684 ASSERT_TRUE(status->update_progress()); |
412 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 685 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
413 << "All updates should have been attempted"; | 686 << "All updates should have been attempted"; |
414 ASSERT_TRUE(status->conflict_progress()); | 687 ASSERT_TRUE(status->conflict_progress()); |
415 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 688 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
416 << "The updates that can't be decrypted should not be in regular " | 689 << "The updates that can't be decrypted should not be in regular " |
417 << "conflict"; | 690 << "conflict"; |
418 EXPECT_EQ(1, status->conflict_progress()->NonblockingConflictingItemsSize()) | 691 EXPECT_EQ(1, status->conflict_progress()->EncryptionConflictingItemsSize()) |
419 << "The updates that can't be decrypted should be in nonblocking " | 692 << "The updates that can't be decrypted should be in encryption " |
420 << "conflict"; | 693 << "conflict"; |
421 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 694 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
422 << "The undecryptable password update shouldn't be applied"; | 695 << "The undecryptable password update shouldn't be applied"; |
423 } | 696 } |
424 } | 697 } |
425 | 698 |
426 TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) { | 699 TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) { |
427 // Storing the cryptographer separately is bad, but for this test we | 700 // Storing the cryptographer separately is bad, but for this test we |
428 // know it's safe. | 701 // know it's safe. |
429 Cryptographer* cryptographer; | 702 Cryptographer* cryptographer; |
(...skipping 26 matching lines...) Expand all Loading... |
456 | 729 |
457 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 730 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
458 apply_updates_command_.ExecuteImpl(session()); | 731 apply_updates_command_.ExecuteImpl(session()); |
459 | 732 |
460 sessions::StatusController* status = session()->mutable_status_controller(); | 733 sessions::StatusController* status = session()->mutable_status_controller(); |
461 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 734 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
462 ASSERT_TRUE(status->update_progress()); | 735 ASSERT_TRUE(status->update_progress()); |
463 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 736 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
464 << "All updates should have been attempted"; | 737 << "All updates should have been attempted"; |
465 ASSERT_TRUE(status->conflict_progress()); | 738 ASSERT_TRUE(status->conflict_progress()); |
466 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 739 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
467 << "The nigori update shouldn't be in conflict"; | 740 << "The nigori update shouldn't be in conflict"; |
468 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 741 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
469 << "The nigori update should be applied"; | 742 << "The nigori update should be applied"; |
470 | 743 |
471 EXPECT_FALSE(cryptographer->is_ready()); | 744 EXPECT_FALSE(cryptographer->is_ready()); |
472 EXPECT_TRUE(cryptographer->has_pending_keys()); | 745 EXPECT_TRUE(cryptographer->has_pending_keys()); |
473 EXPECT_TRUE( | 746 EXPECT_TRUE( |
474 cryptographer->GetEncryptedTypes() | 747 cryptographer->GetEncryptedTypes() |
475 .Equals(syncable::ModelTypeSet::All())); | 748 .Equals(syncable::ModelTypeSet::All())); |
476 } | 749 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 783 |
511 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 784 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
512 apply_updates_command_.ExecuteImpl(session()); | 785 apply_updates_command_.ExecuteImpl(session()); |
513 | 786 |
514 sessions::StatusController* status = session()->mutable_status_controller(); | 787 sessions::StatusController* status = session()->mutable_status_controller(); |
515 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 788 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
516 ASSERT_TRUE(status->update_progress()); | 789 ASSERT_TRUE(status->update_progress()); |
517 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 790 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
518 << "All updates should have been attempted"; | 791 << "All updates should have been attempted"; |
519 ASSERT_TRUE(status->conflict_progress()); | 792 ASSERT_TRUE(status->conflict_progress()); |
520 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 793 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
521 << "The nigori update shouldn't be in conflict"; | 794 << "The nigori update shouldn't be in conflict"; |
522 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 795 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
523 << "The nigori update should be applied"; | 796 << "The nigori update should be applied"; |
524 | 797 |
525 EXPECT_FALSE(cryptographer->is_ready()); | 798 EXPECT_FALSE(cryptographer->is_ready()); |
526 EXPECT_TRUE(cryptographer->has_pending_keys()); | 799 EXPECT_TRUE(cryptographer->has_pending_keys()); |
527 EXPECT_TRUE( | 800 EXPECT_TRUE( |
528 cryptographer->GetEncryptedTypes() | 801 cryptographer->GetEncryptedTypes() |
529 .Equals(syncable::ModelTypeSet::All())); | 802 .Equals(syncable::ModelTypeSet::All())); |
530 } | 803 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 873 |
601 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 874 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
602 apply_updates_command_.ExecuteImpl(session()); | 875 apply_updates_command_.ExecuteImpl(session()); |
603 | 876 |
604 sessions::StatusController* status = session()->mutable_status_controller(); | 877 sessions::StatusController* status = session()->mutable_status_controller(); |
605 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 878 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
606 ASSERT_TRUE(status->update_progress()); | 879 ASSERT_TRUE(status->update_progress()); |
607 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 880 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
608 << "All updates should have been attempted"; | 881 << "All updates should have been attempted"; |
609 ASSERT_TRUE(status->conflict_progress()); | 882 ASSERT_TRUE(status->conflict_progress()); |
610 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 883 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
611 << "No updates should be in conflict"; | 884 << "No updates should be in conflict"; |
612 EXPECT_EQ(0, status->conflict_progress()->NonblockingConflictingItemsSize()) | 885 EXPECT_EQ(0, status->conflict_progress()->EncryptionConflictingItemsSize()) |
613 << "No updates should be in conflict"; | 886 << "No updates should be in conflict"; |
614 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 887 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
615 << "The nigori update should be applied"; | 888 << "The nigori update should be applied"; |
616 EXPECT_FALSE(cryptographer->has_pending_keys()); | 889 EXPECT_FALSE(cryptographer->has_pending_keys()); |
617 EXPECT_TRUE(cryptographer->is_ready()); | 890 EXPECT_TRUE(cryptographer->is_ready()); |
618 { | 891 { |
619 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 892 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
620 ASSERT_TRUE(dir.good()); | 893 ASSERT_TRUE(dir.good()); |
621 ReadTransaction trans(FROM_HERE, dir); | 894 ReadTransaction trans(FROM_HERE, dir); |
622 | 895 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 976 |
704 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 977 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
705 apply_updates_command_.ExecuteImpl(session()); | 978 apply_updates_command_.ExecuteImpl(session()); |
706 | 979 |
707 sessions::StatusController* status = session()->mutable_status_controller(); | 980 sessions::StatusController* status = session()->mutable_status_controller(); |
708 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 981 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
709 ASSERT_TRUE(status->update_progress()); | 982 ASSERT_TRUE(status->update_progress()); |
710 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 983 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
711 << "All updates should have been attempted"; | 984 << "All updates should have been attempted"; |
712 ASSERT_TRUE(status->conflict_progress()); | 985 ASSERT_TRUE(status->conflict_progress()); |
713 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 986 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
714 << "The unsynced changes don't trigger a blocking conflict with the " | 987 << "The unsynced changes don't trigger a blocking conflict with the " |
715 << "nigori update."; | 988 << "nigori update."; |
716 EXPECT_EQ(0, status->conflict_progress()->NonblockingConflictingItemsSize()) | 989 EXPECT_EQ(0, status->conflict_progress()->EncryptionConflictingItemsSize()) |
717 << "The unsynced changes don't trigger a non-blocking conflict with the " | 990 << "The unsynced changes don't trigger an encryption conflict with the " |
718 << "nigori update."; | 991 << "nigori update."; |
719 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 992 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
720 << "The nigori update should be applied"; | 993 << "The nigori update should be applied"; |
721 EXPECT_FALSE(cryptographer->is_ready()); | 994 EXPECT_FALSE(cryptographer->is_ready()); |
722 EXPECT_TRUE(cryptographer->has_pending_keys()); | 995 EXPECT_TRUE(cryptographer->has_pending_keys()); |
723 { | 996 { |
724 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 997 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
725 ASSERT_TRUE(dir.good()); | 998 ASSERT_TRUE(dir.good()); |
726 ReadTransaction trans(FROM_HERE, dir); | 999 ReadTransaction trans(FROM_HERE, dir); |
727 | 1000 |
728 // Since we have pending keys, we would have failed to encrypt, but the | 1001 // Since we have pending keys, we would have failed to encrypt, but the |
729 // cryptographer should be updated. | 1002 // cryptographer should be updated. |
730 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 1003 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
731 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals( | 1004 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals( |
732 syncable::ModelTypeSet().All())); | 1005 syncable::ModelTypeSet().All())); |
733 EXPECT_FALSE(cryptographer->is_ready()); | 1006 EXPECT_FALSE(cryptographer->is_ready()); |
734 EXPECT_TRUE(cryptographer->has_pending_keys()); | 1007 EXPECT_TRUE(cryptographer->has_pending_keys()); |
735 | 1008 |
736 Syncer::UnsyncedMetaHandles handles; | 1009 Syncer::UnsyncedMetaHandles handles; |
737 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 1010 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
738 EXPECT_EQ(2*batch_s+1, handles.size()); | 1011 EXPECT_EQ(2*batch_s+1, handles.size()); |
739 } | 1012 } |
740 } | 1013 } |
741 | 1014 |
742 } // namespace browser_sync | 1015 } // namespace browser_sync |
OLD | NEW |