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 SOFTBUS_BLE_MGR_MOCK_H 17 #define SOFTBUS_BLE_MGR_MOCK_H 18 19 #include "gmock/gmock.h" 20 21 #include "softbus_adapter_bt_common.h" 22 #include "softbus_ble_gatt.h" 23 #include "softbus_broadcast_adapter_interface.h" 24 #include "softbus_broadcast_manager.h" 25 #include "softbus_broadcast_mgr_utils.h" 26 27 class BleGattInterface { 28 public: 29 virtual void SoftbusBleAdapterInit() = 0; 30 virtual int32_t SoftBusAddBtStateListener(const SoftBusBtStateListener *listener, int32_t *listenerId) = 0; 31 virtual int32_t SoftBusRemoveBtStateListener(int32_t listenerId) = 0; 32 virtual int32_t BleAsyncCallbackDelayHelper(SoftBusLooper *looper, BleAsyncCallbackFunc callback, 33 void *para, uint64_t delayMillis) = 0; 34 virtual int32_t SoftBusCondWait(SoftBusCond *cond, SoftBusMutex *mutex, SoftBusSysTime *time) = 0; 35 }; 36 37 class ManagerMock : public BleGattInterface { 38 public: 39 static ManagerMock *GetMock(); 40 41 ManagerMock(); 42 ~ManagerMock(); 43 44 MOCK_METHOD(void, SoftbusBleAdapterInit, (), (override)); 45 MOCK_METHOD(int32_t, SoftBusAddBtStateListener, 46 (const SoftBusBtStateListener *listener, int32_t *listenerId), (override)); 47 MOCK_METHOD(int32_t, SoftBusRemoveBtStateListener, (int32_t listenerId), (override)); 48 MOCK_METHOD(int32_t, BleAsyncCallbackDelayHelper, 49 (SoftBusLooper *looper, BleAsyncCallbackFunc callback, 50 void *para, uint64_t delayMillis), (override)); 51 MOCK_METHOD(int32_t, SoftBusCondWait, 52 (SoftBusCond *cond, SoftBusMutex *mutex, SoftBusSysTime *time), (override)); 53 54 static const SoftbusBroadcastCallback *broadcastCallback; 55 static const SoftbusScanCallback *scanCallback; 56 static inline const SoftbusScanCallback *softbusScanCallback {}; 57 static inline const SoftbusBroadcastCallback *softbusBroadcastCallback {}; 58 59 private: 60 static ManagerMock *managerMock; 61 }; 62 63 #endif /* SOFTBUS_BLE_MGR_MOCK_H */