• 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") = 0;
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 OHOS_FILEMGMT_BACKUP_SA_BACKUP_CONNECTION_MOCK_H
17 #define OHOS_FILEMGMT_BACKUP_SA_BACKUP_CONNECTION_MOCK_H
18 
19 #include <gmock/gmock.h>
20 
21 #include "module_ipc/sa_backup_connection.h"
22 
23 namespace OHOS::FileManagement::Backup {
24 class BSABackupConnection {
25 public:
26     virtual bool InputParaSet(MessageParcel&) = 0;
27     virtual bool OutputParaGet(MessageParcel&) = 0;
28     virtual ErrCode ConnectBackupSAExt(std::string, std::string, std::string) = 0;
29     virtual ErrCode DisconnectBackupSAExt() = 0;
30     virtual bool IsSAExtConnected() = 0;
31     virtual sptr<ILocalAbilityManager> GetBackupSAExtProxy() = 0;
32     virtual ErrCode LoadBackupSAExt() = 0;
33     virtual ErrCode LoadBackupSAExtInner() = 0;
34     virtual ErrCode CallBackupSA() = 0;
35     virtual ErrCode CallRestoreSA(UniqueFd) = 0;
36 public:
37     BSABackupConnection() = default;
38     virtual ~BSABackupConnection() = default;
39 public:
40     static inline std::shared_ptr<BSABackupConnection> saConnect = nullptr;
41 };
42 
43 class SABackupConnectionMock : public BSABackupConnection {
44 public:
45     MOCK_METHOD(bool, InputParaSet, (MessageParcel&));
46     MOCK_METHOD(bool, OutputParaGet, (MessageParcel&));
47     MOCK_METHOD(ErrCode, ConnectBackupSAExt, (std::string, std::string, std::string));
48     MOCK_METHOD(ErrCode, DisconnectBackupSAExt, ());
49     MOCK_METHOD(bool, IsSAExtConnected, ());
50     MOCK_METHOD((sptr<ILocalAbilityManager>), GetBackupSAExtProxy, ());
51     MOCK_METHOD(ErrCode, LoadBackupSAExt, ());
52     MOCK_METHOD(ErrCode, LoadBackupSAExtInner, ());
53     MOCK_METHOD(ErrCode, CallBackupSA, ());
54     MOCK_METHOD(ErrCode, CallRestoreSA, (UniqueFd));
55 };
56 } // namespace OHOS::FileManagement::Backup
57 #endif // OHOS_FILEMGMT_BACKUP_SA_BACKUP_CONNECTION_MOCK_H