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 #ifndef SECURITY_GUARD_LIB_LOADER_MOCK_H 16 #define SECURITY_GUARD_LIB_LOADER_MOCK_H 17 18 #include <string> 19 #include <dlfcn.h> 20 #include "gmock/gmock.h" 21 #include "security_collector_define.h" 22 #include "i_collector.h" 23 24 namespace OHOS::Security::SecurityCollector { 25 class BaseLibLoader { 26 public: 27 BaseLibLoader() = default; 28 virtual ~BaseLibLoader() = default; 29 virtual ErrorCode LoadLib() = 0; 30 virtual ICollector* CallGetCollector() = 0; 31 }; 32 33 class LibLoader : public BaseLibLoader { 34 public: GetInstance()35 static LibLoader &GetInstance() 36 { 37 static LibLoader instance("test"); 38 return instance; 39 }; LibLoader(const std::string soPath)40 explicit LibLoader(const std::string soPath) {}; 41 ~LibLoader() override = default; 42 43 MOCK_METHOD0(LoadLib, ErrorCode()); 44 MOCK_METHOD0(CallGetCollector, ICollector*()); 45 }; 46 } 47 #endif // SECURITY_GUARD_LIB_LOADER_MOCK_H