OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> | |
9 #include <limits> | |
10 #include <list> | 8 #include <list> |
11 #include <map> | 9 #include <map> |
12 #include <set> | 10 #include <set> |
13 #include <string> | 11 #include <string> |
14 | 12 |
15 #include "base/callback.h" | 13 #include "base/callback.h" |
16 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
17 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
18 #include "build/build_config.h" | 16 #include "build/build_config.h" |
19 #include "chrome/browser/sync/engine/conflict_resolver.h" | 17 #include "chrome/browser/sync/engine/conflict_resolver.h" |
20 #include "chrome/browser/sync/engine/get_commit_ids_command.h" | 18 #include "chrome/browser/sync/engine/get_commit_ids_command.h" |
21 #include "chrome/browser/sync/engine/model_safe_worker.h" | 19 #include "chrome/browser/sync/engine/model_safe_worker.h" |
22 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 20 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
23 #include "chrome/browser/sync/engine/process_updates_command.h" | 21 #include "chrome/browser/sync/engine/process_updates_command.h" |
24 #include "chrome/browser/sync/engine/syncer.h" | 22 #include "chrome/browser/sync/engine/syncer.h" |
25 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 23 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
26 #include "chrome/browser/sync/engine/syncer_util.h" | 24 #include "chrome/browser/sync/engine/syncer_util.h" |
27 #include "chrome/browser/sync/engine/syncproto.h" | 25 #include "chrome/browser/sync/engine/syncproto.h" |
28 #include "chrome/browser/sync/protocol/sync.pb.h" | 26 #include "chrome/browser/sync/protocol/sync.pb.h" |
29 #include "chrome/browser/sync/syncable/directory_manager.h" | 27 #include "chrome/browser/sync/syncable/directory_manager.h" |
30 #include "chrome/browser/sync/syncable/model_type.h" | |
31 #include "chrome/browser/sync/syncable/syncable.h" | 28 #include "chrome/browser/sync/syncable/syncable.h" |
32 #include "chrome/common/deprecated/event_sys-inl.h" | 29 #include "chrome/common/deprecated/event_sys-inl.h" |
33 #include "chrome/test/sync/engine/mock_connection_manager.h" | 30 #include "chrome/test/sync/engine/mock_connection_manager.h" |
34 #include "chrome/test/sync/engine/test_directory_setter_upper.h" | 31 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
35 #include "chrome/test/sync/engine/test_id_factory.h" | 32 #include "chrome/test/sync/engine/test_id_factory.h" |
36 #include "chrome/test/sync/engine/test_syncable_utils.h" | 33 #include "chrome/test/sync/engine/test_syncable_utils.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
38 | 35 |
39 using base::TimeDelta; | 36 using base::TimeDelta; |
40 | 37 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 CHECK(false) << "Handling unknown error type in unit tests!!"; | 143 CHECK(false) << "Handling unknown error type in unit tests!!"; |
147 } | 144 } |
148 saw_syncer_event_ = true; | 145 saw_syncer_event_ = true; |
149 } | 146 } |
150 | 147 |
151 SyncSession* MakeSession() { | 148 SyncSession* MakeSession() { |
152 ModelSafeRoutingInfo info; | 149 ModelSafeRoutingInfo info; |
153 std::vector<ModelSafeWorker*> workers; | 150 std::vector<ModelSafeWorker*> workers; |
154 GetModelSafeRoutingInfo(&info); | 151 GetModelSafeRoutingInfo(&info); |
155 GetWorkers(&workers); | 152 GetWorkers(&workers); |
156 sessions::TypePayloadMap types = sessions::RoutingInfoToTypePayloadMap( | 153 return new SyncSession(context_.get(), this, sessions::SyncSourceInfo(), |
157 info, std::string()); | 154 info, workers); |
158 return new SyncSession(context_.get(), this, | |
159 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), | |
160 info, workers); | |
161 } | 155 } |
162 | 156 |
163 bool SyncShareAsDelegate() { | 157 bool SyncShareAsDelegate() { |
164 scoped_ptr<SyncSession> session(MakeSession()); | 158 scoped_ptr<SyncSession> session(MakeSession()); |
165 syncer_->SyncShare(session.get()); | 159 syncer_->SyncShare(session.get()); |
166 return session->HasMoreToSync(); | 160 return session->HasMoreToSync(); |
167 } | 161 } |
168 | 162 |
169 void LoopSyncShare() { | 163 void LoopSyncShare() { |
170 bool should_loop = false; | 164 bool should_loop = false; |
(...skipping 5004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5175 Add(low_id_); | 5169 Add(low_id_); |
5176 Add(high_id_); | 5170 Add(high_id_); |
5177 SyncShareAsDelegate(); | 5171 SyncShareAsDelegate(); |
5178 ExpectLocalOrderIsByServerId(); | 5172 ExpectLocalOrderIsByServerId(); |
5179 } | 5173 } |
5180 | 5174 |
5181 const SyncerTest::CommitOrderingTest | 5175 const SyncerTest::CommitOrderingTest |
5182 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 5176 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
5183 | 5177 |
5184 } // namespace browser_sync | 5178 } // namespace browser_sync |
OLD | NEW |