• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef OHOS_META_DATA_MANAGER_MOCK_H
16 #define OHOS_META_DATA_MANAGER_MOCK_H
17 
18 #include <gmock/gmock.h>
19 
20 #include "metadata/appid_meta_data.h"
21 #include "metadata/meta_data_manager.h"
22 #include "metadata/store_meta_data.h"
23 #include "metadata/strategy_meta_data.h"
24 
25 namespace OHOS::DistributedData {
26 class BMetaDataManager {
27 public:
28     virtual bool LoadMeta(const std::string &, Serializable &, bool) = 0;
29     virtual bool Sync(const std::vector<std::string> &, MetaDataManager::OnComplete, bool, bool) = 0;
30     BMetaDataManager() = default;
31     virtual ~BMetaDataManager() = default;
32     static inline std::shared_ptr<BMetaDataManager> metaDataManager = nullptr;
33 };
34 class MetaDataManagerMock : public BMetaDataManager {
35 public:
36     MOCK_METHOD(bool, LoadMeta, (const std::string &, Serializable &, bool), (override));
37     MOCK_METHOD(bool, Sync, (const std::vector<std::string> &, MetaDataManager::OnComplete, bool, bool), (override));
38 };
39 
40 template<class T> class BMetaData {
41 public:
42     virtual bool LoadMeta(const std::string &, std::vector<T> &, bool) = 0;
43     BMetaData() = default;
44     virtual ~BMetaData() = default;
45     static inline std::shared_ptr<BMetaData<T>> metaDataManager = nullptr;
46 };
47 template<class StoreMetaData> class MetaDataMock : public BMetaData<StoreMetaData> {
48 public:
49     MOCK_METHOD(bool, LoadMeta, (const std::string &, std::vector<StoreMetaData> &, bool), (override));
50 };
51 } // namespace OHOS::DistributedData
52 #endif //OHOS_META_DATA_MANAGER_MOCK_H
53