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

Side by Side Diff: sync/engine/process_commit_response_command_unittest.cc

Issue 11637053: sync: Start moving away from PREV_ID and NEXT_ID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « sync/engine/get_commit_ids_command.cc ('k') | sync/engine/syncer_unittest.cc » ('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 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 #include "sync/engine/process_commit_response_command.h" 5 #include "sync/engine/process_commit_response_command.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 ASSERT_TRUE(b_folder.good()); 240 ASSERT_TRUE(b_folder.good());
241 ASSERT_EQ("A bookmark folder", b_folder.Get(NON_UNIQUE_NAME)) 241 ASSERT_EQ("A bookmark folder", b_folder.Get(NON_UNIQUE_NAME))
242 << "Name of bookmark folder should not change."; 242 << "Name of bookmark folder should not change.";
243 ASSERT_LT(0, b_folder.Get(BASE_VERSION)) 243 ASSERT_LT(0, b_folder.Get(BASE_VERSION))
244 << "Bookmark folder should have a valid (positive) server base revision"; 244 << "Bookmark folder should have a valid (positive) server base revision";
245 245
246 // Look at the two bookmarks in bookmark_folder. 246 // Look at the two bookmarks in bookmark_folder.
247 Id cid; 247 Id cid;
248 ASSERT_TRUE(directory()->GetFirstChildId(&trans, new_fid, &cid)); 248 ASSERT_TRUE(directory()->GetFirstChildId(&trans, new_fid, &cid));
249 Entry b1(&trans, syncable::GET_BY_ID, cid); 249 Entry b1(&trans, syncable::GET_BY_ID, cid);
250 Entry b2(&trans, syncable::GET_BY_ID, b1.Get(syncable::NEXT_ID)); 250 Entry b2(&trans, syncable::GET_BY_ID, b1.GetSuccessorId());
251 CheckEntry(&b1, "bookmark 1", BOOKMARKS, new_fid); 251 CheckEntry(&b1, "bookmark 1", BOOKMARKS, new_fid);
252 CheckEntry(&b2, "bookmark 2", BOOKMARKS, new_fid); 252 CheckEntry(&b2, "bookmark 2", BOOKMARKS, new_fid);
253 ASSERT_TRUE(b2.Get(syncable::NEXT_ID).IsRoot()); 253 ASSERT_TRUE(b2.GetSuccessorId().IsRoot());
254 254
255 // Look at the prefs and autofill items. 255 // Look at the prefs and autofill items.
256 Entry p1(&trans, syncable::GET_BY_ID, b_folder.Get(syncable::NEXT_ID)); 256 Entry p1(&trans, syncable::GET_BY_ID, b_folder.GetSuccessorId());
257 Entry p2(&trans, syncable::GET_BY_ID, p1.Get(syncable::NEXT_ID)); 257 Entry p2(&trans, syncable::GET_BY_ID, p1.GetSuccessorId());
258 CheckEntry(&p1, "Pref 1", PREFERENCES, id_factory_.root()); 258 CheckEntry(&p1, "Pref 1", PREFERENCES, id_factory_.root());
259 CheckEntry(&p2, "Pref 2", PREFERENCES, id_factory_.root()); 259 CheckEntry(&p2, "Pref 2", PREFERENCES, id_factory_.root());
260 260
261 Entry a1(&trans, syncable::GET_BY_ID, p2.Get(syncable::NEXT_ID)); 261 Entry a1(&trans, syncable::GET_BY_ID, p2.GetSuccessorId());
262 Entry a2(&trans, syncable::GET_BY_ID, a1.Get(syncable::NEXT_ID)); 262 Entry a2(&trans, syncable::GET_BY_ID, a1.GetSuccessorId());
263 CheckEntry(&a1, "Autofill 1", AUTOFILL, id_factory_.root()); 263 CheckEntry(&a1, "Autofill 1", AUTOFILL, id_factory_.root());
264 CheckEntry(&a2, "Autofill 2", AUTOFILL, id_factory_.root()); 264 CheckEntry(&a2, "Autofill 2", AUTOFILL, id_factory_.root());
265 ASSERT_TRUE(a2.Get(syncable::NEXT_ID).IsRoot()); 265 ASSERT_TRUE(a2.GetSuccessorId().IsRoot());
266 } 266 }
267 267
268 // In this test, we test processing a commit response for a commit batch that 268 // In this test, we test processing a commit response for a commit batch that
269 // includes a newly created folder and some (but not all) of its children. 269 // includes a newly created folder and some (but not all) of its children.
270 // In particular, the folder has 50 children, which alternate between being 270 // In particular, the folder has 50 children, which alternate between being
271 // new items and preexisting items. This mixture of new and old is meant to 271 // new items and preexisting items. This mixture of new and old is meant to
272 // be a torture test of the code in ProcessCommitResponseCommand that changes 272 // be a torture test of the code in ProcessCommitResponseCommand that changes
273 // an item's ID from a local ID to a server-generated ID on the first commit. 273 // an item's ID from a local ID to a server-generated ID on the first commit.
274 // We commit only the first 25 children in the sibling order, leaving the 274 // We commit only the first 25 children in the sibling order, leaving the
275 // second 25 children as unsynced items. http://crbug.com/33081 describes 275 // second 25 children as unsynced items. http://crbug.com/33081 describes
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // We alternated between creates and edits; double check that these items 364 // We alternated between creates and edits; double check that these items
365 // have been preserved. 365 // have been preserved.
366 if (child_count % 4 < 2) { 366 if (child_count % 4 < 2) {
367 ASSERT_FALSE(cid.ServerKnows()); 367 ASSERT_FALSE(cid.ServerKnows());
368 ASSERT_GE(0, c.Get(BASE_VERSION)); 368 ASSERT_GE(0, c.Get(BASE_VERSION));
369 } else { 369 } else {
370 ASSERT_TRUE(cid.ServerKnows()); 370 ASSERT_TRUE(cid.ServerKnows());
371 ASSERT_LT(0, c.Get(BASE_VERSION)); 371 ASSERT_LT(0, c.Get(BASE_VERSION));
372 } 372 }
373 } 373 }
374 cid = c.Get(syncable::NEXT_ID); 374 cid = c.GetSuccessorId();
375 child_count++; 375 child_count++;
376 } 376 }
377 ASSERT_EQ(batch_size*2, child_count) 377 ASSERT_EQ(batch_size*2, child_count)
378 << "Too few or too many children in parent folder after commit."; 378 << "Too few or too many children in parent folder after commit.";
379 } 379 }
380 380
381 // This test fixture runs across a Cartesian product of per-type fail/success 381 // This test fixture runs across a Cartesian product of per-type fail/success
382 // possibilities. 382 // possibilities.
383 enum { 383 enum {
384 TEST_PARAM_BOOKMARK_ENABLE_BIT, 384 TEST_PARAM_BOOKMARK_ENABLE_BIT,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 448 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
449 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 449 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
450 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 450 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
451 } else { 451 } else {
452 EXPECT_TRUE(final_monitor_records.empty()) 452 EXPECT_TRUE(final_monitor_records.empty())
453 << "Should not restore records after successful bookmark commit."; 453 << "Should not restore records after successful bookmark commit.";
454 } 454 }
455 } 455 }
456 456
457 } // namespace syncer 457 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/get_commit_ids_command.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698