Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: sync/test/engine/mock_connection_manager.h

Issue 10455012: [Sync] Add support for performing a GetKey on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 void SetGetKeyResponseStatus(sync_pb::SyncEnums::ErrorType errortype);
127
125 void FailNonPeriodicGetUpdates() { fail_non_periodic_get_updates_ = true; } 128 void FailNonPeriodicGetUpdates() { fail_non_periodic_get_updates_ = true; }
126 129
127 // Simple inspectors. 130 // Simple inspectors.
128 bool client_stuck() const { return client_stuck_; } 131 bool client_stuck() const { return client_stuck_; }
129 132
130 sync_pb::ClientCommand* GetNextClientCommand(); 133 sync_pb::ClientCommand* GetNextClientCommand();
131 134
132 const std::vector<syncable::Id>& committed_ids() const { 135 const std::vector<syncable::Id>& committed_ids() const {
133 return committed_ids_; 136 return committed_ids_;
134 } 137 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 std::string name, int64 version, 232 std::string name, int64 version,
230 int64 sync_ts); 233 int64 sync_ts);
231 234
232 // Functions to handle the various types of server request. 235 // Functions to handle the various types of server request.
233 void ProcessGetUpdates(sync_pb::ClientToServerMessage* csm, 236 void ProcessGetUpdates(sync_pb::ClientToServerMessage* csm,
234 sync_pb::ClientToServerResponse* response); 237 sync_pb::ClientToServerResponse* response);
235 void ProcessCommit(sync_pb::ClientToServerMessage* csm, 238 void ProcessCommit(sync_pb::ClientToServerMessage* csm,
236 sync_pb::ClientToServerResponse* response_buffer); 239 sync_pb::ClientToServerResponse* response_buffer);
237 void ProcessClearData(sync_pb::ClientToServerMessage* csm, 240 void ProcessClearData(sync_pb::ClientToServerMessage* csm,
238 sync_pb::ClientToServerResponse* response); 241 sync_pb::ClientToServerResponse* response);
242 void ProcessGetKey(sync_pb::ClientToServerMessage* csm,
243 sync_pb::ClientToServerResponse* response);
239 void AddDefaultBookmarkData(sync_pb::SyncEntity* entity, bool is_folder); 244 void AddDefaultBookmarkData(sync_pb::SyncEntity* entity, bool is_folder);
240 245
241 // Determine if one entry in a commit should be rejected with a conflict. 246 // Determine if one entry in a commit should be rejected with a conflict.
242 bool ShouldConflictThisCommit(); 247 bool ShouldConflictThisCommit();
243 248
244 // Generate a numeric position_in_parent value. We use a global counter 249 // Generate a numeric position_in_parent value. We use a global counter
245 // that only decreases; this simulates new objects always being added to the 250 // that only decreases; this simulates new objects always being added to the
246 // front of the ordering. 251 // front of the ordering.
247 int64 GeneratePositionInParent() { 252 int64 GeneratePositionInParent() {
248 return next_position_in_parent_--; 253 return next_position_in_parent_--;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 syncable::Directory* directory_; 305 syncable::Directory* directory_;
301 306
302 // The updates we'll return to the next request. 307 // The updates we'll return to the next request.
303 std::list<sync_pb::GetUpdatesResponse> update_queue_; 308 std::list<sync_pb::GetUpdatesResponse> update_queue_;
304 base::Closure mid_commit_callback_; 309 base::Closure mid_commit_callback_;
305 MidCommitObserver* mid_commit_observer_; 310 MidCommitObserver* mid_commit_observer_;
306 311
307 // The clear data response we'll return in the next response 312 // The clear data response we'll return in the next response
308 sync_pb::SyncEnums::ErrorType clear_user_data_response_errortype_; 313 sync_pb::SyncEnums::ErrorType clear_user_data_response_errortype_;
309 314
315 // The keystore key we return in a GetKey response.
316 std::string keystore_key_;
317 // The GetKey response we'll next return.
318 sync_pb::SyncEnums::ErrorType get_key_response_errortype_;
319
310 // The AUTHENTICATE response we'll return for auth requests. 320 // The AUTHENTICATE response we'll return for auth requests.
311 sync_pb::AuthenticateResponse auth_response_; 321 sync_pb::AuthenticateResponse auth_response_;
312 // What we use to determine if we should return SUCCESS or BAD_AUTH_TOKEN. 322 // What we use to determine if we should return SUCCESS or BAD_AUTH_TOKEN.
313 std::string valid_auth_token_; 323 std::string valid_auth_token_;
314 324
315 // Whether we are faking a server mandating clients to throttle requests. 325 // Whether we are faking a server mandating clients to throttle requests.
316 // Protected by |response_code_override_lock_|. 326 // Protected by |response_code_override_lock_|.
317 bool throttling_; 327 bool throttling_;
318 328
319 // Whether we are failing all requests by returning 329 // Whether we are failing all requests by returning
(...skipping 25 matching lines...) Expand all
345 std::string next_token_; 355 std::string next_token_;
346 356
347 sync_pb::ClientToServerMessage last_request_; 357 sync_pb::ClientToServerMessage last_request_;
348 358
349 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); 359 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
350 }; 360 };
351 361
352 } // namespace syncer 362 } // namespace syncer
353 363
354 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 364 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698