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