• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_METHOD2(InitRestoreSession, ErrCode(sptr<IServiceReverse> remote, std::string &errMsg));
31     MOCK_METHOD1(InitBackupSession, ErrCode(sptr<IServiceReverse> remote));
32     MOCK_METHOD2(InitBackupSession, ErrCode(sptr<IServiceReverse> remote, std::string &errMsg));
33     MOCK_METHOD0(Start, ErrCode());
34     MOCK_METHOD0(AsObject, sptr<IRemoteObject>());
35     MOCK_METHOD0(GetLocalCapabilities, UniqueFd());
36     MOCK_METHOD0(GetLocalCapabilitiesForBundleInfos, UniqueFd());
37     MOCK_METHOD1(PublishFile, ErrCode(const BFileInfo &fileInfo));
38     MOCK_METHOD2(AppFileReady, ErrCode(const std::string &fileName, UniqueFd fd));
39     MOCK_METHOD3(AppFileReady, ErrCode(const std::string &fileName, UniqueFd fd, int32_t errCode));
40     MOCK_METHOD1(AppDone, ErrCode(ErrCode errCode));
41     MOCK_METHOD3(ServiceResultReport, ErrCode(const std::string restoreRetInfo,
42         BackupRestoreScenario scenario, ErrCode errCode));
43     MOCK_METHOD2(GetFileHandle, ErrCode(const std::string &bundleName, const std::string &fileName));
44     MOCK_METHOD5(AppendBundlesRestoreSession, ErrCode(UniqueFd fd, const std::vector<BundleName> &bundleNames,
45         const std::vector<std::string> &detailInfos, RestoreTypeEnum restoreType, int32_t userId));
46     MOCK_METHOD4(AppendBundlesRestoreSession, ErrCode(UniqueFd fd, const std::vector<BundleName> &bundleNames,
47         RestoreTypeEnum restoreType, int32_t userId));
48     MOCK_METHOD1(AppendBundlesBackupSession, ErrCode(const std::vector<BundleName> &bundleNames));
49     MOCK_METHOD0(Finish, ErrCode());
50     MOCK_METHOD0(Release, ErrCode());
51     MOCK_METHOD2(Cancel, ErrCode(std::string bundleName, int32_t &result));
52     MOCK_METHOD1(GetLocalCapabilitiesIncremental, UniqueFd(const std::vector<BIncrementalData> &bundleNames));
53     MOCK_METHOD1(InitIncrementalBackupSession, ErrCode(sptr<IServiceReverse> remote));
54     MOCK_METHOD2(InitIncrementalBackupSession, ErrCode(sptr<IServiceReverse> remote, std::string &errMsg));
55     MOCK_METHOD1(AppendBundlesIncrementalBackupSession, ErrCode(const std::vector<BIncrementalData> &bundlesToBackup));
56     MOCK_METHOD2(AppendBundlesIncrementalBackupSession,
57         ErrCode(const std::vector<BIncrementalData> &bundlesToBackup, const std::vector<std::string> &infos));
58     MOCK_METHOD1(PublishIncrementalFile, ErrCode(const BFileInfo &fileInfo));
59     MOCK_METHOD2(PublishSAIncrementalFile, ErrCode(const BFileInfo &fileInfo, UniqueFd fd));
60     MOCK_METHOD3(AppIncrementalFileReady, ErrCode(const std::string &fileName, UniqueFd fd, UniqueFd manifestFd));
61     MOCK_METHOD4(AppIncrementalFileReady, ErrCode(const std::string &fileName, UniqueFd fd, UniqueFd manifestFd,
62         int32_t errCode));
63     MOCK_METHOD1(AppIncrementalDone, ErrCode(ErrCode errCode));
64     MOCK_METHOD2(GetIncrementalFileHandle, ErrCode(const std::string &bundleName, const std::string &fileName));
65     MOCK_METHOD2(GetBackupInfo, ErrCode(BundleName &bundleName, std::string &result));
66     MOCK_METHOD3(UpdateTimer, ErrCode(BundleName &bundleName, uint32_t timeout, bool &result));
67     MOCK_METHOD0(GetAppLocalListAndDoIncrementalBackup, ErrCode());
68     MOCK_METHOD1(StopExtTimer, ErrCode(bool &isExtStop));
69     MOCK_METHOD1(RefreshDataSize, ErrCode(int64_t totalsize));
70     MOCK_METHOD2(GetBackupDataSize, ErrCode(bool isPreciseScan, std::vector<BIncrementalData> bundleNameList));
71 };
72 } // End of namespace OHOS::FileManagement::Backup
73 #endif // TEST_UNITTEST_SERVICE_PROXY_MOCK_H
74