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

Side by Side Diff: components/sync/driver/backend_migrator_unittest.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/sync/driver/backend_migrator.cc ('k') | components/sync/driver/change_processor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/driver/backend_migrator.h" 5 #include "components/sync/driver/backend_migrator.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/tracked_objects.h" 9 #include "base/tracked_objects.h"
10 #include "components/sync/base/model_type_test_util.h" 10 #include "components/sync/base/model_type_test_util.h"
11 #include "components/sync/core/test/test_user_share.h" 11 #include "components/sync/core/test/test_user_share.h"
12 #include "components/sync/core/write_transaction.h" 12 #include "components/sync/core/write_transaction.h"
13 #include "components/sync/driver/data_type_manager_mock.h" 13 #include "components/sync/driver/data_type_manager_mock.h"
14 #include "components/sync/driver/fake_sync_service.h" 14 #include "components/sync/driver/fake_sync_service.h"
15 #include "components/sync/protocol/sync.pb.h" 15 #include "components/sync/protocol/sync.pb.h"
16 #include "components/sync/syncable/directory.h" // TODO(tim): Remove. Bug 13113 0. 16 #include "components/sync/syncable/directory.h" // TODO(tim): Remove. Bug 13113 0.
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using ::testing::_; 20 using ::testing::_;
21 using ::testing::Eq; 21 using ::testing::Eq;
22 using ::testing::Mock; 22 using ::testing::Mock;
23 using ::testing::NiceMock; 23 using ::testing::NiceMock;
24 using ::testing::Return; 24 using ::testing::Return;
25 using sync_driver::DataTypeManager;
26 using sync_driver::DataTypeManagerMock;
25 27
26 namespace syncer { 28 namespace browser_sync {
29
30 using syncer::SyncCycleSnapshot;
27 31
28 class SyncBackendMigratorTest : public testing::Test { 32 class SyncBackendMigratorTest : public testing::Test {
29 public: 33 public:
30 SyncBackendMigratorTest() {} 34 SyncBackendMigratorTest() {}
31 virtual ~SyncBackendMigratorTest() {} 35 virtual ~SyncBackendMigratorTest() {}
32 36
33 virtual void SetUp() { 37 virtual void SetUp() {
34 test_user_share_.SetUp(); 38 test_user_share_.SetUp();
35 Mock::VerifyAndClear(manager()); 39 Mock::VerifyAndClear(manager());
36 preferred_types_.Put(BOOKMARKS); 40 preferred_types_.Put(syncer::BOOKMARKS);
37 preferred_types_.Put(PREFERENCES); 41 preferred_types_.Put(syncer::PREFERENCES);
38 preferred_types_.Put(AUTOFILL); 42 preferred_types_.Put(syncer::AUTOFILL);
39 43
40 migrator_.reset(new BackendMigrator("Profile0", 44 migrator_.reset(new BackendMigrator("Profile0",
41 test_user_share_.user_share(), 45 test_user_share_.user_share(),
42 service(), manager(), base::Closure())); 46 service(), manager(), base::Closure()));
43 SetUnsyncedTypes(ModelTypeSet()); 47 SetUnsyncedTypes(syncer::ModelTypeSet());
44 } 48 }
45 49
46 virtual void TearDown() { 50 virtual void TearDown() {
47 migrator_.reset(); 51 migrator_.reset();
48 test_user_share_.TearDown(); 52 test_user_share_.TearDown();
49 } 53 }
50 54
51 // Marks all types in |unsynced_types| as unsynced and all other 55 // Marks all types in |unsynced_types| as unsynced and all other
52 // types as synced. 56 // types as synced.
53 void SetUnsyncedTypes(ModelTypeSet unsynced_types) { 57 void SetUnsyncedTypes(syncer::ModelTypeSet unsynced_types) {
54 WriteTransaction trans(FROM_HERE, test_user_share_.user_share()); 58 syncer::WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
55 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 59 for (int i = syncer::FIRST_REAL_MODEL_TYPE; i < syncer::MODEL_TYPE_COUNT;
56 ModelType type = ModelTypeFromInt(i); 60 ++i) {
61 syncer::ModelType type = syncer::ModelTypeFromInt(i);
57 sync_pb::DataTypeProgressMarker progress_marker; 62 sync_pb::DataTypeProgressMarker progress_marker;
58 if (!unsynced_types.Has(type)) { 63 if (!unsynced_types.Has(type)) {
59 progress_marker.set_token("dummy"); 64 progress_marker.set_token("dummy");
60 } 65 }
61 trans.GetDirectory()->SetDownloadProgress(type, progress_marker); 66 trans.GetDirectory()->SetDownloadProgress(type, progress_marker);
62 } 67 }
63 } 68 }
64 69
65 void SendConfigureDone(DataTypeManager::ConfigureStatus status, 70 void SendConfigureDone(DataTypeManager::ConfigureStatus status,
66 ModelTypeSet requested_types) { 71 syncer::ModelTypeSet requested_types) {
67 if (status == DataTypeManager::OK) { 72 if (status == DataTypeManager::OK) {
68 DataTypeManager::ConfigureResult result(status, requested_types); 73 DataTypeManager::ConfigureResult result(status, requested_types);
69 migrator_->OnConfigureDone(result); 74 migrator_->OnConfigureDone(result);
70 } else { 75 } else {
71 DataTypeManager::ConfigureResult result(status, requested_types); 76 DataTypeManager::ConfigureResult result(status, requested_types);
72 migrator_->OnConfigureDone(result); 77 migrator_->OnConfigureDone(result);
73 } 78 }
74 base::RunLoop run_loop; 79 base::RunLoop run_loop;
75 run_loop.RunUntilIdle(); 80 run_loop.RunUntilIdle();
76 } 81 }
77 82
78 SyncService* service() { return &service_; } 83 sync_driver::SyncService* service() { return &service_; }
79 DataTypeManagerMock* manager() { return &manager_; } 84 DataTypeManagerMock* manager() { return &manager_; }
80 ModelTypeSet preferred_types() { return preferred_types_; } 85 syncer::ModelTypeSet preferred_types() { return preferred_types_; }
81 BackendMigrator* migrator() { return migrator_.get(); } 86 BackendMigrator* migrator() { return migrator_.get(); }
82 void RemovePreferredType(ModelType type) { preferred_types_.Remove(type); } 87 void RemovePreferredType(syncer::ModelType type) {
88 preferred_types_.Remove(type);
89 }
83 90
84 private: 91 private:
85 base::MessageLoop message_loop_; 92 base::MessageLoop message_loop_;
86 ModelTypeSet preferred_types_; 93 syncer::ModelTypeSet preferred_types_;
87 FakeSyncService service_; 94 sync_driver::FakeSyncService service_;
88 NiceMock<DataTypeManagerMock> manager_; 95 NiceMock<DataTypeManagerMock> manager_;
89 TestUserShare test_user_share_; 96 syncer::TestUserShare test_user_share_;
90 std::unique_ptr<BackendMigrator> migrator_; 97 std::unique_ptr<BackendMigrator> migrator_;
91 }; 98 };
92 99
93 class MockMigrationObserver : public MigrationObserver { 100 class MockMigrationObserver : public MigrationObserver {
94 public: 101 public:
95 virtual ~MockMigrationObserver() {} 102 virtual ~MockMigrationObserver() {}
96 103
97 MOCK_METHOD0(OnMigrationStateChange, void()); 104 MOCK_METHOD0(OnMigrationStateChange, void());
98 }; 105 };
99 106
100 // Test that in the normal case a migration does transition through each state 107 // Test that in the normal case a migration does transition through each state
101 // and wind up back in IDLE. 108 // and wind up back in IDLE.
102 TEST_F(SyncBackendMigratorTest, Sanity) { 109 TEST_F(SyncBackendMigratorTest, Sanity) {
103 MockMigrationObserver migration_observer; 110 MockMigrationObserver migration_observer;
104 migrator()->AddMigrationObserver(&migration_observer); 111 migrator()->AddMigrationObserver(&migration_observer);
105 EXPECT_CALL(migration_observer, OnMigrationStateChange()).Times(4); 112 EXPECT_CALL(migration_observer, OnMigrationStateChange()).Times(4);
106 113
107 ModelTypeSet to_migrate, difference; 114 syncer::ModelTypeSet to_migrate, difference;
108 to_migrate.Put(PREFERENCES); 115 to_migrate.Put(syncer::PREFERENCES);
109 difference.Put(AUTOFILL); 116 difference.Put(syncer::AUTOFILL);
110 difference.Put(BOOKMARKS); 117 difference.Put(syncer::BOOKMARKS);
111 118
112 EXPECT_CALL(*manager(), state()) 119 EXPECT_CALL(*manager(), state())
113 .WillOnce(Return(DataTypeManager::CONFIGURED)); 120 .WillOnce(Return(DataTypeManager::CONFIGURED));
114 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)) 121 EXPECT_CALL(*manager(),
122 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
115 .Times(1); 123 .Times(1);
116 EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1); 124 EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
125 .Times(1);
117 126
118 migrator()->MigrateTypes(to_migrate); 127 migrator()->MigrateTypes(to_migrate);
119 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 128 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
120 129
121 SetUnsyncedTypes(to_migrate); 130 SetUnsyncedTypes(to_migrate);
122 SendConfigureDone(DataTypeManager::OK, difference); 131 SendConfigureDone(DataTypeManager::OK, difference);
123 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state()); 132 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
124 133
125 SetUnsyncedTypes(ModelTypeSet()); 134 SetUnsyncedTypes(syncer::ModelTypeSet());
126 SendConfigureDone(DataTypeManager::OK, preferred_types()); 135 SendConfigureDone(DataTypeManager::OK, preferred_types());
127 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state()); 136 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
128 137
129 migrator()->RemoveMigrationObserver(&migration_observer); 138 migrator()->RemoveMigrationObserver(&migration_observer);
130 } 139 }
131 140
132 // Test that in the normal case with Nigori a migration transitions through 141 // Test that in the normal case with Nigori a migration transitions through
133 // each state and wind up back in IDLE. 142 // each state and wind up back in IDLE.
134 TEST_F(SyncBackendMigratorTest, MigrateNigori) { 143 TEST_F(SyncBackendMigratorTest, MigrateNigori) {
135 ModelTypeSet to_migrate, difference; 144 syncer::ModelTypeSet to_migrate, difference;
136 to_migrate.Put(NIGORI); 145 to_migrate.Put(syncer::NIGORI);
137 difference.Put(AUTOFILL); 146 difference.Put(syncer::AUTOFILL);
138 difference.Put(BOOKMARKS); 147 difference.Put(syncer::BOOKMARKS);
139 148
140 EXPECT_CALL(*manager(), state()) 149 EXPECT_CALL(*manager(), state())
141 .WillOnce(Return(DataTypeManager::CONFIGURED)); 150 .WillOnce(Return(DataTypeManager::CONFIGURED));
142 151
143 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)); 152 EXPECT_CALL(*manager(),
153 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION));
144 154
145 migrator()->MigrateTypes(to_migrate); 155 migrator()->MigrateTypes(to_migrate);
146 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 156 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
147 157
148 SetUnsyncedTypes(to_migrate); 158 SetUnsyncedTypes(to_migrate);
149 SendConfigureDone(DataTypeManager::OK, difference); 159 SendConfigureDone(DataTypeManager::OK, difference);
150 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state()); 160 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
151 161
152 SetUnsyncedTypes(ModelTypeSet()); 162 SetUnsyncedTypes(syncer::ModelTypeSet());
153 SendConfigureDone(DataTypeManager::OK, preferred_types()); 163 SendConfigureDone(DataTypeManager::OK, preferred_types());
154 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state()); 164 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
155 } 165 }
156 166
157 // Test that the migrator waits for the data type manager to be idle before 167 // Test that the migrator waits for the data type manager to be idle before
158 // starting a migration. 168 // starting a migration.
159 TEST_F(SyncBackendMigratorTest, WaitToStart) { 169 TEST_F(SyncBackendMigratorTest, WaitToStart) {
160 ModelTypeSet to_migrate; 170 syncer::ModelTypeSet to_migrate;
161 to_migrate.Put(PREFERENCES); 171 to_migrate.Put(syncer::PREFERENCES);
162 172
163 EXPECT_CALL(*manager(), state()) 173 EXPECT_CALL(*manager(), state())
164 .WillOnce(Return(DataTypeManager::CONFIGURING)); 174 .WillOnce(Return(DataTypeManager::CONFIGURING));
165 EXPECT_CALL(*manager(), Configure(_, _)).Times(0); 175 EXPECT_CALL(*manager(), Configure(_, _)).Times(0);
166 migrator()->MigrateTypes(to_migrate); 176 migrator()->MigrateTypes(to_migrate);
167 EXPECT_EQ(BackendMigrator::WAITING_TO_START, migrator()->state()); 177 EXPECT_EQ(BackendMigrator::WAITING_TO_START, migrator()->state());
168 178
169 Mock::VerifyAndClearExpectations(manager()); 179 Mock::VerifyAndClearExpectations(manager());
170 EXPECT_CALL(*manager(), state()) 180 EXPECT_CALL(*manager(), state())
171 .WillOnce(Return(DataTypeManager::CONFIGURED)); 181 .WillOnce(Return(DataTypeManager::CONFIGURED));
172 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)); 182 EXPECT_CALL(*manager(),
173 SetUnsyncedTypes(ModelTypeSet()); 183 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION));
174 SendConfigureDone(DataTypeManager::OK, ModelTypeSet()); 184 SetUnsyncedTypes(syncer::ModelTypeSet());
185 SendConfigureDone(DataTypeManager::OK, syncer::ModelTypeSet());
175 186
176 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 187 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
177 } 188 }
178 189
179 // Test that the migrator can cope with a migration request while a migration 190 // Test that the migrator can cope with a migration request while a migration
180 // is in progress. 191 // is in progress.
181 TEST_F(SyncBackendMigratorTest, RestartMigration) { 192 TEST_F(SyncBackendMigratorTest, RestartMigration) {
182 ModelTypeSet to_migrate1, to_migrate2, to_migrate_union, bookmarks; 193 syncer::ModelTypeSet to_migrate1, to_migrate2, to_migrate_union, bookmarks;
183 to_migrate1.Put(PREFERENCES); 194 to_migrate1.Put(syncer::PREFERENCES);
184 to_migrate2.Put(AUTOFILL); 195 to_migrate2.Put(syncer::AUTOFILL);
185 to_migrate_union.Put(PREFERENCES); 196 to_migrate_union.Put(syncer::PREFERENCES);
186 to_migrate_union.Put(AUTOFILL); 197 to_migrate_union.Put(syncer::AUTOFILL);
187 bookmarks.Put(BOOKMARKS); 198 bookmarks.Put(syncer::BOOKMARKS);
188 199
189 EXPECT_CALL(*manager(), state()) 200 EXPECT_CALL(*manager(), state())
190 .WillOnce(Return(DataTypeManager::CONFIGURED)); 201 .WillOnce(Return(DataTypeManager::CONFIGURED));
191 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)) 202 EXPECT_CALL(*manager(),
203 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
192 .Times(2); 204 .Times(2);
193 migrator()->MigrateTypes(to_migrate1); 205 migrator()->MigrateTypes(to_migrate1);
194 206
195 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 207 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
196 migrator()->MigrateTypes(to_migrate2); 208 migrator()->MigrateTypes(to_migrate2);
197 209
198 const ModelTypeSet difference1 = Difference(preferred_types(), to_migrate1); 210 const syncer::ModelTypeSet difference1 =
211 Difference(preferred_types(), to_migrate1);
199 212
200 Mock::VerifyAndClearExpectations(manager()); 213 Mock::VerifyAndClearExpectations(manager());
201 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)) 214 EXPECT_CALL(*manager(),
215 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
202 .Times(1); 216 .Times(1);
203 EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1); 217 EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
218 .Times(1);
204 SetUnsyncedTypes(to_migrate1); 219 SetUnsyncedTypes(to_migrate1);
205 SendConfigureDone(DataTypeManager::OK, difference1); 220 SendConfigureDone(DataTypeManager::OK, difference1);
206 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 221 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
207 222
208 SetUnsyncedTypes(to_migrate_union); 223 SetUnsyncedTypes(to_migrate_union);
209 SendConfigureDone(DataTypeManager::OK, bookmarks); 224 SendConfigureDone(DataTypeManager::OK, bookmarks);
210 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state()); 225 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
211 } 226 }
212 227
213 // Test that an external invocation of Configure(...) during a migration results 228 // Test that an external invocation of Configure(...) during a migration results
214 // in a migration reattempt. 229 // in a migration reattempt.
215 TEST_F(SyncBackendMigratorTest, InterruptedWhileDisablingTypes) { 230 TEST_F(SyncBackendMigratorTest, InterruptedWhileDisablingTypes) {
216 ModelTypeSet to_migrate; 231 syncer::ModelTypeSet to_migrate;
217 ModelTypeSet difference; 232 syncer::ModelTypeSet difference;
218 to_migrate.Put(PREFERENCES); 233 to_migrate.Put(syncer::PREFERENCES);
219 difference.Put(AUTOFILL); 234 difference.Put(syncer::AUTOFILL);
220 difference.Put(BOOKMARKS); 235 difference.Put(syncer::BOOKMARKS);
221 236
222 EXPECT_CALL(*manager(), state()) 237 EXPECT_CALL(*manager(), state())
223 .WillOnce(Return(DataTypeManager::CONFIGURED)); 238 .WillOnce(Return(DataTypeManager::CONFIGURED));
224 EXPECT_CALL(*manager(), PurgeForMigration(HasModelTypes(to_migrate), 239 EXPECT_CALL(*manager(),
225 CONFIGURE_REASON_MIGRATION)); 240 PurgeForMigration(HasModelTypes(to_migrate),
241 syncer::CONFIGURE_REASON_MIGRATION));
226 migrator()->MigrateTypes(to_migrate); 242 migrator()->MigrateTypes(to_migrate);
227 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 243 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
228 244
229 Mock::VerifyAndClearExpectations(manager()); 245 Mock::VerifyAndClearExpectations(manager());
230 EXPECT_CALL(*manager(), PurgeForMigration(HasModelTypes(to_migrate), 246 EXPECT_CALL(*manager(),
231 CONFIGURE_REASON_MIGRATION)); 247 PurgeForMigration(HasModelTypes(to_migrate),
232 SetUnsyncedTypes(ModelTypeSet()); 248 syncer::CONFIGURE_REASON_MIGRATION));
249 SetUnsyncedTypes(syncer::ModelTypeSet());
233 SendConfigureDone(DataTypeManager::OK, preferred_types()); 250 SendConfigureDone(DataTypeManager::OK, preferred_types());
234 251
235 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 252 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
236 } 253 }
237 254
238 // Test that spurious OnConfigureDone events don't confuse the 255 // Test that spurious OnConfigureDone events don't confuse the
239 // migrator while it's waiting for disabled types to have been purged 256 // migrator while it's waiting for disabled types to have been purged
240 // from the sync db. 257 // from the sync db.
241 TEST_F(SyncBackendMigratorTest, WaitingForPurge) { 258 TEST_F(SyncBackendMigratorTest, WaitingForPurge) {
242 ModelTypeSet to_migrate, difference; 259 syncer::ModelTypeSet to_migrate, difference;
243 to_migrate.Put(PREFERENCES); 260 to_migrate.Put(syncer::PREFERENCES);
244 to_migrate.Put(AUTOFILL); 261 to_migrate.Put(syncer::AUTOFILL);
245 difference.Put(BOOKMARKS); 262 difference.Put(syncer::BOOKMARKS);
246 263
247 EXPECT_CALL(*manager(), state()) 264 EXPECT_CALL(*manager(), state())
248 .WillOnce(Return(DataTypeManager::CONFIGURED)); 265 .WillOnce(Return(DataTypeManager::CONFIGURED));
249 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)) 266 EXPECT_CALL(*manager(),
267 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
250 .Times(1); 268 .Times(1);
251 EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1); 269 EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
270 .Times(1);
252 271
253 migrator()->MigrateTypes(to_migrate); 272 migrator()->MigrateTypes(to_migrate);
254 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 273 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
255 274
256 SendConfigureDone(DataTypeManager::OK, difference); 275 SendConfigureDone(DataTypeManager::OK, difference);
257 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 276 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
258 277
259 ModelTypeSet prefs; 278 syncer::ModelTypeSet prefs;
260 prefs.Put(PREFERENCES); 279 prefs.Put(syncer::PREFERENCES);
261 SetUnsyncedTypes(prefs); 280 SetUnsyncedTypes(prefs);
262 SendConfigureDone(DataTypeManager::OK, difference); 281 SendConfigureDone(DataTypeManager::OK, difference);
263 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state()); 282 EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
264 283
265 SetUnsyncedTypes(to_migrate); 284 SetUnsyncedTypes(to_migrate);
266 SendConfigureDone(DataTypeManager::OK, difference); 285 SendConfigureDone(DataTypeManager::OK, difference);
267 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state()); 286 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
268 } 287 }
269 288
270 TEST_F(SyncBackendMigratorTest, MigratedTypeDisabledByUserDuringMigration) { 289 TEST_F(SyncBackendMigratorTest, MigratedTypeDisabledByUserDuringMigration) {
271 ModelTypeSet to_migrate; 290 syncer::ModelTypeSet to_migrate;
272 to_migrate.Put(PREFERENCES); 291 to_migrate.Put(syncer::PREFERENCES);
273 292
274 EXPECT_CALL(*manager(), state()) 293 EXPECT_CALL(*manager(), state())
275 .WillOnce(Return(DataTypeManager::CONFIGURED)); 294 .WillOnce(Return(DataTypeManager::CONFIGURED));
276 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)) 295 EXPECT_CALL(*manager(),
296 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
277 .Times(1); 297 .Times(1);
278 EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1); 298 EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
299 .Times(1);
279 migrator()->MigrateTypes(to_migrate); 300 migrator()->MigrateTypes(to_migrate);
280 301
281 RemovePreferredType(PREFERENCES); 302 RemovePreferredType(syncer::PREFERENCES);
282 SetUnsyncedTypes(to_migrate); 303 SetUnsyncedTypes(to_migrate);
283 SendConfigureDone(DataTypeManager::OK, preferred_types()); 304 SendConfigureDone(DataTypeManager::OK, preferred_types());
284 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state()); 305 EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
285 SetUnsyncedTypes(ModelTypeSet()); 306 SetUnsyncedTypes(syncer::ModelTypeSet());
286 SendConfigureDone(DataTypeManager::OK, preferred_types()); 307 SendConfigureDone(DataTypeManager::OK, preferred_types());
287 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state()); 308 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
288 } 309 }
289 310
290 TEST_F(SyncBackendMigratorTest, ConfigureFailure) { 311 TEST_F(SyncBackendMigratorTest, ConfigureFailure) {
291 ModelTypeSet to_migrate; 312 syncer::ModelTypeSet to_migrate;
292 to_migrate.Put(PREFERENCES); 313 to_migrate.Put(syncer::PREFERENCES);
293 314
294 EXPECT_CALL(*manager(), state()) 315 EXPECT_CALL(*manager(), state())
295 .WillOnce(Return(DataTypeManager::CONFIGURED)); 316 .WillOnce(Return(DataTypeManager::CONFIGURED));
296 EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION)) 317 EXPECT_CALL(*manager(),
318 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
297 .Times(1); 319 .Times(1);
298 migrator()->MigrateTypes(to_migrate); 320 migrator()->MigrateTypes(to_migrate);
299 SetUnsyncedTypes(ModelTypeSet()); 321 SetUnsyncedTypes(syncer::ModelTypeSet());
300 SendConfigureDone(DataTypeManager::ABORTED, ModelTypeSet()); 322 SendConfigureDone(DataTypeManager::ABORTED, syncer::ModelTypeSet());
301 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state()); 323 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
302 } 324 }
303 325
304 }; // namespace browser_sync 326 }; // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync/driver/backend_migrator.cc ('k') | components/sync/driver/change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698