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