OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <list> | 10 #include <list> |
(...skipping 4318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4329 ASSERT_TRUE(tag2.GetId().ServerKnows()); | 4329 ASSERT_TRUE(tag2.GetId().ServerKnows()); |
4330 ASSERT_TRUE(id4 == tag2.GetId()); | 4330 ASSERT_TRUE(id4 == tag2.GetId()); |
4331 EXPECT_FALSE(tag2.GetIsDel()); | 4331 EXPECT_FALSE(tag2.GetIsDel()); |
4332 EXPECT_FALSE(tag2.GetIsUnappliedUpdate()); | 4332 EXPECT_FALSE(tag2.GetIsUnappliedUpdate()); |
4333 EXPECT_FALSE(tag2.GetIsUnsynced()); | 4333 EXPECT_FALSE(tag2.GetIsUnsynced()); |
4334 EXPECT_EQ(11, tag2.GetBaseVersion()); | 4334 EXPECT_EQ(11, tag2.GetBaseVersion()); |
4335 EXPECT_EQ("tag2", tag2.GetUniqueClientTag()); | 4335 EXPECT_EQ("tag2", tag2.GetUniqueClientTag()); |
4336 tag2_metahandle = tag2.GetMetahandle(); | 4336 tag2_metahandle = tag2.GetMetahandle(); |
4337 | 4337 |
4338 // Preferences type root should have been created by the updates above. | 4338 // Preferences type root should have been created by the updates above. |
| 4339 ASSERT_TRUE(directory()->InitialSyncEndedForType(&trans, PREFERENCES)); |
| 4340 |
4339 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); | 4341 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); |
4340 ASSERT_TRUE(pref_root.good()); | 4342 ASSERT_TRUE(pref_root.good()); |
4341 | 4343 |
4342 syncable::Directory::Metahandles children; | 4344 syncable::Directory::Metahandles children; |
4343 directory()->GetChildHandlesById(&trans, pref_root.GetId(), &children); | 4345 directory()->GetChildHandlesById(&trans, pref_root.GetId(), &children); |
4344 ASSERT_EQ(2U, children.size()); | 4346 ASSERT_EQ(2U, children.size()); |
4345 } | 4347 } |
4346 | 4348 |
4347 syncable::Id id2 = TestIdFactory::MakeServer("2"); | 4349 syncable::Id id2 = TestIdFactory::MakeServer("2"); |
4348 mock_server_->AddUpdatePref(id2.GetServerId(), "", "tag1", 12, 120); | 4350 mock_server_->AddUpdatePref(id2.GetServerId(), "", "tag1", 12, 120); |
(...skipping 22 matching lines...) Expand all Loading... |
4371 ASSERT_EQ(id3, tag2.GetId()) | 4373 ASSERT_EQ(id3, tag2.GetId()) |
4372 << "ID 3 should be kept, since it was less than ID 4."; | 4374 << "ID 3 should be kept, since it was less than ID 4."; |
4373 EXPECT_FALSE(tag2.GetIsDel()); | 4375 EXPECT_FALSE(tag2.GetIsDel()); |
4374 EXPECT_FALSE(tag2.GetIsUnappliedUpdate()); | 4376 EXPECT_FALSE(tag2.GetIsUnappliedUpdate()); |
4375 EXPECT_FALSE(tag2.GetIsUnsynced()); | 4377 EXPECT_FALSE(tag2.GetIsUnsynced()); |
4376 EXPECT_EQ(13, tag2.GetBaseVersion()); | 4378 EXPECT_EQ(13, tag2.GetBaseVersion()); |
4377 EXPECT_EQ("tag2", tag2.GetUniqueClientTag()); | 4379 EXPECT_EQ("tag2", tag2.GetUniqueClientTag()); |
4378 EXPECT_EQ(tag2_metahandle, tag2.GetMetahandle()); | 4380 EXPECT_EQ(tag2_metahandle, tag2.GetMetahandle()); |
4379 | 4381 |
4380 // Preferences type root should have been created by the updates above. | 4382 // Preferences type root should have been created by the updates above. |
| 4383 ASSERT_TRUE(directory()->InitialSyncEndedForType(&trans, PREFERENCES)); |
| 4384 |
4381 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); | 4385 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); |
4382 ASSERT_TRUE(pref_root.good()); | 4386 ASSERT_TRUE(pref_root.good()); |
4383 | 4387 |
4384 syncable::Directory::Metahandles children; | 4388 syncable::Directory::Metahandles children; |
4385 directory()->GetChildHandlesById(&trans, pref_root.GetId(), &children); | 4389 directory()->GetChildHandlesById(&trans, pref_root.GetId(), &children); |
4386 ASSERT_EQ(2U, children.size()); | 4390 ASSERT_EQ(2U, children.size()); |
4387 } | 4391 } |
4388 } | 4392 } |
4389 | 4393 |
4390 TEST_F(SyncerTest, ClientTagClashWithinBatchOfUpdates) { | 4394 TEST_F(SyncerTest, ClientTagClashWithinBatchOfUpdates) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4453 ASSERT_TRUE(tag_c.good()); | 4457 ASSERT_TRUE(tag_c.good()); |
4454 EXPECT_TRUE(tag_c.GetId().ServerKnows()); | 4458 EXPECT_TRUE(tag_c.GetId().ServerKnows()); |
4455 EXPECT_EQ(ids_.FromNumber(201), tag_c.GetId()); | 4459 EXPECT_EQ(ids_.FromNumber(201), tag_c.GetId()); |
4456 EXPECT_FALSE(tag_c.GetIsDel()); | 4460 EXPECT_FALSE(tag_c.GetIsDel()); |
4457 EXPECT_FALSE(tag_c.GetIsUnappliedUpdate()); | 4461 EXPECT_FALSE(tag_c.GetIsUnappliedUpdate()); |
4458 EXPECT_FALSE(tag_c.GetIsUnsynced()); | 4462 EXPECT_FALSE(tag_c.GetIsUnsynced()); |
4459 EXPECT_EQ(21, tag_c.GetBaseVersion()); | 4463 EXPECT_EQ(21, tag_c.GetBaseVersion()); |
4460 EXPECT_EQ("tag c", tag_c.GetUniqueClientTag()); | 4464 EXPECT_EQ("tag c", tag_c.GetUniqueClientTag()); |
4461 | 4465 |
4462 // Preferences type root should have been created by the updates above. | 4466 // Preferences type root should have been created by the updates above. |
| 4467 ASSERT_TRUE(directory()->InitialSyncEndedForType(&trans, PREFERENCES)); |
| 4468 |
4463 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); | 4469 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); |
4464 ASSERT_TRUE(pref_root.good()); | 4470 ASSERT_TRUE(pref_root.good()); |
4465 | 4471 |
4466 // Verify that we have exactly 3 tagged nodes under the type root. | 4472 // Verify that we have exactly 3 tagged nodes under the type root. |
4467 syncable::Directory::Metahandles children; | 4473 syncable::Directory::Metahandles children; |
4468 directory()->GetChildHandlesById(&trans, pref_root.GetId(), &children); | 4474 directory()->GetChildHandlesById(&trans, pref_root.GetId(), &children); |
4469 ASSERT_EQ(3U, children.size()); | 4475 ASSERT_EQ(3U, children.size()); |
4470 } | 4476 } |
4471 } | 4477 } |
4472 | 4478 |
4473 // This verifies transition to implicit permanent folders. | 4479 // This verifies transition to implicit permanent folders. |
4474 TEST_F(SyncerTest, EntryWithParentIdUpdatedWithEntryWithoutParentId) { | 4480 TEST_F(SyncerTest, EntryWithParentIdUpdatedWithEntryWithoutParentId) { |
4475 // Make sure SPECIFICS root exists so that we can get its parent ID. | 4481 // Make sure SPECIFICS root exists so that we can get its parent ID. |
4476 mock_server_->AddUpdateSpecifics(1, 0, "Folder", 10, 10, true, 1, | 4482 mock_server_->AddUpdateSpecifics(1, 0, "Folder", 10, 10, true, 1, |
4477 DefaultPreferencesSpecifics()); | 4483 DefaultPreferencesSpecifics()); |
4478 mock_server_->SetLastUpdateServerTag(ModelTypeToRootTag(PREFERENCES)); | 4484 mock_server_->SetLastUpdateServerTag(ModelTypeToRootTag(PREFERENCES)); |
4479 EXPECT_TRUE(SyncShareNudge()); | 4485 EXPECT_TRUE(SyncShareNudge()); |
4480 | 4486 |
4481 Id pref_root_id; | 4487 Id pref_root_id; |
4482 { | 4488 { |
4483 // Preferences type root should have been created by the update above. | 4489 // Preferences type root should have been created by the update above. |
4484 // We need it in order to get its ID. | 4490 // We need it in order to get its ID. |
4485 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4491 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 4492 |
| 4493 ASSERT_TRUE(directory()->InitialSyncEndedForType(&trans, PREFERENCES)); |
| 4494 |
4486 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); | 4495 Entry pref_root(&trans, GET_TYPE_ROOT, PREFERENCES); |
4487 ASSERT_TRUE(pref_root.good()); | 4496 ASSERT_TRUE(pref_root.good()); |
4488 pref_root_id = pref_root.GetId(); | 4497 pref_root_id = pref_root.GetId(); |
4489 } | 4498 } |
4490 | 4499 |
4491 // Add a preference item with explicit parent ID. | 4500 // Add a preference item with explicit parent ID. |
4492 { | 4501 { |
4493 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 4502 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
4494 MutableEntry entry(&trans, CREATE, PREFERENCES, pref_root_id, "tag"); | 4503 MutableEntry entry(&trans, CREATE, PREFERENCES, pref_root_id, "tag"); |
4495 ASSERT_TRUE(entry.good()); | 4504 ASSERT_TRUE(entry.good()); |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5597 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 5606 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
5598 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 5607 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
5599 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 5608 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
5600 } else { | 5609 } else { |
5601 EXPECT_TRUE(final_monitor_records.empty()) | 5610 EXPECT_TRUE(final_monitor_records.empty()) |
5602 << "Should not restore records after successful bookmark commit."; | 5611 << "Should not restore records after successful bookmark commit."; |
5603 } | 5612 } |
5604 } | 5613 } |
5605 | 5614 |
5606 } // namespace syncer | 5615 } // namespace syncer |
OLD | NEW |