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

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

Issue 10584019: sync: Remove ClearUserData command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 8 years, 6 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') | no next file » | 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
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 bool result = true; 139 bool result = true;
140 EXPECT_TRUE(!store_birthday_sent_ || post.has_store_birthday() || 140 EXPECT_TRUE(!store_birthday_sent_ || post.has_store_birthday() ||
141 post.message_contents() == ClientToServerMessage::AUTHENTICATE); 141 post.message_contents() == ClientToServerMessage::AUTHENTICATE);
142 store_birthday_sent_ = true; 142 store_birthday_sent_ = true;
143 143
144 if (post.message_contents() == ClientToServerMessage::COMMIT) { 144 if (post.message_contents() == ClientToServerMessage::COMMIT) {
145 ProcessCommit(&post, &response); 145 ProcessCommit(&post, &response);
146 } else if (post.message_contents() == ClientToServerMessage::GET_UPDATES) { 146 } else if (post.message_contents() == ClientToServerMessage::GET_UPDATES) {
147 ProcessGetUpdates(&post, &response); 147 ProcessGetUpdates(&post, &response);
148 } else if (post.message_contents() == ClientToServerMessage::CLEAR_DATA) {
149 ProcessClearData(&post, &response);
150 } else { 148 } else {
151 EXPECT_TRUE(false) << "Unknown/unsupported ClientToServerMessage"; 149 EXPECT_TRUE(false) << "Unknown/unsupported ClientToServerMessage";
152 return false; 150 return false;
153 } 151 }
154 if (client_command_.get()) { 152 if (client_command_.get()) {
155 response.mutable_client_command()->CopyFrom(*client_command_.get()); 153 response.mutable_client_command()->CopyFrom(*client_command_.get());
156 } 154 }
157 155
158 { 156 {
159 base::AutoLock lock(response_code_override_lock_); 157 base::AutoLock lock(response_code_override_lock_);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 sync_pb::DataTypeProgressMarker* new_marker = 443 sync_pb::DataTypeProgressMarker* new_marker =
446 response->mutable_get_updates()->add_new_progress_marker(); 444 response->mutable_get_updates()->add_new_progress_marker();
447 new_marker->set_data_type_id(gu.from_progress_marker(i).data_type_id()); 445 new_marker->set_data_type_id(gu.from_progress_marker(i).data_type_id());
448 new_marker->set_token(token); 446 new_marker->set_token(token);
449 } 447 }
450 } 448 }
451 449
452 update_queue_.pop_front(); 450 update_queue_.pop_front();
453 } 451 }
454 452
455 void MockConnectionManager::SetClearUserDataResponseStatus(
456 sync_pb::SyncEnums::ErrorType errortype ) {
457 // Note: this is not a thread-safe set, ok for now. NOT ok if tests
458 // run the syncer on the background thread while this method is called.
459 clear_user_data_response_errortype_ = errortype;
460 }
461
462 void MockConnectionManager::ProcessClearData(ClientToServerMessage* csm,
463 ClientToServerResponse* response) {
464 CHECK(csm->has_clear_user_data());
465 ASSERT_EQ(csm->message_contents(), ClientToServerMessage::CLEAR_DATA);
466 response->clear_user_data();
467 response->set_error_code(clear_user_data_response_errortype_);
468 }
469
470 bool MockConnectionManager::ShouldConflictThisCommit() { 453 bool MockConnectionManager::ShouldConflictThisCommit() {
471 bool conflict = false; 454 bool conflict = false;
472 if (conflict_all_commits_) { 455 if (conflict_all_commits_) {
473 conflict = true; 456 conflict = true;
474 } else if (conflict_n_commits_ > 0) { 457 } else if (conflict_n_commits_ > 0) {
475 conflict = true; 458 conflict = true;
476 --conflict_n_commits_; 459 --conflict_n_commits_;
477 } 460 }
478 return conflict; 461 return conflict;
479 } 462 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 server_reachable_ = false; 585 server_reachable_ = false;
603 } 586 }
604 587
605 void MockConnectionManager::UpdateConnectionStatus() { 588 void MockConnectionManager::UpdateConnectionStatus() {
606 if (!server_reachable_) { 589 if (!server_reachable_) {
607 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; 590 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE;
608 } else { 591 } else {
609 server_status_ = HttpResponse::SERVER_CONNECTION_OK; 592 server_status_ = HttpResponse::SERVER_CONNECTION_OK;
610 } 593 }
611 } 594 }
OLDNEW
« no previous file with comments | « sync/test/engine/mock_connection_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698