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> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void SetChangesRemaining(int64 count); | 115 void SetChangesRemaining(int64 count); |
116 | 116 |
117 // Add a new batch of updates after the current one. Allows multiple | 117 // Add a new batch of updates after the current one. Allows multiple |
118 // GetUpdates responses to be buffered up, since the syncer may | 118 // GetUpdates responses to be buffered up, since the syncer may |
119 // issue multiple requests during a sync cycle. | 119 // issue multiple requests during a sync cycle. |
120 void NextUpdateBatch(); | 120 void NextUpdateBatch(); |
121 | 121 |
122 void FailNextPostBufferToPathCall() { countdown_to_postbuffer_fail_ = 1; } | 122 void FailNextPostBufferToPathCall() { countdown_to_postbuffer_fail_ = 1; } |
123 void FailNthPostBufferToPathCall(int n) { countdown_to_postbuffer_fail_ = n; } | 123 void FailNthPostBufferToPathCall(int n) { countdown_to_postbuffer_fail_ = n; } |
124 | 124 |
| 125 void SetKeystoreKey(const std::string& key); |
| 126 |
125 void FailNonPeriodicGetUpdates() { fail_non_periodic_get_updates_ = true; } | 127 void FailNonPeriodicGetUpdates() { fail_non_periodic_get_updates_ = true; } |
126 | 128 |
127 // Simple inspectors. | 129 // Simple inspectors. |
128 bool client_stuck() const { return client_stuck_; } | 130 bool client_stuck() const { return client_stuck_; } |
129 | 131 |
130 sync_pb::ClientCommand* GetNextClientCommand(); | 132 sync_pb::ClientCommand* GetNextClientCommand(); |
131 | 133 |
132 const std::vector<syncable::Id>& committed_ids() const { | 134 const std::vector<syncable::Id>& committed_ids() const { |
133 return committed_ids_; | 135 return committed_ids_; |
134 } | 136 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // Our directory. Used only to ensure that we are not holding the transaction | 297 // Our directory. Used only to ensure that we are not holding the transaction |
296 // lock when performing network I/O. Can be NULL if the test author is | 298 // lock when performing network I/O. Can be NULL if the test author is |
297 // confident this can't happen. | 299 // confident this can't happen. |
298 syncable::Directory* directory_; | 300 syncable::Directory* directory_; |
299 | 301 |
300 // The updates we'll return to the next request. | 302 // The updates we'll return to the next request. |
301 std::list<sync_pb::GetUpdatesResponse> update_queue_; | 303 std::list<sync_pb::GetUpdatesResponse> update_queue_; |
302 base::Closure mid_commit_callback_; | 304 base::Closure mid_commit_callback_; |
303 MidCommitObserver* mid_commit_observer_; | 305 MidCommitObserver* mid_commit_observer_; |
304 | 306 |
305 // The clear data response we'll return in the next response | 307 // The keystore key we return for a GetUpdates with need_encryption_key set. |
306 sync_pb::SyncEnums::ErrorType clear_user_data_response_errortype_; | 308 std::string keystore_key_; |
307 | 309 |
308 // The AUTHENTICATE response we'll return for auth requests. | 310 // The AUTHENTICATE response we'll return for auth requests. |
309 sync_pb::AuthenticateResponse auth_response_; | 311 sync_pb::AuthenticateResponse auth_response_; |
310 // What we use to determine if we should return SUCCESS or BAD_AUTH_TOKEN. | 312 // What we use to determine if we should return SUCCESS or BAD_AUTH_TOKEN. |
311 std::string valid_auth_token_; | 313 std::string valid_auth_token_; |
312 | 314 |
313 // Whether we are faking a server mandating clients to throttle requests. | 315 // Whether we are faking a server mandating clients to throttle requests. |
314 // Protected by |response_code_override_lock_|. | 316 // Protected by |response_code_override_lock_|. |
315 bool throttling_; | 317 bool throttling_; |
316 | 318 |
(...skipping 26 matching lines...) Expand all Loading... |
343 std::string next_token_; | 345 std::string next_token_; |
344 | 346 |
345 sync_pb::ClientToServerMessage last_request_; | 347 sync_pb::ClientToServerMessage last_request_; |
346 | 348 |
347 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); | 349 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); |
348 }; | 350 }; |
349 | 351 |
350 } // namespace syncer | 352 } // namespace syncer |
351 | 353 |
352 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ | 354 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ |
OLD | NEW |