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 // Mock ServerConnectionManager class for use in client unit tests. | 5 // Mock ServerConnectionManager class for use in client unit tests. |
6 | 6 |
7 #ifndef SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ | 7 #ifndef SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ |
8 #define SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ | 8 #define SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ |
9 | 9 |
10 #include <bitset> | 10 #include <bitset> |
11 #include <list> | 11 #include <list> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
18 #include "sync/engine/net/server_connection_manager.h" | 18 #include "sync/engine/net/server_connection_manager.h" |
19 #include "sync/internal_api/public/base/model_type.h" | 19 #include "sync/internal_api/public/base/model_type.h" |
20 #include "sync/internal_api/public/base/model_type_state_map.h" | 20 #include "sync/internal_api/public/base/model_type_invalidation_map.h" |
21 #include "sync/protocol/sync.pb.h" | 21 #include "sync/protocol/sync.pb.h" |
22 | 22 |
23 namespace syncer { | 23 namespace syncer { |
24 | 24 |
25 class MockConnectionManager : public ServerConnectionManager { | 25 class MockConnectionManager : public ServerConnectionManager { |
26 public: | 26 public: |
27 class MidCommitObserver { | 27 class MidCommitObserver { |
28 public: | 28 public: |
29 virtual void Observe() = 0; | 29 virtual void Observe() = 0; |
30 | 30 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 num_get_updates_requests_ = 0; | 183 num_get_updates_requests_ = 0; |
184 return result; | 184 return result; |
185 } | 185 } |
186 | 186 |
187 // Expect that GetUpdates will request exactly the types indicated in | 187 // Expect that GetUpdates will request exactly the types indicated in |
188 // the bitset. | 188 // the bitset. |
189 void ExpectGetUpdatesRequestTypes(ModelTypeSet expected_filter) { | 189 void ExpectGetUpdatesRequestTypes(ModelTypeSet expected_filter) { |
190 expected_filter_ = expected_filter; | 190 expected_filter_ = expected_filter; |
191 } | 191 } |
192 | 192 |
193 void ExpectGetUpdatesRequestStates(const ModelTypeStateMap& states) { | 193 void ExpectGetUpdatesRequestStates(const ModelTypeInvalidationMap& states) { |
194 expected_states_ = states; | 194 expected_states_ = states; |
195 } | 195 } |
196 | 196 |
197 void SetServerReachable(); | 197 void SetServerReachable(); |
198 | 198 |
199 void SetServerNotReachable(); | 199 void SetServerNotReachable(); |
200 | 200 |
201 // Updates our internal state as if we had attempted a connection. Does not | 201 // Updates our internal state as if we had attempted a connection. Does not |
202 // send notifications as a real connection attempt would. This is useful in | 202 // send notifications as a real connection attempt would. This is useful in |
203 // cases where we're mocking out most of the code that performs network | 203 // cases where we're mocking out most of the code that performs network |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // The next value to use for the position_in_parent property. | 334 // The next value to use for the position_in_parent property. |
335 int64 next_position_in_parent_; | 335 int64 next_position_in_parent_; |
336 | 336 |
337 // The default is to use the newer sync_pb::BookmarkSpecifics-style protocol. | 337 // The default is to use the newer sync_pb::BookmarkSpecifics-style protocol. |
338 // If this option is set to true, then the MockConnectionManager will | 338 // If this option is set to true, then the MockConnectionManager will |
339 // use the older sync_pb::SyncEntity_BookmarkData-style protocol. | 339 // use the older sync_pb::SyncEntity_BookmarkData-style protocol. |
340 bool use_legacy_bookmarks_protocol_; | 340 bool use_legacy_bookmarks_protocol_; |
341 | 341 |
342 ModelTypeSet expected_filter_; | 342 ModelTypeSet expected_filter_; |
343 | 343 |
344 ModelTypeStateMap expected_states_; | 344 ModelTypeInvalidationMap expected_states_; |
345 | 345 |
346 int num_get_updates_requests_; | 346 int num_get_updates_requests_; |
347 | 347 |
348 std::string next_token_; | 348 std::string next_token_; |
349 | 349 |
350 sync_pb::ClientToServerMessage last_request_; | 350 sync_pb::ClientToServerMessage last_request_; |
351 | 351 |
352 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); | 352 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); |
353 }; | 353 }; |
354 | 354 |
355 } // namespace syncer | 355 } // namespace syncer |
356 | 356 |
357 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ | 357 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ |
OLD | NEW |