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 {} BackupOnScanningInfo(std::string scannedInfo)45 void BackupOnScanningInfo(std::string scannedInfo) override {} 46 RestoreOnBundleStarted(int32_t errCode,std::string bundleName)47 void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {} RestoreOnBundleFinished(int32_t errCode,std::string bundleName)48 void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {} RestoreOnAllBundlesFinished(int32_t errCode)49 void RestoreOnAllBundlesFinished(int32_t errCode) override {} RestoreOnFileReady(std::string bundleName,std::string fileName,int fd,int32_t errCode)50 void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override {} RestoreOnResultReport(std::string result,std::string bundleName,ErrCode errCode)51 void RestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {} RestoreOnProcessInfo(std::string bundleName,std::string processInfo)52 void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {} 53 IncrementalBackupOnFileReady(std::string bundleName,std::string fileName,int fd,int manifestFd,int32_t errCode)54 void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, 55 int32_t errCode) override {} IncrementalBackupOnBundleStarted(int32_t errCode,std::string bundleName)56 void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override {} IncrementalBackupOnResultReport(std::string result,std::string bundleName)57 void IncrementalBackupOnResultReport(std::string result, std::string bundleName) override {} IncrementalBackupOnBundleFinished(int32_t errCode,std::string bundleName)58 void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override {} IncrementalBackupOnAllBundlesFinished(int32_t errCode)59 void IncrementalBackupOnAllBundlesFinished(int32_t errCode) override {} IncrementalBackupOnProcessInfo(std::string bundleName,std::string processInfo)60 void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override {} IncrementalBackupOnScanningInfo(std::string scannedInfo)61 void IncrementalBackupOnScanningInfo(std::string scannedInfo) override {} 62 IncrementalRestoreOnBundleStarted(int32_t errCode,std::string bundleName)63 void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {} IncrementalRestoreOnBundleFinished(int32_t errCode,std::string bundleName)64 void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {} IncrementalRestoreOnAllBundlesFinished(int32_t errCode)65 void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override {} IncrementalRestoreOnFileReady(std::string bundleName,std::string fileName,int fd,int manifestFd,int32_t errCode)66 void IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, 67 int32_t errCode) override {} IncrementalRestoreOnResultReport(std::string result,std::string bundleName,ErrCode errCode)68 void IncrementalRestoreOnResultReport(std::string result, std::string bundleName, ErrCode errCode) override {}; IncrementalRestoreOnProcessInfo(std::string bundleName,std::string processInfo)69 void IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override {} 70 }; 71 } // namespace OHOS::FileManagement::Backup 72 #endif // MOCK_SERVICE_REVERSE_MOCK_H