1 /* 2 * Copyright (c) 2023 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 SECURITY_GUARD_CONFIG_DATA_MANAGER_MOCK_H 17 #define SECURITY_GUARD_CONFIG_DATA_MANAGER_MOCK_H 18 19 #include "gmock/gmock.h" 20 #include "security_event_info.h" 21 #include "i_model_info.h" 22 23 namespace OHOS::Security::SecurityGuard { 24 class BaseConfigDataManager { 25 public: 26 virtual std::vector<EventCfg> GetAllEventConfigs() = 0; 27 virtual std::vector<uint32_t> GetAllModelIds() = 0; 28 virtual bool GetModelConfig(uint32_t modelId, ModelCfg &config) = 0; 29 virtual bool GetEventConfig(int64_t eventId, EventCfg &config) = 0; 30 virtual std::string GetTableFromEventId(int64_t eventId) = 0; 31 virtual std::vector<int64_t> GetAllEventIds() = 0; 32 virtual bool GetEventGroupConfig(const std::string &groupName, EventGroupCfg &config) = 0; 33 virtual bool GetIsBatchUpload(const std::string &groupName) = 0; 34 }; 35 36 class ConfigDataManager : public BaseConfigDataManager { 37 public: GetInstance()38 static ConfigDataManager &GetInstance() 39 { 40 static ConfigDataManager instance; 41 return instance; 42 }; 43 MOCK_METHOD0(GetAllModelIds, std::vector<uint32_t>()); 44 MOCK_METHOD2(GetModelConfig, bool(uint32_t modelId, ModelCfg &config)); 45 MOCK_METHOD2(GetEventConfig, bool(int64_t eventId, EventCfg &config)); 46 MOCK_METHOD1(GetTableFromEventId, std::string(int64_t eventId)); 47 MOCK_METHOD0(GetAllEventIds, std::vector<int64_t>()); 48 MOCK_METHOD0(GetAllEventConfigs, std::vector<EventCfg>()); 49 MOCK_METHOD2(GetEventGroupConfig, bool(const std::string &groupName, EventGroupCfg &config)); 50 MOCK_METHOD1(GetIsBatchUpload, bool(const std::string &groupName)); 51 }; 52 } // OHOS::Security::SecurityGuard 53 54 #endif // SECURITY_GUARD_CONFIG_DATA_MANAGER_MOCK_H