1 /* 2 * Copyright (c) 2022-2023 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)39 void BackupOnFileReady(std::string bundleName, std::string fileName, int fd) override {} BackupOnBundleStarted(int32_t errCode,std::string bundleName)40 void BackupOnBundleStarted(int32_t errCode, std::string bundleName) override {} BackupOnBundleFinished(int32_t errCode,std::string bundleName)41 void BackupOnBundleFinished(int32_t errCode, std::string bundleName) override {} BackupOnAllBundlesFinished(int32_t errCode)42 void BackupOnAllBundlesFinished(int32_t errCode) override {} 43 RestoreOnBundleStarted(int32_t errCode,std::string bundleName)44 void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override {} RestoreOnBundleFinished(int32_t errCode,std::string bundleName)45 void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override {} RestoreOnAllBundlesFinished(int32_t errCode)46 void RestoreOnAllBundlesFinished(int32_t errCode) override {} RestoreOnFileReady(std::string bundleName,std::string fileName,int fd)47 void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd) override {} 48 }; 49 } // namespace OHOS::FileManagement::Backup 50 #endif // MOCK_SERVICE_REVERSE_MOCK_H