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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 Entry entry(&rt, syncable::GET_BY_ID, child_id_); | 1030 Entry entry(&rt, syncable::GET_BY_ID, child_id_); |
1031 ASSERT_TRUE(entry.good()); | 1031 ASSERT_TRUE(entry.good()); |
1032 VerifyTestDataInEntry(&rt, &entry); | 1032 VerifyTestDataInEntry(&rt, &entry); |
1033 } | 1033 } |
1034 } | 1034 } |
1035 | 1035 |
1036 TEST_F(SyncerTest, TestPurgeWhileUnsynced) { | 1036 TEST_F(SyncerTest, TestPurgeWhileUnsynced) { |
1037 // Similar to above, but throw a purge operation into the mix. Bug 49278. | 1037 // Similar to above, but throw a purge operation into the mix. Bug 49278. |
1038 syncable::Id pref_node_id = TestIdFactory::MakeServer("Tim"); | 1038 syncable::Id pref_node_id = TestIdFactory::MakeServer("Tim"); |
1039 { | 1039 { |
| 1040 directory()->SetDownloadProgress(BOOKMARKS, |
| 1041 syncable::BuildProgress(BOOKMARKS)); |
| 1042 directory()->SetDownloadProgress(PREFERENCES, |
| 1043 syncable::BuildProgress(PREFERENCES)); |
1040 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1044 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1041 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); | 1045 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); |
1042 ASSERT_TRUE(parent.good()); | 1046 ASSERT_TRUE(parent.good()); |
1043 parent.PutIsUnsynced(true); | 1047 parent.PutIsUnsynced(true); |
1044 parent.PutIsDir(true); | 1048 parent.PutIsDir(true); |
1045 parent.PutSpecifics(DefaultBookmarkSpecifics()); | 1049 parent.PutSpecifics(DefaultBookmarkSpecifics()); |
1046 parent.PutBaseVersion(1); | 1050 parent.PutBaseVersion(1); |
1047 parent.PutId(parent_id_); | 1051 parent.PutId(parent_id_); |
1048 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete"); | 1052 MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete"); |
1049 ASSERT_TRUE(child.good()); | 1053 ASSERT_TRUE(child.good()); |
(...skipping 29 matching lines...) Expand all Loading... |
1079 { | 1083 { |
1080 syncable::ReadTransaction rt(FROM_HERE, directory()); | 1084 syncable::ReadTransaction rt(FROM_HERE, directory()); |
1081 Entry entry(&rt, syncable::GET_BY_ID, pref_node_id); | 1085 Entry entry(&rt, syncable::GET_BY_ID, pref_node_id); |
1082 ASSERT_FALSE(entry.good()); | 1086 ASSERT_FALSE(entry.good()); |
1083 } | 1087 } |
1084 } | 1088 } |
1085 | 1089 |
1086 TEST_F(SyncerTest, TestPurgeWhileUnapplied) { | 1090 TEST_F(SyncerTest, TestPurgeWhileUnapplied) { |
1087 // Similar to above, but for unapplied items. Bug 49278. | 1091 // Similar to above, but for unapplied items. Bug 49278. |
1088 { | 1092 { |
| 1093 directory()->SetDownloadProgress(BOOKMARKS, |
| 1094 syncable::BuildProgress(BOOKMARKS)); |
1089 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1095 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1090 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); | 1096 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete"); |
1091 ASSERT_TRUE(parent.good()); | 1097 ASSERT_TRUE(parent.good()); |
1092 parent.PutIsUnappliedUpdate(true); | 1098 parent.PutIsUnappliedUpdate(true); |
1093 parent.PutIsDir(true); | 1099 parent.PutIsDir(true); |
1094 parent.PutSpecifics(DefaultBookmarkSpecifics()); | 1100 parent.PutSpecifics(DefaultBookmarkSpecifics()); |
1095 parent.PutBaseVersion(1); | 1101 parent.PutBaseVersion(1); |
1096 parent.PutId(parent_id_); | 1102 parent.PutId(parent_id_); |
1097 } | 1103 } |
1098 | 1104 |
1099 directory()->PurgeEntriesWithTypeIn(ModelTypeSet(BOOKMARKS), | 1105 directory()->PurgeEntriesWithTypeIn(ModelTypeSet(BOOKMARKS), |
1100 ModelTypeSet(), | 1106 ModelTypeSet(), |
1101 ModelTypeSet()); | 1107 ModelTypeSet()); |
1102 | 1108 |
1103 SyncShareNudge(); | 1109 SyncShareNudge(); |
1104 directory()->SaveChanges(); | 1110 directory()->SaveChanges(); |
1105 { | 1111 { |
1106 syncable::ReadTransaction rt(FROM_HERE, directory()); | 1112 syncable::ReadTransaction rt(FROM_HERE, directory()); |
1107 Entry entry(&rt, syncable::GET_BY_ID, parent_id_); | 1113 Entry entry(&rt, syncable::GET_BY_ID, parent_id_); |
1108 ASSERT_FALSE(entry.good()); | 1114 ASSERT_FALSE(entry.good()); |
1109 } | 1115 } |
1110 } | 1116 } |
1111 | 1117 |
1112 TEST_F(SyncerTest, TestPurgeWithJournal) { | 1118 TEST_F(SyncerTest, TestPurgeWithJournal) { |
1113 { | 1119 { |
| 1120 directory()->SetDownloadProgress(BOOKMARKS, |
| 1121 syncable::BuildProgress(BOOKMARKS)); |
1114 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1122 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1115 MutableEntry parent(&wtrans, syncable::CREATE, BOOKMARKS, wtrans.root_id(), | 1123 MutableEntry parent(&wtrans, syncable::CREATE, BOOKMARKS, wtrans.root_id(), |
1116 "Pete"); | 1124 "Pete"); |
1117 ASSERT_TRUE(parent.good()); | 1125 ASSERT_TRUE(parent.good()); |
1118 parent.PutIsDir(true); | 1126 parent.PutIsDir(true); |
1119 parent.PutSpecifics(DefaultBookmarkSpecifics()); | 1127 parent.PutSpecifics(DefaultBookmarkSpecifics()); |
1120 parent.PutBaseVersion(1); | 1128 parent.PutBaseVersion(1); |
1121 parent.PutId(parent_id_); | 1129 parent.PutId(parent_id_); |
1122 MutableEntry child(&wtrans, syncable::CREATE, BOOKMARKS, parent_id_, | 1130 MutableEntry child(&wtrans, syncable::CREATE, BOOKMARKS, parent_id_, |
1123 "Pete"); | 1131 "Pete"); |
(...skipping 3841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4965 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4973 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
4966 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4974 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
4967 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4975 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
4968 } else { | 4976 } else { |
4969 EXPECT_TRUE(final_monitor_records.empty()) | 4977 EXPECT_TRUE(final_monitor_records.empty()) |
4970 << "Should not restore records after successful bookmark commit."; | 4978 << "Should not restore records after successful bookmark commit."; |
4971 } | 4979 } |
4972 } | 4980 } |
4973 | 4981 |
4974 } // namespace syncer | 4982 } // namespace syncer |
OLD | NEW |