| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 workers()->push_back( | 56 workers()->push_back( |
| 57 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 57 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
| 58 workers()->push_back( | 58 workers()->push_back( |
| 59 make_scoped_refptr(new FakeModelWorker(GROUP_PASSWORD))); | 59 make_scoped_refptr(new FakeModelWorker(GROUP_PASSWORD))); |
| 60 workers()->push_back( | 60 workers()->push_back( |
| 61 make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); | 61 make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); |
| 62 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; | 62 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; |
| 63 (*mutable_routing_info())[syncable::PASSWORDS] = GROUP_PASSWORD; | 63 (*mutable_routing_info())[syncable::PASSWORDS] = GROUP_PASSWORD; |
| 64 (*mutable_routing_info())[syncable::NIGORI] = GROUP_PASSIVE; | 64 (*mutable_routing_info())[syncable::NIGORI] = GROUP_PASSIVE; |
| 65 SyncerCommandTest::SetUp(); | 65 SyncerCommandTest::SetUp(); |
| 66 ExpectNoGroupsToChange(apply_updates_command_); |
| 66 } | 67 } |
| 67 | 68 |
| 68 // Create a new unapplied folder node with a parent. | 69 // Create a new unapplied folder node with a parent. |
| 69 void CreateUnappliedNewItemWithParent( | 70 void CreateUnappliedNewItemWithParent( |
| 70 const string& item_id, | 71 const string& item_id, |
| 71 const sync_pb::EntitySpecifics& specifics, | 72 const sync_pb::EntitySpecifics& specifics, |
| 72 const string& parent_id) { | 73 const string& parent_id) { |
| 73 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 74 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 74 ASSERT_TRUE(dir.good()); | 75 ASSERT_TRUE(dir.good()); |
| 75 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 76 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 154 |
| 154 TEST_F(ApplyUpdatesCommandTest, Simple) { | 155 TEST_F(ApplyUpdatesCommandTest, Simple) { |
| 155 string root_server_id = syncable::GetNullId().GetServerId(); | 156 string root_server_id = syncable::GetNullId().GetServerId(); |
| 156 CreateUnappliedNewItemWithParent("parent", | 157 CreateUnappliedNewItemWithParent("parent", |
| 157 DefaultBookmarkSpecifics(), | 158 DefaultBookmarkSpecifics(), |
| 158 root_server_id); | 159 root_server_id); |
| 159 CreateUnappliedNewItemWithParent("child", | 160 CreateUnappliedNewItemWithParent("child", |
| 160 DefaultBookmarkSpecifics(), | 161 DefaultBookmarkSpecifics(), |
| 161 "parent"); | 162 "parent"); |
| 162 | 163 |
| 164 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 163 apply_updates_command_.ExecuteImpl(session()); | 165 apply_updates_command_.ExecuteImpl(session()); |
| 164 | 166 |
| 165 sessions::StatusController* status = session()->mutable_status_controller(); | 167 sessions::StatusController* status = session()->mutable_status_controller(); |
| 166 | 168 |
| 167 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 169 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 168 ASSERT_TRUE(status->update_progress()); | 170 ASSERT_TRUE(status->update_progress()); |
| 169 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 171 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
| 170 << "All updates should have been attempted"; | 172 << "All updates should have been attempted"; |
| 171 ASSERT_TRUE(status->conflict_progress()); | 173 ASSERT_TRUE(status->conflict_progress()); |
| 172 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 174 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 188 CreateUnappliedNewItemWithParent("parent", | 190 CreateUnappliedNewItemWithParent("parent", |
| 189 DefaultBookmarkSpecifics(), | 191 DefaultBookmarkSpecifics(), |
| 190 root_server_id); | 192 root_server_id); |
| 191 CreateUnappliedNewItemWithParent("a_child_created_second", | 193 CreateUnappliedNewItemWithParent("a_child_created_second", |
| 192 DefaultBookmarkSpecifics(), | 194 DefaultBookmarkSpecifics(), |
| 193 "parent"); | 195 "parent"); |
| 194 CreateUnappliedNewItemWithParent("x_child_created_second", | 196 CreateUnappliedNewItemWithParent("x_child_created_second", |
| 195 DefaultBookmarkSpecifics(), | 197 DefaultBookmarkSpecifics(), |
| 196 "parent"); | 198 "parent"); |
| 197 | 199 |
| 200 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 198 apply_updates_command_.ExecuteImpl(session()); | 201 apply_updates_command_.ExecuteImpl(session()); |
| 199 | 202 |
| 200 sessions::StatusController* status = session()->mutable_status_controller(); | 203 sessions::StatusController* status = session()->mutable_status_controller(); |
| 201 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 204 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 202 ASSERT_TRUE(status->update_progress()); | 205 ASSERT_TRUE(status->update_progress()); |
| 203 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) | 206 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) |
| 204 << "All updates should have been attempted"; | 207 << "All updates should have been attempted"; |
| 205 ASSERT_TRUE(status->conflict_progress()); | 208 ASSERT_TRUE(status->conflict_progress()); |
| 206 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 209 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 207 << "Simple update shouldn't result in conflicts, even if out-of-order"; | 210 << "Simple update shouldn't result in conflicts, even if out-of-order"; |
| 208 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 211 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
| 209 << "All updates should have been successfully applied"; | 212 << "All updates should have been successfully applied"; |
| 210 } | 213 } |
| 211 | 214 |
| 212 TEST_F(ApplyUpdatesCommandTest, NestedItemsWithUnknownParent) { | 215 TEST_F(ApplyUpdatesCommandTest, NestedItemsWithUnknownParent) { |
| 213 // We shouldn't be able to do anything with either of these items. | 216 // We shouldn't be able to do anything with either of these items. |
| 214 CreateUnappliedNewItemWithParent("some_item", | 217 CreateUnappliedNewItemWithParent("some_item", |
| 215 DefaultBookmarkSpecifics(), | 218 DefaultBookmarkSpecifics(), |
| 216 "unknown_parent"); | 219 "unknown_parent"); |
| 217 CreateUnappliedNewItemWithParent("some_other_item", | 220 CreateUnappliedNewItemWithParent("some_other_item", |
| 218 DefaultBookmarkSpecifics(), | 221 DefaultBookmarkSpecifics(), |
| 219 "some_item"); | 222 "some_item"); |
| 220 | 223 |
| 224 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 221 apply_updates_command_.ExecuteImpl(session()); | 225 apply_updates_command_.ExecuteImpl(session()); |
| 222 | 226 |
| 223 sessions::StatusController* status = session()->mutable_status_controller(); | 227 sessions::StatusController* status = session()->mutable_status_controller(); |
| 224 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 228 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 225 ASSERT_TRUE(status->update_progress()); | 229 ASSERT_TRUE(status->update_progress()); |
| 226 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 230 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
| 227 << "All updates should have been attempted"; | 231 << "All updates should have been attempted"; |
| 228 ASSERT_TRUE(status->conflict_progress()); | 232 ASSERT_TRUE(status->conflict_progress()); |
| 229 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 233 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) |
| 230 << "All updates with an unknown ancestors should be in conflict"; | 234 << "All updates with an unknown ancestors should be in conflict"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 247 CreateUnappliedNewItemWithParent("second_known_item", | 251 CreateUnappliedNewItemWithParent("second_known_item", |
| 248 DefaultBookmarkSpecifics(), | 252 DefaultBookmarkSpecifics(), |
| 249 "first_known_item"); | 253 "first_known_item"); |
| 250 CreateUnappliedNewItemWithParent("third_known_item", | 254 CreateUnappliedNewItemWithParent("third_known_item", |
| 251 DefaultBookmarkSpecifics(), | 255 DefaultBookmarkSpecifics(), |
| 252 "fourth_known_item"); | 256 "fourth_known_item"); |
| 253 CreateUnappliedNewItemWithParent("fourth_known_item", | 257 CreateUnappliedNewItemWithParent("fourth_known_item", |
| 254 DefaultBookmarkSpecifics(), | 258 DefaultBookmarkSpecifics(), |
| 255 root_server_id); | 259 root_server_id); |
| 256 | 260 |
| 261 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
| 257 apply_updates_command_.ExecuteImpl(session()); | 262 apply_updates_command_.ExecuteImpl(session()); |
| 258 | 263 |
| 259 sessions::StatusController* status = session()->mutable_status_controller(); | 264 sessions::StatusController* status = session()->mutable_status_controller(); |
| 260 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 265 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 261 ASSERT_TRUE(status->update_progress()); | 266 ASSERT_TRUE(status->update_progress()); |
| 262 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) | 267 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) |
| 263 << "All updates should have been attempted"; | 268 << "All updates should have been attempted"; |
| 264 ASSERT_TRUE(status->conflict_progress()); | 269 ASSERT_TRUE(status->conflict_progress()); |
| 265 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 270 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) |
| 266 << "The updates with unknown ancestors should be in conflict"; | 271 << "The updates with unknown ancestors should be in conflict"; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 285 cryptographer->AddKey(params); | 290 cryptographer->AddKey(params); |
| 286 | 291 |
| 287 sync_pb::EntitySpecifics specifics; | 292 sync_pb::EntitySpecifics specifics; |
| 288 sync_pb::PasswordSpecificsData data; | 293 sync_pb::PasswordSpecificsData data; |
| 289 data.set_origin("http://example.com"); | 294 data.set_origin("http://example.com"); |
| 290 | 295 |
| 291 cryptographer->Encrypt(data, | 296 cryptographer->Encrypt(data, |
| 292 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); | 297 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); |
| 293 CreateUnappliedNewItem("item", specifics, false); | 298 CreateUnappliedNewItem("item", specifics, false); |
| 294 | 299 |
| 300 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); |
| 295 apply_updates_command_.ExecuteImpl(session()); | 301 apply_updates_command_.ExecuteImpl(session()); |
| 296 | 302 |
| 297 sessions::StatusController* status = session()->mutable_status_controller(); | 303 sessions::StatusController* status = session()->mutable_status_controller(); |
| 298 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 304 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
| 299 ASSERT_TRUE(status->update_progress()); | 305 ASSERT_TRUE(status->update_progress()); |
| 300 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 306 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
| 301 << "All updates should have been attempted"; | 307 << "All updates should have been attempted"; |
| 302 ASSERT_TRUE(status->conflict_progress()); | 308 ASSERT_TRUE(status->conflict_progress()); |
| 303 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 309 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 304 << "No update should be in conflict because they're all decryptable"; | 310 << "No update should be in conflict because they're all decryptable"; |
| 305 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 311 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
| 306 << "The updates that can be decrypted should be applied"; | 312 << "The updates that can be decrypted should be applied"; |
| 307 } | 313 } |
| 308 | 314 |
| 309 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { | 315 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { |
| 310 // Undecryptable updates should not be applied. | 316 // Undecryptable updates should not be applied. |
| 311 sync_pb::EntitySpecifics encrypted_bookmark; | 317 sync_pb::EntitySpecifics encrypted_bookmark; |
| 312 encrypted_bookmark.mutable_encrypted(); | 318 encrypted_bookmark.mutable_encrypted(); |
| 313 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); | 319 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); |
| 314 string root_server_id = syncable::GetNullId().GetServerId(); | 320 string root_server_id = syncable::GetNullId().GetServerId(); |
| 315 CreateUnappliedNewItemWithParent("folder", | 321 CreateUnappliedNewItemWithParent("folder", |
| 316 encrypted_bookmark, | 322 encrypted_bookmark, |
| 317 root_server_id); | 323 root_server_id); |
| 318 CreateUnappliedNewItem("item2", encrypted_bookmark, false); | 324 CreateUnappliedNewItem("item2", encrypted_bookmark, false); |
| 319 sync_pb::EntitySpecifics encrypted_password; | 325 sync_pb::EntitySpecifics encrypted_password; |
| 320 encrypted_password.MutableExtension(sync_pb::password); | 326 encrypted_password.MutableExtension(sync_pb::password); |
| 321 CreateUnappliedNewItem("item3", encrypted_password, false); | 327 CreateUnappliedNewItem("item3", encrypted_password, false); |
| 322 | 328 |
| 329 ExpectGroupsToChange(apply_updates_command_, GROUP_UI, GROUP_PASSWORD); |
| 323 apply_updates_command_.ExecuteImpl(session()); | 330 apply_updates_command_.ExecuteImpl(session()); |
| 324 | 331 |
| 325 sessions::StatusController* status = session()->mutable_status_controller(); | 332 sessions::StatusController* status = session()->mutable_status_controller(); |
| 326 EXPECT_TRUE(status->HasConflictingUpdates()) | 333 EXPECT_TRUE(status->HasConflictingUpdates()) |
| 327 << "Updates that can't be decrypted should trigger the syncer to have " | 334 << "Updates that can't be decrypted should trigger the syncer to have " |
| 328 << "conflicting updates."; | 335 << "conflicting updates."; |
| 329 { | 336 { |
| 330 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 337 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 331 ASSERT_TRUE(status->update_progress()); | 338 ASSERT_TRUE(status->update_progress()); |
| 332 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 339 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 394 |
| 388 sync_pb::EntitySpecifics specifics; | 395 sync_pb::EntitySpecifics specifics; |
| 389 sync_pb::PasswordSpecificsData data; | 396 sync_pb::PasswordSpecificsData data; |
| 390 data.set_origin("http://example.com/2"); | 397 data.set_origin("http://example.com/2"); |
| 391 | 398 |
| 392 cryptographer.Encrypt(data, | 399 cryptographer.Encrypt(data, |
| 393 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); | 400 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); |
| 394 CreateUnappliedNewItem("item2", specifics, false); | 401 CreateUnappliedNewItem("item2", specifics, false); |
| 395 } | 402 } |
| 396 | 403 |
| 404 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); |
| 397 apply_updates_command_.ExecuteImpl(session()); | 405 apply_updates_command_.ExecuteImpl(session()); |
| 398 | 406 |
| 399 sessions::StatusController* status = session()->mutable_status_controller(); | 407 sessions::StatusController* status = session()->mutable_status_controller(); |
| 400 EXPECT_TRUE(status->HasConflictingUpdates()) | 408 EXPECT_TRUE(status->HasConflictingUpdates()) |
| 401 << "Updates that can't be decrypted should trigger the syncer to have " | 409 << "Updates that can't be decrypted should trigger the syncer to have " |
| 402 << "conflicting updates."; | 410 << "conflicting updates."; |
| 403 { | 411 { |
| 404 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 412 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
| 405 ASSERT_TRUE(status->update_progress()); | 413 ASSERT_TRUE(status->update_progress()); |
| 406 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 414 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 sync_pb::EntitySpecifics specifics; | 449 sync_pb::EntitySpecifics specifics; |
| 442 sync_pb::NigoriSpecifics* nigori = | 450 sync_pb::NigoriSpecifics* nigori = |
| 443 specifics.MutableExtension(sync_pb::nigori); | 451 specifics.MutableExtension(sync_pb::nigori); |
| 444 other_cryptographer.GetKeys(nigori->mutable_encrypted()); | 452 other_cryptographer.GetKeys(nigori->mutable_encrypted()); |
| 445 nigori->set_encrypt_bookmarks(true); | 453 nigori->set_encrypt_bookmarks(true); |
| 446 encrypted_types.insert(syncable::BOOKMARKS); | 454 encrypted_types.insert(syncable::BOOKMARKS); |
| 447 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), | 455 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), |
| 448 specifics, true); | 456 specifics, true); |
| 449 EXPECT_FALSE(cryptographer->has_pending_keys()); | 457 EXPECT_FALSE(cryptographer->has_pending_keys()); |
| 450 | 458 |
| 459 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
| 451 apply_updates_command_.ExecuteImpl(session()); | 460 apply_updates_command_.ExecuteImpl(session()); |
| 452 | 461 |
| 453 sessions::StatusController* status = session()->mutable_status_controller(); | 462 sessions::StatusController* status = session()->mutable_status_controller(); |
| 454 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 463 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
| 455 ASSERT_TRUE(status->update_progress()); | 464 ASSERT_TRUE(status->update_progress()); |
| 456 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 465 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
| 457 << "All updates should have been attempted"; | 466 << "All updates should have been attempted"; |
| 458 ASSERT_TRUE(status->conflict_progress()); | 467 ASSERT_TRUE(status->conflict_progress()); |
| 459 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 468 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 460 << "The nigori update shouldn't be in conflict"; | 469 << "The nigori update shouldn't be in conflict"; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 specifics.MutableExtension(sync_pb::nigori); | 501 specifics.MutableExtension(sync_pb::nigori); |
| 493 other_cryptographer.GetKeys(nigori->mutable_encrypted()); | 502 other_cryptographer.GetKeys(nigori->mutable_encrypted()); |
| 494 nigori->set_encrypt_sessions(true); | 503 nigori->set_encrypt_sessions(true); |
| 495 nigori->set_encrypt_themes(true); | 504 nigori->set_encrypt_themes(true); |
| 496 encrypted_types.insert(syncable::SESSIONS); | 505 encrypted_types.insert(syncable::SESSIONS); |
| 497 encrypted_types.insert(syncable::THEMES); | 506 encrypted_types.insert(syncable::THEMES); |
| 498 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), | 507 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), |
| 499 specifics, true); | 508 specifics, true); |
| 500 EXPECT_FALSE(cryptographer->has_pending_keys()); | 509 EXPECT_FALSE(cryptographer->has_pending_keys()); |
| 501 | 510 |
| 511 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
| 502 apply_updates_command_.ExecuteImpl(session()); | 512 apply_updates_command_.ExecuteImpl(session()); |
| 503 | 513 |
| 504 sessions::StatusController* status = session()->mutable_status_controller(); | 514 sessions::StatusController* status = session()->mutable_status_controller(); |
| 505 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 515 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
| 506 ASSERT_TRUE(status->update_progress()); | 516 ASSERT_TRUE(status->update_progress()); |
| 507 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 517 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
| 508 << "All updates should have been attempted"; | 518 << "All updates should have been attempted"; |
| 509 ASSERT_TRUE(status->conflict_progress()); | 519 ASSERT_TRUE(status->conflict_progress()); |
| 510 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 520 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 511 << "The nigori update shouldn't be in conflict"; | 521 << "The nigori update shouldn't be in conflict"; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 589 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 580 ASSERT_TRUE(dir.good()); | 590 ASSERT_TRUE(dir.good()); |
| 581 ReadTransaction trans(FROM_HERE, dir); | 591 ReadTransaction trans(FROM_HERE, dir); |
| 582 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 592 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
| 583 | 593 |
| 584 Syncer::UnsyncedMetaHandles handles; | 594 Syncer::UnsyncedMetaHandles handles; |
| 585 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 595 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
| 586 EXPECT_EQ(2*batch_s+1, handles.size()); | 596 EXPECT_EQ(2*batch_s+1, handles.size()); |
| 587 } | 597 } |
| 588 | 598 |
| 599 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
| 589 apply_updates_command_.ExecuteImpl(session()); | 600 apply_updates_command_.ExecuteImpl(session()); |
| 590 | 601 |
| 591 sessions::StatusController* status = session()->mutable_status_controller(); | 602 sessions::StatusController* status = session()->mutable_status_controller(); |
| 592 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 603 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
| 593 ASSERT_TRUE(status->update_progress()); | 604 ASSERT_TRUE(status->update_progress()); |
| 594 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 605 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
| 595 << "All updates should have been attempted"; | 606 << "All updates should have been attempted"; |
| 596 ASSERT_TRUE(status->conflict_progress()); | 607 ASSERT_TRUE(status->conflict_progress()); |
| 597 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 608 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 598 << "No updates should be in conflict"; | 609 << "No updates should be in conflict"; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // Ensure we have unsynced nodes that aren't properly encrypted. | 692 // Ensure we have unsynced nodes that aren't properly encrypted. |
| 682 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 693 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
| 683 ASSERT_TRUE(dir.good()); | 694 ASSERT_TRUE(dir.good()); |
| 684 ReadTransaction trans(FROM_HERE, dir); | 695 ReadTransaction trans(FROM_HERE, dir); |
| 685 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 696 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
| 686 Syncer::UnsyncedMetaHandles handles; | 697 Syncer::UnsyncedMetaHandles handles; |
| 687 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 698 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
| 688 EXPECT_EQ(2*batch_s+1, handles.size()); | 699 EXPECT_EQ(2*batch_s+1, handles.size()); |
| 689 } | 700 } |
| 690 | 701 |
| 702 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
| 691 apply_updates_command_.ExecuteImpl(session()); | 703 apply_updates_command_.ExecuteImpl(session()); |
| 692 | 704 |
| 693 sessions::StatusController* status = session()->mutable_status_controller(); | 705 sessions::StatusController* status = session()->mutable_status_controller(); |
| 694 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 706 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
| 695 ASSERT_TRUE(status->update_progress()); | 707 ASSERT_TRUE(status->update_progress()); |
| 696 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 708 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
| 697 << "All updates should have been attempted"; | 709 << "All updates should have been attempted"; |
| 698 ASSERT_TRUE(status->conflict_progress()); | 710 ASSERT_TRUE(status->conflict_progress()); |
| 699 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 711 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
| 700 << "The unsynced changes don't trigger a blocking conflict with the " | 712 << "The unsynced changes don't trigger a blocking conflict with the " |
| (...skipping 19 matching lines...) Expand all Loading... |
| 720 encrypted_types.insert(syncable::BOOKMARKS); | 732 encrypted_types.insert(syncable::BOOKMARKS); |
| 721 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); | 733 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); |
| 722 | 734 |
| 723 Syncer::UnsyncedMetaHandles handles; | 735 Syncer::UnsyncedMetaHandles handles; |
| 724 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 736 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
| 725 EXPECT_EQ(2*batch_s+1, handles.size()); | 737 EXPECT_EQ(2*batch_s+1, handles.size()); |
| 726 } | 738 } |
| 727 } | 739 } |
| 728 | 740 |
| 729 } // namespace browser_sync | 741 } // namespace browser_sync |
| OLD | NEW |