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

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

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