1 /*
2  * Copyright (c) 2022-2024 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_SERVICE_REVERSE_MOCK_H
17 #define MOCK_SERVICE_REVERSE_MOCK_H
18 
19 #include <gmock/gmock.h>
20 
21 #include "b_error/b_error.h"
22 #include "i_service_reverse.h"
23 #include "iremote_stub.h"
24 
25 namespace OHOS::FileManagement::Backup {
26 class ServiceReverseMock : public IRemoteStub<IServiceReverse> {
27 public:
28     int code_ = 0;
ServiceReverseMock()29     ServiceReverseMock() : code_(0) {}
~ServiceReverseMock()30     virtual ~ServiceReverseMock() {}
31 
32     MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel &, MessageParcel &, MessageOption &));
33 
InvokeSendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)34     int32_t InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
35     {
36         code_ = code;
37         return BError(BError::Codes::OK);
38     }
BackupOnFileReady(std::string bundleName,std::string fileName,int fd,int32_t errCode)39     void BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override {}
BackupOnBundleStarted(int32_t errCode,std::string bundleName)40     void BackupOnBundleStarted(int32_t errCode, std::string bundleName) override {}
BackupOnResultReport(std::string result,std::string bundleName)41     void BackupOnResultReport(std::string result, std::string bundleName) override {};
BackupOnBundleFinished(int32_t errCode,std::string bundleName)42     void BackupOnBundleFinished(int32_t errCode, std::string bundleName) override {}
BackupOnAllBundlesFinished(int32_t errCode)43     void BackupOnAllBundlesFinished(int32_t errCode) override {}
BackupOnProcessInfo(std::string bundleName,std::string processInfo)44     void BackupOnProcessInfo(std::string bundleName, std::string processInfo) override {}
45 
RestoreOnBundleStarted(int32_t errCode,std::string bundleName)46     void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {}
RestoreOnBundleFinished(int32_t errCode,std::string bundleName)47     void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {}
RestoreOnAllBundlesFinished(int32_t errCode)48     void RestoreOnAllBundlesFinished(int32_t errCode) override {}
RestoreOnFileReady(std::string bundleName,std::string fileName,int fd,int32_t errCode)49     void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override {}
RestoreOnResultReport(std::string result,std::string bundleName,ErrCode errCode)50     void RestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {}
RestoreOnProcessInfo(std::string bundleName,std::string processInfo)51     void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {}
52 
IncrementalBackupOnFileReady(std::string bundleName,std::string fileName,int fd,int manifestFd,int32_t errCode)53     void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd,
54         int32_t errCode) override {}
IncrementalBackupOnBundleStarted(int32_t errCode,std::string bundleName)55     void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override {}
IncrementalBackupOnResultReport(std::string result,std::string bundleName)56     void IncrementalBackupOnResultReport(std::string result, std::string bundleName) override {}
IncrementalBackupOnBundleFinished(int32_t errCode,std::string bundleName)57     void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override {}
IncrementalBackupOnAllBundlesFinished(int32_t errCode)58     void IncrementalBackupOnAllBundlesFinished(int32_t errCode) override {}
IncrementalBackupOnProcessInfo(std::string bundleName,std::string processInfo)59     void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override {}
60 
IncrementalRestoreOnBundleStarted(int32_t errCode,std::string bundleName)61     void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {}
IncrementalRestoreOnBundleFinished(int32_t errCode,std::string bundleName)62     void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {}
IncrementalRestoreOnAllBundlesFinished(int32_t errCode)63     void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override {}
IncrementalRestoreOnFileReady(std::string bundleName,std::string fileName,int fd,int manifestFd,int32_t errCode)64     void IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd,
65         int32_t errCode) override {}
IncrementalRestoreOnResultReport(std::string result,std::string bundleName,ErrCode errCode)66     void IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {};
IncrementalRestoreOnProcessInfo(std::string bundleName,std::string processInfo)67     void IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {}
68 };
69 } // namespace OHOS::FileManagement::Backup
70 #endif // MOCK_SERVICE_REVERSE_MOCK_H