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