1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "sync/test/engine/mock_update_handler.h" 6 7 #include "sync/internal_api/public/base/model_type.h" 8 9 namespace syncer { 10 MockUpdateHandler(ModelType type)11MockUpdateHandler::MockUpdateHandler(ModelType type) 12 : apply_updates_count_(0), 13 passive_apply_updates_count_(0) { 14 progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); 15 const std::string& token_str = 16 std::string("Mock token: ") + std::string(ModelTypeToString(type)); 17 progress_marker_.set_token(token_str); 18 } 19 ~MockUpdateHandler()20MockUpdateHandler::~MockUpdateHandler() {} 21 GetDownloadProgress(sync_pb::DataTypeProgressMarker * progress_marker) const22void MockUpdateHandler::GetDownloadProgress( 23 sync_pb::DataTypeProgressMarker* progress_marker) const { 24 progress_marker->CopyFrom(progress_marker_); 25 } 26 GetDataTypeContext(sync_pb::DataTypeContext * context) const27void MockUpdateHandler::GetDataTypeContext( 28 sync_pb::DataTypeContext* context) const { 29 context->Clear(); 30 } 31 ProcessGetUpdatesResponse(const sync_pb::DataTypeProgressMarker & progress_marker,const sync_pb::DataTypeContext & mutated_context,const SyncEntityList & applicable_updates,sessions::StatusController * status)32SyncerError MockUpdateHandler::ProcessGetUpdatesResponse( 33 const sync_pb::DataTypeProgressMarker& progress_marker, 34 const sync_pb::DataTypeContext& mutated_context, 35 const SyncEntityList& applicable_updates, 36 sessions::StatusController* status) { 37 progress_marker_.CopyFrom(progress_marker); 38 return syncer::SYNCER_OK; 39 } 40 ApplyUpdates(sessions::StatusController * status)41void MockUpdateHandler::ApplyUpdates(sessions::StatusController* status) { 42 apply_updates_count_++; 43 } 44 PassiveApplyUpdates(sessions::StatusController * status)45void MockUpdateHandler::PassiveApplyUpdates( 46 sessions::StatusController* status) { 47 passive_apply_updates_count_++; 48 } 49 GetApplyUpdatesCount()50int MockUpdateHandler::GetApplyUpdatesCount() { 51 return apply_updates_count_; 52 } 53 GetPassiveApplyUpdatesCount()54int MockUpdateHandler::GetPassiveApplyUpdatesCount() { 55 return passive_apply_updates_count_; 56 } 57 58 } // namespace syncer 59