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

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

Issue 11636006: WIP: The Bookmark Position Megapatch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Various updates, including switch suffix to unique_client_tag style Created 8 years 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
« no previous file with comments | « sync/syncable/syncable_util.cc ('k') | sync/test/engine/mock_connection_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
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_invalidation_map.h" 20 #include "sync/internal_api/public/base/model_type_invalidation_map.h"
21 #include "sync/internal_api/public/base/unique_position.h"
21 #include "sync/protocol/sync.pb.h" 22 #include "sync/protocol/sync.pb.h"
22 23
23 namespace syncer { 24 namespace syncer {
24 25
25 class MockConnectionManager : public ServerConnectionManager { 26 class MockConnectionManager : public ServerConnectionManager {
26 public: 27 public:
27 class MidCommitObserver { 28 class MidCommitObserver {
28 public: 29 public:
29 virtual void Observe() = 0; 30 virtual void Observe() = 0;
30 31
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 int64 sync_ts); 86 int64 sync_ts);
86 sync_pb::SyncEntity* AddUpdateBookmark(std::string id, 87 sync_pb::SyncEntity* AddUpdateBookmark(std::string id,
87 std::string parent_id, 88 std::string parent_id,
88 std::string name, 89 std::string name,
89 int64 version, 90 int64 version,
90 int64 sync_ts); 91 int64 sync_ts);
91 // Versions of the AddUpdate function that accept specifics. 92 // Versions of the AddUpdate function that accept specifics.
92 sync_pb::SyncEntity* AddUpdateSpecifics(int id, int parent_id, 93 sync_pb::SyncEntity* AddUpdateSpecifics(int id, int parent_id,
93 std::string name,int64 version, int64 sync_ts, bool is_dir, 94 std::string name,int64 version, int64 sync_ts, bool is_dir,
94 int64 position, const sync_pb::EntitySpecifics& specifics); 95 int64 position, const sync_pb::EntitySpecifics& specifics);
96 sync_pb::SyncEntity* AddBookmarkUpdateSpecifics(
97 int id, int parent_id, std::string name, int64 version, int64 sync_ts,
98 bool is_dir, int64 position, const sync_pb::EntitySpecifics& specifics);
99 sync_pb::SyncEntity* AddBookmarkUpdateSpecifics(int id, int parent_id,
100 std::string name, int64 version, int64 sync_ts, bool is_dir,
101 const syncer::UniquePosition& position,
102 const sync_pb::EntitySpecifics& specifics);
95 sync_pb::SyncEntity* SetNigori(int id, int64 version, int64 sync_ts, 103 sync_pb::SyncEntity* SetNigori(int id, int64 version, int64 sync_ts,
96 const sync_pb::EntitySpecifics& specifics); 104 const sync_pb::EntitySpecifics& specifics);
97 105
98 // Find the last commit sent by the client, and replay it for the next get 106 // Find the last commit sent by the client, and replay it for the next get
99 // updates command. This can be used to simulate the GetUpdates that happens 107 // updates command. This can be used to simulate the GetUpdates that happens
100 // immediately after a successful commit. 108 // immediately after a successful commit.
101 sync_pb::SyncEntity* AddUpdateFromLastCommit(); 109 sync_pb::SyncEntity* AddUpdateFromLastCommit();
102 110
103 // Add a deleted item. Deletion records typically contain no 111 // Add a deleted item. Deletion records typically contain no
104 // additional information beyond the deletion, and no specifics. 112 // additional information beyond the deletion, and no specifics.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 bool IsModelTypePresentInSpecifics( 269 bool IsModelTypePresentInSpecifics(
262 const google::protobuf::RepeatedPtrField< 270 const google::protobuf::RepeatedPtrField<
263 sync_pb::DataTypeProgressMarker>& filter, 271 sync_pb::DataTypeProgressMarker>& filter,
264 ModelType value); 272 ModelType value);
265 273
266 sync_pb::DataTypeProgressMarker const* GetProgressMarkerForType( 274 sync_pb::DataTypeProgressMarker const* GetProgressMarkerForType(
267 const google::protobuf::RepeatedPtrField< 275 const google::protobuf::RepeatedPtrField<
268 sync_pb::DataTypeProgressMarker>& filter, 276 sync_pb::DataTypeProgressMarker>& filter,
269 ModelType value); 277 ModelType value);
270 278
279 // Sets some reasonable values for originator_item_id and
280 // originator_cache_guid if the given entity is of type BOOKMARKS.
281 //
282 // Unfortunately, there's no guarantee that a single item will always have the
283 // same originator_client_item_id, though such a guarantee would be exist in a
284 // real sync system. This could lead to spurious position changes in some
285 // situations.
286 void SetUpdateOriginatorFields(sync_pb::SyncEntity* ent);
287
271 // When false, we pretend to have network connectivity issues. 288 // When false, we pretend to have network connectivity issues.
272 bool server_reachable_; 289 bool server_reachable_;
273 290
274 // All IDs that have been committed. 291 // All IDs that have been committed.
275 std::vector<syncable::Id> committed_ids_; 292 std::vector<syncable::Id> committed_ids_;
276 293
277 // Control of when/if we return conflicts. 294 // Control of when/if we return conflicts.
278 bool conflict_all_commits_; 295 bool conflict_all_commits_;
279 int conflict_n_commits_; 296 int conflict_n_commits_;
280 297
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 ModelTypeSet expected_filter_; 359 ModelTypeSet expected_filter_;
343 360
344 ModelTypeInvalidationMap expected_states_; 361 ModelTypeInvalidationMap expected_states_;
345 362
346 int num_get_updates_requests_; 363 int num_get_updates_requests_;
347 364
348 std::string next_token_; 365 std::string next_token_;
349 366
350 sync_pb::ClientToServerMessage last_request_; 367 sync_pb::ClientToServerMessage last_request_;
351 368
369 // A unique originator_item_id value.
370 int64 originator_item_id_;
371
352 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); 372 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
353 }; 373 };
354 374
355 } // namespace syncer 375 } // namespace syncer
356 376
357 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 377 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « sync/syncable/syncable_util.cc ('k') | sync/test/engine/mock_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698