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 }; 38 39 class DataCollection : public BaseDataCollection { 40 public: GetInstance()41 static DataCollection &GetInstance() 42 { 43 static DataCollection instance; 44 return instance; 45 }; 46 DataCollection() = default; 47 ~DataCollection() override = default; 48 MOCK_METHOD2(StartCollectors, bool(const std::vector<int64_t>& eventIds, std::shared_ptr<ICollectorFwk> api)); 49 MOCK_METHOD1(StopCollectors, bool(const std::vector<int64_t>& eventIds)); 50 MOCK_METHOD2(GetCollectorType, ErrorCode(int64_t eventId, int32_t& collectorType)); 51 MOCK_METHOD2(QuerySecurityEvent, int32_t(const std::vector<SecurityEventRuler> rulers, 52 std::vector<SecurityEvent> &events)); 53 }; 54 } 55 #endif // DATA_COLLECTION_MOCK_H