• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
GetCurrentState()60     uint8_t GetCurrentState()
61     {
62         return currentState_;
63     }
64 
CallResponsePullError(int errCode,bool ignoreInnerErr)65     void CallResponsePullError(int errCode, bool ignoreInnerErr)
66     {
67         SingleVerSyncStateMachine::ResponsePullError(errCode, ignoreInnerErr);
68     }
69 
70     MOCK_METHOD1(SwitchStateAndStep, void(uint8_t));
71 
72     MOCK_METHOD0(PrepareNextSyncTask, int(void));
73 
74     MOCK_METHOD3(DoSaveDataNotify, void(uint32_t, uint32_t, uint32_t));
75 
76     MOCK_METHOD0(DoTimeSync, Event());
77 };
78 } // namespace DistributedDB
79 #endif  // #define MOCK_SINGLE_VER_STATE_MACHINE_H