OLD | NEW |
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 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <list> | 10 #include <list> |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 182 } |
183 | 183 |
184 void SyncShareNudge() { | 184 void SyncShareNudge() { |
185 session_.reset(SyncSession::Build(context_.get(), this)); | 185 session_.reset(SyncSession::Build(context_.get(), this)); |
186 | 186 |
187 // Pretend we've seen a local change, to make the nudge_tracker look normal. | 187 // Pretend we've seen a local change, to make the nudge_tracker look normal. |
188 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | 188 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
189 | 189 |
190 EXPECT_TRUE( | 190 EXPECT_TRUE( |
191 syncer_->NormalSyncShare( | 191 syncer_->NormalSyncShare( |
192 GetRoutingInfoTypes(context_->routing_info()), | 192 context_->enabled_types(), |
193 nudge_tracker_, | 193 nudge_tracker_, |
194 session_.get())); | 194 session_.get())); |
195 } | 195 } |
196 | 196 |
197 void SyncShareConfigure() { | 197 void SyncShareConfigure() { |
198 session_.reset(SyncSession::Build(context_.get(), this)); | 198 session_.reset(SyncSession::Build(context_.get(), this)); |
199 EXPECT_TRUE(syncer_->ConfigureSyncShare( | 199 EXPECT_TRUE(syncer_->ConfigureSyncShare( |
200 GetRoutingInfoTypes(context_->routing_info()), | 200 context_->enabled_types(), |
201 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, | 201 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, |
202 session_.get())); | 202 session_.get())); |
203 } | 203 } |
204 | 204 |
205 virtual void SetUp() { | 205 virtual void SetUp() { |
206 dir_maker_.SetUp(); | 206 dir_maker_.SetUp(); |
207 mock_server_.reset(new MockConnectionManager(directory(), | 207 mock_server_.reset(new MockConnectionManager(directory(), |
208 &cancelation_signal_)); | 208 &cancelation_signal_)); |
209 EnableDatatype(BOOKMARKS); | 209 EnableDatatype(BOOKMARKS); |
210 EnableDatatype(NIGORI); | 210 EnableDatatype(NIGORI); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 523 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
524 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 524 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
525 ASSERT_TRUE(A.good()); | 525 ASSERT_TRUE(A.good()); |
526 A.PutIsUnsynced(true); | 526 A.PutIsUnsynced(true); |
527 A.PutSpecifics(bookmark_data); | 527 A.PutSpecifics(bookmark_data); |
528 A.PutNonUniqueName("bookmark"); | 528 A.PutNonUniqueName("bookmark"); |
529 } | 529 } |
530 | 530 |
531 // Now sync without enabling bookmarks. | 531 // Now sync without enabling bookmarks. |
532 syncer_->NormalSyncShare( | 532 syncer_->NormalSyncShare( |
533 Difference(GetRoutingInfoTypes(context_->routing_info()), | 533 Difference(context_->enabled_types(), ModelTypeSet(BOOKMARKS)), |
534 ModelTypeSet(BOOKMARKS)), | |
535 nudge_tracker_, | 534 nudge_tracker_, |
536 session_.get()); | 535 session_.get()); |
537 | 536 |
538 { | 537 { |
539 // Nothing should have been committed as bookmarks is throttled. | 538 // Nothing should have been committed as bookmarks is throttled. |
540 syncable::ReadTransaction rtrans(FROM_HERE, directory()); | 539 syncable::ReadTransaction rtrans(FROM_HERE, directory()); |
541 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 540 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
542 ASSERT_TRUE(entryA.good()); | 541 ASSERT_TRUE(entryA.good()); |
543 EXPECT_TRUE(entryA.GetIsUnsynced()); | 542 EXPECT_TRUE(entryA.GetIsUnsynced()); |
544 } | 543 } |
545 | 544 |
546 // Sync again with bookmarks enabled. | 545 // Sync again with bookmarks enabled. |
547 syncer_->NormalSyncShare( | 546 syncer_->NormalSyncShare( |
548 GetRoutingInfoTypes(context_->routing_info()), | 547 context_->enabled_types(), |
549 nudge_tracker_, | 548 nudge_tracker_, |
550 session_.get()); | 549 session_.get()); |
551 SyncShareNudge(); | 550 SyncShareNudge(); |
552 { | 551 { |
553 // It should have been committed. | 552 // It should have been committed. |
554 syncable::ReadTransaction rtrans(FROM_HERE, directory()); | 553 syncable::ReadTransaction rtrans(FROM_HERE, directory()); |
555 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 554 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
556 ASSERT_TRUE(entryA.good()); | 555 ASSERT_TRUE(entryA.good()); |
557 EXPECT_FALSE(entryA.GetIsUnsynced()); | 556 EXPECT_FALSE(entryA.GetIsUnsynced()); |
558 } | 557 } |
(...skipping 4101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4660 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4659 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
4661 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4660 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
4662 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4661 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
4663 } else { | 4662 } else { |
4664 EXPECT_TRUE(final_monitor_records.empty()) | 4663 EXPECT_TRUE(final_monitor_records.empty()) |
4665 << "Should not restore records after successful bookmark commit."; | 4664 << "Should not restore records after successful bookmark commit."; |
4666 } | 4665 } |
4667 } | 4666 } |
4668 | 4667 |
4669 } // namespace syncer | 4668 } // namespace syncer |
OLD | NEW |