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 DATA_COLLECTION_MOCK_H 17 #define DATA_COLLECTION_MOCK_H 18 19 #include "gmock/gmock.h" 20 #include "parcel.h" 21 22 #include <vector> 23 24 #include "lib_loader.h" 25 #include "i_collector_fwk.h" 26 #include "security_event.h" 27 28 namespace OHOS::Security::SecurityCollector { 29 class BaseDataCollection { 30 public: 31 virtual ~BaseDataCollection() = default; 32 virtual bool StartCollectors(const std::vector<int64_t>& eventIds, std::shared_ptr<ICollectorFwk> api) = 0; 33 virtual bool StopCollectors(const std::vector<int64_t>& eventIds) = 0; 34 virtual ErrorCode GetCollectorType(int64_t eventId, int32_t& collectorType) = 0; 35 virtual int32_t QuerySecurityEvent(const std::vector<SecurityEventRuler> rulers, 36 std::vector<SecurityEvent> &events) = 0; 37 virtual int32_t QuerySecurityEventConfig(std::string &result) = 0; 38 virtual bool Mute(const SecurityCollectorEventMuteFilter &filter, const std::string &sdkFlag) = 0; 39 virtual bool Unmute(const SecurityCollectorEventMuteFilter &filter, const std::string &sdkFlag) = 0; 40 virtual bool SecurityGuardSubscribeCollector(const std::vector<int64_t>& eventIds) = 0; 41 }; 42 43 class DataCollection : public BaseDataCollection { 44 public: GetInstance()45 static DataCollection &GetInstance() 46 { 47 static DataCollection instance; 48 return instance; 49 }; 50 DataCollection() = default; 51 ~DataCollection() override = default; 52 MOCK_METHOD2(StartCollectors, bool(const std::vector<int64_t>& eventIds, std::shared_ptr<ICollectorFwk> api)); 53 MOCK_METHOD1(StopCollectors, bool(const std::vector<int64_t>& eventIds)); 54 MOCK_METHOD2(GetCollectorType, ErrorCode(int64_t eventId, int32_t& collectorType)); 55 MOCK_METHOD2(QuerySecurityEvent, int32_t(const std::vector<SecurityEventRuler> rulers, 56 std::vector<SecurityEvent> &events)); 57 MOCK_METHOD1(QuerySecurityEventConfig, int32_t(std::string &result)); 58 MOCK_METHOD2(Mute, bool(const SecurityCollectorEventMuteFilter &filter, const std::string &sdkFlag)); 59 MOCK_METHOD2(Unmute, bool(const SecurityCollectorEventMuteFilter &filter, const std::string &sdkFlag)); 60 MOCK_METHOD1(SecurityGuardSubscribeCollector, bool(const std::vector<int64_t>& eventIds)); CloseLib()61 void CloseLib() {}; 62 }; 63 } 64 #endif // DATA_COLLECTION_MOCK_H