1 /* 2 * Copyright (c) 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 TEST_UNITTEST_SERVICE_PROXY_MOCK_H 17 #define TEST_UNITTEST_SERVICE_PROXY_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "service_proxy.h" 22 23 namespace OHOS::FileManagement::Backup { 24 class ServiceProxyMock : public ServiceProxy { 25 public: ServiceProxyMock(const sptr<IRemoteObject> & impl)26 explicit ServiceProxyMock(const sptr<IRemoteObject> &impl) : ServiceProxy(impl) {} ~ServiceProxyMock()27 ~ServiceProxyMock() override {} 28 public: 29 MOCK_METHOD1(InitRestoreSession, ErrCode(sptr<IServiceReverse> remote)); 30 MOCK_METHOD1(InitBackupSession, ErrCode(sptr<IServiceReverse> remote)); 31 MOCK_METHOD0(Start, ErrCode()); 32 MOCK_METHOD0(AsObject, sptr<IRemoteObject>()); 33 MOCK_METHOD0(GetLocalCapabilities, UniqueFd()); 34 MOCK_METHOD1(PublishFile, ErrCode(const BFileInfo &fileInfo)); 35 MOCK_METHOD2(AppFileReady, ErrCode(const std::string &fileName, UniqueFd fd)); 36 MOCK_METHOD3(AppFileReady, ErrCode(const std::string &fileName, UniqueFd fd, int32_t errCode)); 37 MOCK_METHOD1(AppDone, ErrCode(ErrCode errCode)); 38 MOCK_METHOD3(ServiceResultReport, ErrCode(const std::string restoreRetInfo, 39 BackupRestoreScenario scenario, ErrCode errCode)); 40 MOCK_METHOD2(GetFileHandle, ErrCode(const std::string &bundleName, const std::string &fileName)); 41 MOCK_METHOD5(AppendBundlesRestoreSession, ErrCode(UniqueFd fd, const std::vector<BundleName> &bundleNames, 42 const std::vector<std::string> &detailInfos, RestoreTypeEnum restoreType, int32_t userId)); 43 MOCK_METHOD4(AppendBundlesRestoreSession, ErrCode(UniqueFd fd, const std::vector<BundleName> &bundleNames, 44 RestoreTypeEnum restoreType, int32_t userId)); 45 MOCK_METHOD1(AppendBundlesBackupSession, ErrCode(const std::vector<BundleName> &bundleNames)); 46 MOCK_METHOD0(Finish, ErrCode()); 47 MOCK_METHOD0(Release, ErrCode()); 48 MOCK_METHOD1(GetLocalCapabilitiesIncremental, UniqueFd(const std::vector<BIncrementalData> &bundleNames)); 49 MOCK_METHOD1(InitIncrementalBackupSession, ErrCode(sptr<IServiceReverse> remote)); 50 MOCK_METHOD1(AppendBundlesIncrementalBackupSession, ErrCode(const std::vector<BIncrementalData> &bundlesToBackup)); 51 MOCK_METHOD2(AppendBundlesIncrementalBackupSession, 52 ErrCode(const std::vector<BIncrementalData> &bundlesToBackup, const std::vector<std::string> &infos)); 53 MOCK_METHOD1(PublishIncrementalFile, ErrCode(const BFileInfo &fileInfo)); 54 MOCK_METHOD3(AppIncrementalFileReady, ErrCode(const std::string &fileName, UniqueFd fd, UniqueFd manifestFd)); 55 MOCK_METHOD4(AppIncrementalFileReady, ErrCode(const std::string &fileName, UniqueFd fd, UniqueFd manifestFd, 56 int32_t errCode)); 57 MOCK_METHOD1(AppIncrementalDone, ErrCode(ErrCode errCode)); 58 MOCK_METHOD2(GetIncrementalFileHandle, ErrCode(const std::string &bundleName, const std::string &fileName)); 59 MOCK_METHOD2(GetBackupInfo, ErrCode(BundleName &bundleName, std::string &result)); 60 MOCK_METHOD3(UpdateTimer, ErrCode(BundleName &bundleName, uint32_t timeout, bool &result)); 61 MOCK_METHOD0(GetAppLocalListAndDoIncrementalBackup, ErrCode()); 62 }; 63 } // End of namespace OHOS::FileManagement::Backup 64 #endif // TEST_UNITTEST_SERVICE_PROXY_MOCK_H 65