| OLD | NEW |
| 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 // 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> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/location.h" | 19 #include "base/location.h" |
| 20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
| 22 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
| 23 #include "base/stringprintf.h" | 23 #include "base/stringprintf.h" |
| 24 #include "base/time.h" | 24 #include "base/time.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 #include "sync/engine/get_commit_ids_command.h" | 26 #include "sync/engine/get_commit_ids_command.h" |
| 27 #include "sync/engine/net/server_connection_manager.h" | 27 #include "sync/engine/net/server_connection_manager.h" |
| 28 #include "sync/engine/process_updates_command.h" | 28 #include "sync/engine/process_updates_command.h" |
| 29 #include "sync/engine/sync_scheduler.h" | 29 #include "sync/engine/sync_scheduler_impl.h" |
| 30 #include "sync/engine/syncer.h" | 30 #include "sync/engine/syncer.h" |
| 31 #include "sync/engine/syncer_proto_util.h" | 31 #include "sync/engine/syncer_proto_util.h" |
| 32 #include "sync/engine/throttled_data_type_tracker.h" | 32 #include "sync/engine/throttled_data_type_tracker.h" |
| 33 #include "sync/engine/traffic_recorder.h" | 33 #include "sync/engine/traffic_recorder.h" |
| 34 #include "sync/internal_api/public/base/model_type.h" | 34 #include "sync/internal_api/public/base/model_type.h" |
| 35 #include "sync/internal_api/public/engine/model_safe_worker.h" | 35 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 36 #include "sync/protocol/bookmark_specifics.pb.h" | 36 #include "sync/protocol/bookmark_specifics.pb.h" |
| 37 #include "sync/protocol/nigori_specifics.pb.h" | 37 #include "sync/protocol/nigori_specifics.pb.h" |
| 38 #include "sync/protocol/preference_specifics.pb.h" | 38 #include "sync/protocol/preference_specifics.pb.h" |
| 39 #include "sync/protocol/sync.pb.h" | 39 #include "sync/protocol/sync.pb.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 GetModelSafeRoutingInfo(&info); | 178 GetModelSafeRoutingInfo(&info); |
| 179 GetWorkers(&workers); | 179 GetWorkers(&workers); |
| 180 syncer::ModelTypePayloadMap types = | 180 syncer::ModelTypePayloadMap types = |
| 181 ModelSafeRoutingInfoToPayloadMap(info, std::string()); | 181 ModelSafeRoutingInfoToPayloadMap(info, std::string()); |
| 182 return new SyncSession(context_.get(), this, | 182 return new SyncSession(context_.get(), this, |
| 183 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), | 183 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), |
| 184 info, workers); | 184 info, workers); |
| 185 } | 185 } |
| 186 | 186 |
| 187 bool SyncShareAsDelegate( | 187 bool SyncShareAsDelegate( |
| 188 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { | 188 SyncSchedulerImpl::SyncSessionJob::SyncSessionJobPurpose purpose) { |
| 189 SyncerStep start; | 189 SyncerStep start; |
| 190 SyncerStep end; | 190 SyncerStep end; |
| 191 SyncScheduler::SetSyncerStepsForPurpose(purpose, &start, &end); | 191 SyncSchedulerImpl::SetSyncerStepsForPurpose(purpose, &start, &end); |
| 192 | 192 |
| 193 session_.reset(MakeSession()); | 193 session_.reset(MakeSession()); |
| 194 syncer_->SyncShare(session_.get(), start, end); | 194 syncer_->SyncShare(session_.get(), start, end); |
| 195 return session_->HasMoreToSync(); | 195 return session_->HasMoreToSync(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool SyncShareNudge() { | 198 bool SyncShareNudge() { |
| 199 session_.reset(MakeSession()); | 199 session_.reset(MakeSession()); |
| 200 return SyncShareAsDelegate(SyncScheduler::SyncSessionJob::NUDGE); | 200 return SyncShareAsDelegate(SyncSchedulerImpl::SyncSessionJob::NUDGE); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool SyncShareConfigure() { | 203 bool SyncShareConfigure() { |
| 204 session_.reset(MakeSession()); | 204 session_.reset(MakeSession()); |
| 205 return SyncShareAsDelegate(SyncScheduler::SyncSessionJob::CONFIGURATION); | 205 return SyncShareAsDelegate( |
| 206 SyncSchedulerImpl::SyncSessionJob::CONFIGURATION); |
| 206 } | 207 } |
| 207 | 208 |
| 208 void LoopSyncShare() { | 209 void LoopSyncShare() { |
| 209 bool should_loop = false; | 210 bool should_loop = false; |
| 210 int loop_iterations = 0; | 211 int loop_iterations = 0; |
| 211 do { | 212 do { |
| 212 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; | 213 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; |
| 213 should_loop = SyncShareNudge(); | 214 should_loop = SyncShareNudge(); |
| 214 } while (should_loop); | 215 } while (should_loop); |
| 215 } | 216 } |
| (...skipping 4607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4823 | 4824 |
| 4824 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4825 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
| 4825 Add(mid_id_); | 4826 Add(mid_id_); |
| 4826 Add(low_id_); | 4827 Add(low_id_); |
| 4827 Add(high_id_); | 4828 Add(high_id_); |
| 4828 SyncShareNudge(); | 4829 SyncShareNudge(); |
| 4829 ExpectLocalOrderIsByServerId(); | 4830 ExpectLocalOrderIsByServerId(); |
| 4830 } | 4831 } |
| 4831 | 4832 |
| 4832 } // namespace syncer | 4833 } // namespace syncer |
| OLD | NEW |