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

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

Issue 10699044: [Sync] Move sync/{internal_api,syncable} into syncer namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head 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
« no previous file with comments | « sync/test/engine/mock_connection_manager.h ('k') | sync/test/engine/syncer_command_test.h » ('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 regression tests. 5 // Mock ServerConnectionManager class for use in client regression tests.
6 6
7 #include "sync/test/engine/mock_connection_manager.h" 7 #include "sync/test/engine/mock_connection_manager.h"
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "sync/engine/syncer_proto_util.h" 13 #include "sync/engine/syncer_proto_util.h"
14 #include "sync/protocol/bookmark_specifics.pb.h" 14 #include "sync/protocol/bookmark_specifics.pb.h"
15 #include "sync/syncable/directory.h" 15 #include "sync/syncable/directory.h"
16 #include "sync/syncable/write_transaction.h" 16 #include "sync/syncable/write_transaction.h"
17 #include "sync/test/engine/test_id_factory.h" 17 #include "sync/test/engine/test_id_factory.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using syncer::HttpResponse;
21 using syncer::ServerConnectionManager;
22 using syncer::ServerConnectionEventListener;
23 using syncer::ServerConnectionEvent;
24 using syncer::SyncerProtoUtil;
25 using syncer::TestIdFactory;
26 using std::map; 20 using std::map;
27 using std::string; 21 using std::string;
28 using sync_pb::ClientToServerMessage;
29 using sync_pb::ClientToServerResponse;
30 using sync_pb::CommitMessage; 22 using sync_pb::CommitMessage;
31 using sync_pb::CommitResponse; 23 using sync_pb::CommitResponse;
32 using sync_pb::CommitResponse_EntryResponse;
33 using sync_pb::GetUpdatesMessage; 24 using sync_pb::GetUpdatesMessage;
34 using sync_pb::SyncEnums; 25 using sync_pb::SyncEnums;
35 using sync_pb::SyncEntity; 26
27 namespace syncer {
28
36 using syncable::FIRST_REAL_MODEL_TYPE; 29 using syncable::FIRST_REAL_MODEL_TYPE;
37 using syncable::MODEL_TYPE_COUNT; 30 using syncable::MODEL_TYPE_COUNT;
38 using syncable::ModelType; 31 using syncable::ModelType;
39 using syncable::WriteTransaction; 32 using syncable::WriteTransaction;
40 33
41 static char kValidAuthToken[] = "AuthToken"; 34 static char kValidAuthToken[] = "AuthToken";
42 35
43 MockConnectionManager::MockConnectionManager(syncable::Directory* directory) 36 MockConnectionManager::MockConnectionManager(syncable::Directory* directory)
44 : ServerConnectionManager("unused", 0, false), 37 : ServerConnectionManager("unused", 0, false),
45 server_reachable_(true), 38 server_reachable_(true),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } else { 191 } else {
199 entity->set_folder(is_folder); 192 entity->set_folder(is_folder);
200 entity->mutable_specifics()->mutable_bookmark(); 193 entity->mutable_specifics()->mutable_bookmark();
201 if (!is_folder) { 194 if (!is_folder) {
202 entity->mutable_specifics()->mutable_bookmark()-> 195 entity->mutable_specifics()->mutable_bookmark()->
203 set_url("http://google.com"); 196 set_url("http://google.com");
204 } 197 }
205 } 198 }
206 } 199 }
207 200
208 SyncEntity* MockConnectionManager::AddUpdateDirectory(int id, 201 sync_pb::SyncEntity* MockConnectionManager::AddUpdateDirectory(
209 int parent_id, 202 int id,
210 string name, 203 int parent_id,
211 int64 version, 204 string name,
212 int64 sync_ts) { 205 int64 version,
206 int64 sync_ts) {
213 return AddUpdateDirectory(TestIdFactory::FromNumber(id), 207 return AddUpdateDirectory(TestIdFactory::FromNumber(id),
214 TestIdFactory::FromNumber(parent_id), 208 TestIdFactory::FromNumber(parent_id),
215 name, 209 name,
216 version, 210 version,
217 sync_ts); 211 sync_ts);
218 } 212 }
219 213
220 sync_pb::ClientCommand* MockConnectionManager::GetNextClientCommand() { 214 sync_pb::ClientCommand* MockConnectionManager::GetNextClientCommand() {
221 if (!client_command_.get()) 215 if (!client_command_.get())
222 client_command_.reset(new sync_pb::ClientCommand()); 216 client_command_.reset(new sync_pb::ClientCommand());
223 return client_command_.get(); 217 return client_command_.get();
224 } 218 }
225 219
226 SyncEntity* MockConnectionManager::AddUpdateBookmark(int id, int parent_id, 220 sync_pb::SyncEntity* MockConnectionManager::AddUpdateBookmark(
227 string name, int64 version, 221 int id, int parent_id,
228 int64 sync_ts) { 222 string name, int64 version,
223 int64 sync_ts) {
229 return AddUpdateBookmark(TestIdFactory::FromNumber(id), 224 return AddUpdateBookmark(TestIdFactory::FromNumber(id),
230 TestIdFactory::FromNumber(parent_id), 225 TestIdFactory::FromNumber(parent_id),
231 name, 226 name,
232 version, 227 version,
233 sync_ts); 228 sync_ts);
234 } 229 }
235 230
236 SyncEntity* MockConnectionManager::AddUpdateSpecifics( 231 sync_pb::SyncEntity* MockConnectionManager::AddUpdateSpecifics(
237 int id, int parent_id, string name, int64 version, int64 sync_ts, 232 int id, int parent_id, string name, int64 version, int64 sync_ts,
238 bool is_dir, int64 position, const sync_pb::EntitySpecifics& specifics) { 233 bool is_dir, int64 position, const sync_pb::EntitySpecifics& specifics) {
239 SyncEntity* ent = AddUpdateMeta( 234 sync_pb::SyncEntity* ent = AddUpdateMeta(
240 TestIdFactory::FromNumber(id).GetServerId(), 235 TestIdFactory::FromNumber(id).GetServerId(),
241 TestIdFactory::FromNumber(parent_id).GetServerId(), 236 TestIdFactory::FromNumber(parent_id).GetServerId(),
242 name, version, sync_ts); 237 name, version, sync_ts);
243 ent->set_position_in_parent(position); 238 ent->set_position_in_parent(position);
244 ent->mutable_specifics()->CopyFrom(specifics); 239 ent->mutable_specifics()->CopyFrom(specifics);
245 ent->set_folder(is_dir); 240 ent->set_folder(is_dir);
246 return ent; 241 return ent;
247 } 242 }
248 243
249 sync_pb::SyncEntity* MockConnectionManager::SetNigori( 244 sync_pb::SyncEntity* MockConnectionManager::SetNigori(
250 int id, int64 version,int64 sync_ts, 245 int id, int64 version,int64 sync_ts,
251 const sync_pb::EntitySpecifics& specifics) { 246 const sync_pb::EntitySpecifics& specifics) {
252 SyncEntity* ent = GetUpdateResponse()->add_entries(); 247 sync_pb::SyncEntity* ent = GetUpdateResponse()->add_entries();
253 ent->set_id_string(TestIdFactory::FromNumber(id).GetServerId()); 248 ent->set_id_string(TestIdFactory::FromNumber(id).GetServerId());
254 ent->set_parent_id_string(TestIdFactory::FromNumber(0).GetServerId()); 249 ent->set_parent_id_string(TestIdFactory::FromNumber(0).GetServerId());
255 ent->set_server_defined_unique_tag(syncable::ModelTypeToRootTag( 250 ent->set_server_defined_unique_tag(syncable::ModelTypeToRootTag(
256 syncable::NIGORI)); 251 syncable::NIGORI));
257 ent->set_name("Nigori"); 252 ent->set_name("Nigori");
258 ent->set_non_unique_name("Nigori"); 253 ent->set_non_unique_name("Nigori");
259 ent->set_version(version); 254 ent->set_version(version);
260 ent->set_sync_timestamp(sync_ts); 255 ent->set_sync_timestamp(sync_ts);
261 ent->set_mtime(sync_ts); 256 ent->set_mtime(sync_ts);
262 ent->set_ctime(1); 257 ent->set_ctime(1);
263 ent->set_position_in_parent(0); 258 ent->set_position_in_parent(0);
264 ent->set_folder(false); 259 ent->set_folder(false);
265 ent->mutable_specifics()->CopyFrom(specifics); 260 ent->mutable_specifics()->CopyFrom(specifics);
266 return ent; 261 return ent;
267 } 262 }
268 263
269 SyncEntity* MockConnectionManager::AddUpdateFull(string id, string parent_id, 264 sync_pb::SyncEntity* MockConnectionManager::AddUpdateFull(
270 string name, int64 version, 265 string id, string parent_id,
271 int64 sync_ts, bool is_dir) { 266 string name, int64 version,
272 SyncEntity* ent = AddUpdateMeta(id, parent_id, name, version, sync_ts); 267 int64 sync_ts, bool is_dir) {
268 sync_pb::SyncEntity* ent =
269 AddUpdateMeta(id, parent_id, name, version, sync_ts);
273 AddDefaultBookmarkData(ent, is_dir); 270 AddDefaultBookmarkData(ent, is_dir);
274 return ent; 271 return ent;
275 } 272 }
276 273
277 SyncEntity* MockConnectionManager::AddUpdateMeta(string id, string parent_id, 274 sync_pb::SyncEntity* MockConnectionManager::AddUpdateMeta(
278 string name, int64 version, 275 string id, string parent_id,
279 int64 sync_ts) { 276 string name, int64 version,
280 SyncEntity* ent = GetUpdateResponse()->add_entries(); 277 int64 sync_ts) {
278 sync_pb::SyncEntity* ent = GetUpdateResponse()->add_entries();
281 ent->set_id_string(id); 279 ent->set_id_string(id);
282 ent->set_parent_id_string(parent_id); 280 ent->set_parent_id_string(parent_id);
283 ent->set_non_unique_name(name); 281 ent->set_non_unique_name(name);
284 ent->set_name(name); 282 ent->set_name(name);
285 ent->set_version(version); 283 ent->set_version(version);
286 ent->set_sync_timestamp(sync_ts); 284 ent->set_sync_timestamp(sync_ts);
287 ent->set_mtime(sync_ts); 285 ent->set_mtime(sync_ts);
288 ent->set_ctime(1); 286 ent->set_ctime(1);
289 ent->set_position_in_parent(GeneratePositionInParent()); 287 ent->set_position_in_parent(GeneratePositionInParent());
290 return ent; 288 return ent;
291 } 289 }
292 290
293 SyncEntity* MockConnectionManager::AddUpdateDirectory(string id, 291 sync_pb::SyncEntity* MockConnectionManager::AddUpdateDirectory(
294 string parent_id, 292 string id,
295 string name, 293 string parent_id,
296 int64 version, 294 string name,
297 int64 sync_ts) { 295 int64 version,
296 int64 sync_ts) {
298 return AddUpdateFull(id, parent_id, name, version, sync_ts, true); 297 return AddUpdateFull(id, parent_id, name, version, sync_ts, true);
299 } 298 }
300 299
301 SyncEntity* MockConnectionManager::AddUpdateBookmark(string id, 300 sync_pb::SyncEntity* MockConnectionManager::AddUpdateBookmark(
302 string parent_id, 301 string id,
303 string name, int64 version, 302 string parent_id,
304 int64 sync_ts) { 303 string name, int64 version,
304 int64 sync_ts) {
305 return AddUpdateFull(id, parent_id, name, version, sync_ts, false); 305 return AddUpdateFull(id, parent_id, name, version, sync_ts, false);
306 } 306 }
307 307
308 SyncEntity* MockConnectionManager::AddUpdateFromLastCommit() { 308 sync_pb::SyncEntity* MockConnectionManager::AddUpdateFromLastCommit() {
309 EXPECT_EQ(1, last_sent_commit().entries_size()); 309 EXPECT_EQ(1, last_sent_commit().entries_size());
310 EXPECT_EQ(1, last_commit_response().entryresponse_size()); 310 EXPECT_EQ(1, last_commit_response().entryresponse_size());
311 EXPECT_EQ(CommitResponse::SUCCESS, 311 EXPECT_EQ(CommitResponse::SUCCESS,
312 last_commit_response().entryresponse(0).response_type()); 312 last_commit_response().entryresponse(0).response_type());
313 313
314 if (last_sent_commit().entries(0).deleted()) { 314 if (last_sent_commit().entries(0).deleted()) {
315 AddUpdateTombstone(syncable::Id::CreateFromServerId( 315 AddUpdateTombstone(syncable::Id::CreateFromServerId(
316 last_sent_commit().entries(0).id_string())); 316 last_sent_commit().entries(0).id_string()));
317 } else { 317 } else {
318 SyncEntity* ent = GetUpdateResponse()->add_entries(); 318 sync_pb::SyncEntity* ent = GetUpdateResponse()->add_entries();
319 ent->CopyFrom(last_sent_commit().entries(0)); 319 ent->CopyFrom(last_sent_commit().entries(0));
320 ent->clear_insert_after_item_id(); 320 ent->clear_insert_after_item_id();
321 ent->clear_old_parent_id(); 321 ent->clear_old_parent_id();
322 ent->set_position_in_parent( 322 ent->set_position_in_parent(
323 last_commit_response().entryresponse(0).position_in_parent()); 323 last_commit_response().entryresponse(0).position_in_parent());
324 ent->set_version( 324 ent->set_version(
325 last_commit_response().entryresponse(0).version()); 325 last_commit_response().entryresponse(0).version());
326 ent->set_id_string( 326 ent->set_id_string(
327 last_commit_response().entryresponse(0).id_string()); 327 last_commit_response().entryresponse(0).id_string());
328 // Tests don't currently care about the following: 328 // Tests don't currently care about the following:
329 // originator_cache_guid, originator_client_item_id, parent_id_string, 329 // originator_cache_guid, originator_client_item_id, parent_id_string,
330 // name, non_unique_name. 330 // name, non_unique_name.
331 } 331 }
332 return GetMutableLastUpdate(); 332 return GetMutableLastUpdate();
333 } 333 }
334 334
335 void MockConnectionManager::AddUpdateTombstone(const syncable::Id& id) { 335 void MockConnectionManager::AddUpdateTombstone(const syncable::Id& id) {
336 // Tombstones have only the ID set and dummy values for the required fields. 336 // Tombstones have only the ID set and dummy values for the required fields.
337 SyncEntity* ent = GetUpdateResponse()->add_entries(); 337 sync_pb::SyncEntity* ent = GetUpdateResponse()->add_entries();
338 ent->set_id_string(id.GetServerId()); 338 ent->set_id_string(id.GetServerId());
339 ent->set_version(0); 339 ent->set_version(0);
340 ent->set_name(""); 340 ent->set_name("");
341 ent->set_deleted(true); 341 ent->set_deleted(true);
342 } 342 }
343 343
344 void MockConnectionManager::SetLastUpdateDeleted() { 344 void MockConnectionManager::SetLastUpdateDeleted() {
345 // Tombstones have only the ID set. Wipe anything else. 345 // Tombstones have only the ID set. Wipe anything else.
346 string id_string = GetMutableLastUpdate()->id_string(); 346 string id_string = GetMutableLastUpdate()->id_string();
347 GetUpdateResponse()->mutable_entries()->RemoveLast(); 347 GetUpdateResponse()->mutable_entries()->RemoveLast();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 GetUpdateResponse()->add_new_progress_marker(); 379 GetUpdateResponse()->add_new_progress_marker();
380 new_marker->set_data_type_id(-1); // Invalid -- clients shouldn't see. 380 new_marker->set_data_type_id(-1); // Invalid -- clients shouldn't see.
381 new_marker->set_token(next_token_); 381 new_marker->set_token(next_token_);
382 } 382 }
383 } 383 }
384 384
385 void MockConnectionManager::SetChangesRemaining(int64 timestamp) { 385 void MockConnectionManager::SetChangesRemaining(int64 timestamp) {
386 GetUpdateResponse()->set_changes_remaining(timestamp); 386 GetUpdateResponse()->set_changes_remaining(timestamp);
387 } 387 }
388 388
389 void MockConnectionManager::ProcessGetUpdates(ClientToServerMessage* csm, 389 void MockConnectionManager::ProcessGetUpdates(
390 ClientToServerResponse* response) { 390 sync_pb::ClientToServerMessage* csm,
391 sync_pb::ClientToServerResponse* response) {
391 CHECK(csm->has_get_updates()); 392 CHECK(csm->has_get_updates());
392 ASSERT_EQ(csm->message_contents(), ClientToServerMessage::GET_UPDATES); 393 ASSERT_EQ(csm->message_contents(), ClientToServerMessage::GET_UPDATES);
393 const GetUpdatesMessage& gu = csm->get_updates(); 394 const GetUpdatesMessage& gu = csm->get_updates();
394 num_get_updates_requests_++; 395 num_get_updates_requests_++;
395 EXPECT_FALSE(gu.has_from_timestamp()); 396 EXPECT_FALSE(gu.has_from_timestamp());
396 EXPECT_FALSE(gu.has_requested_types()); 397 EXPECT_FALSE(gu.has_requested_types());
397 398
398 if (fail_non_periodic_get_updates_) { 399 if (fail_non_periodic_get_updates_) {
399 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::PERIODIC, 400 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::PERIODIC,
400 gu.caller_info().source()); 401 gu.caller_info().source());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 bool conflict = false; 457 bool conflict = false;
457 if (conflict_all_commits_) { 458 if (conflict_all_commits_) {
458 conflict = true; 459 conflict = true;
459 } else if (conflict_n_commits_ > 0) { 460 } else if (conflict_n_commits_ > 0) {
460 conflict = true; 461 conflict = true;
461 --conflict_n_commits_; 462 --conflict_n_commits_;
462 } 463 }
463 return conflict; 464 return conflict;
464 } 465 }
465 466
466 void MockConnectionManager::ProcessCommit(ClientToServerMessage* csm, 467 void MockConnectionManager::ProcessCommit(
467 ClientToServerResponse* response_buffer) { 468 sync_pb::ClientToServerMessage* csm,
469 sync_pb::ClientToServerResponse* response_buffer) {
468 CHECK(csm->has_commit()); 470 CHECK(csm->has_commit());
469 ASSERT_EQ(csm->message_contents(), ClientToServerMessage::COMMIT); 471 ASSERT_EQ(csm->message_contents(), ClientToServerMessage::COMMIT);
470 map <string, string> changed_ids; 472 map <string, string> changed_ids;
471 const CommitMessage& commit_message = csm->commit(); 473 const CommitMessage& commit_message = csm->commit();
472 CommitResponse* commit_response = response_buffer->mutable_commit(); 474 CommitResponse* commit_response = response_buffer->mutable_commit();
473 commit_messages_.push_back(new CommitMessage); 475 commit_messages_.push_back(new CommitMessage);
474 commit_messages_.back()->CopyFrom(commit_message); 476 commit_messages_.back()->CopyFrom(commit_message);
475 map<string, CommitResponse_EntryResponse*> response_map; 477 map<string, sync_pb::CommitResponse_EntryResponse*> response_map;
476 for (int i = 0; i < commit_message.entries_size() ; i++) { 478 for (int i = 0; i < commit_message.entries_size() ; i++) {
477 const sync_pb::SyncEntity& entry = commit_message.entries(i); 479 const sync_pb::SyncEntity& entry = commit_message.entries(i);
478 CHECK(entry.has_id_string()); 480 CHECK(entry.has_id_string());
479 string id = entry.id_string(); 481 string id = entry.id_string();
480 ASSERT_LT(entry.name().length(), 256ul) << " name probably too long. True " 482 ASSERT_LT(entry.name().length(), 256ul) << " name probably too long. True "
481 "server name checking not implemented"; 483 "server name checking not implemented";
482 if (entry.version() == 0) { 484 if (entry.version() == 0) {
483 // Relies on our new item string id format. (string representation of a 485 // Relies on our new item string id format. (string representation of a
484 // negative number). 486 // negative number).
485 committed_ids_.push_back(syncable::Id::CreateFromClientString(id)); 487 committed_ids_.push_back(syncable::Id::CreateFromClientString(id));
486 } else { 488 } else {
487 committed_ids_.push_back(syncable::Id::CreateFromServerId(id)); 489 committed_ids_.push_back(syncable::Id::CreateFromServerId(id));
488 } 490 }
489 if (response_map.end() == response_map.find(id)) 491 if (response_map.end() == response_map.find(id))
490 response_map[id] = commit_response->add_entryresponse(); 492 response_map[id] = commit_response->add_entryresponse();
491 CommitResponse_EntryResponse* er = response_map[id]; 493 sync_pb::CommitResponse_EntryResponse* er = response_map[id];
492 if (ShouldConflictThisCommit()) { 494 if (ShouldConflictThisCommit()) {
493 er->set_response_type(CommitResponse::CONFLICT); 495 er->set_response_type(CommitResponse::CONFLICT);
494 continue; 496 continue;
495 } 497 }
496 er->set_response_type(CommitResponse::SUCCESS); 498 er->set_response_type(CommitResponse::SUCCESS);
497 er->set_version(entry.version() + 1); 499 er->set_version(entry.version() + 1);
498 if (!commit_time_rename_prepended_string_.empty()) { 500 if (!commit_time_rename_prepended_string_.empty()) {
499 // Commit time rename sent down from the server. 501 // Commit time rename sent down from the server.
500 er->set_name(commit_time_rename_prepended_string_ + entry.name()); 502 er->set_name(commit_time_rename_prepended_string_ + entry.name());
501 } 503 }
502 string parent_id = entry.parent_id_string(); 504 string parent_id = entry.parent_id_string();
503 // Remap id's we've already assigned. 505 // Remap id's we've already assigned.
504 if (changed_ids.end() != changed_ids.find(parent_id)) { 506 if (changed_ids.end() != changed_ids.find(parent_id)) {
505 parent_id = changed_ids[parent_id]; 507 parent_id = changed_ids[parent_id];
506 er->set_parent_id_string(parent_id); 508 er->set_parent_id_string(parent_id);
507 } 509 }
508 if (entry.has_version() && 0 != entry.version()) { 510 if (entry.has_version() && 0 != entry.version()) {
509 er->set_id_string(id); // Allows verification. 511 er->set_id_string(id); // Allows verification.
510 } else { 512 } else {
511 string new_id = base::StringPrintf("mock_server:%d", next_new_id_++); 513 string new_id = base::StringPrintf("mock_server:%d", next_new_id_++);
512 changed_ids[id] = new_id; 514 changed_ids[id] = new_id;
513 er->set_id_string(new_id); 515 er->set_id_string(new_id);
514 } 516 }
515 } 517 }
516 commit_responses_.push_back(new CommitResponse(*commit_response)); 518 commit_responses_.push_back(new CommitResponse(*commit_response));
517 } 519 }
518 520
519 SyncEntity* MockConnectionManager::AddUpdateDirectory( 521 sync_pb::SyncEntity* MockConnectionManager::AddUpdateDirectory(
520 syncable::Id id, syncable::Id parent_id, string name, int64 version, 522 syncable::Id id, syncable::Id parent_id, string name, int64 version,
521 int64 sync_ts) { 523 int64 sync_ts) {
522 return AddUpdateDirectory(id.GetServerId(), parent_id.GetServerId(), 524 return AddUpdateDirectory(id.GetServerId(), parent_id.GetServerId(),
523 name, version, sync_ts); 525 name, version, sync_ts);
524 } 526 }
525 527
526 SyncEntity* MockConnectionManager::AddUpdateBookmark( 528 sync_pb::SyncEntity* MockConnectionManager::AddUpdateBookmark(
527 syncable::Id id, syncable::Id parent_id, string name, int64 version, 529 syncable::Id id, syncable::Id parent_id, string name, int64 version,
528 int64 sync_ts) { 530 int64 sync_ts) {
529 return AddUpdateBookmark(id.GetServerId(), parent_id.GetServerId(), 531 return AddUpdateBookmark(id.GetServerId(), parent_id.GetServerId(),
530 name, version, sync_ts); 532 name, version, sync_ts);
531 } 533 }
532 534
533 SyncEntity* MockConnectionManager::GetMutableLastUpdate() { 535 sync_pb::SyncEntity* MockConnectionManager::GetMutableLastUpdate() {
534 sync_pb::GetUpdatesResponse* updates = GetUpdateResponse(); 536 sync_pb::GetUpdatesResponse* updates = GetUpdateResponse();
535 EXPECT_GT(updates->entries_size(), 0); 537 EXPECT_GT(updates->entries_size(), 0);
536 return updates->mutable_entries()->Mutable(updates->entries_size() - 1); 538 return updates->mutable_entries()->Mutable(updates->entries_size() - 1);
537 } 539 }
538 540
539 void MockConnectionManager::NextUpdateBatch() { 541 void MockConnectionManager::NextUpdateBatch() {
540 update_queue_.push_back(sync_pb::GetUpdatesResponse::default_instance()); 542 update_queue_.push_back(sync_pb::GetUpdatesResponse::default_instance());
541 SetChangesRemaining(0); 543 SetChangesRemaining(0);
542 ApplyToken(); 544 ApplyToken();
543 } 545 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 server_reachable_ = false; 589 server_reachable_ = false;
588 } 590 }
589 591
590 void MockConnectionManager::UpdateConnectionStatus() { 592 void MockConnectionManager::UpdateConnectionStatus() {
591 if (!server_reachable_) { 593 if (!server_reachable_) {
592 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; 594 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE;
593 } else { 595 } else {
594 server_status_ = HttpResponse::SERVER_CONNECTION_OK; 596 server_status_ = HttpResponse::SERVER_CONNECTION_OK;
595 } 597 }
596 } 598 }
599
600 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/test/engine/mock_connection_manager.h ('k') | sync/test/engine/syncer_command_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698