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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/sync/engine/process_commit_response_command.h" | 9 #include "chrome/browser/sync/engine/process_commit_response_command.h" |
10 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 10 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 workers()->push_back( | 46 workers()->push_back( |
47 make_scoped_refptr(new FakeModelWorker(GROUP_DB))); | 47 make_scoped_refptr(new FakeModelWorker(GROUP_DB))); |
48 workers()->push_back( | 48 workers()->push_back( |
49 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 49 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
50 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; | 50 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; |
51 (*mutable_routing_info())[syncable::PREFERENCES] = GROUP_UI; | 51 (*mutable_routing_info())[syncable::PREFERENCES] = GROUP_UI; |
52 (*mutable_routing_info())[syncable::AUTOFILL] = GROUP_DB; | 52 (*mutable_routing_info())[syncable::AUTOFILL] = GROUP_DB; |
53 | 53 |
54 commit_set_.reset(new sessions::OrderedCommitSet(routing_info())); | 54 commit_set_.reset(new sessions::OrderedCommitSet(routing_info())); |
55 SyncerCommandTestWithParam<T>::SetUp(); | 55 SyncerCommandTestWithParam<T>::SetUp(); |
| 56 // Need to explicitly use this-> to avoid obscure template |
| 57 // warning. |
| 58 this->ExpectNoGroupsToChange(command_); |
56 } | 59 } |
57 | 60 |
58 protected: | 61 protected: |
59 using SyncerCommandTestWithParam<T>::context; | 62 using SyncerCommandTestWithParam<T>::context; |
60 using SyncerCommandTestWithParam<T>::mutable_routing_info; | 63 using SyncerCommandTestWithParam<T>::mutable_routing_info; |
61 using SyncerCommandTestWithParam<T>::routing_info; | 64 using SyncerCommandTestWithParam<T>::routing_info; |
62 using SyncerCommandTestWithParam<T>::session; | 65 using SyncerCommandTestWithParam<T>::session; |
63 using SyncerCommandTestWithParam<T>::syncdb; | 66 using SyncerCommandTestWithParam<T>::syncdb; |
64 using SyncerCommandTestWithParam<T>::workers; | 67 using SyncerCommandTestWithParam<T>::workers; |
65 | 68 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 "bookmark 2", syncable::BOOKMARKS); | 229 "bookmark 2", syncable::BOOKMARKS); |
227 CreateUnprocessedCommitResult(pref_id1, id_factory_.root(), | 230 CreateUnprocessedCommitResult(pref_id1, id_factory_.root(), |
228 "Pref 1", syncable::PREFERENCES); | 231 "Pref 1", syncable::PREFERENCES); |
229 CreateUnprocessedCommitResult(pref_id2, id_factory_.root(), | 232 CreateUnprocessedCommitResult(pref_id2, id_factory_.root(), |
230 "Pref 2", syncable::PREFERENCES); | 233 "Pref 2", syncable::PREFERENCES); |
231 CreateUnprocessedCommitResult(autofill_id1, id_factory_.root(), | 234 CreateUnprocessedCommitResult(autofill_id1, id_factory_.root(), |
232 "Autofill 1", syncable::AUTOFILL); | 235 "Autofill 1", syncable::AUTOFILL); |
233 CreateUnprocessedCommitResult(autofill_id2, id_factory_.root(), | 236 CreateUnprocessedCommitResult(autofill_id2, id_factory_.root(), |
234 "Autofill 2", syncable::AUTOFILL); | 237 "Autofill 2", syncable::AUTOFILL); |
235 | 238 |
| 239 ExpectGroupsToChange(command_, GROUP_UI, GROUP_DB); |
236 command_.ExecuteImpl(session()); | 240 command_.ExecuteImpl(session()); |
237 | 241 |
238 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 242 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
239 ASSERT_TRUE(dir.good()); | 243 ASSERT_TRUE(dir.good()); |
240 ReadTransaction trans(FROM_HERE, dir); | 244 ReadTransaction trans(FROM_HERE, dir); |
241 Id new_fid; | 245 Id new_fid; |
242 ASSERT_TRUE(dir->GetFirstChildId(&trans, id_factory_.root(), &new_fid)); | 246 ASSERT_TRUE(dir->GetFirstChildId(&trans, id_factory_.root(), &new_fid)); |
243 ASSERT_FALSE(new_fid.IsRoot()); | 247 ASSERT_FALSE(new_fid.IsRoot()); |
244 EXPECT_TRUE(new_fid.ServerKnows()); | 248 EXPECT_TRUE(new_fid.ServerKnows()); |
245 EXPECT_FALSE(bookmark_folder_id.ServerKnows()); | 249 EXPECT_FALSE(bookmark_folder_id.ServerKnows()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // Alternate between new and old child items, just for kicks. | 321 // Alternate between new and old child items, just for kicks. |
318 Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId(); | 322 Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId(); |
319 CreateUnsyncedItem(id, folder_id, base::StringPrintf("Item %d", i), | 323 CreateUnsyncedItem(id, folder_id, base::StringPrintf("Item %d", i), |
320 false, syncable::BOOKMARKS, NULL); | 324 false, syncable::BOOKMARKS, NULL); |
321 } | 325 } |
322 | 326 |
323 // Process the commit response for the parent folder and the first | 327 // Process the commit response for the parent folder and the first |
324 // 25 items. This should apply the values indicated by | 328 // 25 items. This should apply the values indicated by |
325 // each CommitResponse_EntryResponse to the syncable Entries. All new | 329 // each CommitResponse_EntryResponse to the syncable Entries. All new |
326 // items in the commit batch should have their IDs changed to server IDs. | 330 // items in the commit batch should have their IDs changed to server IDs. |
| 331 ExpectGroupToChange(command_, GROUP_UI); |
327 command_.ExecuteImpl(session()); | 332 command_.ExecuteImpl(session()); |
328 | 333 |
329 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 334 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
330 ASSERT_TRUE(dir.good()); | 335 ASSERT_TRUE(dir.good()); |
331 ReadTransaction trans(FROM_HERE, dir); | 336 ReadTransaction trans(FROM_HERE, dir); |
332 // Lookup the parent folder by finding a child of the root. We can't use | 337 // Lookup the parent folder by finding a child of the root. We can't use |
333 // folder_id here, because it changed during the commit. | 338 // folder_id here, because it changed during the commit. |
334 Id new_fid; | 339 Id new_fid; |
335 ASSERT_TRUE(dir->GetFirstChildId(&trans, id_factory_.root(), &new_fid)); | 340 ASSERT_TRUE(dir->GetFirstChildId(&trans, id_factory_.root(), &new_fid)); |
336 ASSERT_FALSE(new_fid.IsRoot()); | 341 ASSERT_FALSE(new_fid.IsRoot()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 426 |
422 // Put some extensions activity in the session. | 427 // Put some extensions activity in the session. |
423 { | 428 { |
424 ExtensionsActivityMonitor::Records* records = | 429 ExtensionsActivityMonitor::Records* records = |
425 session()->mutable_extensions_activity(); | 430 session()->mutable_extensions_activity(); |
426 (*records)["ABC"].extension_id = "ABC"; | 431 (*records)["ABC"].extension_id = "ABC"; |
427 (*records)["ABC"].bookmark_write_count = 2049U; | 432 (*records)["ABC"].bookmark_write_count = 2049U; |
428 (*records)["xyz"].extension_id = "xyz"; | 433 (*records)["xyz"].extension_id = "xyz"; |
429 (*records)["xyz"].bookmark_write_count = 4U; | 434 (*records)["xyz"].bookmark_write_count = 4U; |
430 } | 435 } |
| 436 ExpectGroupsToChange(command_, GROUP_UI, GROUP_DB); |
431 command_.ExecuteImpl(session()); | 437 command_.ExecuteImpl(session()); |
432 | 438 |
433 ExtensionsActivityMonitor::Records final_monitor_records; | 439 ExtensionsActivityMonitor::Records final_monitor_records; |
434 context()->extensions_monitor()->GetAndClearRecords(&final_monitor_records); | 440 context()->extensions_monitor()->GetAndClearRecords(&final_monitor_records); |
435 | 441 |
436 if (ShouldFailBookmarkCommit()) { | 442 if (ShouldFailBookmarkCommit()) { |
437 ASSERT_EQ(2U, final_monitor_records.size()) | 443 ASSERT_EQ(2U, final_monitor_records.size()) |
438 << "Should restore records after unsuccessful bookmark commit."; | 444 << "Should restore records after unsuccessful bookmark commit."; |
439 EXPECT_EQ("ABC", final_monitor_records["ABC"].extension_id); | 445 EXPECT_EQ("ABC", final_monitor_records["ABC"].extension_id); |
440 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 446 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
441 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 447 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
442 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 448 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
443 } else { | 449 } else { |
444 EXPECT_TRUE(final_monitor_records.empty()) | 450 EXPECT_TRUE(final_monitor_records.empty()) |
445 << "Should not restore records after successful bookmark commit."; | 451 << "Should not restore records after successful bookmark commit."; |
446 } | 452 } |
447 } | 453 } |
448 | 454 |
449 | 455 |
450 } // namespace browser_sync | 456 } // namespace browser_sync |
OLD | NEW |