• 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 OHOS_FILEMGMT_BACKUP_BMS_ADAPTER_MOCK_H
17 #define OHOS_FILEMGMT_BACKUP_BMS_ADAPTER_MOCK_H
18 
19 #include <gmock/gmock.h>
20 
21 #include "module_external/bms_adapter.h"
22 
23 namespace OHOS::FileManagement::Backup {
24 class BBundleMgrAdapter {
25 public:
26     virtual std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfos(const std::vector<std::string>&, int32_t) = 0;
27     virtual std::string GetAppGalleryBundleName() = 0;
28     virtual std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForIncremental(
29         const std::vector<BIncrementalData>&, int32_t) = 0;
30     virtual std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForIncremental(int32_t,
31         const std::vector<BIncrementalData>&) = 0;
32     virtual std::string GetExtName(string, int32_t) = 0;
33     virtual std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForSA() = 0;
34     virtual void GetBundleInfoForSA(std::string, std::vector<BJsonEntityCaps::BundleInfo>&) = 0;
35     virtual bool IsUser0BundleName(std::string, int32_t) = 0;
36     virtual std::vector<BJsonEntityCaps::BundleInfo>
37         GetBundleInfosForAppend(const std::vector<BIncrementalData>&, int32_t) = 0;
38     virtual std::vector<BJsonEntityCaps::BundleInfo> GetFullBundleInfos(int32_t) = 0;
39     virtual std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForLocalCapabilities(int32_t) = 0;
40     virtual std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForIndex(const vector<string>&, int32_t) = 0;
41     virtual int64_t GetBundleDataSize(const std::string&, int32_t) = 0;
42     virtual void CreatBackupEnv(const std::vector<BIncrementalData>&, int32_t) = 0;
43     virtual std::vector<BJsonEntityCaps::BundleInfo>
44         GetBundleInfosForAppendBundles(const std::vector<BIncrementalData>&, int32_t) = 0;
45 public:
46     BBundleMgrAdapter() = default;
47     virtual ~BBundleMgrAdapter() = default;
48 public:
49     static inline std::shared_ptr<BBundleMgrAdapter> bms = nullptr;
50 };
51 
52 class BundleMgrAdapterMock : public BBundleMgrAdapter {
53 public:
54     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfos,
55         ((const std::vector<std::string>&), int32_t));
56     MOCK_METHOD(std::string,  GetAppGalleryBundleName, ());
57     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfosForIncremental,
58         ((const std::vector<BIncrementalData>&), int32_t));
59     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfosForIncremental, (int32_t,
60         (const std::vector<BIncrementalData>&)));
61     MOCK_METHOD(std::string, GetExtName, (std::string, int32_t));
62     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfosForSA, ());
63     MOCK_METHOD(void, GetBundleInfoForSA, (std::string, (std::vector<BJsonEntityCaps::BundleInfo>&)));
64     MOCK_METHOD(bool, IsUser0BundleName, (std::string, int32_t));
65     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfosForAppend,
66         ((const std::vector<BIncrementalData>&), int32_t));
67     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetFullBundleInfos, (int32_t));
68     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfosForLocalCapabilities, (int32_t));
69     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfosForIndex, (const vector<string>&, int32_t));
70     MOCK_METHOD(int64_t, GetBundleDataSize, (const std::string&, int32_t));
71     MOCK_METHOD(void, CreatBackupEnv, (const std::vector<BIncrementalData>&, int32_t));
72     MOCK_METHOD((std::vector<BJsonEntityCaps::BundleInfo>), GetBundleInfosForAppendBundles,
73         ((const std::vector<BIncrementalData>&), int32_t));
74 };
75 } // namespace OHOS::FileManagement::Backup
76 #endif // OHOS_FILEMGMT_BACKUP_BMS_ADAPTER_MOCK_H
77