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

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

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent Created 8 years, 5 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/process_commit_response_command.cc ('k') | sync/engine/process_updates_command.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 (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 "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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 class ProcessCommitResponseCommandTest : public SyncerCommandTest { 43 class ProcessCommitResponseCommandTest : public SyncerCommandTest {
44 public: 44 public:
45 virtual void SetUp() { 45 virtual void SetUp() {
46 workers()->clear(); 46 workers()->clear();
47 mutable_routing_info()->clear(); 47 mutable_routing_info()->clear();
48 48
49 workers()->push_back( 49 workers()->push_back(
50 make_scoped_refptr(new FakeModelWorker(GROUP_DB))); 50 make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
51 workers()->push_back( 51 workers()->push_back(
52 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); 52 make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
53 (*mutable_routing_info())[syncer::BOOKMARKS] = GROUP_UI; 53 (*mutable_routing_info())[BOOKMARKS] = GROUP_UI;
54 (*mutable_routing_info())[syncer::PREFERENCES] = GROUP_UI; 54 (*mutable_routing_info())[PREFERENCES] = GROUP_UI;
55 (*mutable_routing_info())[syncer::AUTOFILL] = GROUP_DB; 55 (*mutable_routing_info())[AUTOFILL] = GROUP_DB;
56 56
57 SyncerCommandTest::SetUp(); 57 SyncerCommandTest::SetUp();
58 } 58 }
59 59
60 protected: 60 protected:
61 61
62 ProcessCommitResponseCommandTest() 62 ProcessCommitResponseCommandTest()
63 : next_old_revision_(1), 63 : next_old_revision_(1),
64 next_new_revision_(4000), 64 next_new_revision_(4000),
65 next_server_position_(10000) { 65 next_server_position_(10000) {
66 } 66 }
67 67
68 void CheckEntry(Entry* e, const std::string& name, 68 void CheckEntry(Entry* e, const std::string& name,
69 syncer::ModelType model_type, const Id& parent_id) { 69 ModelType model_type, const Id& parent_id) {
70 EXPECT_TRUE(e->good()); 70 EXPECT_TRUE(e->good());
71 ASSERT_EQ(name, e->Get(NON_UNIQUE_NAME)); 71 ASSERT_EQ(name, e->Get(NON_UNIQUE_NAME));
72 ASSERT_EQ(model_type, e->GetModelType()); 72 ASSERT_EQ(model_type, e->GetModelType());
73 ASSERT_EQ(parent_id, e->Get(syncable::PARENT_ID)); 73 ASSERT_EQ(parent_id, e->Get(syncable::PARENT_ID));
74 ASSERT_LT(0, e->Get(BASE_VERSION)) 74 ASSERT_LT(0, e->Get(BASE_VERSION))
75 << "Item should have a valid (positive) server base revision"; 75 << "Item should have a valid (positive) server base revision";
76 } 76 }
77 77
78 // Create an unsynced item in the database. If item_id is a local ID, it 78 // Create an unsynced item in the database. If item_id is a local ID, it
79 // will be treated as a create-new. Otherwise, if it's a server ID, we'll 79 // will be treated as a create-new. Otherwise, if it's a server ID, we'll
80 // fake the server data so that it looks like it exists on the server. 80 // fake the server data so that it looks like it exists on the server.
81 // Returns the methandle of the created item in |metahandle_out| if not NULL. 81 // Returns the methandle of the created item in |metahandle_out| if not NULL.
82 void CreateUnsyncedItem(const Id& item_id, 82 void CreateUnsyncedItem(const Id& item_id,
83 const Id& parent_id, 83 const Id& parent_id,
84 const string& name, 84 const string& name,
85 bool is_folder, 85 bool is_folder,
86 syncer::ModelType model_type, 86 ModelType model_type,
87 int64* metahandle_out) { 87 int64* metahandle_out) {
88 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); 88 WriteTransaction trans(FROM_HERE, UNITTEST, directory());
89 Id predecessor_id; 89 Id predecessor_id;
90 ASSERT_TRUE( 90 ASSERT_TRUE(
91 directory()->GetLastChildIdForTest(&trans, parent_id, &predecessor_id)); 91 directory()->GetLastChildIdForTest(&trans, parent_id, &predecessor_id));
92 MutableEntry entry(&trans, syncable::CREATE, parent_id, name); 92 MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
93 ASSERT_TRUE(entry.good()); 93 ASSERT_TRUE(entry.good());
94 entry.Put(syncable::ID, item_id); 94 entry.Put(syncable::ID, item_id);
95 entry.Put(syncable::BASE_VERSION, 95 entry.Put(syncable::BASE_VERSION,
96 item_id.ServerKnows() ? next_old_revision_++ : 0); 96 item_id.ServerKnows() ? next_old_revision_++ : 0);
97 entry.Put(syncable::IS_UNSYNCED, true); 97 entry.Put(syncable::IS_UNSYNCED, true);
98 entry.Put(syncable::IS_DIR, is_folder); 98 entry.Put(syncable::IS_DIR, is_folder);
99 entry.Put(syncable::IS_DEL, false); 99 entry.Put(syncable::IS_DEL, false);
100 entry.Put(syncable::PARENT_ID, parent_id); 100 entry.Put(syncable::PARENT_ID, parent_id);
101 entry.PutPredecessor(predecessor_id); 101 entry.PutPredecessor(predecessor_id);
102 sync_pb::EntitySpecifics default_specifics; 102 sync_pb::EntitySpecifics default_specifics;
103 syncer::AddDefaultFieldValue(model_type, &default_specifics); 103 AddDefaultFieldValue(model_type, &default_specifics);
104 entry.Put(syncable::SPECIFICS, default_specifics); 104 entry.Put(syncable::SPECIFICS, default_specifics);
105 if (item_id.ServerKnows()) { 105 if (item_id.ServerKnows()) {
106 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); 106 entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
107 entry.Put(syncable::SERVER_IS_DIR, is_folder); 107 entry.Put(syncable::SERVER_IS_DIR, is_folder);
108 entry.Put(syncable::SERVER_PARENT_ID, parent_id); 108 entry.Put(syncable::SERVER_PARENT_ID, parent_id);
109 entry.Put(syncable::SERVER_IS_DEL, false); 109 entry.Put(syncable::SERVER_IS_DEL, false);
110 } 110 }
111 if (metahandle_out) 111 if (metahandle_out)
112 *metahandle_out = entry.Get(syncable::META_HANDLE); 112 *metahandle_out = entry.Get(syncable::META_HANDLE);
113 } 113 }
114 114
115 // Create a new unsynced item in the database, and synthesize a commit 115 // Create a new unsynced item in the database, and synthesize a commit
116 // record and a commit response for it in the syncer session. If item_id 116 // record and a commit response for it in the syncer session. If item_id
117 // is a local ID, the item will be a create operation. Otherwise, it 117 // is a local ID, the item will be a create operation. Otherwise, it
118 // will be an edit. 118 // will be an edit.
119 void CreateUnprocessedCommitResult( 119 void CreateUnprocessedCommitResult(
120 const Id& item_id, 120 const Id& item_id,
121 const Id& parent_id, 121 const Id& parent_id,
122 const string& name, 122 const string& name,
123 syncer::ModelType model_type, 123 ModelType model_type,
124 sessions::OrderedCommitSet *commit_set, 124 sessions::OrderedCommitSet *commit_set,
125 sync_pb::ClientToServerMessage *commit, 125 sync_pb::ClientToServerMessage *commit,
126 sync_pb::ClientToServerResponse *response) { 126 sync_pb::ClientToServerResponse *response) {
127 bool is_folder = true; 127 bool is_folder = true;
128 int64 metahandle = 0; 128 int64 metahandle = 0;
129 CreateUnsyncedItem(item_id, parent_id, name, is_folder, model_type, 129 CreateUnsyncedItem(item_id, parent_id, name, is_folder, model_type,
130 &metahandle); 130 &metahandle);
131 131
132 // ProcessCommitResponseCommand consumes commit_ids from the session 132 // ProcessCommitResponseCommand consumes commit_ids from the session
133 // state, so we need to update that. O(n^2) because it's a test. 133 // state, so we need to update that. O(n^2) because it's a test.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 sync_pb::ClientToServerMessage request; 196 sync_pb::ClientToServerMessage request;
197 sync_pb::ClientToServerResponse response; 197 sync_pb::ClientToServerResponse response;
198 198
199 Id bookmark_folder_id = id_factory_.NewLocalId(); 199 Id bookmark_folder_id = id_factory_.NewLocalId();
200 Id bookmark_id1 = id_factory_.NewLocalId(); 200 Id bookmark_id1 = id_factory_.NewLocalId();
201 Id bookmark_id2 = id_factory_.NewLocalId(); 201 Id bookmark_id2 = id_factory_.NewLocalId();
202 Id pref_id1 = id_factory_.NewLocalId(), pref_id2 = id_factory_.NewLocalId(); 202 Id pref_id1 = id_factory_.NewLocalId(), pref_id2 = id_factory_.NewLocalId();
203 Id autofill_id1 = id_factory_.NewLocalId(); 203 Id autofill_id1 = id_factory_.NewLocalId();
204 Id autofill_id2 = id_factory_.NewLocalId(); 204 Id autofill_id2 = id_factory_.NewLocalId();
205 CreateUnprocessedCommitResult(bookmark_folder_id, id_factory_.root(), 205 CreateUnprocessedCommitResult(bookmark_folder_id, id_factory_.root(),
206 "A bookmark folder", syncer::BOOKMARKS, 206 "A bookmark folder", BOOKMARKS,
207 &commit_set, &request, &response); 207 &commit_set, &request, &response);
208 CreateUnprocessedCommitResult(bookmark_id1, bookmark_folder_id, 208 CreateUnprocessedCommitResult(bookmark_id1, bookmark_folder_id,
209 "bookmark 1", syncer::BOOKMARKS, 209 "bookmark 1", BOOKMARKS,
210 &commit_set, &request, &response); 210 &commit_set, &request, &response);
211 CreateUnprocessedCommitResult(bookmark_id2, bookmark_folder_id, 211 CreateUnprocessedCommitResult(bookmark_id2, bookmark_folder_id,
212 "bookmark 2", syncer::BOOKMARKS, 212 "bookmark 2", BOOKMARKS,
213 &commit_set, &request, &response); 213 &commit_set, &request, &response);
214 CreateUnprocessedCommitResult(pref_id1, id_factory_.root(), 214 CreateUnprocessedCommitResult(pref_id1, id_factory_.root(),
215 "Pref 1", syncer::PREFERENCES, 215 "Pref 1", PREFERENCES,
216 &commit_set, &request, &response); 216 &commit_set, &request, &response);
217 CreateUnprocessedCommitResult(pref_id2, id_factory_.root(), 217 CreateUnprocessedCommitResult(pref_id2, id_factory_.root(),
218 "Pref 2", syncer::PREFERENCES, 218 "Pref 2", PREFERENCES,
219 &commit_set, &request, &response); 219 &commit_set, &request, &response);
220 CreateUnprocessedCommitResult(autofill_id1, id_factory_.root(), 220 CreateUnprocessedCommitResult(autofill_id1, id_factory_.root(),
221 "Autofill 1", syncer::AUTOFILL, 221 "Autofill 1", AUTOFILL,
222 &commit_set, &request, &response); 222 &commit_set, &request, &response);
223 CreateUnprocessedCommitResult(autofill_id2, id_factory_.root(), 223 CreateUnprocessedCommitResult(autofill_id2, id_factory_.root(),
224 "Autofill 2", syncer::AUTOFILL, 224 "Autofill 2", AUTOFILL,
225 &commit_set, &request, &response); 225 &commit_set, &request, &response);
226 226
227 ProcessCommitResponseCommand command(commit_set, request, response); 227 ProcessCommitResponseCommand command(commit_set, request, response);
228 ExpectGroupsToChange(command, GROUP_UI, GROUP_DB); 228 ExpectGroupsToChange(command, GROUP_UI, GROUP_DB);
229 command.ExecuteImpl(session()); 229 command.ExecuteImpl(session());
230 230
231 syncable::ReadTransaction trans(FROM_HERE, directory()); 231 syncable::ReadTransaction trans(FROM_HERE, directory());
232 Id new_fid; 232 Id new_fid;
233 ASSERT_TRUE(directory()->GetFirstChildId( 233 ASSERT_TRUE(directory()->GetFirstChildId(
234 &trans, id_factory_.root(), &new_fid)); 234 &trans, id_factory_.root(), &new_fid));
235 ASSERT_FALSE(new_fid.IsRoot()); 235 ASSERT_FALSE(new_fid.IsRoot());
236 EXPECT_TRUE(new_fid.ServerKnows()); 236 EXPECT_TRUE(new_fid.ServerKnows());
237 EXPECT_FALSE(bookmark_folder_id.ServerKnows()); 237 EXPECT_FALSE(bookmark_folder_id.ServerKnows());
238 EXPECT_FALSE(new_fid == bookmark_folder_id); 238 EXPECT_FALSE(new_fid == bookmark_folder_id);
239 Entry b_folder(&trans, syncable::GET_BY_ID, new_fid); 239 Entry b_folder(&trans, syncable::GET_BY_ID, new_fid);
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.Get(syncable::NEXT_ID));
251 CheckEntry(&b1, "bookmark 1", syncer::BOOKMARKS, new_fid); 251 CheckEntry(&b1, "bookmark 1", BOOKMARKS, new_fid);
252 CheckEntry(&b2, "bookmark 2", syncer::BOOKMARKS, new_fid); 252 CheckEntry(&b2, "bookmark 2", BOOKMARKS, new_fid);
253 ASSERT_TRUE(b2.Get(syncable::NEXT_ID).IsRoot()); 253 ASSERT_TRUE(b2.Get(syncable::NEXT_ID).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.Get(syncable::NEXT_ID));
257 Entry p2(&trans, syncable::GET_BY_ID, p1.Get(syncable::NEXT_ID)); 257 Entry p2(&trans, syncable::GET_BY_ID, p1.Get(syncable::NEXT_ID));
258 CheckEntry(&p1, "Pref 1", syncer::PREFERENCES, id_factory_.root()); 258 CheckEntry(&p1, "Pref 1", PREFERENCES, id_factory_.root());
259 CheckEntry(&p2, "Pref 2", syncer::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.Get(syncable::NEXT_ID));
262 Entry a2(&trans, syncable::GET_BY_ID, a1.Get(syncable::NEXT_ID)); 262 Entry a2(&trans, syncable::GET_BY_ID, a1.Get(syncable::NEXT_ID));
263 CheckEntry(&a1, "Autofill 1", syncer::AUTOFILL, id_factory_.root()); 263 CheckEntry(&a1, "Autofill 1", AUTOFILL, id_factory_.root());
264 CheckEntry(&a2, "Autofill 2", syncer::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.Get(syncable::NEXT_ID).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
276 // how this scenario used to fail, reversing the order for the second half 276 // how this scenario used to fail, reversing the order for the second half
277 // of the children. 277 // of the children.
278 TEST_F(ProcessCommitResponseCommandTest, NewFolderCommitKeepsChildOrder) { 278 TEST_F(ProcessCommitResponseCommandTest, NewFolderCommitKeepsChildOrder) {
279 sessions::OrderedCommitSet commit_set(session()->routing_info()); 279 sessions::OrderedCommitSet commit_set(session()->routing_info());
280 sync_pb::ClientToServerMessage request; 280 sync_pb::ClientToServerMessage request;
281 sync_pb::ClientToServerResponse response; 281 sync_pb::ClientToServerResponse response;
282 282
283 // Create the parent folder, a new item whose ID will change on commit. 283 // Create the parent folder, a new item whose ID will change on commit.
284 Id folder_id = id_factory_.NewLocalId(); 284 Id folder_id = id_factory_.NewLocalId();
285 CreateUnprocessedCommitResult(folder_id, id_factory_.root(), "A", 285 CreateUnprocessedCommitResult(folder_id, id_factory_.root(), "A",
286 syncer::BOOKMARKS, 286 BOOKMARKS,
287 &commit_set, &request, &response); 287 &commit_set, &request, &response);
288 288
289 // Verify that the item is reachable. 289 // Verify that the item is reachable.
290 { 290 {
291 syncable::ReadTransaction trans(FROM_HERE, directory()); 291 syncable::ReadTransaction trans(FROM_HERE, directory());
292 Id child_id; 292 Id child_id;
293 ASSERT_TRUE(directory()->GetFirstChildId( 293 ASSERT_TRUE(directory()->GetFirstChildId(
294 &trans, id_factory_.root(), &child_id)); 294 &trans, id_factory_.root(), &child_id));
295 ASSERT_EQ(folder_id, child_id); 295 ASSERT_EQ(folder_id, child_id);
296 } 296 }
297 297
298 // The first 25 children of the parent folder will be part of the commit 298 // The first 25 children of the parent folder will be part of the commit
299 // batch. 299 // batch.
300 int batch_size = 25; 300 int batch_size = 25;
301 int i = 0; 301 int i = 0;
302 for (; i < batch_size; ++i) { 302 for (; i < batch_size; ++i) {
303 // Alternate between new and old child items, just for kicks. 303 // Alternate between new and old child items, just for kicks.
304 Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId(); 304 Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId();
305 CreateUnprocessedCommitResult( 305 CreateUnprocessedCommitResult(
306 id, folder_id, base::StringPrintf("Item %d", i), syncer::BOOKMARKS, 306 id, folder_id, base::StringPrintf("Item %d", i), BOOKMARKS,
307 &commit_set, &request, &response); 307 &commit_set, &request, &response);
308 } 308 }
309 // The second 25 children will be unsynced items but NOT part of the commit 309 // The second 25 children will be unsynced items but NOT part of the commit
310 // batch. When the ID of the parent folder changes during the commit, 310 // batch. When the ID of the parent folder changes during the commit,
311 // these items PARENT_ID should be updated, and their ordering should be 311 // these items PARENT_ID should be updated, and their ordering should be
312 // preserved. 312 // preserved.
313 for (; i < 2*batch_size; ++i) { 313 for (; i < 2*batch_size; ++i) {
314 // Alternate between new and old child items, just for kicks. 314 // Alternate between new and old child items, just for kicks.
315 Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId(); 315 Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId();
316 CreateUnsyncedItem(id, folder_id, base::StringPrintf("Item %d", i), 316 CreateUnsyncedItem(id, folder_id, base::StringPrintf("Item %d", i),
317 false, syncer::BOOKMARKS, NULL); 317 false, BOOKMARKS, NULL);
318 } 318 }
319 319
320 // Process the commit response for the parent folder and the first 320 // Process the commit response for the parent folder and the first
321 // 25 items. This should apply the values indicated by 321 // 25 items. This should apply the values indicated by
322 // each CommitResponse_EntryResponse to the syncable Entries. All new 322 // each CommitResponse_EntryResponse to the syncable Entries. All new
323 // items in the commit batch should have their IDs changed to server IDs. 323 // items in the commit batch should have their IDs changed to server IDs.
324 ProcessCommitResponseCommand command(commit_set, request, response); 324 ProcessCommitResponseCommand command(commit_set, request, response);
325 ExpectGroupToChange(command, GROUP_UI); 325 ExpectGroupToChange(command, GROUP_UI);
326 command.ExecuteImpl(session()); 326 command.ExecuteImpl(session());
327 327
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 testing::Range(0, 1 << TEST_PARAM_BIT_COUNT)); 401 testing::Range(0, 1 << TEST_PARAM_BIT_COUNT));
402 402
403 // This test commits 2 items (one bookmark, one autofill) and validates what 403 // This test commits 2 items (one bookmark, one autofill) and validates what
404 // happens to the extensions activity records. Commits could fail or succeed, 404 // happens to the extensions activity records. Commits could fail or succeed,
405 // depending on the test parameter. 405 // depending on the test parameter.
406 TEST_P(MixedResult, ExtensionActivity) { 406 TEST_P(MixedResult, ExtensionActivity) {
407 sessions::OrderedCommitSet commit_set(session()->routing_info()); 407 sessions::OrderedCommitSet commit_set(session()->routing_info());
408 sync_pb::ClientToServerMessage request; 408 sync_pb::ClientToServerMessage request;
409 sync_pb::ClientToServerResponse response; 409 sync_pb::ClientToServerResponse response;
410 410
411 EXPECT_NE(routing_info().find(syncer::BOOKMARKS)->second, 411 EXPECT_NE(routing_info().find(BOOKMARKS)->second,
412 routing_info().find(syncer::AUTOFILL)->second) 412 routing_info().find(AUTOFILL)->second)
413 << "To not be lame, this test requires more than one active group."; 413 << "To not be lame, this test requires more than one active group.";
414 414
415 // Bookmark item setup. 415 // Bookmark item setup.
416 CreateUnprocessedCommitResult(id_factory_.NewServerId(), 416 CreateUnprocessedCommitResult(id_factory_.NewServerId(),
417 id_factory_.root(), "Some bookmark", syncer::BOOKMARKS, 417 id_factory_.root(), "Some bookmark", BOOKMARKS,
418 &commit_set, &request, &response); 418 &commit_set, &request, &response);
419 if (ShouldFailBookmarkCommit()) 419 if (ShouldFailBookmarkCommit())
420 SetLastErrorCode(CommitResponse::TRANSIENT_ERROR, &response); 420 SetLastErrorCode(CommitResponse::TRANSIENT_ERROR, &response);
421 // Autofill item setup. 421 // Autofill item setup.
422 CreateUnprocessedCommitResult(id_factory_.NewServerId(), 422 CreateUnprocessedCommitResult(id_factory_.NewServerId(),
423 id_factory_.root(), "Some autofill", syncer::AUTOFILL, 423 id_factory_.root(), "Some autofill", AUTOFILL,
424 &commit_set, &request, &response); 424 &commit_set, &request, &response);
425 if (ShouldFailAutofillCommit()) 425 if (ShouldFailAutofillCommit())
426 SetLastErrorCode(CommitResponse::TRANSIENT_ERROR, &response); 426 SetLastErrorCode(CommitResponse::TRANSIENT_ERROR, &response);
427 427
428 // Put some extensions activity in the session. 428 // Put some extensions activity in the session.
429 { 429 {
430 ExtensionsActivityMonitor::Records* records = 430 ExtensionsActivityMonitor::Records* records =
431 session()->mutable_extensions_activity(); 431 session()->mutable_extensions_activity();
432 (*records)["ABC"].extension_id = "ABC"; 432 (*records)["ABC"].extension_id = "ABC";
433 (*records)["ABC"].bookmark_write_count = 2049U; 433 (*records)["ABC"].bookmark_write_count = 2049U;
(...skipping 14 matching lines...) Expand all
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/process_commit_response_command.cc ('k') | sync/engine/process_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698