| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 case SyncEngineEvent::STATUS_CHANGED: | 174 case SyncEngineEvent::STATUS_CHANGED: |
| 175 case SyncEngineEvent::SYNC_CYCLE_ENDED: | 175 case SyncEngineEvent::SYNC_CYCLE_ENDED: |
| 176 return; | 176 return; |
| 177 default: | 177 default: |
| 178 CHECK(false) << "Handling unknown error type in unit tests!!"; | 178 CHECK(false) << "Handling unknown error type in unit tests!!"; |
| 179 } | 179 } |
| 180 saw_syncer_event_ = true; | 180 saw_syncer_event_ = true; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void SyncShareNudge() { | 183 void SyncShareNudge() { |
| 184 ModelSafeRoutingInfo info; | 184 session_.reset(SyncSession::Build(context_.get(), this)); |
| 185 GetModelSafeRoutingInfo(&info); | |
| 186 ModelTypeInvalidationMap invalidation_map = | |
| 187 ModelSafeRoutingInfoToInvalidationMap(info, std::string()); | |
| 188 sessions::SyncSourceInfo source_info( | |
| 189 sync_pb::GetUpdatesCallerInfo::LOCAL, | |
| 190 invalidation_map); | |
| 191 session_.reset(SyncSession::Build(context_.get(), this, source_info)); | |
| 192 | 185 |
| 193 // Pretend we've seen a local change, to make the nudge_tracker look normal. | 186 // Pretend we've seen a local change, to make the nudge_tracker look normal. |
| 194 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | 187 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
| 195 | 188 |
| 196 EXPECT_TRUE( | 189 EXPECT_TRUE( |
| 197 syncer_->NormalSyncShare( | 190 syncer_->NormalSyncShare( |
| 198 GetRoutingInfoTypes(context_->routing_info()), | 191 GetRoutingInfoTypes(context_->routing_info()), |
| 199 nudge_tracker_, | 192 nudge_tracker_, |
| 200 session_.get())); | 193 session_.get())); |
| 201 } | 194 } |
| 202 | 195 |
| 203 void SyncShareConfigure() { | 196 void SyncShareConfigure() { |
| 204 ModelSafeRoutingInfo info; | 197 session_.reset(SyncSession::Build(context_.get(), this)); |
| 205 GetModelSafeRoutingInfo(&info); | |
| 206 ModelTypeInvalidationMap invalidation_map = | |
| 207 ModelSafeRoutingInfoToInvalidationMap(info, std::string()); | |
| 208 sessions::SyncSourceInfo source_info( | |
| 209 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, | |
| 210 invalidation_map); | |
| 211 session_.reset(SyncSession::Build(context_.get(), | |
| 212 this, | |
| 213 source_info)); | |
| 214 EXPECT_TRUE(syncer_->ConfigureSyncShare( | 198 EXPECT_TRUE(syncer_->ConfigureSyncShare( |
| 215 GetRoutingInfoTypes(context_->routing_info()), | 199 GetRoutingInfoTypes(context_->routing_info()), |
| 200 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, |
| 216 session_.get())); | 201 session_.get())); |
| 217 } | 202 } |
| 218 | 203 |
| 219 virtual void SetUp() { | 204 virtual void SetUp() { |
| 220 dir_maker_.SetUp(); | 205 dir_maker_.SetUp(); |
| 221 mock_server_.reset(new MockConnectionManager(directory())); | 206 mock_server_.reset(new MockConnectionManager(directory())); |
| 222 EnableDatatype(BOOKMARKS); | 207 EnableDatatype(BOOKMARKS); |
| 223 EnableDatatype(NIGORI); | 208 EnableDatatype(NIGORI); |
| 224 EnableDatatype(PREFERENCES); | 209 EnableDatatype(PREFERENCES); |
| 225 EnableDatatype(NIGORI); | 210 EnableDatatype(NIGORI); |
| (...skipping 4593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4819 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4804 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
| 4820 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4805 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
| 4821 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4806 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
| 4822 } else { | 4807 } else { |
| 4823 EXPECT_TRUE(final_monitor_records.empty()) | 4808 EXPECT_TRUE(final_monitor_records.empty()) |
| 4824 << "Should not restore records after successful bookmark commit."; | 4809 << "Should not restore records after successful bookmark commit."; |
| 4825 } | 4810 } |
| 4826 } | 4811 } |
| 4827 | 4812 |
| 4828 } // namespace syncer | 4813 } // namespace syncer |
| OLD | NEW |