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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 348 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
349 while (!test->id.IsRoot()) { | 349 while (!test->id.IsRoot()) { |
350 if (test->commit_index >= 0) { | 350 if (test->commit_index >= 0) { |
351 map<int, syncable::Id>::value_type entry(test->commit_index, | 351 map<int, syncable::Id>::value_type entry(test->commit_index, |
352 test->id); | 352 test->id); |
353 bool double_position = !expected_positions.insert(entry).second; | 353 bool double_position = !expected_positions.insert(entry).second; |
354 ASSERT_FALSE(double_position) << "Two id's expected at one position"; | 354 ASSERT_FALSE(double_position) << "Two id's expected at one position"; |
355 } | 355 } |
356 string utf8_name = test->id.GetServerId(); | 356 string utf8_name = test->id.GetServerId(); |
357 string name(utf8_name.begin(), utf8_name.end()); | 357 string name(utf8_name.begin(), utf8_name.end()); |
358 MutableEntry entry(&trans, CREATE, BOOKMARKS, test->parent_id, name); | 358 MutableEntry entry(&trans, CREATE, test->parent_id, name); |
359 | 359 |
360 entry.Put(syncable::ID, test->id); | 360 entry.Put(syncable::ID, test->id); |
361 if (test->id.ServerKnows()) { | 361 if (test->id.ServerKnows()) { |
362 entry.Put(BASE_VERSION, 5); | 362 entry.Put(BASE_VERSION, 5); |
363 entry.Put(SERVER_VERSION, 5); | 363 entry.Put(SERVER_VERSION, 5); |
364 entry.Put(SERVER_PARENT_ID, test->parent_id); | 364 entry.Put(SERVER_PARENT_ID, test->parent_id); |
365 } | 365 } |
366 entry.Put(syncable::IS_DIR, true); | 366 entry.Put(syncable::IS_DIR, true); |
367 entry.Put(syncable::IS_UNSYNCED, true); | 367 entry.Put(syncable::IS_UNSYNCED, true); |
368 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 368 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 int64 CreateUnsyncedDirectory(const string& entry_name, | 452 int64 CreateUnsyncedDirectory(const string& entry_name, |
453 const string& idstring) { | 453 const string& idstring) { |
454 return CreateUnsyncedDirectory(entry_name, | 454 return CreateUnsyncedDirectory(entry_name, |
455 syncable::Id::CreateFromServerId(idstring)); | 455 syncable::Id::CreateFromServerId(idstring)); |
456 } | 456 } |
457 | 457 |
458 int64 CreateUnsyncedDirectory(const string& entry_name, | 458 int64 CreateUnsyncedDirectory(const string& entry_name, |
459 const syncable::Id& id) { | 459 const syncable::Id& id) { |
460 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 460 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
461 MutableEntry entry( | 461 MutableEntry entry(&wtrans, syncable::CREATE, wtrans.root_id(), |
462 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), entry_name); | 462 entry_name); |
463 EXPECT_TRUE(entry.good()); | 463 EXPECT_TRUE(entry.good()); |
464 entry.Put(syncable::IS_UNSYNCED, true); | 464 entry.Put(syncable::IS_UNSYNCED, true); |
465 entry.Put(syncable::IS_DIR, true); | 465 entry.Put(syncable::IS_DIR, true); |
466 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 466 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
467 entry.Put(syncable::BASE_VERSION, id.ServerKnows() ? 1 : 0); | 467 entry.Put(syncable::BASE_VERSION, id.ServerKnows() ? 1 : 0); |
468 entry.Put(syncable::ID, id); | 468 entry.Put(syncable::ID, id); |
469 return entry.Get(META_HANDLE); | 469 return entry.Get(META_HANDLE); |
470 } | 470 } |
471 | 471 |
472 void EnableDatatype(ModelType model_type) { | 472 void EnableDatatype(ModelType model_type) { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 VERIFY_ENTRY(2, false, false, false, 1, 31, 31, ids_, &rtrans); | 980 VERIFY_ENTRY(2, false, false, false, 1, 31, 31, ids_, &rtrans); |
981 VERIFY_ENTRY(3, false, false, false, 1, 30, 30, ids_, &rtrans); | 981 VERIFY_ENTRY(3, false, false, false, 1, 30, 30, ids_, &rtrans); |
982 VERIFY_ENTRY(4, false, false, false, 0, 31, 31, ids_, &rtrans); | 982 VERIFY_ENTRY(4, false, false, false, 0, 31, 31, ids_, &rtrans); |
983 } | 983 } |
984 | 984 |
985 #undef VERIFY_ENTRY | 985 #undef VERIFY_ENTRY |
986 | 986 |
987 TEST_F(SyncerTest, TestGetUnsyncedAndSimpleCommit) { | 987 TEST_F(SyncerTest, TestGetUnsyncedAndSimpleCommit) { |
988 { | 988 { |
989 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 989 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
990 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); | 990 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), |
| 991 "Pete"); |
991 ASSERT_TRUE(parent.good()); | 992 ASSERT_TRUE(parent.good()); |
992 parent.Put(syncable::IS_UNSYNCED, true); | 993 parent.Put(syncable::IS_UNSYNCED, true); |
993 parent.Put(syncable::IS_DIR, true); | 994 parent.Put(syncable::IS_DIR, true); |
994 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 995 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
995 parent.Put(syncable::BASE_VERSION, 1); | 996 parent.Put(syncable::BASE_VERSION, 1); |
996 parent.Put(syncable::ID, parent_id_); | 997 parent.Put(syncable::ID, parent_id_); |
997 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete"); | 998 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete"); |
998 ASSERT_TRUE(child.good()); | 999 ASSERT_TRUE(child.good()); |
999 child.Put(syncable::ID, child_id_); | 1000 child.Put(syncable::ID, child_id_); |
1000 child.Put(syncable::BASE_VERSION, 1); | 1001 child.Put(syncable::BASE_VERSION, 1); |
1001 WriteTestDataToEntry(&wtrans, &child); | 1002 WriteTestDataToEntry(&wtrans, &child); |
1002 } | 1003 } |
1003 | 1004 |
1004 SyncShareNudge(); | 1005 SyncShareNudge(); |
1005 ASSERT_EQ(2u, mock_server_->committed_ids().size()); | 1006 ASSERT_EQ(2u, mock_server_->committed_ids().size()); |
1006 // If this test starts failing, be aware other sort orders could be valid. | 1007 // If this test starts failing, be aware other sort orders could be valid. |
1007 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1008 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
1008 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1009 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
1009 { | 1010 { |
1010 syncable::ReadTransaction rt(FROM_HERE, directory()); | 1011 syncable::ReadTransaction rt(FROM_HERE, directory()); |
1011 Entry entry(&rt, syncable::GET_BY_ID, child_id_); | 1012 Entry entry(&rt, syncable::GET_BY_ID, child_id_); |
1012 ASSERT_TRUE(entry.good()); | 1013 ASSERT_TRUE(entry.good()); |
1013 VerifyTestDataInEntry(&rt, &entry); | 1014 VerifyTestDataInEntry(&rt, &entry); |
1014 } | 1015 } |
1015 } | 1016 } |
1016 | 1017 |
1017 TEST_F(SyncerTest, TestPurgeWhileUnsynced) { | 1018 TEST_F(SyncerTest, TestPurgeWhileUnsynced) { |
1018 // Similar to above, but throw a purge operation into the mix. Bug 49278. | 1019 // Similar to above, but throw a purge operation into the mix. Bug 49278. |
1019 syncable::Id pref_node_id = TestIdFactory::MakeServer("Tim"); | 1020 syncable::Id pref_node_id = TestIdFactory::MakeServer("Tim"); |
1020 { | 1021 { |
1021 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1022 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1022 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); | 1023 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "Pete"); |
1023 ASSERT_TRUE(parent.good()); | 1024 ASSERT_TRUE(parent.good()); |
1024 parent.Put(syncable::IS_UNSYNCED, true); | 1025 parent.Put(syncable::IS_UNSYNCED, true); |
1025 parent.Put(syncable::IS_DIR, true); | 1026 parent.Put(syncable::IS_DIR, true); |
1026 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1027 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1027 parent.Put(syncable::BASE_VERSION, 1); | 1028 parent.Put(syncable::BASE_VERSION, 1); |
1028 parent.Put(syncable::ID, parent_id_); | 1029 parent.Put(syncable::ID, parent_id_); |
1029 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete"); | 1030 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete"); |
1030 ASSERT_TRUE(child.good()); | 1031 ASSERT_TRUE(child.good()); |
1031 child.Put(syncable::ID, child_id_); | 1032 child.Put(syncable::ID, child_id_); |
1032 child.Put(syncable::BASE_VERSION, 1); | 1033 child.Put(syncable::BASE_VERSION, 1); |
1033 WriteTestDataToEntry(&wtrans, &child); | 1034 WriteTestDataToEntry(&wtrans, &child); |
1034 | 1035 |
1035 MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Tim"); | 1036 MutableEntry parent2(&wtrans, syncable::CREATE, wtrans.root_id(), "Tim"); |
1036 ASSERT_TRUE(parent2.good()); | 1037 ASSERT_TRUE(parent2.good()); |
1037 parent2.Put(syncable::IS_UNSYNCED, true); | 1038 parent2.Put(syncable::IS_UNSYNCED, true); |
1038 parent2.Put(syncable::IS_DIR, true); | 1039 parent2.Put(syncable::IS_DIR, true); |
1039 parent2.Put(syncable::SPECIFICS, DefaultPreferencesSpecifics()); | 1040 parent2.Put(syncable::SPECIFICS, DefaultPreferencesSpecifics()); |
1040 parent2.Put(syncable::BASE_VERSION, 1); | 1041 parent2.Put(syncable::BASE_VERSION, 1); |
1041 parent2.Put(syncable::ID, pref_node_id); | 1042 parent2.Put(syncable::ID, pref_node_id); |
1042 } | 1043 } |
1043 | 1044 |
1044 directory()->PurgeEntriesWithTypeIn(ModelTypeSet(PREFERENCES)); | 1045 directory()->PurgeEntriesWithTypeIn(ModelTypeSet(PREFERENCES)); |
1045 | 1046 |
(...skipping 13 matching lines...) Expand all Loading... |
1059 syncable::ReadTransaction rt(FROM_HERE, directory()); | 1060 syncable::ReadTransaction rt(FROM_HERE, directory()); |
1060 Entry entry(&rt, syncable::GET_BY_ID, pref_node_id); | 1061 Entry entry(&rt, syncable::GET_BY_ID, pref_node_id); |
1061 ASSERT_FALSE(entry.good()); | 1062 ASSERT_FALSE(entry.good()); |
1062 } | 1063 } |
1063 } | 1064 } |
1064 | 1065 |
1065 TEST_F(SyncerTest, TestPurgeWhileUnapplied) { | 1066 TEST_F(SyncerTest, TestPurgeWhileUnapplied) { |
1066 // Similar to above, but for unapplied items. Bug 49278. | 1067 // Similar to above, but for unapplied items. Bug 49278. |
1067 { | 1068 { |
1068 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1069 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1069 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); | 1070 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "Pete"); |
1070 ASSERT_TRUE(parent.good()); | 1071 ASSERT_TRUE(parent.good()); |
1071 parent.Put(syncable::IS_UNAPPLIED_UPDATE, true); | 1072 parent.Put(syncable::IS_UNAPPLIED_UPDATE, true); |
1072 parent.Put(syncable::IS_DIR, true); | 1073 parent.Put(syncable::IS_DIR, true); |
1073 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1074 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1074 parent.Put(syncable::BASE_VERSION, 1); | 1075 parent.Put(syncable::BASE_VERSION, 1); |
1075 parent.Put(syncable::ID, parent_id_); | 1076 parent.Put(syncable::ID, parent_id_); |
1076 } | 1077 } |
1077 | 1078 |
1078 directory()->PurgeEntriesWithTypeIn( | 1079 directory()->PurgeEntriesWithTypeIn( |
1079 ModelTypeSet(BOOKMARKS)); | 1080 ModelTypeSet(BOOKMARKS)); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 }; | 1215 }; |
1215 RunCommitOrderingTest(items); | 1216 RunCommitOrderingTest(items); |
1216 } | 1217 } |
1217 | 1218 |
1218 TEST_F(SyncerTest, TestCommitListOrderingWithNesting) { | 1219 TEST_F(SyncerTest, TestCommitListOrderingWithNesting) { |
1219 const base::Time& now_minus_2h = | 1220 const base::Time& now_minus_2h = |
1220 base::Time::Now() - base::TimeDelta::FromHours(2); | 1221 base::Time::Now() - base::TimeDelta::FromHours(2); |
1221 { | 1222 { |
1222 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1223 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1223 { | 1224 { |
1224 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bob"); | 1225 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), |
| 1226 "Bob"); |
1225 ASSERT_TRUE(parent.good()); | 1227 ASSERT_TRUE(parent.good()); |
1226 parent.Put(syncable::IS_UNSYNCED, true); | 1228 parent.Put(syncable::IS_UNSYNCED, true); |
1227 parent.Put(syncable::IS_DIR, true); | 1229 parent.Put(syncable::IS_DIR, true); |
1228 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1230 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1229 parent.Put(syncable::ID, ids_.FromNumber(100)); | 1231 parent.Put(syncable::ID, ids_.FromNumber(100)); |
1230 parent.Put(syncable::BASE_VERSION, 1); | 1232 parent.Put(syncable::BASE_VERSION, 1); |
1231 MutableEntry child( | 1233 MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(100), |
1232 &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(100), "Bob"); | 1234 "Bob"); |
1233 ASSERT_TRUE(child.good()); | 1235 ASSERT_TRUE(child.good()); |
1234 child.Put(syncable::IS_UNSYNCED, true); | 1236 child.Put(syncable::IS_UNSYNCED, true); |
1235 child.Put(syncable::IS_DIR, true); | 1237 child.Put(syncable::IS_DIR, true); |
1236 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1238 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1237 child.Put(syncable::ID, ids_.FromNumber(101)); | 1239 child.Put(syncable::ID, ids_.FromNumber(101)); |
1238 child.Put(syncable::BASE_VERSION, 1); | 1240 child.Put(syncable::BASE_VERSION, 1); |
1239 MutableEntry grandchild( | 1241 MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(101), |
1240 &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(101), "Bob"); | 1242 "Bob"); |
1241 ASSERT_TRUE(grandchild.good()); | 1243 ASSERT_TRUE(grandchild.good()); |
1242 grandchild.Put(syncable::ID, ids_.FromNumber(102)); | 1244 grandchild.Put(syncable::ID, ids_.FromNumber(102)); |
1243 grandchild.Put(syncable::IS_UNSYNCED, true); | 1245 grandchild.Put(syncable::IS_UNSYNCED, true); |
1244 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1246 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1245 grandchild.Put(syncable::BASE_VERSION, 1); | 1247 grandchild.Put(syncable::BASE_VERSION, 1); |
1246 } | 1248 } |
1247 { | 1249 { |
1248 // Create three deleted items which deletions we expect to be sent to the | 1250 // Create three deleted items which deletions we expect to be sent to the |
1249 // server. | 1251 // server. |
1250 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); | 1252 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), |
| 1253 "Pete"); |
1251 ASSERT_TRUE(parent.good()); | 1254 ASSERT_TRUE(parent.good()); |
1252 parent.Put(syncable::ID, ids_.FromNumber(103)); | 1255 parent.Put(syncable::ID, ids_.FromNumber(103)); |
1253 parent.Put(syncable::IS_UNSYNCED, true); | 1256 parent.Put(syncable::IS_UNSYNCED, true); |
1254 parent.Put(syncable::IS_DIR, true); | 1257 parent.Put(syncable::IS_DIR, true); |
1255 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1258 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1256 parent.Put(syncable::IS_DEL, true); | 1259 parent.Put(syncable::IS_DEL, true); |
1257 parent.Put(syncable::BASE_VERSION, 1); | 1260 parent.Put(syncable::BASE_VERSION, 1); |
1258 parent.Put(syncable::MTIME, now_minus_2h); | 1261 parent.Put(syncable::MTIME, now_minus_2h); |
1259 MutableEntry child( | 1262 MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(103), |
1260 &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(103), "Pete"); | 1263 "Pete"); |
1261 ASSERT_TRUE(child.good()); | 1264 ASSERT_TRUE(child.good()); |
1262 child.Put(syncable::ID, ids_.FromNumber(104)); | 1265 child.Put(syncable::ID, ids_.FromNumber(104)); |
1263 child.Put(syncable::IS_UNSYNCED, true); | 1266 child.Put(syncable::IS_UNSYNCED, true); |
1264 child.Put(syncable::IS_DIR, true); | 1267 child.Put(syncable::IS_DIR, true); |
1265 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1268 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1266 child.Put(syncable::IS_DEL, true); | 1269 child.Put(syncable::IS_DEL, true); |
1267 child.Put(syncable::BASE_VERSION, 1); | 1270 child.Put(syncable::BASE_VERSION, 1); |
1268 child.Put(syncable::MTIME, now_minus_2h); | 1271 child.Put(syncable::MTIME, now_minus_2h); |
1269 MutableEntry grandchild( | 1272 MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(104), |
1270 &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(104), "Pete"); | 1273 "Pete"); |
1271 ASSERT_TRUE(grandchild.good()); | 1274 ASSERT_TRUE(grandchild.good()); |
1272 grandchild.Put(syncable::ID, ids_.FromNumber(105)); | 1275 grandchild.Put(syncable::ID, ids_.FromNumber(105)); |
1273 grandchild.Put(syncable::IS_UNSYNCED, true); | 1276 grandchild.Put(syncable::IS_UNSYNCED, true); |
1274 grandchild.Put(syncable::IS_DEL, true); | 1277 grandchild.Put(syncable::IS_DEL, true); |
1275 grandchild.Put(syncable::IS_DIR, false); | 1278 grandchild.Put(syncable::IS_DIR, false); |
1276 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1279 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1277 grandchild.Put(syncable::BASE_VERSION, 1); | 1280 grandchild.Put(syncable::BASE_VERSION, 1); |
1278 grandchild.Put(syncable::MTIME, now_minus_2h); | 1281 grandchild.Put(syncable::MTIME, now_minus_2h); |
1279 } | 1282 } |
1280 } | 1283 } |
1281 | 1284 |
1282 SyncShareNudge(); | 1285 SyncShareNudge(); |
1283 ASSERT_EQ(6u, mock_server_->committed_ids().size()); | 1286 ASSERT_EQ(6u, mock_server_->committed_ids().size()); |
1284 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. | 1287 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. |
1285 // It will treat these like moves. | 1288 // It will treat these like moves. |
1286 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); | 1289 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); |
1287 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); | 1290 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); |
1288 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); | 1291 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); |
1289 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); | 1292 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); |
1290 // We don't guarantee the delete orders in this test, only that they occur | 1293 // We don't guarantee the delete orders in this test, only that they occur |
1291 // at the end. | 1294 // at the end. |
1292 std::sort(commit_ids.begin() + 3, commit_ids.end()); | 1295 std::sort(commit_ids.begin() + 3, commit_ids.end()); |
1293 EXPECT_TRUE(ids_.FromNumber(103) == commit_ids[3]); | 1296 EXPECT_TRUE(ids_.FromNumber(103) == commit_ids[3]); |
1294 EXPECT_TRUE(ids_.FromNumber(104) == commit_ids[4]); | 1297 EXPECT_TRUE(ids_.FromNumber(104) == commit_ids[4]); |
1295 EXPECT_TRUE(ids_.FromNumber(105) == commit_ids[5]); | 1298 EXPECT_TRUE(ids_.FromNumber(105) == commit_ids[5]); |
1296 } | 1299 } |
1297 | 1300 |
1298 TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) { | 1301 TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) { |
1299 syncable::Id parent1_id = ids_.MakeServer("p1"); | |
1300 syncable::Id parent2_id = ids_.MakeServer("p2"); | |
1301 | |
1302 { | 1302 { |
1303 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1303 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1304 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "1"); | 1304 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "1"); |
1305 ASSERT_TRUE(parent.good()); | 1305 ASSERT_TRUE(parent.good()); |
1306 parent.Put(syncable::IS_UNSYNCED, true); | 1306 parent.Put(syncable::IS_UNSYNCED, true); |
1307 parent.Put(syncable::IS_DIR, true); | 1307 parent.Put(syncable::IS_DIR, true); |
1308 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1308 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1309 parent.Put(syncable::ID, parent1_id); | 1309 parent.Put(syncable::ID, parent_id_); |
1310 MutableEntry child(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "2"); | 1310 MutableEntry child(&wtrans, syncable::CREATE, wtrans.root_id(), "2"); |
1311 ASSERT_TRUE(child.good()); | 1311 ASSERT_TRUE(child.good()); |
1312 child.Put(syncable::IS_UNSYNCED, true); | 1312 child.Put(syncable::IS_UNSYNCED, true); |
1313 child.Put(syncable::IS_DIR, true); | 1313 child.Put(syncable::IS_DIR, true); |
1314 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1314 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1315 child.Put(syncable::ID, parent2_id); | 1315 child.Put(syncable::ID, child_id_); |
1316 parent.Put(syncable::BASE_VERSION, 1); | 1316 parent.Put(syncable::BASE_VERSION, 1); |
1317 child.Put(syncable::BASE_VERSION, 1); | 1317 child.Put(syncable::BASE_VERSION, 1); |
1318 } | 1318 } |
1319 { | 1319 { |
1320 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1320 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1321 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, parent1_id, "A"); | 1321 MutableEntry parent(&wtrans, syncable::CREATE, parent_id_, "A"); |
1322 ASSERT_TRUE(parent.good()); | 1322 ASSERT_TRUE(parent.good()); |
1323 parent.Put(syncable::IS_UNSYNCED, true); | 1323 parent.Put(syncable::IS_UNSYNCED, true); |
1324 parent.Put(syncable::IS_DIR, true); | 1324 parent.Put(syncable::IS_DIR, true); |
1325 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1325 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1326 parent.Put(syncable::ID, ids_.FromNumber(102)); | 1326 parent.Put(syncable::ID, ids_.FromNumber(102)); |
1327 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent1_id, "B"); | 1327 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "B"); |
1328 ASSERT_TRUE(child.good()); | 1328 ASSERT_TRUE(child.good()); |
1329 child.Put(syncable::IS_UNSYNCED, true); | 1329 child.Put(syncable::IS_UNSYNCED, true); |
1330 child.Put(syncable::IS_DIR, true); | 1330 child.Put(syncable::IS_DIR, true); |
1331 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1331 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1332 child.Put(syncable::ID, ids_.FromNumber(-103)); | 1332 child.Put(syncable::ID, ids_.FromNumber(-103)); |
1333 parent.Put(syncable::BASE_VERSION, 1); | 1333 parent.Put(syncable::BASE_VERSION, 1); |
1334 } | 1334 } |
1335 { | 1335 { |
1336 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1336 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1337 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, parent2_id, "A"); | 1337 MutableEntry parent(&wtrans, syncable::CREATE, child_id_, "A"); |
1338 ASSERT_TRUE(parent.good()); | 1338 ASSERT_TRUE(parent.good()); |
1339 parent.Put(syncable::IS_UNSYNCED, true); | 1339 parent.Put(syncable::IS_UNSYNCED, true); |
1340 parent.Put(syncable::IS_DIR, true); | 1340 parent.Put(syncable::IS_DIR, true); |
1341 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1341 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1342 parent.Put(syncable::ID, ids_.FromNumber(-104)); | 1342 parent.Put(syncable::ID, ids_.FromNumber(-104)); |
1343 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent2_id, "B"); | 1343 MutableEntry child(&wtrans, syncable::CREATE, child_id_, "B"); |
1344 ASSERT_TRUE(child.good()); | 1344 ASSERT_TRUE(child.good()); |
1345 child.Put(syncable::IS_UNSYNCED, true); | 1345 child.Put(syncable::IS_UNSYNCED, true); |
1346 child.Put(syncable::IS_DIR, true); | 1346 child.Put(syncable::IS_DIR, true); |
1347 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1347 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1348 child.Put(syncable::ID, ids_.FromNumber(105)); | 1348 child.Put(syncable::ID, ids_.FromNumber(105)); |
1349 child.Put(syncable::BASE_VERSION, 1); | 1349 child.Put(syncable::BASE_VERSION, 1); |
1350 } | 1350 } |
1351 | 1351 |
1352 SyncShareNudge(); | 1352 SyncShareNudge(); |
1353 ASSERT_EQ(6u, mock_server_->committed_ids().size()); | 1353 ASSERT_EQ(6u, mock_server_->committed_ids().size()); |
1354 // If this test starts failing, be aware other sort orders could be valid. | 1354 // If this test starts failing, be aware other sort orders could be valid. |
1355 EXPECT_TRUE(parent1_id == mock_server_->committed_ids()[0]); | 1355 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
1356 EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]); | 1356 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
1357 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); | 1357 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); |
1358 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); | 1358 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); |
1359 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); | 1359 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); |
1360 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); | 1360 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); |
1361 } | 1361 } |
1362 | 1362 |
1363 TEST_F(SyncerTest, TestCommitListOrderingCounterexample) { | 1363 TEST_F(SyncerTest, TestCommitListOrderingCounterexample) { |
1364 syncable::Id child2_id = ids_.NewServerId(); | 1364 syncable::Id child2_id = ids_.NewServerId(); |
1365 | 1365 |
1366 { | 1366 { |
1367 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1367 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1368 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "P"); | 1368 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "P"); |
1369 ASSERT_TRUE(parent.good()); | 1369 ASSERT_TRUE(parent.good()); |
1370 parent.Put(syncable::IS_UNSYNCED, true); | 1370 parent.Put(syncable::IS_UNSYNCED, true); |
1371 parent.Put(syncable::IS_DIR, true); | 1371 parent.Put(syncable::IS_DIR, true); |
1372 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1372 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1373 parent.Put(syncable::ID, parent_id_); | 1373 parent.Put(syncable::ID, parent_id_); |
1374 MutableEntry child1(&wtrans, CREATE, BOOKMARKS, parent_id_, "1"); | 1374 MutableEntry child1(&wtrans, syncable::CREATE, parent_id_, "1"); |
1375 ASSERT_TRUE(child1.good()); | 1375 ASSERT_TRUE(child1.good()); |
1376 child1.Put(syncable::IS_UNSYNCED, true); | 1376 child1.Put(syncable::IS_UNSYNCED, true); |
1377 child1.Put(syncable::ID, child_id_); | 1377 child1.Put(syncable::ID, child_id_); |
1378 child1.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1378 child1.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1379 MutableEntry child2(&wtrans, CREATE, BOOKMARKS, parent_id_, "2"); | 1379 MutableEntry child2(&wtrans, syncable::CREATE, parent_id_, "2"); |
1380 ASSERT_TRUE(child2.good()); | 1380 ASSERT_TRUE(child2.good()); |
1381 child2.Put(syncable::IS_UNSYNCED, true); | 1381 child2.Put(syncable::IS_UNSYNCED, true); |
1382 child2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1382 child2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1383 child2.Put(syncable::ID, child2_id); | 1383 child2.Put(syncable::ID, child2_id); |
1384 | 1384 |
1385 parent.Put(syncable::BASE_VERSION, 1); | 1385 parent.Put(syncable::BASE_VERSION, 1); |
1386 child1.Put(syncable::BASE_VERSION, 1); | 1386 child1.Put(syncable::BASE_VERSION, 1); |
1387 child2.Put(syncable::BASE_VERSION, 1); | 1387 child2.Put(syncable::BASE_VERSION, 1); |
1388 } | 1388 } |
1389 | 1389 |
1390 SyncShareNudge(); | 1390 SyncShareNudge(); |
1391 ASSERT_EQ(3u, mock_server_->committed_ids().size()); | 1391 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
1392 // If this test starts failing, be aware other sort orders could be valid. | 1392 // If this test starts failing, be aware other sort orders could be valid. |
1393 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1393 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
1394 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1394 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
1395 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); | 1395 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); |
1396 } | 1396 } |
1397 | 1397 |
1398 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { | 1398 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { |
1399 string parent1_name = "1"; | 1399 string parent1_name = "1"; |
1400 string parent2_name = "A"; | 1400 string parent2_name = "A"; |
1401 string child_name = "B"; | 1401 string child_name = "B"; |
1402 | 1402 |
1403 { | 1403 { |
1404 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1404 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1405 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), | 1405 MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), |
1406 parent1_name); | 1406 parent1_name); |
1407 ASSERT_TRUE(parent.good()); | 1407 ASSERT_TRUE(parent.good()); |
1408 parent.Put(syncable::IS_UNSYNCED, true); | 1408 parent.Put(syncable::IS_UNSYNCED, true); |
1409 parent.Put(syncable::IS_DIR, true); | 1409 parent.Put(syncable::IS_DIR, true); |
1410 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1410 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1411 parent.Put(syncable::ID, parent_id_); | 1411 parent.Put(syncable::ID, parent_id_); |
1412 parent.Put(syncable::BASE_VERSION, 1); | 1412 parent.Put(syncable::BASE_VERSION, 1); |
1413 } | 1413 } |
1414 | 1414 |
1415 syncable::Id parent2_id = ids_.NewLocalId(); | 1415 syncable::Id parent2_id = ids_.NewLocalId(); |
1416 syncable::Id child_id = ids_.NewServerId(); | 1416 syncable::Id child_id = ids_.NewServerId(); |
1417 { | 1417 { |
1418 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1418 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1419 MutableEntry parent2( | 1419 MutableEntry parent2(&wtrans, syncable::CREATE, parent_id_, parent2_name); |
1420 &wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name); | |
1421 ASSERT_TRUE(parent2.good()); | 1420 ASSERT_TRUE(parent2.good()); |
1422 parent2.Put(syncable::IS_UNSYNCED, true); | 1421 parent2.Put(syncable::IS_UNSYNCED, true); |
1423 parent2.Put(syncable::IS_DIR, true); | 1422 parent2.Put(syncable::IS_DIR, true); |
1424 parent2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1423 parent2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1425 parent2.Put(syncable::ID, parent2_id); | 1424 parent2.Put(syncable::ID, parent2_id); |
1426 | 1425 |
1427 MutableEntry child( | 1426 MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name); |
1428 &wtrans, CREATE, BOOKMARKS, parent2_id, child_name); | |
1429 ASSERT_TRUE(child.good()); | 1427 ASSERT_TRUE(child.good()); |
1430 child.Put(syncable::IS_UNSYNCED, true); | 1428 child.Put(syncable::IS_UNSYNCED, true); |
1431 child.Put(syncable::IS_DIR, true); | 1429 child.Put(syncable::IS_DIR, true); |
1432 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1430 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1433 child.Put(syncable::ID, child_id); | 1431 child.Put(syncable::ID, child_id); |
1434 child.Put(syncable::BASE_VERSION, 1); | 1432 child.Put(syncable::BASE_VERSION, 1); |
1435 } | 1433 } |
1436 | 1434 |
1437 SyncShareNudge(); | 1435 SyncShareNudge(); |
1438 ASSERT_EQ(3u, mock_server_->committed_ids().size()); | 1436 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
(...skipping 26 matching lines...) Expand all Loading... |
1465 } | 1463 } |
1466 | 1464 |
1467 TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) { | 1465 TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) { |
1468 string parent_name = "1"; | 1466 string parent_name = "1"; |
1469 string parent2_name = "A"; | 1467 string parent2_name = "A"; |
1470 string child_name = "B"; | 1468 string child_name = "B"; |
1471 | 1469 |
1472 { | 1470 { |
1473 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1471 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1474 MutableEntry parent(&wtrans, | 1472 MutableEntry parent(&wtrans, |
1475 CREATE, BOOKMARKS, | 1473 syncable::CREATE, |
1476 wtrans.root_id(), | 1474 wtrans.root_id(), |
1477 parent_name); | 1475 parent_name); |
1478 ASSERT_TRUE(parent.good()); | 1476 ASSERT_TRUE(parent.good()); |
1479 parent.Put(syncable::IS_UNSYNCED, true); | 1477 parent.Put(syncable::IS_UNSYNCED, true); |
1480 parent.Put(syncable::IS_DIR, true); | 1478 parent.Put(syncable::IS_DIR, true); |
1481 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1479 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1482 parent.Put(syncable::ID, parent_id_); | 1480 parent.Put(syncable::ID, parent_id_); |
1483 parent.Put(syncable::BASE_VERSION, 1); | 1481 parent.Put(syncable::BASE_VERSION, 1); |
1484 } | 1482 } |
1485 | 1483 |
1486 int64 meta_handle_b; | 1484 int64 meta_handle_b; |
1487 const Id parent2_local_id = ids_.NewLocalId(); | 1485 const Id parent2_local_id = ids_.NewLocalId(); |
1488 const Id child_local_id = ids_.NewLocalId(); | 1486 const Id child_local_id = ids_.NewLocalId(); |
1489 { | 1487 { |
1490 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1488 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1491 MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name); | 1489 MutableEntry parent2(&wtrans, syncable::CREATE, parent_id_, parent2_name); |
1492 ASSERT_TRUE(parent2.good()); | 1490 ASSERT_TRUE(parent2.good()); |
1493 parent2.Put(syncable::IS_UNSYNCED, true); | 1491 parent2.Put(syncable::IS_UNSYNCED, true); |
1494 parent2.Put(syncable::IS_DIR, true); | 1492 parent2.Put(syncable::IS_DIR, true); |
1495 parent2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1493 parent2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1496 | 1494 |
1497 parent2.Put(syncable::ID, parent2_local_id); | 1495 parent2.Put(syncable::ID, parent2_local_id); |
1498 MutableEntry child( | 1496 MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name); |
1499 &wtrans, CREATE, BOOKMARKS, parent2_local_id, child_name); | |
1500 ASSERT_TRUE(child.good()); | 1497 ASSERT_TRUE(child.good()); |
1501 child.Put(syncable::IS_UNSYNCED, true); | 1498 child.Put(syncable::IS_UNSYNCED, true); |
1502 child.Put(syncable::IS_DIR, true); | 1499 child.Put(syncable::IS_DIR, true); |
1503 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1500 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1504 child.Put(syncable::ID, child_local_id); | 1501 child.Put(syncable::ID, child_local_id); |
1505 meta_handle_b = child.Get(syncable::META_HANDLE); | 1502 meta_handle_b = child.Get(syncable::META_HANDLE); |
1506 } | 1503 } |
1507 | 1504 |
1508 SyncShareNudge(); | 1505 SyncShareNudge(); |
1509 ASSERT_EQ(3u, mock_server_->committed_ids().size()); | 1506 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 EXPECT_EQ(4, status().num_hierarchy_conflicts()); | 1704 EXPECT_EQ(4, status().num_hierarchy_conflicts()); |
1708 } | 1705 } |
1709 | 1706 |
1710 TEST_F(SyncerTest, CommitTimeRename) { | 1707 TEST_F(SyncerTest, CommitTimeRename) { |
1711 int64 metahandle_folder; | 1708 int64 metahandle_folder; |
1712 int64 metahandle_new_entry; | 1709 int64 metahandle_new_entry; |
1713 | 1710 |
1714 // Create a folder and an entry. | 1711 // Create a folder and an entry. |
1715 { | 1712 { |
1716 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1713 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1717 MutableEntry parent(&trans, CREATE, BOOKMARKS, root_id_, "Folder"); | 1714 MutableEntry parent(&trans, CREATE, root_id_, "Folder"); |
1718 ASSERT_TRUE(parent.good()); | 1715 ASSERT_TRUE(parent.good()); |
1719 parent.Put(IS_DIR, true); | 1716 parent.Put(IS_DIR, true); |
1720 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1717 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1721 parent.Put(IS_UNSYNCED, true); | 1718 parent.Put(IS_UNSYNCED, true); |
1722 metahandle_folder = parent.Get(META_HANDLE); | 1719 metahandle_folder = parent.Get(META_HANDLE); |
1723 | 1720 |
1724 MutableEntry entry(&trans, CREATE, BOOKMARKS, parent.Get(ID), "new_entry"); | 1721 MutableEntry entry(&trans, CREATE, parent.Get(ID), "new_entry"); |
1725 ASSERT_TRUE(entry.good()); | 1722 ASSERT_TRUE(entry.good()); |
1726 metahandle_new_entry = entry.Get(META_HANDLE); | 1723 metahandle_new_entry = entry.Get(META_HANDLE); |
1727 WriteTestDataToEntry(&trans, &entry); | 1724 WriteTestDataToEntry(&trans, &entry); |
1728 } | 1725 } |
1729 | 1726 |
1730 // Mix in a directory creation too for later. | 1727 // Mix in a directory creation too for later. |
1731 mock_server_->AddUpdateDirectory(2, 0, "dir_in_root", 10, 10); | 1728 mock_server_->AddUpdateDirectory(2, 0, "dir_in_root", 10, 10); |
1732 mock_server_->SetCommitTimeRename("renamed_"); | 1729 mock_server_->SetCommitTimeRename("renamed_"); |
1733 SyncShareNudge(); | 1730 SyncShareNudge(); |
1734 | 1731 |
(...skipping 20 matching lines...) Expand all Loading... |
1755 TEST_F(SyncerTest, CommitTimeRenameI18N) { | 1752 TEST_F(SyncerTest, CommitTimeRenameI18N) { |
1756 // This is utf-8 for the diacritized Internationalization. | 1753 // This is utf-8 for the diacritized Internationalization. |
1757 const char* i18nString = "\xc3\x8e\xc3\xb1\x74\xc3\xa9\x72\xc3\xb1" | 1754 const char* i18nString = "\xc3\x8e\xc3\xb1\x74\xc3\xa9\x72\xc3\xb1" |
1758 "\xc3\xa5\x74\xc3\xae\xc3\xb6\xc3\xb1\xc3\xa5\x6c\xc3\xae" | 1755 "\xc3\xa5\x74\xc3\xae\xc3\xb6\xc3\xb1\xc3\xa5\x6c\xc3\xae" |
1759 "\xc2\x9e\xc3\xa5\x74\xc3\xae\xc3\xb6\xc3\xb1"; | 1756 "\xc2\x9e\xc3\xa5\x74\xc3\xae\xc3\xb6\xc3\xb1"; |
1760 | 1757 |
1761 int64 metahandle; | 1758 int64 metahandle; |
1762 // Create a folder, expect a commit time rename. | 1759 // Create a folder, expect a commit time rename. |
1763 { | 1760 { |
1764 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1761 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1765 MutableEntry parent(&trans, CREATE, BOOKMARKS, root_id_, "Folder"); | 1762 MutableEntry parent(&trans, CREATE, root_id_, "Folder"); |
1766 ASSERT_TRUE(parent.good()); | 1763 ASSERT_TRUE(parent.good()); |
1767 parent.Put(IS_DIR, true); | 1764 parent.Put(IS_DIR, true); |
1768 parent.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 1765 parent.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
1769 parent.Put(IS_UNSYNCED, true); | 1766 parent.Put(IS_UNSYNCED, true); |
1770 metahandle = parent.Get(META_HANDLE); | 1767 metahandle = parent.Get(META_HANDLE); |
1771 } | 1768 } |
1772 | 1769 |
1773 mock_server_->SetCommitTimeRename(i18nString); | 1770 mock_server_->SetCommitTimeRename(i18nString); |
1774 SyncShareNudge(); | 1771 SyncShareNudge(); |
1775 | 1772 |
(...skipping 10 matching lines...) Expand all Loading... |
1786 } | 1783 } |
1787 } | 1784 } |
1788 | 1785 |
1789 // A commit with a lost response produces an update that has to be reunited with | 1786 // A commit with a lost response produces an update that has to be reunited with |
1790 // its parent. | 1787 // its parent. |
1791 TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { | 1788 TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { |
1792 // Create a folder in the root. | 1789 // Create a folder in the root. |
1793 int64 metahandle_folder; | 1790 int64 metahandle_folder; |
1794 { | 1791 { |
1795 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1792 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1796 MutableEntry entry( | 1793 MutableEntry entry(&trans, CREATE, trans.root_id(), "new_folder"); |
1797 &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder"); | |
1798 ASSERT_TRUE(entry.good()); | 1794 ASSERT_TRUE(entry.good()); |
1799 entry.Put(IS_DIR, true); | 1795 entry.Put(IS_DIR, true); |
1800 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 1796 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
1801 entry.Put(IS_UNSYNCED, true); | 1797 entry.Put(IS_UNSYNCED, true); |
1802 metahandle_folder = entry.Get(META_HANDLE); | 1798 metahandle_folder = entry.Get(META_HANDLE); |
1803 } | 1799 } |
1804 | 1800 |
1805 // Verify it and pull the ID out of the folder. | 1801 // Verify it and pull the ID out of the folder. |
1806 syncable::Id folder_id; | 1802 syncable::Id folder_id; |
1807 int64 metahandle_entry; | 1803 int64 metahandle_entry; |
1808 { | 1804 { |
1809 syncable::ReadTransaction trans(FROM_HERE, directory()); | 1805 syncable::ReadTransaction trans(FROM_HERE, directory()); |
1810 Entry entry(&trans, GET_BY_HANDLE, metahandle_folder); | 1806 Entry entry(&trans, GET_BY_HANDLE, metahandle_folder); |
1811 ASSERT_TRUE(entry.good()); | 1807 ASSERT_TRUE(entry.good()); |
1812 folder_id = entry.Get(ID); | 1808 folder_id = entry.Get(ID); |
1813 ASSERT_TRUE(!folder_id.ServerKnows()); | 1809 ASSERT_TRUE(!folder_id.ServerKnows()); |
1814 } | 1810 } |
1815 | 1811 |
1816 // Create an entry in the newly created folder. | 1812 // Create an entry in the newly created folder. |
1817 { | 1813 { |
1818 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1814 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1819 MutableEntry entry(&trans, CREATE, BOOKMARKS, folder_id, "new_entry"); | 1815 MutableEntry entry(&trans, CREATE, folder_id, "new_entry"); |
1820 ASSERT_TRUE(entry.good()); | 1816 ASSERT_TRUE(entry.good()); |
1821 metahandle_entry = entry.Get(META_HANDLE); | 1817 metahandle_entry = entry.Get(META_HANDLE); |
1822 WriteTestDataToEntry(&trans, &entry); | 1818 WriteTestDataToEntry(&trans, &entry); |
1823 } | 1819 } |
1824 | 1820 |
1825 // Verify it and pull the ID out of the entry. | 1821 // Verify it and pull the ID out of the entry. |
1826 syncable::Id entry_id; | 1822 syncable::Id entry_id; |
1827 { | 1823 { |
1828 syncable::ReadTransaction trans(FROM_HERE, directory()); | 1824 syncable::ReadTransaction trans(FROM_HERE, directory()); |
1829 Entry entry(&trans, syncable::GET_BY_HANDLE, metahandle_entry); | 1825 Entry entry(&trans, syncable::GET_BY_HANDLE, metahandle_entry); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 } | 1874 } |
1879 } | 1875 } |
1880 | 1876 |
1881 // A commit with a lost response produces an update that has to be reunited with | 1877 // A commit with a lost response produces an update that has to be reunited with |
1882 // its parent. | 1878 // its parent. |
1883 TEST_F(SyncerTest, CommitReuniteUpdate) { | 1879 TEST_F(SyncerTest, CommitReuniteUpdate) { |
1884 // Create an entry in the root. | 1880 // Create an entry in the root. |
1885 int64 entry_metahandle; | 1881 int64 entry_metahandle; |
1886 { | 1882 { |
1887 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1883 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1888 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry"); | 1884 MutableEntry entry(&trans, CREATE, trans.root_id(), "new_entry"); |
1889 ASSERT_TRUE(entry.good()); | 1885 ASSERT_TRUE(entry.good()); |
1890 entry_metahandle = entry.Get(META_HANDLE); | 1886 entry_metahandle = entry.Get(META_HANDLE); |
1891 WriteTestDataToEntry(&trans, &entry); | 1887 WriteTestDataToEntry(&trans, &entry); |
1892 } | 1888 } |
1893 | 1889 |
1894 // Verify it and pull the ID out. | 1890 // Verify it and pull the ID out. |
1895 syncable::Id entry_id; | 1891 syncable::Id entry_id; |
1896 { | 1892 { |
1897 syncable::ReadTransaction trans(FROM_HERE, directory()); | 1893 syncable::ReadTransaction trans(FROM_HERE, directory()); |
1898 | 1894 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 // A commit with a lost response must work even if the local entry was deleted | 1928 // A commit with a lost response must work even if the local entry was deleted |
1933 // before the update is applied. We should not duplicate the local entry in | 1929 // before the update is applied. We should not duplicate the local entry in |
1934 // this case, but just create another one alongside. We may wish to examine | 1930 // this case, but just create another one alongside. We may wish to examine |
1935 // this behavior in the future as it can create hanging uploads that never | 1931 // this behavior in the future as it can create hanging uploads that never |
1936 // finish, that must be cleaned up on the server side after some time. | 1932 // finish, that must be cleaned up on the server side after some time. |
1937 TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) { | 1933 TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) { |
1938 // Create a entry in the root. | 1934 // Create a entry in the root. |
1939 int64 entry_metahandle; | 1935 int64 entry_metahandle; |
1940 { | 1936 { |
1941 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1937 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1942 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry"); | 1938 MutableEntry entry(&trans, CREATE, trans.root_id(), "new_entry"); |
1943 ASSERT_TRUE(entry.good()); | 1939 ASSERT_TRUE(entry.good()); |
1944 entry_metahandle = entry.Get(META_HANDLE); | 1940 entry_metahandle = entry.Get(META_HANDLE); |
1945 WriteTestDataToEntry(&trans, &entry); | 1941 WriteTestDataToEntry(&trans, &entry); |
1946 } | 1942 } |
1947 // Verify it and pull the ID out. | 1943 // Verify it and pull the ID out. |
1948 syncable::Id entry_id; | 1944 syncable::Id entry_id; |
1949 { | 1945 { |
1950 syncable::ReadTransaction trans(FROM_HERE, directory()); | 1946 syncable::ReadTransaction trans(FROM_HERE, directory()); |
1951 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); | 1947 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); |
1952 ASSERT_TRUE(entry.good()); | 1948 ASSERT_TRUE(entry.good()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 public: | 2092 public: |
2097 void CreateFolderInBob() { | 2093 void CreateFolderInBob() { |
2098 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2094 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2099 MutableEntry bob(&trans, | 2095 MutableEntry bob(&trans, |
2100 syncable::GET_BY_ID, | 2096 syncable::GET_BY_ID, |
2101 GetOnlyEntryWithName(&trans, | 2097 GetOnlyEntryWithName(&trans, |
2102 TestIdFactory::root(), | 2098 TestIdFactory::root(), |
2103 "bob")); | 2099 "bob")); |
2104 CHECK(bob.good()); | 2100 CHECK(bob.good()); |
2105 | 2101 |
2106 MutableEntry entry2( | 2102 MutableEntry entry2(&trans, syncable::CREATE, bob.Get(syncable::ID), |
2107 &trans, CREATE, BOOKMARKS, bob.Get(syncable::ID), "bob"); | 2103 "bob"); |
2108 CHECK(entry2.good()); | 2104 CHECK(entry2.good()); |
2109 entry2.Put(syncable::IS_DIR, true); | 2105 entry2.Put(syncable::IS_DIR, true); |
2110 entry2.Put(syncable::IS_UNSYNCED, true); | 2106 entry2.Put(syncable::IS_UNSYNCED, true); |
2111 entry2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 2107 entry2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
2112 } | 2108 } |
2113 }; | 2109 }; |
2114 | 2110 |
2115 TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) { | 2111 TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) { |
2116 { | 2112 { |
2117 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2113 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2118 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob"); | 2114 MutableEntry entry(&trans, syncable::CREATE, trans.root_id(), |
| 2115 "bob"); |
2119 ASSERT_TRUE(entry.good()); | 2116 ASSERT_TRUE(entry.good()); |
2120 entry.Put(syncable::IS_DIR, true); | 2117 entry.Put(syncable::IS_DIR, true); |
2121 entry.Put(syncable::IS_UNSYNCED, true); | 2118 entry.Put(syncable::IS_UNSYNCED, true); |
2122 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 2119 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
2123 } | 2120 } |
2124 | 2121 |
2125 mock_server_->SetMidCommitCallback( | 2122 mock_server_->SetMidCommitCallback( |
2126 base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob, | 2123 base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob, |
2127 base::Unretained(this))); | 2124 base::Unretained(this))); |
2128 syncer_->SyncShare(session_.get(), COMMIT, SYNCER_END); | 2125 syncer_->SyncShare(session_.get(), COMMIT, SYNCER_END); |
(...skipping 17 matching lines...) Expand all Loading... |
2146 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); | 2143 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); |
2147 SyncShareNudge(); | 2144 SyncShareNudge(); |
2148 // The negative id would make us CHECK! | 2145 // The negative id would make us CHECK! |
2149 } | 2146 } |
2150 | 2147 |
2151 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { | 2148 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { |
2152 int64 metahandle_fred; | 2149 int64 metahandle_fred; |
2153 { | 2150 { |
2154 // Create an item. | 2151 // Create an item. |
2155 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2152 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2156 MutableEntry fred_match(&trans, CREATE, BOOKMARKS, trans.root_id(), | 2153 MutableEntry fred_match(&trans, CREATE, trans.root_id(), |
2157 "fred_match"); | 2154 "fred_match"); |
2158 ASSERT_TRUE(fred_match.good()); | 2155 ASSERT_TRUE(fred_match.good()); |
2159 metahandle_fred = fred_match.Get(META_HANDLE); | 2156 metahandle_fred = fred_match.Get(META_HANDLE); |
2160 WriteTestDataToEntry(&trans, &fred_match); | 2157 WriteTestDataToEntry(&trans, &fred_match); |
2161 } | 2158 } |
2162 // Commit it. | 2159 // Commit it. |
2163 SyncShareNudge(); | 2160 SyncShareNudge(); |
2164 EXPECT_EQ(1u, mock_server_->committed_ids().size()); | 2161 EXPECT_EQ(1u, mock_server_->committed_ids().size()); |
2165 mock_server_->set_conflict_all_commits(true); | 2162 mock_server_->set_conflict_all_commits(true); |
2166 syncable::Id fred_match_id; | 2163 syncable::Id fred_match_id; |
(...skipping 15 matching lines...) Expand all Loading... |
2182 | 2179 |
2183 /** | 2180 /** |
2184 * In the event that we have a double changed entry, that is changed on both | 2181 * In the event that we have a double changed entry, that is changed on both |
2185 * the client and the server, the conflict resolver should just drop one of | 2182 * the client and the server, the conflict resolver should just drop one of |
2186 * them and accept the other. | 2183 * them and accept the other. |
2187 */ | 2184 */ |
2188 | 2185 |
2189 TEST_F(SyncerTest, DoublyChangedWithResolver) { | 2186 TEST_F(SyncerTest, DoublyChangedWithResolver) { |
2190 { | 2187 { |
2191 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2188 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2192 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "Folder"); | 2189 MutableEntry parent(&wtrans, syncable::CREATE, root_id_, "Folder"); |
2193 ASSERT_TRUE(parent.good()); | 2190 ASSERT_TRUE(parent.good()); |
2194 parent.Put(syncable::IS_DIR, true); | 2191 parent.Put(syncable::IS_DIR, true); |
2195 parent.Put(syncable::ID, parent_id_); | 2192 parent.Put(syncable::ID, parent_id_); |
2196 parent.Put(syncable::BASE_VERSION, 5); | 2193 parent.Put(syncable::BASE_VERSION, 5); |
2197 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 2194 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
2198 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete.htm"); | 2195 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete.htm"); |
2199 ASSERT_TRUE(child.good()); | 2196 ASSERT_TRUE(child.good()); |
2200 child.Put(syncable::ID, child_id_); | 2197 child.Put(syncable::ID, child_id_); |
2201 child.Put(syncable::BASE_VERSION, 10); | 2198 child.Put(syncable::BASE_VERSION, 10); |
2202 WriteTestDataToEntry(&wtrans, &child); | 2199 WriteTestDataToEntry(&wtrans, &child); |
2203 } | 2200 } |
2204 mock_server_->AddUpdateBookmark(child_id_, parent_id_, "Pete2.htm", 11, 10); | 2201 mock_server_->AddUpdateBookmark(child_id_, parent_id_, "Pete2.htm", 11, 10); |
2205 mock_server_->set_conflict_all_commits(true); | 2202 mock_server_->set_conflict_all_commits(true); |
2206 SyncShareNudge(); | 2203 SyncShareNudge(); |
2207 syncable::Directory::ChildHandles children; | 2204 syncable::Directory::ChildHandles children; |
2208 { | 2205 { |
(...skipping 14 matching lines...) Expand all Loading... |
2223 saw_syncer_event_ = false; | 2220 saw_syncer_event_ = false; |
2224 } | 2221 } |
2225 | 2222 |
2226 // We got this repro case when someone was editing bookmarks while sync was | 2223 // We got this repro case when someone was editing bookmarks while sync was |
2227 // occuring. The entry had changed out underneath the user. | 2224 // occuring. The entry had changed out underneath the user. |
2228 TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { | 2225 TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { |
2229 const base::Time& test_time = ProtoTimeToTime(123456); | 2226 const base::Time& test_time = ProtoTimeToTime(123456); |
2230 int64 entry_metahandle; | 2227 int64 entry_metahandle; |
2231 { | 2228 { |
2232 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2229 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2233 MutableEntry entry(&wtrans, CREATE, BOOKMARKS, root_id_, "Pete"); | 2230 MutableEntry entry(&wtrans, syncable::CREATE, root_id_, "Pete"); |
2234 ASSERT_TRUE(entry.good()); | 2231 ASSERT_TRUE(entry.good()); |
2235 EXPECT_FALSE(entry.Get(ID).ServerKnows()); | 2232 EXPECT_FALSE(entry.Get(ID).ServerKnows()); |
2236 entry.Put(syncable::IS_DIR, true); | 2233 entry.Put(syncable::IS_DIR, true); |
2237 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 2234 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
2238 entry.Put(syncable::IS_UNSYNCED, true); | 2235 entry.Put(syncable::IS_UNSYNCED, true); |
2239 entry.Put(syncable::MTIME, test_time); | 2236 entry.Put(syncable::MTIME, test_time); |
2240 entry_metahandle = entry.Get(META_HANDLE); | 2237 entry_metahandle = entry.Get(META_HANDLE); |
2241 } | 2238 } |
2242 SyncShareNudge(); | 2239 SyncShareNudge(); |
2243 syncable::Id id; | 2240 syncable::Id id; |
(...skipping 25 matching lines...) Expand all Loading... |
2269 } | 2266 } |
2270 } | 2267 } |
2271 | 2268 |
2272 TEST_F(SyncerTest, ParentAndChildBothMatch) { | 2269 TEST_F(SyncerTest, ParentAndChildBothMatch) { |
2273 const FullModelTypeSet all_types = FullModelTypeSet::All(); | 2270 const FullModelTypeSet all_types = FullModelTypeSet::All(); |
2274 syncable::Id parent_id = ids_.NewServerId(); | 2271 syncable::Id parent_id = ids_.NewServerId(); |
2275 syncable::Id child_id = ids_.NewServerId(); | 2272 syncable::Id child_id = ids_.NewServerId(); |
2276 | 2273 |
2277 { | 2274 { |
2278 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2275 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2279 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "Folder"); | 2276 MutableEntry parent(&wtrans, CREATE, root_id_, "Folder"); |
2280 ASSERT_TRUE(parent.good()); | 2277 ASSERT_TRUE(parent.good()); |
2281 parent.Put(IS_DIR, true); | 2278 parent.Put(IS_DIR, true); |
2282 parent.Put(IS_UNSYNCED, true); | 2279 parent.Put(IS_UNSYNCED, true); |
2283 parent.Put(ID, parent_id); | 2280 parent.Put(ID, parent_id); |
2284 parent.Put(BASE_VERSION, 1); | 2281 parent.Put(BASE_VERSION, 1); |
2285 parent.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2282 parent.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2286 | 2283 |
2287 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "test.htm"); | 2284 MutableEntry child(&wtrans, CREATE, parent.Get(ID), "test.htm"); |
2288 ASSERT_TRUE(child.good()); | 2285 ASSERT_TRUE(child.good()); |
2289 child.Put(ID, child_id); | 2286 child.Put(ID, child_id); |
2290 child.Put(BASE_VERSION, 1); | 2287 child.Put(BASE_VERSION, 1); |
2291 child.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2288 child.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2292 WriteTestDataToEntry(&wtrans, &child); | 2289 WriteTestDataToEntry(&wtrans, &child); |
2293 } | 2290 } |
2294 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); | 2291 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); |
2295 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); | 2292 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); |
2296 mock_server_->set_conflict_all_commits(true); | 2293 mock_server_->set_conflict_all_commits(true); |
2297 SyncShareNudge(); | 2294 SyncShareNudge(); |
(...skipping 12 matching lines...) Expand all Loading... |
2310 syncable::Directory::UnsyncedMetaHandles unsynced; | 2307 syncable::Directory::UnsyncedMetaHandles unsynced; |
2311 directory()->GetUnsyncedMetaHandles(&trans, &unsynced); | 2308 directory()->GetUnsyncedMetaHandles(&trans, &unsynced); |
2312 EXPECT_EQ(0u, unsynced.size()); | 2309 EXPECT_EQ(0u, unsynced.size()); |
2313 saw_syncer_event_ = false; | 2310 saw_syncer_event_ = false; |
2314 } | 2311 } |
2315 } | 2312 } |
2316 | 2313 |
2317 TEST_F(SyncerTest, CommittingNewDeleted) { | 2314 TEST_F(SyncerTest, CommittingNewDeleted) { |
2318 { | 2315 { |
2319 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2316 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2320 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob"); | 2317 MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); |
2321 entry.Put(IS_UNSYNCED, true); | 2318 entry.Put(IS_UNSYNCED, true); |
2322 entry.Put(IS_DEL, true); | 2319 entry.Put(IS_DEL, true); |
2323 } | 2320 } |
2324 SyncShareNudge(); | 2321 SyncShareNudge(); |
2325 EXPECT_EQ(0u, mock_server_->committed_ids().size()); | 2322 EXPECT_EQ(0u, mock_server_->committed_ids().size()); |
2326 } | 2323 } |
2327 | 2324 |
2328 // Original problem synopsis: | 2325 // Original problem synopsis: |
2329 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) | 2326 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) |
2330 // Client creates entry, client finishes committing entry. Between | 2327 // Client creates entry, client finishes committing entry. Between |
2331 // commit and getting update back, we delete the entry. | 2328 // commit and getting update back, we delete the entry. |
2332 // We get the update for the entry, but the local one was modified | 2329 // We get the update for the entry, but the local one was modified |
2333 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. | 2330 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. |
2334 // We commit deletion and get a new version number. | 2331 // We commit deletion and get a new version number. |
2335 // We apply unapplied updates again before we get the update about the deletion. | 2332 // We apply unapplied updates again before we get the update about the deletion. |
2336 // This means we have an unapplied update where server_version < base_version. | 2333 // This means we have an unapplied update where server_version < base_version. |
2337 TEST_F(SyncerTest, UnappliedUpdateDuringCommit) { | 2334 TEST_F(SyncerTest, UnappliedUpdateDuringCommit) { |
2338 // This test is a little fake. | 2335 // This test is a little fake. |
2339 { | 2336 { |
2340 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2337 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2341 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob"); | 2338 MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); |
2342 entry.Put(ID, ids_.FromNumber(20)); | 2339 entry.Put(ID, ids_.FromNumber(20)); |
2343 entry.Put(BASE_VERSION, 1); | 2340 entry.Put(BASE_VERSION, 1); |
2344 entry.Put(SERVER_VERSION, 1); | 2341 entry.Put(SERVER_VERSION, 1); |
2345 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent. | 2342 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent. |
2346 entry.Put(IS_UNSYNCED, true); | 2343 entry.Put(IS_UNSYNCED, true); |
2347 entry.Put(IS_UNAPPLIED_UPDATE, true); | 2344 entry.Put(IS_UNAPPLIED_UPDATE, true); |
2348 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2345 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2349 entry.Put(SERVER_SPECIFICS, DefaultBookmarkSpecifics()); | 2346 entry.Put(SERVER_SPECIFICS, DefaultBookmarkSpecifics()); |
2350 entry.Put(IS_DEL, false); | 2347 entry.Put(IS_DEL, false); |
2351 } | 2348 } |
(...skipping 11 matching lines...) Expand all Loading... |
2363 // make a new folder fred | 2360 // make a new folder fred |
2364 // move bob into fred | 2361 // move bob into fred |
2365 // remove bob | 2362 // remove bob |
2366 // remove fred | 2363 // remove fred |
2367 // if no syncing occured midway, bob will have an illegal parent | 2364 // if no syncing occured midway, bob will have an illegal parent |
2368 TEST_F(SyncerTest, DeletingEntryInFolder) { | 2365 TEST_F(SyncerTest, DeletingEntryInFolder) { |
2369 // This test is a little fake. | 2366 // This test is a little fake. |
2370 int64 existing_metahandle; | 2367 int64 existing_metahandle; |
2371 { | 2368 { |
2372 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2369 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2373 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "existing"); | 2370 MutableEntry entry(&trans, CREATE, trans.root_id(), "existing"); |
2374 ASSERT_TRUE(entry.good()); | 2371 ASSERT_TRUE(entry.good()); |
2375 entry.Put(IS_DIR, true); | 2372 entry.Put(IS_DIR, true); |
2376 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2373 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2377 entry.Put(IS_UNSYNCED, true); | 2374 entry.Put(IS_UNSYNCED, true); |
2378 existing_metahandle = entry.Get(META_HANDLE); | 2375 existing_metahandle = entry.Get(META_HANDLE); |
2379 } | 2376 } |
2380 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 2377 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
2381 { | 2378 { |
2382 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2379 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2383 MutableEntry newfolder(&trans, CREATE, BOOKMARKS, trans.root_id(), "new"); | 2380 MutableEntry newfolder(&trans, CREATE, trans.root_id(), "new"); |
2384 ASSERT_TRUE(newfolder.good()); | 2381 ASSERT_TRUE(newfolder.good()); |
2385 newfolder.Put(IS_DIR, true); | 2382 newfolder.Put(IS_DIR, true); |
2386 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2383 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2387 newfolder.Put(IS_UNSYNCED, true); | 2384 newfolder.Put(IS_UNSYNCED, true); |
2388 | 2385 |
2389 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); | 2386 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); |
2390 ASSERT_TRUE(existing.good()); | 2387 ASSERT_TRUE(existing.good()); |
2391 existing.Put(PARENT_ID, newfolder.Get(ID)); | 2388 existing.Put(PARENT_ID, newfolder.Get(ID)); |
2392 existing.Put(IS_UNSYNCED, true); | 2389 existing.Put(IS_UNSYNCED, true); |
2393 EXPECT_TRUE(existing.Get(ID).ServerKnows()); | 2390 EXPECT_TRUE(existing.Get(ID).ServerKnows()); |
2394 | 2391 |
2395 newfolder.Put(IS_DEL, true); | 2392 newfolder.Put(IS_DEL, true); |
2396 existing.Put(IS_DEL, true); | 2393 existing.Put(IS_DEL, true); |
2397 } | 2394 } |
2398 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 2395 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
2399 EXPECT_EQ(0, status().num_server_conflicts()); | 2396 EXPECT_EQ(0, status().num_server_conflicts()); |
2400 } | 2397 } |
2401 | 2398 |
2402 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { | 2399 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { |
2403 int64 newfolder_metahandle; | 2400 int64 newfolder_metahandle; |
2404 | 2401 |
2405 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2402 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
2406 SyncShareNudge(); | 2403 SyncShareNudge(); |
2407 { | 2404 { |
2408 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2405 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2409 MutableEntry newfolder( | 2406 MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), "local"); |
2410 &trans, CREATE, BOOKMARKS, ids_.FromNumber(1), "local"); | |
2411 ASSERT_TRUE(newfolder.good()); | 2407 ASSERT_TRUE(newfolder.good()); |
2412 newfolder.Put(IS_UNSYNCED, true); | 2408 newfolder.Put(IS_UNSYNCED, true); |
2413 newfolder.Put(IS_DIR, true); | 2409 newfolder.Put(IS_DIR, true); |
2414 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2410 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2415 newfolder_metahandle = newfolder.Get(META_HANDLE); | 2411 newfolder_metahandle = newfolder.Get(META_HANDLE); |
2416 } | 2412 } |
2417 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20); | 2413 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20); |
2418 mock_server_->SetLastUpdateDeleted(); | 2414 mock_server_->SetLastUpdateDeleted(); |
2419 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, APPLY_UPDATES); | 2415 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, APPLY_UPDATES); |
2420 { | 2416 { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 // we post more than one commit command to the server. This test makes | 2487 // we post more than one commit command to the server. This test makes |
2492 // sure that scenario works as expected. | 2488 // sure that scenario works as expected. |
2493 TEST_F(SyncerTest, CommitManyItemsInOneGo_Success) { | 2489 TEST_F(SyncerTest, CommitManyItemsInOneGo_Success) { |
2494 uint32 num_batches = 3; | 2490 uint32 num_batches = 3; |
2495 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; | 2491 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; |
2496 { | 2492 { |
2497 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2493 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2498 for (uint32 i = 0; i < items_to_commit; i++) { | 2494 for (uint32 i = 0; i < items_to_commit; i++) { |
2499 string nameutf8 = base::StringPrintf("%d", i); | 2495 string nameutf8 = base::StringPrintf("%d", i); |
2500 string name(nameutf8.begin(), nameutf8.end()); | 2496 string name(nameutf8.begin(), nameutf8.end()); |
2501 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); | 2497 MutableEntry e(&trans, CREATE, trans.root_id(), name); |
2502 e.Put(IS_UNSYNCED, true); | 2498 e.Put(IS_UNSYNCED, true); |
2503 e.Put(IS_DIR, true); | 2499 e.Put(IS_DIR, true); |
2504 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2500 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2505 } | 2501 } |
2506 } | 2502 } |
2507 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 2503 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
2508 | 2504 |
2509 SyncShareNudge(); | 2505 SyncShareNudge(); |
2510 EXPECT_EQ(num_batches, mock_server_->commit_messages().size()); | 2506 EXPECT_EQ(num_batches, mock_server_->commit_messages().size()); |
2511 EXPECT_EQ(0, directory()->unsynced_entity_count()); | 2507 EXPECT_EQ(0, directory()->unsynced_entity_count()); |
2512 } | 2508 } |
2513 | 2509 |
2514 // Test that a single failure to contact the server will cause us to exit the | 2510 // Test that a single failure to contact the server will cause us to exit the |
2515 // commit loop immediately. | 2511 // commit loop immediately. |
2516 TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) { | 2512 TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) { |
2517 uint32 num_batches = 3; | 2513 uint32 num_batches = 3; |
2518 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; | 2514 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; |
2519 { | 2515 { |
2520 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2516 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2521 for (uint32 i = 0; i < items_to_commit; i++) { | 2517 for (uint32 i = 0; i < items_to_commit; i++) { |
2522 string nameutf8 = base::StringPrintf("%d", i); | 2518 string nameutf8 = base::StringPrintf("%d", i); |
2523 string name(nameutf8.begin(), nameutf8.end()); | 2519 string name(nameutf8.begin(), nameutf8.end()); |
2524 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); | 2520 MutableEntry e(&trans, CREATE, trans.root_id(), name); |
2525 e.Put(IS_UNSYNCED, true); | 2521 e.Put(IS_UNSYNCED, true); |
2526 e.Put(IS_DIR, true); | 2522 e.Put(IS_DIR, true); |
2527 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2523 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2528 } | 2524 } |
2529 } | 2525 } |
2530 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 2526 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
2531 | 2527 |
2532 // The second commit should fail. It will be preceded by one successful | 2528 // The second commit should fail. It will be preceded by one successful |
2533 // GetUpdate and one succesful commit. | 2529 // GetUpdate and one succesful commit. |
2534 mock_server_->FailNthPostBufferToPathCall(3); | 2530 mock_server_->FailNthPostBufferToPathCall(3); |
2535 SyncShareNudge(); | 2531 SyncShareNudge(); |
2536 | 2532 |
2537 EXPECT_EQ(1U, mock_server_->commit_messages().size()); | 2533 EXPECT_EQ(1U, mock_server_->commit_messages().size()); |
2538 EXPECT_EQ(SYNC_SERVER_ERROR, | 2534 EXPECT_EQ(SYNC_SERVER_ERROR, |
2539 session_->status_controller().model_neutral_state().commit_result); | 2535 session_->status_controller().model_neutral_state().commit_result); |
2540 EXPECT_EQ(items_to_commit - kDefaultMaxCommitBatchSize, | 2536 EXPECT_EQ(items_to_commit - kDefaultMaxCommitBatchSize, |
2541 directory()->unsynced_entity_count()); | 2537 directory()->unsynced_entity_count()); |
2542 } | 2538 } |
2543 | 2539 |
2544 // Test that a single conflict response from the server will cause us to exit | 2540 // Test that a single conflict response from the server will cause us to exit |
2545 // the commit loop immediately. | 2541 // the commit loop immediately. |
2546 TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) { | 2542 TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) { |
2547 uint32 num_batches = 2; | 2543 uint32 num_batches = 2; |
2548 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; | 2544 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; |
2549 { | 2545 { |
2550 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2546 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2551 for (uint32 i = 0; i < items_to_commit; i++) { | 2547 for (uint32 i = 0; i < items_to_commit; i++) { |
2552 string nameutf8 = base::StringPrintf("%d", i); | 2548 string nameutf8 = base::StringPrintf("%d", i); |
2553 string name(nameutf8.begin(), nameutf8.end()); | 2549 string name(nameutf8.begin(), nameutf8.end()); |
2554 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); | 2550 MutableEntry e(&trans, CREATE, trans.root_id(), name); |
2555 e.Put(IS_UNSYNCED, true); | 2551 e.Put(IS_UNSYNCED, true); |
2556 e.Put(IS_DIR, true); | 2552 e.Put(IS_DIR, true); |
2557 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2553 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2558 } | 2554 } |
2559 } | 2555 } |
2560 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 2556 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
2561 | 2557 |
2562 // Return a CONFLICT response for the first item. | 2558 // Return a CONFLICT response for the first item. |
2563 mock_server_->set_conflict_n_commits(1); | 2559 mock_server_->set_conflict_n_commits(1); |
2564 SyncShareNudge(); | 2560 SyncShareNudge(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2642 saw_syncer_event_ = false; | 2638 saw_syncer_event_ = false; |
2643 } | 2639 } |
2644 | 2640 |
2645 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { | 2641 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { |
2646 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); | 2642 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); |
2647 SyncShareNudge(); | 2643 SyncShareNudge(); |
2648 int64 local_folder_handle; | 2644 int64 local_folder_handle; |
2649 syncable::Id local_folder_id; | 2645 syncable::Id local_folder_id; |
2650 { | 2646 { |
2651 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2647 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2652 MutableEntry new_entry( | 2648 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm"); |
2653 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm"); | |
2654 ASSERT_TRUE(new_entry.good()); | 2649 ASSERT_TRUE(new_entry.good()); |
2655 local_folder_id = new_entry.Get(ID); | 2650 local_folder_id = new_entry.Get(ID); |
2656 local_folder_handle = new_entry.Get(META_HANDLE); | 2651 local_folder_handle = new_entry.Get(META_HANDLE); |
2657 new_entry.Put(IS_UNSYNCED, true); | 2652 new_entry.Put(IS_UNSYNCED, true); |
2658 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2653 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2659 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2654 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2660 ASSERT_TRUE(old.good()); | 2655 ASSERT_TRUE(old.good()); |
2661 WriteTestDataToEntry(&wtrans, &old); | 2656 WriteTestDataToEntry(&wtrans, &old); |
2662 } | 2657 } |
2663 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); | 2658 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 | 2704 |
2710 // Same as NewEntryAnddServerEntrySharePath, but using the old-style protocol. | 2705 // Same as NewEntryAnddServerEntrySharePath, but using the old-style protocol. |
2711 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) { | 2706 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) { |
2712 mock_server_->set_use_legacy_bookmarks_protocol(true); | 2707 mock_server_->set_use_legacy_bookmarks_protocol(true); |
2713 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); | 2708 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); |
2714 SyncShareNudge(); | 2709 SyncShareNudge(); |
2715 int64 local_folder_handle; | 2710 int64 local_folder_handle; |
2716 syncable::Id local_folder_id; | 2711 syncable::Id local_folder_id; |
2717 { | 2712 { |
2718 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2713 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2719 MutableEntry new_entry( | 2714 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm"); |
2720 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm"); | |
2721 ASSERT_TRUE(new_entry.good()); | 2715 ASSERT_TRUE(new_entry.good()); |
2722 local_folder_id = new_entry.Get(ID); | 2716 local_folder_id = new_entry.Get(ID); |
2723 local_folder_handle = new_entry.Get(META_HANDLE); | 2717 local_folder_handle = new_entry.Get(META_HANDLE); |
2724 new_entry.Put(IS_UNSYNCED, true); | 2718 new_entry.Put(IS_UNSYNCED, true); |
2725 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2719 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2726 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2720 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2727 ASSERT_TRUE(old.good()); | 2721 ASSERT_TRUE(old.good()); |
2728 WriteTestDataToEntry(&wtrans, &old); | 2722 WriteTestDataToEntry(&wtrans, &old); |
2729 } | 2723 } |
2730 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); | 2724 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2882 EXPECT_EQ(2, bob.Get(BASE_VERSION)); | 2876 EXPECT_EQ(2, bob.Get(BASE_VERSION)); |
2883 } | 2877 } |
2884 saw_syncer_event_ = false; | 2878 saw_syncer_event_ = false; |
2885 } | 2879 } |
2886 | 2880 |
2887 // This test is to reproduce a check failure. Sometimes we would get a bad ID | 2881 // This test is to reproduce a check failure. Sometimes we would get a bad ID |
2888 // back when creating an entry. | 2882 // back when creating an entry. |
2889 TEST_F(SyncerTest, DuplicateIDReturn) { | 2883 TEST_F(SyncerTest, DuplicateIDReturn) { |
2890 { | 2884 { |
2891 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2885 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2892 MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob"); | 2886 MutableEntry folder(&trans, CREATE, trans.root_id(), "bob"); |
2893 ASSERT_TRUE(folder.good()); | 2887 ASSERT_TRUE(folder.good()); |
2894 folder.Put(IS_UNSYNCED, true); | 2888 folder.Put(IS_UNSYNCED, true); |
2895 folder.Put(IS_DIR, true); | 2889 folder.Put(IS_DIR, true); |
2896 folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2890 folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2897 MutableEntry folder2(&trans, CREATE, BOOKMARKS, trans.root_id(), "fred"); | 2891 MutableEntry folder2(&trans, CREATE, trans.root_id(), "fred"); |
2898 ASSERT_TRUE(folder2.good()); | 2892 ASSERT_TRUE(folder2.good()); |
2899 folder2.Put(IS_UNSYNCED, false); | 2893 folder2.Put(IS_UNSYNCED, false); |
2900 folder2.Put(IS_DIR, true); | 2894 folder2.Put(IS_DIR, true); |
2901 folder2.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2895 folder2.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2902 folder2.Put(BASE_VERSION, 3); | 2896 folder2.Put(BASE_VERSION, 3); |
2903 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); | 2897 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); |
2904 } | 2898 } |
2905 mock_server_->set_next_new_id(10000); | 2899 mock_server_->set_next_new_id(10000); |
2906 EXPECT_EQ(1u, directory()->unsynced_entity_count()); | 2900 EXPECT_EQ(1u, directory()->unsynced_entity_count()); |
2907 // we get back a bad id in here (should never happen). | 2901 // we get back a bad id in here (should never happen). |
(...skipping 18 matching lines...) Expand all Loading... |
2926 } | 2920 } |
2927 mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10); | 2921 mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10); |
2928 SyncShareNudge(); | 2922 SyncShareNudge(); |
2929 SyncShareNudge(); | 2923 SyncShareNudge(); |
2930 } | 2924 } |
2931 | 2925 |
2932 TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) { | 2926 TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) { |
2933 { | 2927 { |
2934 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2928 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2935 | 2929 |
2936 MutableEntry local_deleted( | 2930 MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name"); |
2937 &trans, CREATE, BOOKMARKS, trans.root_id(), "name"); | |
2938 local_deleted.Put(ID, ids_.FromNumber(1)); | 2931 local_deleted.Put(ID, ids_.FromNumber(1)); |
2939 local_deleted.Put(BASE_VERSION, 1); | 2932 local_deleted.Put(BASE_VERSION, 1); |
2940 local_deleted.Put(IS_DEL, true); | 2933 local_deleted.Put(IS_DEL, true); |
2941 local_deleted.Put(IS_DIR, false); | 2934 local_deleted.Put(IS_DIR, false); |
2942 local_deleted.Put(IS_UNSYNCED, true); | 2935 local_deleted.Put(IS_UNSYNCED, true); |
2943 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2936 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2944 } | 2937 } |
2945 | 2938 |
2946 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); | 2939 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); |
2947 | 2940 |
(...skipping 12 matching lines...) Expand all Loading... |
2960 } | 2953 } |
2961 } | 2954 } |
2962 | 2955 |
2963 // See what happens if the IS_DIR bit gets flipped. This can cause us | 2956 // See what happens if the IS_DIR bit gets flipped. This can cause us |
2964 // all kinds of disasters. | 2957 // all kinds of disasters. |
2965 TEST_F(SyncerTest, UpdateFlipsTheFolderBit) { | 2958 TEST_F(SyncerTest, UpdateFlipsTheFolderBit) { |
2966 // Local object: a deleted directory (container), revision 1, unsynced. | 2959 // Local object: a deleted directory (container), revision 1, unsynced. |
2967 { | 2960 { |
2968 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2961 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2969 | 2962 |
2970 MutableEntry local_deleted( | 2963 MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name"); |
2971 &trans, CREATE, BOOKMARKS, trans.root_id(), "name"); | |
2972 local_deleted.Put(ID, ids_.FromNumber(1)); | 2964 local_deleted.Put(ID, ids_.FromNumber(1)); |
2973 local_deleted.Put(BASE_VERSION, 1); | 2965 local_deleted.Put(BASE_VERSION, 1); |
2974 local_deleted.Put(IS_DEL, true); | 2966 local_deleted.Put(IS_DEL, true); |
2975 local_deleted.Put(IS_DIR, true); | 2967 local_deleted.Put(IS_DIR, true); |
2976 local_deleted.Put(IS_UNSYNCED, true); | 2968 local_deleted.Put(IS_UNSYNCED, true); |
2977 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2969 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2978 } | 2970 } |
2979 | 2971 |
2980 // Server update: entry-type object (not a container), revision 10. | 2972 // Server update: entry-type object (not a container), revision 10. |
2981 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); | 2973 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); |
(...skipping 17 matching lines...) Expand all Loading... |
2999 | 2991 |
3000 // Bug Synopsis: | 2992 // Bug Synopsis: |
3001 // Merge conflict resolution will merge a new local entry with another entry | 2993 // Merge conflict resolution will merge a new local entry with another entry |
3002 // that needs updates, resulting in CHECK. | 2994 // that needs updates, resulting in CHECK. |
3003 TEST_F(SyncerTest, MergingExistingItems) { | 2995 TEST_F(SyncerTest, MergingExistingItems) { |
3004 mock_server_->set_conflict_all_commits(true); | 2996 mock_server_->set_conflict_all_commits(true); |
3005 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); | 2997 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); |
3006 SyncShareNudge(); | 2998 SyncShareNudge(); |
3007 { | 2999 { |
3008 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3000 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3009 MutableEntry entry( | 3001 MutableEntry entry(&trans, CREATE, trans.root_id(), "Copy of base"); |
3010 &trans, CREATE, BOOKMARKS, trans.root_id(), "Copy of base"); | |
3011 WriteTestDataToEntry(&trans, &entry); | 3002 WriteTestDataToEntry(&trans, &entry); |
3012 } | 3003 } |
3013 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); | 3004 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); |
3014 SyncRepeatedlyToTriggerConflictResolution(session_.get()); | 3005 SyncRepeatedlyToTriggerConflictResolution(session_.get()); |
3015 } | 3006 } |
3016 | 3007 |
3017 // In this test a long changelog contains a child at the start of the changelog | 3008 // In this test a long changelog contains a child at the start of the changelog |
3018 // and a parent at the end. While these updates are in progress the client would | 3009 // and a parent at the end. While these updates are in progress the client would |
3019 // appear stuck. | 3010 // appear stuck. |
3020 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { | 3011 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3190 } | 3181 } |
3191 } | 3182 } |
3192 | 3183 |
3193 TEST_F(SyncerTest, DirectoryCommitTest) { | 3184 TEST_F(SyncerTest, DirectoryCommitTest) { |
3194 syncable::Id in_root_id, in_dir_id; | 3185 syncable::Id in_root_id, in_dir_id; |
3195 int64 foo_metahandle; | 3186 int64 foo_metahandle; |
3196 int64 bar_metahandle; | 3187 int64 bar_metahandle; |
3197 | 3188 |
3198 { | 3189 { |
3199 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 3190 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3200 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "foo"); | 3191 MutableEntry parent(&wtrans, syncable::CREATE, root_id_, "foo"); |
3201 ASSERT_TRUE(parent.good()); | 3192 ASSERT_TRUE(parent.good()); |
3202 parent.Put(syncable::IS_UNSYNCED, true); | 3193 parent.Put(syncable::IS_UNSYNCED, true); |
3203 parent.Put(syncable::IS_DIR, true); | 3194 parent.Put(syncable::IS_DIR, true); |
3204 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 3195 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
3205 in_root_id = parent.Get(syncable::ID); | 3196 in_root_id = parent.Get(syncable::ID); |
3206 foo_metahandle = parent.Get(META_HANDLE); | 3197 foo_metahandle = parent.Get(META_HANDLE); |
3207 | 3198 |
3208 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "bar"); | 3199 MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), "bar"); |
3209 ASSERT_TRUE(child.good()); | 3200 ASSERT_TRUE(child.good()); |
3210 child.Put(syncable::IS_UNSYNCED, true); | 3201 child.Put(syncable::IS_UNSYNCED, true); |
3211 child.Put(syncable::IS_DIR, true); | 3202 child.Put(syncable::IS_DIR, true); |
3212 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 3203 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
3213 bar_metahandle = child.Get(META_HANDLE); | 3204 bar_metahandle = child.Get(META_HANDLE); |
3214 in_dir_id = parent.Get(syncable::ID); | 3205 in_dir_id = parent.Get(syncable::ID); |
3215 } | 3206 } |
3216 SyncShareNudge(); | 3207 SyncShareNudge(); |
3217 { | 3208 { |
3218 syncable::ReadTransaction trans(FROM_HERE, directory()); | 3209 syncable::ReadTransaction trans(FROM_HERE, directory()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3310 "folder_two", 1, 1); | 3301 "folder_two", 1, 1); |
3311 SyncShareNudge(); | 3302 SyncShareNudge(); |
3312 { | 3303 { |
3313 // A moved entry should send an "old parent." | 3304 // A moved entry should send an "old parent." |
3314 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3305 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3315 MutableEntry entry(&trans, GET_BY_ID, folder_one_id); | 3306 MutableEntry entry(&trans, GET_BY_ID, folder_one_id); |
3316 ASSERT_TRUE(entry.good()); | 3307 ASSERT_TRUE(entry.good()); |
3317 entry.Put(PARENT_ID, folder_two_id); | 3308 entry.Put(PARENT_ID, folder_two_id); |
3318 entry.Put(IS_UNSYNCED, true); | 3309 entry.Put(IS_UNSYNCED, true); |
3319 // A new entry should send no "old parent." | 3310 // A new entry should send no "old parent." |
3320 MutableEntry create( | 3311 MutableEntry create(&trans, CREATE, trans.root_id(), "new_folder"); |
3321 &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder"); | |
3322 create.Put(IS_UNSYNCED, true); | 3312 create.Put(IS_UNSYNCED, true); |
3323 create.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3313 create.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3324 } | 3314 } |
3325 SyncShareNudge(); | 3315 SyncShareNudge(); |
3326 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); | 3316 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); |
3327 ASSERT_EQ(2, commit.entries_size()); | 3317 ASSERT_EQ(2, commit.entries_size()); |
3328 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); | 3318 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); |
3329 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); | 3319 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); |
3330 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); | 3320 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); |
3331 } | 3321 } |
3332 | 3322 |
3333 TEST_F(SyncerTest, Test64BitVersionSupport) { | 3323 TEST_F(SyncerTest, Test64BitVersionSupport) { |
3334 int64 really_big_int = std::numeric_limits<int64>::max() - 12; | 3324 int64 really_big_int = std::numeric_limits<int64>::max() - 12; |
3335 const string name("ringo's dang orang ran rings around my o-ring"); | 3325 const string name("ringo's dang orang ran rings around my o-ring"); |
3336 int64 item_metahandle; | 3326 int64 item_metahandle; |
3337 | 3327 |
3338 // Try writing max int64 to the version fields of a meta entry. | 3328 // Try writing max int64 to the version fields of a meta entry. |
3339 { | 3329 { |
3340 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 3330 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3341 MutableEntry entry(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); | 3331 MutableEntry entry(&wtrans, syncable::CREATE, wtrans.root_id(), name); |
3342 ASSERT_TRUE(entry.good()); | 3332 ASSERT_TRUE(entry.good()); |
3343 entry.Put(syncable::BASE_VERSION, really_big_int); | 3333 entry.Put(syncable::BASE_VERSION, really_big_int); |
3344 entry.Put(syncable::SERVER_VERSION, really_big_int); | 3334 entry.Put(syncable::SERVER_VERSION, really_big_int); |
3345 entry.Put(syncable::ID, ids_.NewServerId()); | 3335 entry.Put(syncable::ID, ids_.NewServerId()); |
3346 item_metahandle = entry.Get(META_HANDLE); | 3336 item_metahandle = entry.Get(META_HANDLE); |
3347 } | 3337 } |
3348 // Now read it back out and make sure the value is max int64. | 3338 // Now read it back out and make sure the value is max int64. |
3349 syncable::ReadTransaction rtrans(FROM_HERE, directory()); | 3339 syncable::ReadTransaction rtrans(FROM_HERE, directory()); |
3350 Entry entry(&rtrans, syncable::GET_BY_HANDLE, item_metahandle); | 3340 Entry entry(&rtrans, syncable::GET_BY_HANDLE, item_metahandle); |
3351 ASSERT_TRUE(entry.good()); | 3341 ASSERT_TRUE(entry.good()); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3542 TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) { | 3532 TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) { |
3543 int64 original_metahandle = 0; | 3533 int64 original_metahandle = 0; |
3544 | 3534 |
3545 sync_pb::EntitySpecifics local_bookmark(DefaultBookmarkSpecifics()); | 3535 sync_pb::EntitySpecifics local_bookmark(DefaultBookmarkSpecifics()); |
3546 local_bookmark.mutable_bookmark()->set_url("http://foo/localsite"); | 3536 local_bookmark.mutable_bookmark()->set_url("http://foo/localsite"); |
3547 sync_pb::EntitySpecifics server_bookmark(DefaultBookmarkSpecifics()); | 3537 sync_pb::EntitySpecifics server_bookmark(DefaultBookmarkSpecifics()); |
3548 server_bookmark.mutable_bookmark()->set_url("http://bar/serversite"); | 3538 server_bookmark.mutable_bookmark()->set_url("http://bar/serversite"); |
3549 | 3539 |
3550 { | 3540 { |
3551 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3541 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3552 MutableEntry perm_folder( | 3542 MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname"); |
3553 &trans, CREATE, BOOKMARKS, ids_.root(), "clientname"); | |
3554 ASSERT_TRUE(perm_folder.good()); | 3543 ASSERT_TRUE(perm_folder.good()); |
3555 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm"); | 3544 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm"); |
3556 perm_folder.Put(SPECIFICS, local_bookmark); | 3545 perm_folder.Put(SPECIFICS, local_bookmark); |
3557 perm_folder.Put(IS_UNSYNCED, true); | 3546 perm_folder.Put(IS_UNSYNCED, true); |
3558 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 3547 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
3559 EXPECT_FALSE(perm_folder.Get(ID).ServerKnows()); | 3548 EXPECT_FALSE(perm_folder.Get(ID).ServerKnows()); |
3560 original_metahandle = perm_folder.Get(META_HANDLE); | 3549 original_metahandle = perm_folder.Get(META_HANDLE); |
3561 } | 3550 } |
3562 | 3551 |
3563 mock_server_->AddUpdateBookmark(1, 0, "permitem_renamed", 10, 100); | 3552 mock_server_->AddUpdateBookmark(1, 0, "permitem_renamed", 10, 100); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3608 EXPECT_EQ(local_bookmark.SerializeAsString(), | 3597 EXPECT_EQ(local_bookmark.SerializeAsString(), |
3609 perm_folder.Get(SPECIFICS).SerializeAsString()); | 3598 perm_folder.Get(SPECIFICS).SerializeAsString()); |
3610 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows()); | 3599 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows()); |
3611 } | 3600 } |
3612 } | 3601 } |
3613 | 3602 |
3614 TEST_F(SyncerTest, ClientTagConflictWithDeletedLocalEntry) { | 3603 TEST_F(SyncerTest, ClientTagConflictWithDeletedLocalEntry) { |
3615 { | 3604 { |
3616 // Create a deleted local entry with a unique client tag. | 3605 // Create a deleted local entry with a unique client tag. |
3617 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3606 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3618 MutableEntry perm_folder( | 3607 MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname"); |
3619 &trans, CREATE, BOOKMARKS, ids_.root(), "clientname"); | |
3620 ASSERT_TRUE(perm_folder.good()); | 3608 ASSERT_TRUE(perm_folder.good()); |
3621 ASSERT_FALSE(perm_folder.Get(ID).ServerKnows()); | 3609 ASSERT_FALSE(perm_folder.Get(ID).ServerKnows()); |
3622 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm"); | 3610 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm"); |
3623 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3611 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3624 perm_folder.Put(IS_UNSYNCED, true); | 3612 perm_folder.Put(IS_UNSYNCED, true); |
3625 | 3613 |
3626 // Note: IS_DEL && !ServerKnows() will clear the UNSYNCED bit. | 3614 // Note: IS_DEL && !ServerKnows() will clear the UNSYNCED bit. |
3627 // (We never attempt to commit server-unknown deleted items, so this | 3615 // (We never attempt to commit server-unknown deleted items, so this |
3628 // helps us clean up those entries). | 3616 // helps us clean up those entries). |
3629 perm_folder.Put(IS_DEL, true); | 3617 perm_folder.Put(IS_DEL, true); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4071 // - commitresponse - getupdates. | 4059 // - commitresponse - getupdates. |
4072 class SyncerUndeletionTest : public SyncerTest { | 4060 class SyncerUndeletionTest : public SyncerTest { |
4073 public: | 4061 public: |
4074 SyncerUndeletionTest() | 4062 SyncerUndeletionTest() |
4075 : client_tag_("foobar"), | 4063 : client_tag_("foobar"), |
4076 metahandle_(syncable::kInvalidMetaHandle) { | 4064 metahandle_(syncable::kInvalidMetaHandle) { |
4077 } | 4065 } |
4078 | 4066 |
4079 void Create() { | 4067 void Create() { |
4080 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 4068 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
4081 MutableEntry perm_folder( | 4069 MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname"); |
4082 &trans, CREATE, BOOKMARKS, ids_.root(), "clientname"); | |
4083 ASSERT_TRUE(perm_folder.good()); | 4070 ASSERT_TRUE(perm_folder.good()); |
4084 perm_folder.Put(UNIQUE_CLIENT_TAG, client_tag_); | 4071 perm_folder.Put(UNIQUE_CLIENT_TAG, client_tag_); |
4085 perm_folder.Put(IS_UNSYNCED, true); | 4072 perm_folder.Put(IS_UNSYNCED, true); |
4086 perm_folder.Put(SYNCING, false); | 4073 perm_folder.Put(SYNCING, false); |
4087 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 4074 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
4088 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 4075 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
4089 EXPECT_FALSE(perm_folder.Get(ID).ServerKnows()); | 4076 EXPECT_FALSE(perm_folder.Get(ID).ServerKnows()); |
4090 metahandle_ = perm_folder.Get(META_HANDLE); | 4077 metahandle_ = perm_folder.Get(META_HANDLE); |
4091 } | 4078 } |
4092 | 4079 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4710 | 4697 |
4711 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4698 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
4712 Add(mid_id_); | 4699 Add(mid_id_); |
4713 Add(low_id_); | 4700 Add(low_id_); |
4714 Add(high_id_); | 4701 Add(high_id_); |
4715 SyncShareNudge(); | 4702 SyncShareNudge(); |
4716 ExpectLocalOrderIsByServerId(); | 4703 ExpectLocalOrderIsByServerId(); |
4717 } | 4704 } |
4718 | 4705 |
4719 } // namespace syncer | 4706 } // namespace syncer |
OLD | NEW |