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

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

Issue 9348036: Trim code from sync's ServerConnectionManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small updates Created 8 years, 10 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 CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 7 #ifndef CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
8 #define CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 8 #define CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 29 matching lines...) Expand all
40 const std::string& name); 40 const std::string& name);
41 virtual ~MockConnectionManager(); 41 virtual ~MockConnectionManager();
42 42
43 // Overridden ServerConnectionManager functions. 43 // Overridden ServerConnectionManager functions.
44 virtual bool PostBufferToPath( 44 virtual bool PostBufferToPath(
45 PostBufferParams*, 45 PostBufferParams*,
46 const std::string& path, 46 const std::string& path,
47 const std::string& auth_token, 47 const std::string& auth_token,
48 browser_sync::ScopedServerStatusWatcher* watcher) OVERRIDE; 48 browser_sync::ScopedServerStatusWatcher* watcher) OVERRIDE;
49 49
50 virtual bool IsServerReachable() OVERRIDE;
51 virtual bool IsUserAuthenticated() OVERRIDE;
52
53 // Control of commit response. 50 // Control of commit response.
54 void SetMidCommitCallback(const base::Closure& callback); 51 void SetMidCommitCallback(const base::Closure& callback);
55 void SetMidCommitObserver(MidCommitObserver* observer); 52 void SetMidCommitObserver(MidCommitObserver* observer);
56 53
57 // Set this if you want commit to perform commit time rename. Will request 54 // Set this if you want commit to perform commit time rename. Will request
58 // that the client renames all commited entries, prepending this string. 55 // that the client renames all commited entries, prepending this string.
59 void SetCommitTimeRename(std::string prepend); 56 void SetCommitTimeRename(std::string prepend);
60 57
61 // Generic versions of AddUpdate functions. Tests using these function should 58 // Generic versions of AddUpdate functions. Tests using these function should
62 // compile for both the int64 and string id based versions of the server. 59 // compile for both the int64 and string id based versions of the server.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const std::string& entry_id); 116 const std::string& entry_id);
120 void SetLastUpdatePosition(int64 position_in_parent); 117 void SetLastUpdatePosition(int64 position_in_parent);
121 void SetNewTimestamp(int ts); 118 void SetNewTimestamp(int ts);
122 void SetChangesRemaining(int64 count); 119 void SetChangesRemaining(int64 count);
123 120
124 // Add a new batch of updates after the current one. Allows multiple 121 // Add a new batch of updates after the current one. Allows multiple
125 // GetUpdates responses to be buffered up, since the syncer may 122 // GetUpdates responses to be buffered up, since the syncer may
126 // issue multiple requests during a sync cycle. 123 // issue multiple requests during a sync cycle.
127 void NextUpdateBatch(); 124 void NextUpdateBatch();
128 125
129 // For AUTHENTICATE responses.
130 void SetAuthenticationResponseInfo(const std::string& valid_auth_token,
131 const std::string& user_display_name,
132 const std::string& user_display_email,
133 const std::string& user_obfuscated_id);
134
135 void FailNextPostBufferToPathCall() { fail_next_postbuffer_ = true; } 126 void FailNextPostBufferToPathCall() { fail_next_postbuffer_ = true; }
136 127
137 void SetClearUserDataResponseStatus(sync_pb::SyncEnums::ErrorType errortype); 128 void SetClearUserDataResponseStatus(sync_pb::SyncEnums::ErrorType errortype);
138 129
139 // A visitor class to allow a test to change some monitoring state atomically 130 // A visitor class to allow a test to change some monitoring state atomically
140 // with the action of overriding the response codes sent back to the Syncer 131 // with the action of overriding the response codes sent back to the Syncer
141 // (for example, so you can say "ThrottleNextRequest, and assert no more 132 // (for example, so you can say "ThrottleNextRequest, and assert no more
142 // requests are made once throttling is in effect" in one step. 133 // requests are made once throttling is in effect" in one step.
143 class ResponseCodeOverrideRequestor { 134 class ResponseCodeOverrideRequestor {
144 public: 135 public:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 std::string parentid, std::string name, 234 std::string parentid, std::string name,
244 int64 version, int64 sync_ts, 235 int64 version, int64 sync_ts,
245 bool is_dir); 236 bool is_dir);
246 sync_pb::SyncEntity* AddUpdateMeta(std::string id, std::string parentid, 237 sync_pb::SyncEntity* AddUpdateMeta(std::string id, std::string parentid,
247 std::string name, int64 version, 238 std::string name, int64 version,
248 int64 sync_ts); 239 int64 sync_ts);
249 240
250 // Functions to handle the various types of server request. 241 // Functions to handle the various types of server request.
251 void ProcessGetUpdates(sync_pb::ClientToServerMessage* csm, 242 void ProcessGetUpdates(sync_pb::ClientToServerMessage* csm,
252 sync_pb::ClientToServerResponse* response); 243 sync_pb::ClientToServerResponse* response);
253 void ProcessAuthenticate(sync_pb::ClientToServerMessage* csm,
254 sync_pb::ClientToServerResponse* response,
255 const std::string& auth_token);
256 void ProcessCommit(sync_pb::ClientToServerMessage* csm, 244 void ProcessCommit(sync_pb::ClientToServerMessage* csm,
257 sync_pb::ClientToServerResponse* response_buffer); 245 sync_pb::ClientToServerResponse* response_buffer);
258 void ProcessClearData(sync_pb::ClientToServerMessage* csm, 246 void ProcessClearData(sync_pb::ClientToServerMessage* csm,
259 sync_pb::ClientToServerResponse* response); 247 sync_pb::ClientToServerResponse* response);
260 void AddDefaultBookmarkData(sync_pb::SyncEntity* entity, bool is_folder); 248 void AddDefaultBookmarkData(sync_pb::SyncEntity* entity, bool is_folder);
261 249
262 // Determine if one entry in a commit should be rejected with a conflict. 250 // Determine if one entry in a commit should be rejected with a conflict.
263 bool ShouldConflictThisCommit(); 251 bool ShouldConflictThisCommit();
264 252
265 // Generate a numeric position_in_parent value. We use a global counter 253 // Generate a numeric position_in_parent value. We use a global counter
(...skipping 14 matching lines...) Expand all
280 bool IsModelTypePresentInSpecifics( 268 bool IsModelTypePresentInSpecifics(
281 const google::protobuf::RepeatedPtrField< 269 const google::protobuf::RepeatedPtrField<
282 sync_pb::DataTypeProgressMarker>& filter, 270 sync_pb::DataTypeProgressMarker>& filter,
283 syncable::ModelType value); 271 syncable::ModelType value);
284 272
285 sync_pb::DataTypeProgressMarker const* GetProgressMarkerForType( 273 sync_pb::DataTypeProgressMarker const* GetProgressMarkerForType(
286 const google::protobuf::RepeatedPtrField< 274 const google::protobuf::RepeatedPtrField<
287 sync_pb::DataTypeProgressMarker>& filter, 275 sync_pb::DataTypeProgressMarker>& filter,
288 syncable::ModelType value); 276 syncable::ModelType value);
289 277
278 // When false, we pretend to have network connectivity issues.
279 bool server_reachable_;
280
290 // All IDs that have been committed. 281 // All IDs that have been committed.
291 std::vector<syncable::Id> committed_ids_; 282 std::vector<syncable::Id> committed_ids_;
292 283
293 // Control of when/if we return conflicts. 284 // Control of when/if we return conflicts.
294 bool conflict_all_commits_; 285 bool conflict_all_commits_;
295 int conflict_n_commits_; 286 int conflict_n_commits_;
296 287
297 // Commit messages we've sent, and responses we've returned. 288 // Commit messages we've sent, and responses we've returned.
298 ScopedVector<sync_pb::CommitMessage> commit_messages_; 289 ScopedVector<sync_pb::CommitMessage> commit_messages_;
299 ScopedVector<sync_pb::CommitResponse> commit_responses_; 290 ScopedVector<sync_pb::CommitResponse> commit_responses_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 int num_get_updates_requests_; 350 int num_get_updates_requests_;
360 351
361 std::string next_token_; 352 std::string next_token_;
362 353
363 sync_pb::ClientToServerMessage last_request_; 354 sync_pb::ClientToServerMessage last_request_;
364 355
365 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); 356 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
366 }; 357 };
367 358
368 #endif // CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 359 #endif // CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698