| 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_payload_map.h" | 20 #include "sync/internal_api/public/base/model_type_state_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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 num_get_updates_requests_ = 0; | 181 num_get_updates_requests_ = 0; |
| 182 return result; | 182 return result; |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Expect that GetUpdates will request exactly the types indicated in | 185 // Expect that GetUpdates will request exactly the types indicated in |
| 186 // the bitset. | 186 // the bitset. |
| 187 void ExpectGetUpdatesRequestTypes(ModelTypeSet expected_filter) { | 187 void ExpectGetUpdatesRequestTypes(ModelTypeSet expected_filter) { |
| 188 expected_filter_ = expected_filter; | 188 expected_filter_ = expected_filter; |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ExpectGetUpdatesRequestPayloads(const ModelTypePayloadMap& payloads) { | 191 void ExpectGetUpdatesRequestStates(const ModelTypeStateMap& states) { |
| 192 expected_payloads_ = payloads; | 192 expected_states_ = states; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void SetServerReachable(); | 195 void SetServerReachable(); |
| 196 | 196 |
| 197 void SetServerNotReachable(); | 197 void SetServerNotReachable(); |
| 198 | 198 |
| 199 // Updates our internal state as if we had attempted a connection. Does not | 199 // Updates our internal state as if we had attempted a connection. Does not |
| 200 // send notifications as a real connection attempt would. This is useful in | 200 // send notifications as a real connection attempt would. This is useful in |
| 201 // cases where we're mocking out most of the code that performs network | 201 // cases where we're mocking out most of the code that performs network |
| 202 // requests. | 202 // requests. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // The next value to use for the position_in_parent property. | 331 // The next value to use for the position_in_parent property. |
| 332 int64 next_position_in_parent_; | 332 int64 next_position_in_parent_; |
| 333 | 333 |
| 334 // The default is to use the newer sync_pb::BookmarkSpecifics-style protocol. | 334 // The default is to use the newer sync_pb::BookmarkSpecifics-style protocol. |
| 335 // If this option is set to true, then the MockConnectionManager will | 335 // If this option is set to true, then the MockConnectionManager will |
| 336 // use the older sync_pb::SyncEntity_BookmarkData-style protocol. | 336 // use the older sync_pb::SyncEntity_BookmarkData-style protocol. |
| 337 bool use_legacy_bookmarks_protocol_; | 337 bool use_legacy_bookmarks_protocol_; |
| 338 | 338 |
| 339 ModelTypeSet expected_filter_; | 339 ModelTypeSet expected_filter_; |
| 340 | 340 |
| 341 ModelTypePayloadMap expected_payloads_; | 341 ModelTypeStateMap expected_states_; |
| 342 | 342 |
| 343 int num_get_updates_requests_; | 343 int num_get_updates_requests_; |
| 344 | 344 |
| 345 std::string next_token_; | 345 std::string next_token_; |
| 346 | 346 |
| 347 sync_pb::ClientToServerMessage last_request_; | 347 sync_pb::ClientToServerMessage last_request_; |
| 348 | 348 |
| 349 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); | 349 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); |
| 350 }; | 350 }; |
| 351 | 351 |
| 352 } // namespace syncer | 352 } // namespace syncer |
| 353 | 353 |
| 354 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ | 354 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ |
| OLD | NEW |