OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "chrome/browser/sync/engine/apply_updates_command.h" | 10 #include "chrome/browser/sync/engine/apply_updates_command.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 if (item_id.ServerKnows()) { | 136 if (item_id.ServerKnows()) { |
137 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); | 137 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); |
138 entry.Put(syncable::SERVER_IS_DIR, is_folder); | 138 entry.Put(syncable::SERVER_IS_DIR, is_folder); |
139 entry.Put(syncable::SERVER_PARENT_ID, parent_id); | 139 entry.Put(syncable::SERVER_PARENT_ID, parent_id); |
140 entry.Put(syncable::SERVER_IS_DEL, false); | 140 entry.Put(syncable::SERVER_IS_DEL, false); |
141 } | 141 } |
142 if (metahandle_out) | 142 if (metahandle_out) |
143 *metahandle_out = entry.Get(syncable::META_HANDLE); | 143 *metahandle_out = entry.Get(syncable::META_HANDLE); |
144 } | 144 } |
145 | 145 |
146 // Creates an item that is both unsynced an an unapplied update. The item_id | |
147 // parameter must be a server ID. The metahandle of the created item will be | |
148 // output to metahandle_out. Returns the metahandle of the created item in | |
149 // metahandle_out if not NULL. | |
150 void CreateUnappliedAndUnsyncedItem(const Id& item_id, | |
akalin
2012/02/02 01:34:39
you only call this function twice, with very simil
rlarocque
2012/02/03 22:31:15
Yes, that makes sense. I wrote this function befo
| |
151 const Id& parent_id, | |
152 const string& name, | |
153 bool is_folder, | |
154 syncable::ModelType model_type, | |
155 int64* metahandle_out) { | |
156 // This function requires that the item_id be a server ID. | |
157 CHECK(item_id.ServerKnows()); | |
akalin
2012/02/02 01:34:39
you CHECK here but you ASSERT_TRUE later in the fu
rlarocque
2012/02/03 22:31:15
Good point. I would fix this, but in the latest p
| |
158 | |
159 // If our caller did not specify a location to store the returned | |
160 // metahandle, then use our own temporary storage. | |
161 int64 local_metahandle_out = 0; | |
162 if (!metahandle_out) | |
163 metahandle_out = &local_metahandle_out; | |
164 | |
165 CreateUnsyncedItem(item_id, parent_id, name, is_folder, | |
166 model_type, metahandle_out); | |
167 | |
168 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
169 ASSERT_TRUE(dir.good()); | |
170 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
171 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, *metahandle_out); | |
172 ASSERT_TRUE(entry.good()); | |
173 | |
174 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); | |
175 entry.Put(syncable::SERVER_VERSION, next_revision_++); | |
akalin
2012/02/02 01:34:39
use GetNextRevision() here, too?
rlarocque
2012/02/03 22:31:15
Done.
| |
176 } | |
177 | |
178 int64 GetNextRevision() { | |
179 return next_revision_++; | |
180 } | |
181 | |
146 ApplyUpdatesCommand apply_updates_command_; | 182 ApplyUpdatesCommand apply_updates_command_; |
147 TestIdFactory id_factory_; | 183 TestIdFactory id_factory_; |
148 private: | 184 private: |
149 int64 next_revision_; | 185 int64 next_revision_; |
150 DISALLOW_COPY_AND_ASSIGN(ApplyUpdatesCommandTest); | 186 DISALLOW_COPY_AND_ASSIGN(ApplyUpdatesCommandTest); |
151 }; | 187 }; |
152 | 188 |
153 TEST_F(ApplyUpdatesCommandTest, Simple) { | 189 TEST_F(ApplyUpdatesCommandTest, Simple) { |
154 string root_server_id = syncable::GetNullId().GetServerId(); | 190 string root_server_id = syncable::GetNullId().GetServerId(); |
155 CreateUnappliedNewItemWithParent("parent", | 191 CreateUnappliedNewItemWithParent("parent", |
156 DefaultBookmarkSpecifics(), | 192 DefaultBookmarkSpecifics(), |
157 root_server_id); | 193 root_server_id); |
158 CreateUnappliedNewItemWithParent("child", | 194 CreateUnappliedNewItemWithParent("child", |
159 DefaultBookmarkSpecifics(), | 195 DefaultBookmarkSpecifics(), |
160 "parent"); | 196 "parent"); |
161 | 197 |
162 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 198 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
163 apply_updates_command_.ExecuteImpl(session()); | 199 apply_updates_command_.ExecuteImpl(session()); |
164 | 200 |
165 sessions::StatusController* status = session()->mutable_status_controller(); | 201 sessions::StatusController* status = session()->mutable_status_controller(); |
166 | 202 |
167 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 203 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
168 ASSERT_TRUE(status->update_progress()); | 204 ASSERT_TRUE(status->update_progress()); |
169 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 205 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
akalin
2012/02/02 01:34:39
comment this test, too
| |
170 << "All updates should have been attempted"; | 206 << "All updates should have been attempted"; |
171 ASSERT_TRUE(status->conflict_progress()); | 207 ASSERT_TRUE(status->conflict_progress()); |
172 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 208 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
209 << "Simple update shouldn't result in conflicts"; | |
210 EXPECT_EQ(0, status->conflict_progress()->EncryptionConflictingItemsSize()) | |
211 << "Simple update shouldn't result in conflicts"; | |
212 EXPECT_EQ(0, status->conflict_progress()->HierarchyConflictingItemsSize()) | |
173 << "Simple update shouldn't result in conflicts"; | 213 << "Simple update shouldn't result in conflicts"; |
174 EXPECT_EQ(2, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 214 EXPECT_EQ(2, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
175 << "All items should have been successfully applied"; | 215 << "All items should have been successfully applied"; |
176 } | 216 } |
177 | 217 |
178 TEST_F(ApplyUpdatesCommandTest, UpdateWithChildrenBeforeParents) { | 218 TEST_F(ApplyUpdatesCommandTest, UpdateWithChildrenBeforeParents) { |
179 // Set a bunch of updates which are difficult to apply in the order | 219 // Set a bunch of updates which are difficult to apply in the order |
180 // they're received due to dependencies on other unseen items. | 220 // they're received due to dependencies on other unseen items. |
181 string root_server_id = syncable::GetNullId().GetServerId(); | 221 string root_server_id = syncable::GetNullId().GetServerId(); |
182 CreateUnappliedNewItemWithParent("a_child_created_first", | 222 CreateUnappliedNewItemWithParent("a_child_created_first", |
(...skipping 14 matching lines...) Expand all Loading... | |
197 | 237 |
198 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 238 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
199 apply_updates_command_.ExecuteImpl(session()); | 239 apply_updates_command_.ExecuteImpl(session()); |
200 | 240 |
201 sessions::StatusController* status = session()->mutable_status_controller(); | 241 sessions::StatusController* status = session()->mutable_status_controller(); |
202 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 242 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
203 ASSERT_TRUE(status->update_progress()); | 243 ASSERT_TRUE(status->update_progress()); |
204 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) | 244 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) |
205 << "All updates should have been attempted"; | 245 << "All updates should have been attempted"; |
206 ASSERT_TRUE(status->conflict_progress()); | 246 ASSERT_TRUE(status->conflict_progress()); |
207 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 247 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
208 << "Simple update shouldn't result in conflicts, even if out-of-order"; | 248 << "Simple update shouldn't result in conflicts, even if out-of-order"; |
209 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 249 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
210 << "All updates should have been successfully applied"; | 250 << "All updates should have been successfully applied"; |
211 } | 251 } |
212 | 252 |
213 TEST_F(ApplyUpdatesCommandTest, NestedItemsWithUnknownParent) { | 253 // Runs the ApplyUpdatesCommand on an item that has both local and remote |
254 // modifications (IS_UNSYNCED and IS_UNAPPLIED_UPDATE). We expect the command | |
255 // to detect that this update can't be applied because it is in a CONFLICT | |
256 // state. | |
257 TEST_F(ApplyUpdatesCommandTest, SimpleConflict) { | |
258 string root_server_id = syncable::GetNullId().GetServerId(); | |
akalin
2012/02/02 01:34:39
this variable doesn't seem to be used
rlarocque
2012/02/03 22:31:15
Done.
| |
259 CreateUnappliedAndUnsyncedItem(id_factory_.MakeServer("item"), | |
260 id_factory_.root(), "item", false, | |
261 syncable::BOOKMARKS, NULL); | |
262 | |
263 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
264 apply_updates_command_.ExecuteImpl(session()); | |
265 | |
266 sessions::StatusController* status = session()->mutable_status_controller(); | |
akalin
2012/02/02 01:34:39
can you use the non-mutable status_controller acce
rlarocque
2012/02/03 22:31:15
The ScopedModelSafeGroupRestriction needs to modif
| |
267 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
268 ASSERT_TRUE(status->conflict_progress()); | |
269 EXPECT_EQ(1, status->conflict_progress()->SimpleConflictingItemsSize()) | |
270 << "Unsynced and unapplied item should be a simple conflict"; | |
271 } | |
272 | |
273 // Runs the ApplyUpdatesCommand on an item that has both local and remote | |
274 // modifications *and* the remote modification can not be applied without | |
akalin
2012/02/02 01:34:39
can not -> cannot
rlarocque
2012/02/03 22:31:15
Done.
| |
275 // violating the tree constraints. We expect the command to detect that this | |
276 // update can't be applied and that this situation can't be resolved with the | |
277 // simple conflict processing logic; it is in a CONFLICT_HIERARCHY state. | |
278 TEST_F(ApplyUpdatesCommandTest, HierarchyAndSimpleConflict) { | |
279 int64 handle = 0; | |
280 // Create a simply-conflicting item. It will start with valid parent ids. | |
281 CreateUnappliedAndUnsyncedItem(id_factory_.MakeServer("orphaned_by_server"), | |
282 id_factory_.root(), "orphaned_by_server", | |
283 false, syncable::BOOKMARKS, &handle); | |
284 { | |
285 // Manually set the SERVER_PARENT_ID to bad value. | |
286 // A bad parent indicates a hierarchy conflict. | |
287 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
288 ASSERT_TRUE(dir.good()); | |
289 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
290 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, handle); | |
291 ASSERT_TRUE(entry.good()); | |
292 | |
293 entry.Put(syncable::SERVER_PARENT_ID, | |
294 id_factory_.MakeServer("bogus_parent")); | |
295 } | |
296 | |
297 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
298 apply_updates_command_.ExecuteImpl(session()); | |
299 | |
300 sessions::StatusController* status = session()->mutable_status_controller(); | |
akalin
2012/02/02 01:34:39
here too
akalin
2012/02/02 01:34:39
all these lines are just to check HierarchyConflic
rlarocque
2012/02/03 22:31:15
I'm on the fence about that.
If we pass in the
| |
301 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
302 | |
303 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()); | |
304 | |
305 // An update that is both a simple conflict and a hierarchy conflict should be | |
306 // treated as a hierarchy conflict. | |
307 ASSERT_TRUE(status->conflict_progress()); | |
308 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
309 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()); | |
310 } | |
311 | |
312 | |
313 // Runs the ApplyUpdatesCommand on an item with remote modifications that would | |
314 // create a directory loop if the update were applied. We expect the command to | |
315 // detect that this update can't be applied because it is in a | |
316 // CONFLICT_HIERARCHY state. | |
317 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDirectoryLoop) { | |
318 // Item 'X' locally has parent of 'root'. Server is updating it to have | |
319 // parent of 'Y'. | |
320 { | |
321 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
322 ASSERT_TRUE(dir.good()); | |
323 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
324 | |
325 syncable::Id parent_id(id_factory_.root()); | |
326 MutableEntry entry(&trans, syncable::CREATE, parent_id, "X"); | |
327 ASSERT_TRUE(entry.good()); | |
328 | |
329 entry.Put(syncable::ID, id_factory_.MakeServer("X")); | |
330 entry.Put(syncable::BASE_VERSION, GetNextRevision()); | |
331 entry.Put(syncable::IS_UNSYNCED, false); | |
332 entry.Put(syncable::NON_UNIQUE_NAME, "X"); | |
333 entry.Put(syncable::IS_DIR, true); | |
334 entry.Put(syncable::IS_DEL, false); | |
335 entry.Put(syncable::PARENT_ID, parent_id); | |
336 | |
337 CHECK(entry.PutPredecessor(id_factory_.root())); | |
akalin
2012/02/02 01:34:39
ASSERT_TRUE
rlarocque
2012/02/03 22:31:15
Done.
| |
338 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | |
339 | |
340 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); | |
341 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); | |
342 entry.Put(syncable::SERVER_NON_UNIQUE_NAME, "X"); | |
343 entry.Put(syncable::SERVER_PARENT_ID, id_factory_.MakeServer("Y")); | |
344 entry.Put(syncable::SERVER_IS_DIR, true); | |
345 entry.Put(syncable::SERVER_SPECIFICS, DefaultBookmarkSpecifics()); | |
346 } | |
347 | |
348 // Item 'Y' is child of 'X'. | |
349 CreateUnsyncedItem(id_factory_.MakeServer("Y"), id_factory_.MakeServer("X"), | |
350 "Y", true, syncable::BOOKMARKS, NULL); | |
351 | |
352 // If the server's update were applied, we would have X be a child of Y, and Y | |
353 // as a child of X. That's a directory loop. The UpdateApplicator should | |
354 // prevent the update from being applied and note that this is a hierarchy | |
355 // conflict. | |
356 | |
357 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
358 apply_updates_command_.ExecuteImpl(session()); | |
359 | |
360 sessions::StatusController* status = session()->mutable_status_controller(); | |
361 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
362 | |
363 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()); | |
364 | |
365 // This should count as a hierarchy conflict. | |
366 ASSERT_TRUE(status->conflict_progress()); | |
367 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
368 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()); | |
369 } | |
370 | |
371 // Runs the ApplyUpdatesCommand on a directory where the server sent us an | |
372 // update to add a child to a locally deleted (and unsynced) parent. We expect | |
373 // the command to not apply the update and to indicate the update is in a | |
374 // CONFLICT_HIERARCHY state. | |
375 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeletedParent) { | |
376 // Create a locally deleted parent item. | |
377 int64 parent_handle; | |
378 CreateUnsyncedItem(Id::CreateFromServerId("parent"), id_factory_.root(), | |
379 "parent", true, syncable::BOOKMARKS, &parent_handle); | |
380 { | |
381 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
382 ASSERT_TRUE(dir.good()); | |
383 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
384 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, parent_handle); | |
385 entry.Put(syncable::IS_DEL, true); | |
386 } | |
387 | |
388 // Create an incoming child from the server. | |
389 CreateUnappliedNewItemWithParent("child", DefaultBookmarkSpecifics(), | |
390 "parent"); | |
391 | |
392 // The server's update may seem valid to some other client, but on this client | |
393 // that new item's parent no longer exists. The update should not be applied | |
394 // and the update applicator should indicate this is a hierarchy conflict. | |
395 | |
396 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
397 apply_updates_command_.ExecuteImpl(session()); | |
398 | |
399 sessions::StatusController* status = session()->mutable_status_controller(); | |
400 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
401 | |
402 // This should count as a hierarchy conflict. | |
403 ASSERT_TRUE(status->conflict_progress()); | |
404 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
405 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()); | |
406 } | |
407 | |
408 // Runs the ApplyUpdatesCommand on a directory where the server is trying to | |
409 // delete a folder that has a recently added (and unsynced) child. We expect | |
410 // the command to not apply the update because it is in a CONFLICT_HIERARCHY | |
411 // state. | |
412 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeleteNonEmptyDirectory) { | |
413 // Create a server-deleted directory. | |
414 { | |
415 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
416 ASSERT_TRUE(dir.good()); | |
417 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | |
418 | |
419 syncable::Id parent_id(id_factory_.root()); | |
420 MutableEntry entry(&trans, syncable::CREATE, parent_id, "parent"); | |
421 ASSERT_TRUE(entry.good()); | |
422 | |
423 entry.Put(syncable::ID, id_factory_.MakeServer("parent")); | |
424 entry.Put(syncable::BASE_VERSION, GetNextRevision()); | |
akalin
2012/02/02 01:34:39
i feel like you can decomp this into some helper f
rlarocque
2012/02/03 22:31:15
That's a good idea. Implemented in the next patch
| |
425 entry.Put(syncable::IS_UNSYNCED, false); | |
426 entry.Put(syncable::NON_UNIQUE_NAME, "parent"); | |
427 entry.Put(syncable::IS_DIR, true); | |
428 entry.Put(syncable::IS_DEL, false); | |
429 entry.Put(syncable::PARENT_ID, parent_id); | |
430 | |
431 CHECK(entry.PutPredecessor(id_factory_.root())); | |
432 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | |
433 | |
434 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); | |
435 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); | |
436 entry.Put(syncable::SERVER_NON_UNIQUE_NAME, "parent"); | |
437 entry.Put(syncable::SERVER_PARENT_ID, parent_id); | |
438 entry.Put(syncable::SERVER_IS_DIR, true); | |
439 entry.Put(syncable::SERVER_IS_DEL, true); | |
440 entry.Put(syncable::SERVER_SPECIFICS, DefaultBookmarkSpecifics()); | |
441 } | |
442 | |
443 // Create a local child of the server-deleted directory. | |
444 CreateUnsyncedItem(id_factory_.MakeServer("child"), | |
445 id_factory_.MakeServer("parent"), "child", false, | |
446 syncable::BOOKMARKS, NULL); | |
447 | |
448 // The server's request to delete the directory must be ignored, otherwise our | |
449 // unsynced new child would be orphaned. This is a hierarchy conflict. | |
450 | |
451 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
452 apply_updates_command_.ExecuteImpl(session()); | |
453 | |
454 sessions::StatusController* status = session()->mutable_status_controller(); | |
455 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | |
456 | |
457 // This should count as a hierarchy conflict. | |
458 ASSERT_TRUE(status->conflict_progress()); | |
459 EXPECT_EQ(1, status->conflict_progress()->HierarchyConflictingItemsSize()); | |
460 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()); | |
461 } | |
462 | |
463 // Runs the ApplyUpdatesCommand on a server-created item that has a locally | |
464 // unknown parent. We expect the command to not apply the update because the | |
465 // item is in a CONFLICT_HIERARCHY state. | |
466 TEST_F(ApplyUpdatesCommandTest, HierarchyConflictUnknownParent) { | |
214 // We shouldn't be able to do anything with either of these items. | 467 // We shouldn't be able to do anything with either of these items. |
215 CreateUnappliedNewItemWithParent("some_item", | 468 CreateUnappliedNewItemWithParent("some_item", |
216 DefaultBookmarkSpecifics(), | 469 DefaultBookmarkSpecifics(), |
217 "unknown_parent"); | 470 "unknown_parent"); |
218 CreateUnappliedNewItemWithParent("some_other_item", | 471 CreateUnappliedNewItemWithParent("some_other_item", |
219 DefaultBookmarkSpecifics(), | 472 DefaultBookmarkSpecifics(), |
220 "some_item"); | 473 "some_item"); |
221 | 474 |
222 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 475 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
223 apply_updates_command_.ExecuteImpl(session()); | 476 apply_updates_command_.ExecuteImpl(session()); |
224 | 477 |
225 sessions::StatusController* status = session()->mutable_status_controller(); | 478 sessions::StatusController* status = session()->mutable_status_controller(); |
226 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 479 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
227 ASSERT_TRUE(status->update_progress()); | 480 ASSERT_TRUE(status->update_progress()); |
228 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 481 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
229 << "All updates should have been attempted"; | 482 << "All updates should have been attempted"; |
230 ASSERT_TRUE(status->conflict_progress()); | 483 ASSERT_TRUE(status->conflict_progress()); |
231 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 484 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
485 << "Updates with unknown parent should not be treated as 'simple'" | |
486 << " conflicts"; | |
487 EXPECT_EQ(2, status->conflict_progress()->HierarchyConflictingItemsSize()) | |
232 << "All updates with an unknown ancestors should be in conflict"; | 488 << "All updates with an unknown ancestors should be in conflict"; |
233 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 489 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
234 << "No item with an unknown ancestor should be applied"; | 490 << "No item with an unknown ancestor should be applied"; |
235 } | 491 } |
236 | 492 |
237 TEST_F(ApplyUpdatesCommandTest, ItemsBothKnownAndUnknown) { | 493 TEST_F(ApplyUpdatesCommandTest, ItemsBothKnownAndUnknown) { |
238 // See what happens when there's a mixture of good and bad updates. | 494 // See what happens when there's a mixture of good and bad updates. |
239 string root_server_id = syncable::GetNullId().GetServerId(); | 495 string root_server_id = syncable::GetNullId().GetServerId(); |
240 CreateUnappliedNewItemWithParent("first_unknown_item", | 496 CreateUnappliedNewItemWithParent("first_unknown_item", |
241 DefaultBookmarkSpecifics(), | 497 DefaultBookmarkSpecifics(), |
(...skipping 16 matching lines...) Expand all Loading... | |
258 | 514 |
259 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | 515 ExpectGroupToChange(apply_updates_command_, GROUP_UI); |
260 apply_updates_command_.ExecuteImpl(session()); | 516 apply_updates_command_.ExecuteImpl(session()); |
261 | 517 |
262 sessions::StatusController* status = session()->mutable_status_controller(); | 518 sessions::StatusController* status = session()->mutable_status_controller(); |
263 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 519 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
264 ASSERT_TRUE(status->update_progress()); | 520 ASSERT_TRUE(status->update_progress()); |
265 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) | 521 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) |
266 << "All updates should have been attempted"; | 522 << "All updates should have been attempted"; |
267 ASSERT_TRUE(status->conflict_progress()); | 523 ASSERT_TRUE(status->conflict_progress()); |
268 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 524 EXPECT_EQ(2, status->conflict_progress()->HierarchyConflictingItemsSize()) |
269 << "The updates with unknown ancestors should be in conflict"; | 525 << "The updates with unknown ancestors should be in conflict"; |
270 EXPECT_EQ(4, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 526 EXPECT_EQ(4, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
271 << "The updates with known ancestors should be successfully applied"; | 527 << "The updates with known ancestors should be successfully applied"; |
272 } | 528 } |
273 | 529 |
274 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { | 530 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { |
275 // Decryptable password updates should be applied. | 531 // Decryptable password updates should be applied. |
276 Cryptographer* cryptographer; | 532 Cryptographer* cryptographer; |
277 { | 533 { |
278 // Storing the cryptographer separately is bad, but for this test we | 534 // Storing the cryptographer separately is bad, but for this test we |
(...skipping 18 matching lines...) Expand all Loading... | |
297 | 553 |
298 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); | 554 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); |
299 apply_updates_command_.ExecuteImpl(session()); | 555 apply_updates_command_.ExecuteImpl(session()); |
300 | 556 |
301 sessions::StatusController* status = session()->mutable_status_controller(); | 557 sessions::StatusController* status = session()->mutable_status_controller(); |
302 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 558 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
303 ASSERT_TRUE(status->update_progress()); | 559 ASSERT_TRUE(status->update_progress()); |
304 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 560 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
305 << "All updates should have been attempted"; | 561 << "All updates should have been attempted"; |
306 ASSERT_TRUE(status->conflict_progress()); | 562 ASSERT_TRUE(status->conflict_progress()); |
307 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 563 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
308 << "No update should be in conflict because they're all decryptable"; | 564 << "No update should be in conflict because they're all decryptable"; |
309 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 565 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
310 << "The updates that can be decrypted should be applied"; | 566 << "The updates that can be decrypted should be applied"; |
311 } | 567 } |
312 | 568 |
313 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { | 569 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { |
314 // Undecryptable updates should not be applied. | 570 // Undecryptable updates should not be applied. |
315 sync_pb::EntitySpecifics encrypted_bookmark; | 571 sync_pb::EntitySpecifics encrypted_bookmark; |
316 encrypted_bookmark.mutable_encrypted(); | 572 encrypted_bookmark.mutable_encrypted(); |
317 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); | 573 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); |
(...skipping 12 matching lines...) Expand all Loading... | |
330 sessions::StatusController* status = session()->mutable_status_controller(); | 586 sessions::StatusController* status = session()->mutable_status_controller(); |
331 EXPECT_TRUE(status->HasConflictingUpdates()) | 587 EXPECT_TRUE(status->HasConflictingUpdates()) |
332 << "Updates that can't be decrypted should trigger the syncer to have " | 588 << "Updates that can't be decrypted should trigger the syncer to have " |
333 << "conflicting updates."; | 589 << "conflicting updates."; |
334 { | 590 { |
335 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 591 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
336 ASSERT_TRUE(status->update_progress()); | 592 ASSERT_TRUE(status->update_progress()); |
337 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 593 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
338 << "All updates should have been attempted"; | 594 << "All updates should have been attempted"; |
339 ASSERT_TRUE(status->conflict_progress()); | 595 ASSERT_TRUE(status->conflict_progress()); |
340 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 596 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
341 << "The updates that can't be decrypted should not be in regular " | 597 << "The updates that can't be decrypted should not be in regular " |
342 << "conflict"; | 598 << "conflict"; |
343 EXPECT_EQ(2, status->conflict_progress()->NonblockingConflictingItemsSize()) | 599 EXPECT_EQ(2, status->conflict_progress()->EncryptionConflictingItemsSize()) |
344 << "The updates that can't be decrypted should be in nonblocking " | 600 << "The updates that can't be decrypted should be in encryption " |
345 << "conflict"; | 601 << "conflict"; |
346 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 602 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
347 << "No update that can't be decrypted should be applied"; | 603 << "No update that can't be decrypted should be applied"; |
348 } | 604 } |
349 { | 605 { |
350 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 606 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
351 ASSERT_TRUE(status->update_progress()); | 607 ASSERT_TRUE(status->update_progress()); |
352 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 608 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
353 << "All updates should have been attempted"; | 609 << "All updates should have been attempted"; |
354 ASSERT_TRUE(status->conflict_progress()); | 610 ASSERT_TRUE(status->conflict_progress()); |
355 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 611 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
356 << "The updates that can't be decrypted should not be in regular " | 612 << "The updates that can't be decrypted should not be in regular " |
357 << "conflict"; | 613 << "conflict"; |
358 EXPECT_EQ(1, status->conflict_progress()->NonblockingConflictingItemsSize()) | 614 EXPECT_EQ(1, status->conflict_progress()->EncryptionConflictingItemsSize()) |
359 << "The updates that can't be decrypted should be in nonblocking " | 615 << "The updates that can't be decrypted should be in encryption " |
360 << "conflict"; | 616 << "conflict"; |
361 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 617 EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
362 << "No update that can't be decrypted should be applied"; | 618 << "No update that can't be decrypted should be applied"; |
363 } | 619 } |
364 } | 620 } |
365 | 621 |
366 TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) { | 622 TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) { |
367 // Only decryptable password updates should be applied. | 623 // Only decryptable password updates should be applied. |
368 { | 624 { |
369 sync_pb::EntitySpecifics specifics; | 625 sync_pb::EntitySpecifics specifics; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 sessions::StatusController* status = session()->mutable_status_controller(); | 661 sessions::StatusController* status = session()->mutable_status_controller(); |
406 EXPECT_TRUE(status->HasConflictingUpdates()) | 662 EXPECT_TRUE(status->HasConflictingUpdates()) |
407 << "Updates that can't be decrypted should trigger the syncer to have " | 663 << "Updates that can't be decrypted should trigger the syncer to have " |
408 << "conflicting updates."; | 664 << "conflicting updates."; |
409 { | 665 { |
410 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 666 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
411 ASSERT_TRUE(status->update_progress()); | 667 ASSERT_TRUE(status->update_progress()); |
412 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 668 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
413 << "All updates should have been attempted"; | 669 << "All updates should have been attempted"; |
414 ASSERT_TRUE(status->conflict_progress()); | 670 ASSERT_TRUE(status->conflict_progress()); |
415 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 671 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
416 << "The updates that can't be decrypted should not be in regular " | 672 << "The updates that can't be decrypted should not be in regular " |
417 << "conflict"; | 673 << "conflict"; |
418 EXPECT_EQ(1, status->conflict_progress()->NonblockingConflictingItemsSize()) | 674 EXPECT_EQ(1, status->conflict_progress()->EncryptionConflictingItemsSize()) |
419 << "The updates that can't be decrypted should be in nonblocking " | 675 << "The updates that can't be decrypted should be in encryption " |
420 << "conflict"; | 676 << "conflict"; |
421 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 677 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
422 << "The undecryptable password update shouldn't be applied"; | 678 << "The undecryptable password update shouldn't be applied"; |
423 } | 679 } |
424 } | 680 } |
425 | 681 |
426 TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) { | 682 TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) { |
427 // Storing the cryptographer separately is bad, but for this test we | 683 // Storing the cryptographer separately is bad, but for this test we |
428 // know it's safe. | 684 // know it's safe. |
429 Cryptographer* cryptographer; | 685 Cryptographer* cryptographer; |
(...skipping 26 matching lines...) Expand all Loading... | |
456 | 712 |
457 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 713 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
458 apply_updates_command_.ExecuteImpl(session()); | 714 apply_updates_command_.ExecuteImpl(session()); |
459 | 715 |
460 sessions::StatusController* status = session()->mutable_status_controller(); | 716 sessions::StatusController* status = session()->mutable_status_controller(); |
461 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 717 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
462 ASSERT_TRUE(status->update_progress()); | 718 ASSERT_TRUE(status->update_progress()); |
463 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 719 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
464 << "All updates should have been attempted"; | 720 << "All updates should have been attempted"; |
465 ASSERT_TRUE(status->conflict_progress()); | 721 ASSERT_TRUE(status->conflict_progress()); |
466 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 722 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
467 << "The nigori update shouldn't be in conflict"; | 723 << "The nigori update shouldn't be in conflict"; |
468 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 724 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
469 << "The nigori update should be applied"; | 725 << "The nigori update should be applied"; |
470 | 726 |
471 EXPECT_FALSE(cryptographer->is_ready()); | 727 EXPECT_FALSE(cryptographer->is_ready()); |
472 EXPECT_TRUE(cryptographer->has_pending_keys()); | 728 EXPECT_TRUE(cryptographer->has_pending_keys()); |
473 EXPECT_TRUE( | 729 EXPECT_TRUE( |
474 cryptographer->GetEncryptedTypes() | 730 cryptographer->GetEncryptedTypes() |
475 .Equals(syncable::ModelTypeSet::All())); | 731 .Equals(syncable::ModelTypeSet::All())); |
476 } | 732 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 | 766 |
511 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 767 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
512 apply_updates_command_.ExecuteImpl(session()); | 768 apply_updates_command_.ExecuteImpl(session()); |
513 | 769 |
514 sessions::StatusController* status = session()->mutable_status_controller(); | 770 sessions::StatusController* status = session()->mutable_status_controller(); |
515 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 771 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
516 ASSERT_TRUE(status->update_progress()); | 772 ASSERT_TRUE(status->update_progress()); |
517 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 773 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
518 << "All updates should have been attempted"; | 774 << "All updates should have been attempted"; |
519 ASSERT_TRUE(status->conflict_progress()); | 775 ASSERT_TRUE(status->conflict_progress()); |
520 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 776 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
521 << "The nigori update shouldn't be in conflict"; | 777 << "The nigori update shouldn't be in conflict"; |
522 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 778 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
523 << "The nigori update should be applied"; | 779 << "The nigori update should be applied"; |
524 | 780 |
525 EXPECT_FALSE(cryptographer->is_ready()); | 781 EXPECT_FALSE(cryptographer->is_ready()); |
526 EXPECT_TRUE(cryptographer->has_pending_keys()); | 782 EXPECT_TRUE(cryptographer->has_pending_keys()); |
527 EXPECT_TRUE( | 783 EXPECT_TRUE( |
528 cryptographer->GetEncryptedTypes() | 784 cryptographer->GetEncryptedTypes() |
529 .Equals(syncable::ModelTypeSet::All())); | 785 .Equals(syncable::ModelTypeSet::All())); |
530 } | 786 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 | 856 |
601 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 857 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
602 apply_updates_command_.ExecuteImpl(session()); | 858 apply_updates_command_.ExecuteImpl(session()); |
603 | 859 |
604 sessions::StatusController* status = session()->mutable_status_controller(); | 860 sessions::StatusController* status = session()->mutable_status_controller(); |
605 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 861 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
606 ASSERT_TRUE(status->update_progress()); | 862 ASSERT_TRUE(status->update_progress()); |
607 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 863 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
608 << "All updates should have been attempted"; | 864 << "All updates should have been attempted"; |
609 ASSERT_TRUE(status->conflict_progress()); | 865 ASSERT_TRUE(status->conflict_progress()); |
610 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 866 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
611 << "No updates should be in conflict"; | 867 << "No updates should be in conflict"; |
612 EXPECT_EQ(0, status->conflict_progress()->NonblockingConflictingItemsSize()) | 868 EXPECT_EQ(0, status->conflict_progress()->EncryptionConflictingItemsSize()) |
613 << "No updates should be in conflict"; | 869 << "No updates should be in conflict"; |
614 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 870 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
615 << "The nigori update should be applied"; | 871 << "The nigori update should be applied"; |
616 EXPECT_FALSE(cryptographer->has_pending_keys()); | 872 EXPECT_FALSE(cryptographer->has_pending_keys()); |
617 EXPECT_TRUE(cryptographer->is_ready()); | 873 EXPECT_TRUE(cryptographer->is_ready()); |
618 { | 874 { |
619 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 875 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
620 ASSERT_TRUE(dir.good()); | 876 ASSERT_TRUE(dir.good()); |
621 ReadTransaction trans(FROM_HERE, dir); | 877 ReadTransaction trans(FROM_HERE, dir); |
622 | 878 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 | 959 |
704 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | 960 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); |
705 apply_updates_command_.ExecuteImpl(session()); | 961 apply_updates_command_.ExecuteImpl(session()); |
706 | 962 |
707 sessions::StatusController* status = session()->mutable_status_controller(); | 963 sessions::StatusController* status = session()->mutable_status_controller(); |
708 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 964 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
709 ASSERT_TRUE(status->update_progress()); | 965 ASSERT_TRUE(status->update_progress()); |
710 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 966 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
711 << "All updates should have been attempted"; | 967 << "All updates should have been attempted"; |
712 ASSERT_TRUE(status->conflict_progress()); | 968 ASSERT_TRUE(status->conflict_progress()); |
713 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 969 EXPECT_EQ(0, status->conflict_progress()->SimpleConflictingItemsSize()) |
714 << "The unsynced changes don't trigger a blocking conflict with the " | 970 << "The unsynced changes don't trigger a blocking conflict with the " |
715 << "nigori update."; | 971 << "nigori update."; |
716 EXPECT_EQ(0, status->conflict_progress()->NonblockingConflictingItemsSize()) | 972 EXPECT_EQ(0, status->conflict_progress()->EncryptionConflictingItemsSize()) |
717 << "The unsynced changes don't trigger a non-blocking conflict with the " | 973 << "The unsynced changes don't trigger an encryption conflict with the " |
718 << "nigori update."; | 974 << "nigori update."; |
719 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 975 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
720 << "The nigori update should be applied"; | 976 << "The nigori update should be applied"; |
721 EXPECT_FALSE(cryptographer->is_ready()); | 977 EXPECT_FALSE(cryptographer->is_ready()); |
722 EXPECT_TRUE(cryptographer->has_pending_keys()); | 978 EXPECT_TRUE(cryptographer->has_pending_keys()); |
723 { | 979 { |
724 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 980 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
725 ASSERT_TRUE(dir.good()); | 981 ASSERT_TRUE(dir.good()); |
726 ReadTransaction trans(FROM_HERE, dir); | 982 ReadTransaction trans(FROM_HERE, dir); |
727 | 983 |
728 // Since we have pending keys, we would have failed to encrypt, but the | 984 // Since we have pending keys, we would have failed to encrypt, but the |
729 // cryptographer should be updated. | 985 // cryptographer should be updated. |
730 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 986 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
731 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals( | 987 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals( |
732 syncable::ModelTypeSet().All())); | 988 syncable::ModelTypeSet().All())); |
733 EXPECT_FALSE(cryptographer->is_ready()); | 989 EXPECT_FALSE(cryptographer->is_ready()); |
734 EXPECT_TRUE(cryptographer->has_pending_keys()); | 990 EXPECT_TRUE(cryptographer->has_pending_keys()); |
735 | 991 |
736 Syncer::UnsyncedMetaHandles handles; | 992 Syncer::UnsyncedMetaHandles handles; |
737 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 993 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
738 EXPECT_EQ(2*batch_s+1, handles.size()); | 994 EXPECT_EQ(2*batch_s+1, handles.size()); |
739 } | 995 } |
740 } | 996 } |
741 | 997 |
742 } // namespace browser_sync | 998 } // namespace browser_sync |
OLD | NEW |