| OLD | NEW |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 using syncable::SERVER_PARENT_ID; | 98 using syncable::SERVER_PARENT_ID; |
| 99 using syncable::SERVER_POSITION_IN_PARENT; | 99 using syncable::SERVER_POSITION_IN_PARENT; |
| 100 using syncable::SERVER_SPECIFICS; | 100 using syncable::SERVER_SPECIFICS; |
| 101 using syncable::SERVER_VERSION; | 101 using syncable::SERVER_VERSION; |
| 102 using syncable::UNIQUE_CLIENT_TAG; | 102 using syncable::UNIQUE_CLIENT_TAG; |
| 103 using syncable::UNIQUE_SERVER_TAG; | 103 using syncable::UNIQUE_SERVER_TAG; |
| 104 using syncable::SPECIFICS; | 104 using syncable::SPECIFICS; |
| 105 using syncable::SYNCING; | 105 using syncable::SYNCING; |
| 106 using syncable::UNITTEST; | 106 using syncable::UNITTEST; |
| 107 | 107 |
| 108 using sessions::ConflictProgress; | |
| 109 using sessions::ScopedSetSessionWriteTransaction; | 108 using sessions::ScopedSetSessionWriteTransaction; |
| 110 using sessions::StatusController; | 109 using sessions::StatusController; |
| 111 using sessions::SyncSessionContext; | 110 using sessions::SyncSessionContext; |
| 112 using sessions::SyncSession; | 111 using sessions::SyncSession; |
| 113 | 112 |
| 114 class SyncerTest : public testing::Test, | 113 class SyncerTest : public testing::Test, |
| 115 public SyncSession::Delegate, | 114 public SyncSession::Delegate, |
| 116 public SyncEngineEventListener { | 115 public SyncEngineEventListener { |
| 117 protected: | 116 protected: |
| 118 SyncerTest() | 117 SyncerTest() |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 std::vector<ModelSafeWorker*> workers; | 177 std::vector<ModelSafeWorker*> workers; |
| 179 GetModelSafeRoutingInfo(&info); | 178 GetModelSafeRoutingInfo(&info); |
| 180 GetWorkers(&workers); | 179 GetWorkers(&workers); |
| 181 ModelTypeStateMap types = | 180 ModelTypeStateMap types = |
| 182 ModelSafeRoutingInfoToStateMap(info, std::string()); | 181 ModelSafeRoutingInfoToStateMap(info, std::string()); |
| 183 return new SyncSession(context_.get(), this, | 182 return new SyncSession(context_.get(), this, |
| 184 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), | 183 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), |
| 185 info, workers); | 184 info, workers); |
| 186 } | 185 } |
| 187 | 186 |
| 188 bool SyncShareAsDelegate( | 187 void SyncShareAsDelegate( |
| 189 SyncSchedulerImpl::SyncSessionJob::SyncSessionJobPurpose purpose) { | 188 SyncSchedulerImpl::SyncSessionJob::SyncSessionJobPurpose purpose) { |
| 190 SyncerStep start; | 189 SyncerStep start; |
| 191 SyncerStep end; | 190 SyncerStep end; |
| 192 SyncSchedulerImpl::SetSyncerStepsForPurpose(purpose, &start, &end); | 191 SyncSchedulerImpl::SetSyncerStepsForPurpose(purpose, &start, &end); |
| 193 | 192 |
| 194 session_.reset(MakeSession()); | 193 session_.reset(MakeSession()); |
| 195 syncer_->SyncShare(session_.get(), start, end); | 194 syncer_->SyncShare(session_.get(), start, end); |
| 196 return session_->HasMoreToSync(); | |
| 197 } | 195 } |
| 198 | 196 |
| 199 bool SyncShareNudge() { | 197 void SyncShareNudge() { |
| 200 session_.reset(MakeSession()); | 198 session_.reset(MakeSession()); |
| 201 return SyncShareAsDelegate(SyncSchedulerImpl::SyncSessionJob::NUDGE); | 199 SyncShareAsDelegate(SyncSchedulerImpl::SyncSessionJob::NUDGE); |
| 202 } | 200 } |
| 203 | 201 |
| 204 bool SyncShareConfigure() { | 202 void SyncShareConfigure() { |
| 205 session_.reset(MakeSession()); | 203 session_.reset(MakeSession()); |
| 206 return SyncShareAsDelegate( | 204 SyncShareAsDelegate(SyncSchedulerImpl::SyncSessionJob::CONFIGURATION); |
| 207 SyncSchedulerImpl::SyncSessionJob::CONFIGURATION); | |
| 208 } | |
| 209 | |
| 210 void LoopSyncShare() { | |
| 211 bool should_loop = false; | |
| 212 int loop_iterations = 0; | |
| 213 do { | |
| 214 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; | |
| 215 should_loop = SyncShareNudge(); | |
| 216 } while (should_loop); | |
| 217 } | 205 } |
| 218 | 206 |
| 219 virtual void SetUp() { | 207 virtual void SetUp() { |
| 220 dir_maker_.SetUp(); | 208 dir_maker_.SetUp(); |
| 221 mock_server_.reset(new MockConnectionManager(directory())); | 209 mock_server_.reset(new MockConnectionManager(directory())); |
| 222 EnableDatatype(BOOKMARKS); | 210 EnableDatatype(BOOKMARKS); |
| 223 EnableDatatype(NIGORI); | 211 EnableDatatype(NIGORI); |
| 224 EnableDatatype(PREFERENCES); | 212 EnableDatatype(PREFERENCES); |
| 225 EnableDatatype(NIGORI); | 213 EnableDatatype(NIGORI); |
| 226 worker_ = new FakeModelWorker(GROUP_PASSIVE); | 214 worker_ = new FakeModelWorker(GROUP_PASSIVE); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 case MOVED_FROM_ROOT: | 371 case MOVED_FROM_ROOT: |
| 384 entry.Put(SERVER_PARENT_ID, trans.root_id()); | 372 entry.Put(SERVER_PARENT_ID, trans.root_id()); |
| 385 break; | 373 break; |
| 386 default: | 374 default: |
| 387 FAIL() << "Bad value in CommitOrderingTest list"; | 375 FAIL() << "Bad value in CommitOrderingTest list"; |
| 388 } | 376 } |
| 389 } | 377 } |
| 390 test++; | 378 test++; |
| 391 } | 379 } |
| 392 } | 380 } |
| 393 LoopSyncShare(); | 381 SyncShareNudge(); |
| 394 ASSERT_TRUE(expected_positions.size() == | 382 ASSERT_TRUE(expected_positions.size() == |
| 395 mock_server_->committed_ids().size()); | 383 mock_server_->committed_ids().size()); |
| 396 // If this test starts failing, be aware other sort orders could be valid. | 384 // If this test starts failing, be aware other sort orders could be valid. |
| 397 for (size_t i = 0; i < expected_positions.size(); ++i) { | 385 for (size_t i = 0; i < expected_positions.size(); ++i) { |
| 398 EXPECT_EQ(1u, expected_positions.count(i)); | 386 EXPECT_EQ(1u, expected_positions.count(i)); |
| 399 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); | 387 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); |
| 400 } | 388 } |
| 401 } | 389 } |
| 402 | 390 |
| 403 void DoTruncationTest(const vector<int64>& unsynced_handle_view, | 391 void DoTruncationTest(const vector<int64>& unsynced_handle_view, |
| (...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 // because any string sent by the server is a legal server ID in the sync | 1686 // because any string sent by the server is a legal server ID in the sync |
| 1699 // protocol, but it's not the ID of any item known to the client. This | 1687 // protocol, but it's not the ID of any item known to the client. This |
| 1700 // update should succeed validation, but be stuck in the unapplied state | 1688 // update should succeed validation, but be stuck in the unapplied state |
| 1701 // until an item with the server ID "-80" arrives. | 1689 // until an item with the server ID "-80" arrives. |
| 1702 mock_server_->AddUpdateDirectory(3, -80, "bad_parent", 10, 10); | 1690 mock_server_->AddUpdateDirectory(3, -80, "bad_parent", 10, 10); |
| 1703 | 1691 |
| 1704 SyncShareNudge(); | 1692 SyncShareNudge(); |
| 1705 | 1693 |
| 1706 // Id 3 should be in conflict now. | 1694 // Id 3 should be in conflict now. |
| 1707 EXPECT_EQ(1, status().TotalNumConflictingItems()); | 1695 EXPECT_EQ(1, status().TotalNumConflictingItems()); |
| 1708 { | 1696 EXPECT_EQ(1, status().num_hierarchy_conflicts()); |
| 1709 sessions::ScopedModelSafeGroupRestriction r( | |
| 1710 session_->mutable_status_controller(), GROUP_PASSIVE); | |
| 1711 ASSERT_TRUE(status().conflict_progress()); | |
| 1712 EXPECT_EQ(1, status().conflict_progress()->HierarchyConflictingItemsSize()); | |
| 1713 } | |
| 1714 | 1697 |
| 1715 // These entries will be used in the second set of updates. | 1698 // These entries will be used in the second set of updates. |
| 1716 mock_server_->AddUpdateDirectory(4, 0, "newer_version", 20, 10); | 1699 mock_server_->AddUpdateDirectory(4, 0, "newer_version", 20, 10); |
| 1717 mock_server_->AddUpdateDirectory(5, 0, "circular1", 10, 10); | 1700 mock_server_->AddUpdateDirectory(5, 0, "circular1", 10, 10); |
| 1718 mock_server_->AddUpdateDirectory(6, 5, "circular2", 10, 10); | 1701 mock_server_->AddUpdateDirectory(6, 5, "circular2", 10, 10); |
| 1719 mock_server_->AddUpdateDirectory(9, 3, "bad_parent_child", 10, 10); | 1702 mock_server_->AddUpdateDirectory(9, 3, "bad_parent_child", 10, 10); |
| 1720 mock_server_->AddUpdateDirectory(100, 9, "bad_parent_child2", 10, 10); | 1703 mock_server_->AddUpdateDirectory(100, 9, "bad_parent_child2", 10, 10); |
| 1721 mock_server_->AddUpdateDirectory(10, 0, "dir_to_bookmark", 10, 10); | 1704 mock_server_->AddUpdateDirectory(10, 0, "dir_to_bookmark", 10, 10); |
| 1722 | 1705 |
| 1723 SyncShareNudge(); | 1706 SyncShareNudge(); |
| 1724 // The three items with an unresolved parent should be unapplied (3, 9, 100). | 1707 // The three items with an unresolved parent should be unapplied (3, 9, 100). |
| 1725 // The name clash should also still be in conflict. | 1708 // The name clash should also still be in conflict. |
| 1726 EXPECT_EQ(3, status().TotalNumConflictingItems()); | 1709 EXPECT_EQ(3, status().TotalNumConflictingItems()); |
| 1727 { | 1710 EXPECT_EQ(3, status().num_hierarchy_conflicts()); |
| 1728 sessions::ScopedModelSafeGroupRestriction r( | |
| 1729 session_->mutable_status_controller(), GROUP_PASSIVE); | |
| 1730 ASSERT_TRUE(status().conflict_progress()); | |
| 1731 EXPECT_EQ(3, status().conflict_progress()->HierarchyConflictingItemsSize()); | |
| 1732 } | |
| 1733 | 1711 |
| 1734 { | 1712 { |
| 1735 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1713 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
| 1736 // Even though it has the same name, it should work. | 1714 // Even though it has the same name, it should work. |
| 1737 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); | 1715 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 1738 ASSERT_TRUE(name_clash.good()); | 1716 ASSERT_TRUE(name_clash.good()); |
| 1739 EXPECT_FALSE(name_clash.Get(IS_UNAPPLIED_UPDATE)) | 1717 EXPECT_FALSE(name_clash.Get(IS_UNAPPLIED_UPDATE)) |
| 1740 << "Duplicate name SHOULD be OK."; | 1718 << "Duplicate name SHOULD be OK."; |
| 1741 | 1719 |
| 1742 Entry bad_parent(&trans, GET_BY_ID, ids_.FromNumber(3)); | 1720 Entry bad_parent(&trans, GET_BY_ID, ids_.FromNumber(3)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1812 Entry circular_parent_target(&trans, GET_BY_ID, ids_.FromNumber(6)); | 1790 Entry circular_parent_target(&trans, GET_BY_ID, ids_.FromNumber(6)); |
| 1813 ASSERT_TRUE(circular_parent_target.good()); | 1791 ASSERT_TRUE(circular_parent_target.good()); |
| 1814 EXPECT_FALSE(circular_parent_target.Get(IS_UNAPPLIED_UPDATE)); | 1792 EXPECT_FALSE(circular_parent_target.Get(IS_UNAPPLIED_UPDATE)); |
| 1815 EXPECT_TRUE(circular_parent_issue.Get(ID) == | 1793 EXPECT_TRUE(circular_parent_issue.Get(ID) == |
| 1816 circular_parent_target.Get(PARENT_ID)); | 1794 circular_parent_target.Get(PARENT_ID)); |
| 1817 EXPECT_EQ(10u, circular_parent_target.Get(BASE_VERSION)); | 1795 EXPECT_EQ(10u, circular_parent_target.Get(BASE_VERSION)); |
| 1818 } | 1796 } |
| 1819 | 1797 |
| 1820 EXPECT_FALSE(saw_syncer_event_); | 1798 EXPECT_FALSE(saw_syncer_event_); |
| 1821 EXPECT_EQ(4, status().TotalNumConflictingItems()); | 1799 EXPECT_EQ(4, status().TotalNumConflictingItems()); |
| 1822 { | 1800 EXPECT_EQ(4, status().num_hierarchy_conflicts()); |
| 1823 sessions::ScopedModelSafeGroupRestriction r( | |
| 1824 session_->mutable_status_controller(), GROUP_PASSIVE); | |
| 1825 ASSERT_TRUE(status().conflict_progress()); | |
| 1826 EXPECT_EQ(4, status().conflict_progress()->HierarchyConflictingItemsSize()); | |
| 1827 } | |
| 1828 } | 1801 } |
| 1829 | 1802 |
| 1830 TEST_F(SyncerTest, CommitTimeRename) { | 1803 TEST_F(SyncerTest, CommitTimeRename) { |
| 1831 int64 metahandle_folder; | 1804 int64 metahandle_folder; |
| 1832 int64 metahandle_new_entry; | 1805 int64 metahandle_new_entry; |
| 1833 | 1806 |
| 1834 // Create a folder and an entry. | 1807 // Create a folder and an entry. |
| 1835 { | 1808 { |
| 1836 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1809 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
| 1837 MutableEntry parent(&trans, CREATE, root_id_, "Folder"); | 1810 MutableEntry parent(&trans, CREATE, root_id_, "Folder"); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 ASSERT_TRUE(A.good()); | 2101 ASSERT_TRUE(A.good()); |
| 2129 A.Put(IS_UNSYNCED, true); | 2102 A.Put(IS_UNSYNCED, true); |
| 2130 A.Put(IS_UNAPPLIED_UPDATE, true); | 2103 A.Put(IS_UNAPPLIED_UPDATE, true); |
| 2131 A.Put(SERVER_VERSION, 20); | 2104 A.Put(SERVER_VERSION, 20); |
| 2132 | 2105 |
| 2133 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2106 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
| 2134 ASSERT_TRUE(B.good()); | 2107 ASSERT_TRUE(B.good()); |
| 2135 B.Put(IS_UNAPPLIED_UPDATE, true); | 2108 B.Put(IS_UNAPPLIED_UPDATE, true); |
| 2136 B.Put(SERVER_VERSION, 20); | 2109 B.Put(SERVER_VERSION, 20); |
| 2137 } | 2110 } |
| 2138 LoopSyncShare(); | 2111 SyncShareNudge(); |
| 2139 saw_syncer_event_ = false; | 2112 saw_syncer_event_ = false; |
| 2140 mock_server_->set_conflict_all_commits(false); | 2113 mock_server_->set_conflict_all_commits(false); |
| 2141 | 2114 |
| 2142 { | 2115 { |
| 2143 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2116 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 2144 | 2117 |
| 2145 Entry A(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2118 Entry A(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2146 ASSERT_TRUE(A.good()); | 2119 ASSERT_TRUE(A.good()); |
| 2147 EXPECT_TRUE(A.Get(IS_UNSYNCED) == false); | 2120 EXPECT_TRUE(A.Get(IS_UNSYNCED) == false); |
| 2148 EXPECT_TRUE(A.Get(IS_UNAPPLIED_UPDATE) == false); | 2121 EXPECT_TRUE(A.Get(IS_UNAPPLIED_UPDATE) == false); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2168 ASSERT_TRUE(A.good()); | 2141 ASSERT_TRUE(A.good()); |
| 2169 A.Put(IS_UNSYNCED, true); | 2142 A.Put(IS_UNSYNCED, true); |
| 2170 A.Put(IS_UNAPPLIED_UPDATE, true); | 2143 A.Put(IS_UNAPPLIED_UPDATE, true); |
| 2171 A.Put(SERVER_VERSION, 20); | 2144 A.Put(SERVER_VERSION, 20); |
| 2172 | 2145 |
| 2173 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2146 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
| 2174 ASSERT_TRUE(B.good()); | 2147 ASSERT_TRUE(B.good()); |
| 2175 B.Put(IS_UNAPPLIED_UPDATE, true); | 2148 B.Put(IS_UNAPPLIED_UPDATE, true); |
| 2176 B.Put(SERVER_VERSION, 20); | 2149 B.Put(SERVER_VERSION, 20); |
| 2177 } | 2150 } |
| 2178 LoopSyncShare(); | 2151 SyncShareNudge(); |
| 2179 saw_syncer_event_ = false; | 2152 saw_syncer_event_ = false; |
| 2180 mock_server_->set_conflict_all_commits(false); | 2153 mock_server_->set_conflict_all_commits(false); |
| 2181 | 2154 |
| 2182 { | 2155 { |
| 2183 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2156 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 2184 | 2157 |
| 2185 Entry A(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2158 Entry A(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2186 ASSERT_TRUE(A.good()); | 2159 ASSERT_TRUE(A.good()); |
| 2187 EXPECT_TRUE(A.Get(IS_UNSYNCED) == false); | 2160 EXPECT_TRUE(A.Get(IS_UNSYNCED) == false); |
| 2188 EXPECT_TRUE(A.Get(IS_UNAPPLIED_UPDATE) == false); | 2161 EXPECT_TRUE(A.Get(IS_UNAPPLIED_UPDATE) == false); |
| 2189 EXPECT_TRUE(A.Get(SERVER_VERSION) == 20); | 2162 EXPECT_TRUE(A.Get(SERVER_VERSION) == 20); |
| 2190 | 2163 |
| 2191 Entry B(&trans, GET_BY_ID, ids_.FromNumber(2)); | 2164 Entry B(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 2192 ASSERT_TRUE(B.good()); | 2165 ASSERT_TRUE(B.good()); |
| 2193 EXPECT_TRUE(B.Get(IS_UNSYNCED) == false); | 2166 EXPECT_TRUE(B.Get(IS_UNSYNCED) == false); |
| 2194 EXPECT_TRUE(B.Get(IS_UNAPPLIED_UPDATE) == false); | 2167 EXPECT_TRUE(B.Get(IS_UNAPPLIED_UPDATE) == false); |
| 2195 EXPECT_TRUE(B.Get(SERVER_VERSION) == 20); | 2168 EXPECT_TRUE(B.Get(SERVER_VERSION) == 20); |
| 2196 } | 2169 } |
| 2197 } | 2170 } |
| 2198 | 2171 |
| 2199 TEST_F(SyncerTest, ReverseFolderOrderingTest) { | 2172 TEST_F(SyncerTest, ReverseFolderOrderingTest) { |
| 2200 mock_server_->AddUpdateDirectory(4, 3, "ggchild", 10, 10); | 2173 mock_server_->AddUpdateDirectory(4, 3, "ggchild", 10, 10); |
| 2201 mock_server_->AddUpdateDirectory(3, 2, "gchild", 10, 10); | 2174 mock_server_->AddUpdateDirectory(3, 2, "gchild", 10, 10); |
| 2202 mock_server_->AddUpdateDirectory(5, 4, "gggchild", 10, 10); | 2175 mock_server_->AddUpdateDirectory(5, 4, "gggchild", 10, 10); |
| 2203 mock_server_->AddUpdateDirectory(2, 1, "child", 10, 10); | 2176 mock_server_->AddUpdateDirectory(2, 1, "child", 10, 10); |
| 2204 mock_server_->AddUpdateDirectory(1, 0, "parent", 10, 10); | 2177 mock_server_->AddUpdateDirectory(1, 0, "parent", 10, 10); |
| 2205 LoopSyncShare(); | 2178 SyncShareNudge(); |
| 2206 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2179 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 2207 | 2180 |
| 2208 Id child_id = GetOnlyEntryWithName( | 2181 Id child_id = GetOnlyEntryWithName( |
| 2209 &trans, ids_.FromNumber(4), "gggchild"); | 2182 &trans, ids_.FromNumber(4), "gggchild"); |
| 2210 Entry child(&trans, GET_BY_ID, child_id); | 2183 Entry child(&trans, GET_BY_ID, child_id); |
| 2211 ASSERT_TRUE(child.good()); | 2184 ASSERT_TRUE(child.good()); |
| 2212 } | 2185 } |
| 2213 | 2186 |
| 2214 class EntryCreatedInNewFolderTest : public SyncerTest { | 2187 class EntryCreatedInNewFolderTest : public SyncerTest { |
| 2215 public: | 2188 public: |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 parent.Put(syncable::BASE_VERSION, 5); | 2289 parent.Put(syncable::BASE_VERSION, 5); |
| 2317 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 2290 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
| 2318 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete.htm"); | 2291 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete.htm"); |
| 2319 ASSERT_TRUE(child.good()); | 2292 ASSERT_TRUE(child.good()); |
| 2320 child.Put(syncable::ID, child_id_); | 2293 child.Put(syncable::ID, child_id_); |
| 2321 child.Put(syncable::BASE_VERSION, 10); | 2294 child.Put(syncable::BASE_VERSION, 10); |
| 2322 WriteTestDataToEntry(&wtrans, &child); | 2295 WriteTestDataToEntry(&wtrans, &child); |
| 2323 } | 2296 } |
| 2324 mock_server_->AddUpdateBookmark(child_id_, parent_id_, "Pete2.htm", 11, 10); | 2297 mock_server_->AddUpdateBookmark(child_id_, parent_id_, "Pete2.htm", 11, 10); |
| 2325 mock_server_->set_conflict_all_commits(true); | 2298 mock_server_->set_conflict_all_commits(true); |
| 2326 LoopSyncShare(); | 2299 SyncShareNudge(); |
| 2327 syncable::Directory::ChildHandles children; | 2300 syncable::Directory::ChildHandles children; |
| 2328 { | 2301 { |
| 2329 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2302 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 2330 directory()->GetChildHandlesById(&trans, parent_id_, &children); | 2303 directory()->GetChildHandlesById(&trans, parent_id_, &children); |
| 2331 // We expect the conflict resolver to preserve the local entry. | 2304 // We expect the conflict resolver to preserve the local entry. |
| 2332 Entry child(&trans, syncable::GET_BY_ID, child_id_); | 2305 Entry child(&trans, syncable::GET_BY_ID, child_id_); |
| 2333 ASSERT_TRUE(child.good()); | 2306 ASSERT_TRUE(child.good()); |
| 2334 EXPECT_TRUE(child.Get(syncable::IS_UNSYNCED)); | 2307 EXPECT_TRUE(child.Get(syncable::IS_UNSYNCED)); |
| 2335 EXPECT_FALSE(child.Get(syncable::IS_UNAPPLIED_UPDATE)); | 2308 EXPECT_FALSE(child.Get(syncable::IS_UNAPPLIED_UPDATE)); |
| 2336 EXPECT_TRUE(child.Get(SPECIFICS).has_bookmark()); | 2309 EXPECT_TRUE(child.Get(SPECIFICS).has_bookmark()); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); | 2480 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); |
| 2508 ASSERT_TRUE(existing.good()); | 2481 ASSERT_TRUE(existing.good()); |
| 2509 existing.Put(PARENT_ID, newfolder.Get(ID)); | 2482 existing.Put(PARENT_ID, newfolder.Get(ID)); |
| 2510 existing.Put(IS_UNSYNCED, true); | 2483 existing.Put(IS_UNSYNCED, true); |
| 2511 EXPECT_TRUE(existing.Get(ID).ServerKnows()); | 2484 EXPECT_TRUE(existing.Get(ID).ServerKnows()); |
| 2512 | 2485 |
| 2513 newfolder.Put(IS_DEL, true); | 2486 newfolder.Put(IS_DEL, true); |
| 2514 existing.Put(IS_DEL, true); | 2487 existing.Put(IS_DEL, true); |
| 2515 } | 2488 } |
| 2516 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 2489 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
| 2517 EXPECT_EQ(0, status().TotalNumServerConflictingItems()); | 2490 EXPECT_EQ(0, status().num_server_conflicts()); |
| 2518 } | 2491 } |
| 2519 | 2492 |
| 2520 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { | 2493 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { |
| 2521 int64 newfolder_metahandle; | 2494 int64 newfolder_metahandle; |
| 2522 | 2495 |
| 2523 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2496 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
| 2524 SyncShareNudge(); | 2497 SyncShareNudge(); |
| 2525 { | 2498 { |
| 2526 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2499 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
| 2527 MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), "local"); | 2500 MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), "local"); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2616 string nameutf8 = base::StringPrintf("%d", i); | 2589 string nameutf8 = base::StringPrintf("%d", i); |
| 2617 string name(nameutf8.begin(), nameutf8.end()); | 2590 string name(nameutf8.begin(), nameutf8.end()); |
| 2618 MutableEntry e(&trans, CREATE, trans.root_id(), name); | 2591 MutableEntry e(&trans, CREATE, trans.root_id(), name); |
| 2619 e.Put(IS_UNSYNCED, true); | 2592 e.Put(IS_UNSYNCED, true); |
| 2620 e.Put(IS_DIR, true); | 2593 e.Put(IS_DIR, true); |
| 2621 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2594 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
| 2622 } | 2595 } |
| 2623 } | 2596 } |
| 2624 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 2597 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
| 2625 | 2598 |
| 2626 EXPECT_FALSE(SyncShareNudge()); | 2599 SyncShareNudge(); |
| 2627 EXPECT_EQ(num_batches, mock_server_->commit_messages().size()); | 2600 EXPECT_EQ(num_batches, mock_server_->commit_messages().size()); |
| 2628 EXPECT_EQ(0, directory()->unsynced_entity_count()); | 2601 EXPECT_EQ(0, directory()->unsynced_entity_count()); |
| 2629 } | 2602 } |
| 2630 | 2603 |
| 2631 // Test that a single failure to contact the server will cause us to exit the | 2604 // Test that a single failure to contact the server will cause us to exit the |
| 2632 // commit loop immediately. | 2605 // commit loop immediately. |
| 2633 TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) { | 2606 TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) { |
| 2634 uint32 num_batches = 3; | 2607 uint32 num_batches = 3; |
| 2635 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; | 2608 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; |
| 2636 { | 2609 { |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3156 EXPECT_TRUE(child.good()); | 3129 EXPECT_TRUE(child.good()); |
| 3157 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); | 3130 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); |
| 3158 EXPECT_TRUE(child.Get(IS_DEL)); | 3131 EXPECT_TRUE(child.Get(IS_DEL)); |
| 3159 EXPECT_FALSE(child.Get(IS_UNSYNCED)); | 3132 EXPECT_FALSE(child.Get(IS_UNSYNCED)); |
| 3160 } | 3133 } |
| 3161 | 3134 |
| 3162 // And finally the folder. | 3135 // And finally the folder. |
| 3163 mock_server_->AddUpdateDirectory(folder_id, | 3136 mock_server_->AddUpdateDirectory(folder_id, |
| 3164 TestIdFactory::root(), "folder", 1, 1); | 3137 TestIdFactory::root(), "folder", 1, 1); |
| 3165 mock_server_->SetChangesRemaining(0); | 3138 mock_server_->SetChangesRemaining(0); |
| 3166 LoopSyncShare(); | 3139 SyncShareNudge(); |
| 3167 LoopSyncShare(); | 3140 SyncShareNudge(); |
| 3168 // Check that everything is as expected after the commit. | 3141 // Check that everything is as expected after the commit. |
| 3169 { | 3142 { |
| 3170 syncable::ReadTransaction trans(FROM_HERE, directory()); | 3143 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 3171 Entry entry(&trans, GET_BY_ID, folder_id); | 3144 Entry entry(&trans, GET_BY_ID, folder_id); |
| 3172 ASSERT_TRUE(entry.good()); | 3145 ASSERT_TRUE(entry.good()); |
| 3173 Entry child(&trans, GET_BY_ID, stuck_entry_id); | 3146 Entry child(&trans, GET_BY_ID, stuck_entry_id); |
| 3174 EXPECT_EQ(entry.Get(ID), child.Get(PARENT_ID)); | 3147 EXPECT_EQ(entry.Get(ID), child.Get(PARENT_ID)); |
| 3175 EXPECT_EQ("stuck", child.Get(NON_UNIQUE_NAME)); | 3148 EXPECT_EQ("stuck", child.Get(NON_UNIQUE_NAME)); |
| 3176 EXPECT_TRUE(child.good()); | 3149 EXPECT_TRUE(child.good()); |
| 3177 } | 3150 } |
| (...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4779 | 4752 |
| 4780 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4753 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
| 4781 Add(mid_id_); | 4754 Add(mid_id_); |
| 4782 Add(low_id_); | 4755 Add(low_id_); |
| 4783 Add(high_id_); | 4756 Add(high_id_); |
| 4784 SyncShareNudge(); | 4757 SyncShareNudge(); |
| 4785 ExpectLocalOrderIsByServerId(); | 4758 ExpectLocalOrderIsByServerId(); |
| 4786 } | 4759 } |
| 4787 | 4760 |
| 4788 } // namespace syncer | 4761 } // namespace syncer |
| OLD | NEW |