Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: sync/engine/syncer_unittest.cc

Issue 10389103: Sync: Clear IS_UNSYNCED for deleted local items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary wrapper function Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/process_updates_command.cc ('k') | sync/engine/syncer_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 grandchild.Put(syncable::IS_UNSYNCED, true); 1443 grandchild.Put(syncable::IS_UNSYNCED, true);
1444 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); 1444 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
1445 grandchild.Put(syncable::BASE_VERSION, 1); 1445 grandchild.Put(syncable::BASE_VERSION, 1);
1446 } 1446 }
1447 { 1447 {
1448 // Create three deleted items which deletions we expect to be sent to the 1448 // Create three deleted items which deletions we expect to be sent to the
1449 // server. 1449 // server.
1450 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), 1450 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(),
1451 "Pete"); 1451 "Pete");
1452 ASSERT_TRUE(parent.good()); 1452 ASSERT_TRUE(parent.good());
1453 parent.Put(syncable::ID, ids_.FromNumber(103));
1453 parent.Put(syncable::IS_UNSYNCED, true); 1454 parent.Put(syncable::IS_UNSYNCED, true);
1454 parent.Put(syncable::IS_DIR, true); 1455 parent.Put(syncable::IS_DIR, true);
1455 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); 1456 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
1456 parent.Put(syncable::IS_DEL, true); 1457 parent.Put(syncable::IS_DEL, true);
1457 parent.Put(syncable::ID, ids_.FromNumber(103));
1458 parent.Put(syncable::BASE_VERSION, 1); 1458 parent.Put(syncable::BASE_VERSION, 1);
1459 parent.Put(syncable::MTIME, now_minus_2h); 1459 parent.Put(syncable::MTIME, now_minus_2h);
1460 MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(103), 1460 MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(103),
1461 "Pete"); 1461 "Pete");
1462 ASSERT_TRUE(child.good()); 1462 ASSERT_TRUE(child.good());
1463 child.Put(syncable::ID, ids_.FromNumber(104));
1463 child.Put(syncable::IS_UNSYNCED, true); 1464 child.Put(syncable::IS_UNSYNCED, true);
1464 child.Put(syncable::IS_DIR, true); 1465 child.Put(syncable::IS_DIR, true);
1465 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); 1466 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
1466 child.Put(syncable::IS_DEL, true); 1467 child.Put(syncable::IS_DEL, true);
1467 child.Put(syncable::ID, ids_.FromNumber(104));
1468 child.Put(syncable::BASE_VERSION, 1); 1468 child.Put(syncable::BASE_VERSION, 1);
1469 child.Put(syncable::MTIME, now_minus_2h); 1469 child.Put(syncable::MTIME, now_minus_2h);
1470 MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(104), 1470 MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(104),
1471 "Pete"); 1471 "Pete");
1472 ASSERT_TRUE(grandchild.good()); 1472 ASSERT_TRUE(grandchild.good());
1473 grandchild.Put(syncable::ID, ids_.FromNumber(105));
1473 grandchild.Put(syncable::IS_UNSYNCED, true); 1474 grandchild.Put(syncable::IS_UNSYNCED, true);
1474 grandchild.Put(syncable::ID, ids_.FromNumber(105));
1475 grandchild.Put(syncable::IS_DEL, true); 1475 grandchild.Put(syncable::IS_DEL, true);
1476 grandchild.Put(syncable::IS_DIR, false); 1476 grandchild.Put(syncable::IS_DIR, false);
1477 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); 1477 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
1478 grandchild.Put(syncable::BASE_VERSION, 1); 1478 grandchild.Put(syncable::BASE_VERSION, 1);
1479 grandchild.Put(syncable::MTIME, now_minus_2h); 1479 grandchild.Put(syncable::MTIME, now_minus_2h);
1480 } 1480 }
1481 } 1481 }
1482 1482
1483 SyncShareNudge(); 1483 SyncShareNudge();
1484 EXPECT_EQ(6u, session_->status_controller().unsynced_handles().size()); 1484 EXPECT_EQ(6u, session_->status_controller().unsynced_handles().size());
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 EXPECT_EQ("clientperm", perm_folder.Get(UNIQUE_CLIENT_TAG)); 3702 EXPECT_EQ("clientperm", perm_folder.Get(UNIQUE_CLIENT_TAG));
3703 EXPECT_EQ("clientname", perm_folder.Get(NON_UNIQUE_NAME)); 3703 EXPECT_EQ("clientname", perm_folder.Get(NON_UNIQUE_NAME));
3704 EXPECT_EQ(local_bookmark.SerializeAsString(), 3704 EXPECT_EQ(local_bookmark.SerializeAsString(),
3705 perm_folder.Get(SPECIFICS).SerializeAsString()); 3705 perm_folder.Get(SPECIFICS).SerializeAsString());
3706 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows()); 3706 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows());
3707 } 3707 }
3708 } 3708 }
3709 3709
3710 TEST_F(SyncerTest, ClientTagConflictWithDeletedLocalEntry) { 3710 TEST_F(SyncerTest, ClientTagConflictWithDeletedLocalEntry) {
3711 { 3711 {
3712 // Create a deleted local entry with a unique client tag.
3712 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); 3713 WriteTransaction trans(FROM_HERE, UNITTEST, directory());
3713 MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname"); 3714 MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname");
3714 ASSERT_TRUE(perm_folder.good()); 3715 ASSERT_TRUE(perm_folder.good());
3715 ASSERT_FALSE(perm_folder.Get(ID).ServerKnows()); 3716 ASSERT_FALSE(perm_folder.Get(ID).ServerKnows());
3716 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm"); 3717 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm");
3717 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); 3718 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics());
3718 perm_folder.Put(IS_UNSYNCED, true); 3719 perm_folder.Put(IS_UNSYNCED, true);
3720
3721 // Note: IS_DEL && !ServerKnows() will clear the UNSYNCED bit.
3722 // (We never attempt to commit server-unknown deleted items, so this
3723 // helps us clean up those entries).
3719 perm_folder.Put(IS_DEL, true); 3724 perm_folder.Put(IS_DEL, true);
3720 } 3725 }
3721 3726
3727 // Prepare an update with the same unique client tag.
3722 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100); 3728 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100);
3723 mock_server_->SetLastUpdateClientTag("clientperm"); 3729 mock_server_->SetLastUpdateClientTag("clientperm");
3724 mock_server_->set_conflict_all_commits(true);
3725 3730
3726 SyncShareNudge(); 3731 SyncShareNudge();
3727 // This should cause client tag overwrite. 3732 // The local entry will be overwritten.
3728 { 3733 {
3729 ReadTransaction trans(FROM_HERE, directory()); 3734 ReadTransaction trans(FROM_HERE, directory());
3730 3735
3731 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm"); 3736 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm");
3732 ASSERT_TRUE(perm_folder.good()); 3737 ASSERT_TRUE(perm_folder.good());
3733 ASSERT_TRUE(perm_folder.Get(ID).ServerKnows()); 3738 ASSERT_TRUE(perm_folder.Get(ID).ServerKnows());
3734 EXPECT_TRUE(perm_folder.Get(IS_DEL)); 3739 EXPECT_FALSE(perm_folder.Get(IS_DEL));
3735 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); 3740 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE));
3736 EXPECT_TRUE(perm_folder.Get(IS_UNSYNCED)); 3741 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED));
3737 EXPECT_EQ(perm_folder.Get(BASE_VERSION), 10); 3742 EXPECT_EQ(perm_folder.Get(BASE_VERSION), 10);
3738 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "clientperm"); 3743 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "clientperm");
3739 } 3744 }
3740 } 3745 }
3741 3746
3742 TEST_F(SyncerTest, ClientTagUpdateClashesWithLocalEntry) { 3747 TEST_F(SyncerTest, ClientTagUpdateClashesWithLocalEntry) {
3743 // This test is written assuming that ID comparison 3748 // This test is written assuming that ID comparison
3744 // will work out in a particular way. 3749 // will work out in a particular way.
3745 EXPECT_TRUE(ids_.FromNumber(1) < ids_.FromNumber(2)); 3750 EXPECT_TRUE(ids_.FromNumber(1) < ids_.FromNumber(2));
3746 EXPECT_TRUE(ids_.FromNumber(3) < ids_.FromNumber(4)); 3751 EXPECT_TRUE(ids_.FromNumber(3) < ids_.FromNumber(4));
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
4759 4764
4760 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { 4765 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) {
4761 Add(mid_id_); 4766 Add(mid_id_);
4762 Add(low_id_); 4767 Add(low_id_);
4763 Add(high_id_); 4768 Add(high_id_);
4764 SyncShareNudge(); 4769 SyncShareNudge();
4765 ExpectLocalOrderIsByServerId(); 4770 ExpectLocalOrderIsByServerId();
4766 } 4771 }
4767 4772
4768 } // namespace browser_sync 4773 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/engine/process_updates_command.cc ('k') | sync/engine/syncer_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698