1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MOCK_SINGLE_VER_STATE_MACHINE_H 17 #define MOCK_SINGLE_VER_STATE_MACHINE_H 18 19 #include <gmock/gmock.h> 20 #include "single_ver_sync_state_machine.h" 21 22 namespace DistributedDB { 23 class MockSingleVerStateMachine : public SingleVerSyncStateMachine { 24 public: CallStepToTimeout(TimerId timerId)25 void CallStepToTimeout(TimerId timerId) 26 { 27 SingleVerSyncStateMachine::StepToTimeout(timerId); 28 } 29 CallExecNextTask()30 int CallExecNextTask() 31 { 32 return SyncStateMachine::ExecNextTask(); 33 } 34 CallTimeMarkSyncRecv(const Message * inMsg)35 int CallTimeMarkSyncRecv(const Message *inMsg) 36 { 37 return SingleVerSyncStateMachine::TimeMarkSyncRecv(inMsg); 38 } 39 CallDataAckRecvErrCodeHandle(int errCode,bool handleError)40 void CallDataAckRecvErrCodeHandle(int errCode, bool handleError) 41 { 42 SingleVerSyncStateMachine::DataAckRecvErrCodeHandle(errCode, handleError); 43 } 44 CallStartSaveDataNotify(uint32_t sessionId,uint32_t sequenceId,uint32_t inMsgId)45 bool CallStartSaveDataNotify(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId) 46 { 47 return SingleVerSyncStateMachine::StartSaveDataNotify(sessionId, sequenceId, inMsgId); 48 } 49 CallStopSaveDataNotify()50 void CallStopSaveDataNotify() 51 { 52 SingleVerSyncStateMachine::StopSaveDataNotify(); 53 } 54 CallSwitchMachineState(uint8_t event)55 void CallSwitchMachineState(uint8_t event) 56 { 57 SyncStateMachine::SwitchMachineState(event); 58 } 59 CallPrepareNextSyncTask()60 int CallPrepareNextSyncTask() 61 { 62 return SingleVerSyncStateMachine::PrepareNextSyncTask(); 63 } 64 CallStartWatchDog()65 int CallStartWatchDog() 66 { 67 return SingleVerSyncStateMachine::StartWatchDog(); 68 } 69 CallStopWatchDog()70 void CallStopWatchDog() 71 { 72 SingleVerSyncStateMachine::StopWatchDog(); 73 } 74 GetCurrentState()75 uint8_t GetCurrentState() 76 { 77 return currentState_; 78 } 79 CallResponsePullError(int errCode,bool ignoreInnerErr)80 void CallResponsePullError(int errCode, bool ignoreInnerErr) 81 { 82 SingleVerSyncStateMachine::ResponsePullError(errCode, ignoreInnerErr); 83 } 84 GetSaveDataNotifyRefCount()85 int32_t GetSaveDataNotifyRefCount() 86 { 87 return saveDataNotifyRefCount_; 88 } 89 90 MOCK_METHOD1(SwitchStateAndStep, void(uint8_t)); 91 92 MOCK_METHOD0(PrepareNextSyncTask, int(void)); 93 94 MOCK_METHOD3(DoSaveDataNotify, void(uint32_t, uint32_t, uint32_t)); 95 96 MOCK_METHOD0(DoTimeSync, Event()); 97 }; 98 } // namespace DistributedDB 99 #endif // #define MOCK_SINGLE_VER_STATE_MACHINE_H