1060ff233Sopenharmony_ci/* 2060ff233Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License. 5060ff233Sopenharmony_ci * You may obtain a copy of the License at 6060ff233Sopenharmony_ci * 7060ff233Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8060ff233Sopenharmony_ci * 9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and 13060ff233Sopenharmony_ci * limitations under the License. 14060ff233Sopenharmony_ci */ 15060ff233Sopenharmony_ci 16060ff233Sopenharmony_ci#include "gtest/gtest.h" 17060ff233Sopenharmony_ci 18060ff233Sopenharmony_ci#include "softbus_ble_utils.h" 19060ff233Sopenharmony_ci#include "softbus_adapter_mem.h" 20060ff233Sopenharmony_ci#include "softbus_broadcast_type.h" 21060ff233Sopenharmony_ci#include "softbus_broadcast_utils.h" 22060ff233Sopenharmony_ci#include "softbus_error_code.h" 23060ff233Sopenharmony_ci#include <cstring> 24060ff233Sopenharmony_ci 25060ff233Sopenharmony_ciusing namespace testing::ext; 26060ff233Sopenharmony_ci 27060ff233Sopenharmony_cinamespace OHOS { 28060ff233Sopenharmony_ci 29060ff233Sopenharmony_ci/** 30060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_BtStatusToSoftBus 31060ff233Sopenharmony_ci * @tc.desc: test bt status convert to softbus status 32060ff233Sopenharmony_ci * @tc.type: FUNC 33060ff233Sopenharmony_ci * @tc.require: 1 34060ff233Sopenharmony_ci */ 35060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, BtStatusToSoftBus, TestSize.Level3) 36060ff233Sopenharmony_ci{ 37060ff233Sopenharmony_ci int32_t status = BtStatusToSoftBus(OHOS_BT_STATUS_SUCCESS); 38060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_SUCCESS); 39060ff233Sopenharmony_ci 40060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_FAIL); 41060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_FAIL); 42060ff233Sopenharmony_ci 43060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_NOT_READY); 44060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_NOT_READY); 45060ff233Sopenharmony_ci 46060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_NOMEM); 47060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_NOMEM); 48060ff233Sopenharmony_ci 49060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_BUSY); 50060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_BUSY); 51060ff233Sopenharmony_ci 52060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_DONE); 53060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_DONE); 54060ff233Sopenharmony_ci 55060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_UNSUPPORTED); 56060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_UNSUPPORTED); 57060ff233Sopenharmony_ci 58060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_PARM_INVALID); 59060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_PARM_INVALID); 60060ff233Sopenharmony_ci 61060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_UNHANDLED); 62060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_UNHANDLED); 63060ff233Sopenharmony_ci 64060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_AUTH_FAILURE); 65060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_AUTH_FAILURE); 66060ff233Sopenharmony_ci 67060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_RMT_DEV_DOWN); 68060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_RMT_DEV_DOWN); 69060ff233Sopenharmony_ci 70060ff233Sopenharmony_ci status = BtStatusToSoftBus(OHOS_BT_STATUS_AUTH_REJECTED); 71060ff233Sopenharmony_ci EXPECT_EQ(status, SOFTBUS_BC_STATUS_AUTH_REJECTED); 72060ff233Sopenharmony_ci} 73060ff233Sopenharmony_ci 74060ff233Sopenharmony_ci/** 75060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_SoftbusAdvParamToBt 76060ff233Sopenharmony_ci * @tc.desc: test softbus adv param convert to bt adv params 77060ff233Sopenharmony_ci * @tc.type: FUNC 78060ff233Sopenharmony_ci * @tc.require: 1 79060ff233Sopenharmony_ci */ 80060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, SoftbusAdvParamToBt, TestSize.Level3) 81060ff233Sopenharmony_ci{ 82060ff233Sopenharmony_ci SoftbusBroadcastParam softbusAdvParam = {}; 83060ff233Sopenharmony_ci softbusAdvParam.minInterval = 1; 84060ff233Sopenharmony_ci softbusAdvParam.maxInterval = 1; 85060ff233Sopenharmony_ci softbusAdvParam.advType = 1; 86060ff233Sopenharmony_ci softbusAdvParam.advFilterPolicy = 1; 87060ff233Sopenharmony_ci softbusAdvParam.ownAddrType = 1; 88060ff233Sopenharmony_ci softbusAdvParam.peerAddrType = 1; 89060ff233Sopenharmony_ci softbusAdvParam.channelMap = 1; 90060ff233Sopenharmony_ci softbusAdvParam.duration = 1; 91060ff233Sopenharmony_ci softbusAdvParam.txPower = 1; 92060ff233Sopenharmony_ci 93060ff233Sopenharmony_ci BleAdvParams bleAdvParams = {}; 94060ff233Sopenharmony_ci SoftbusAdvParamToBt(&softbusAdvParam, &bleAdvParams); 95060ff233Sopenharmony_ci 96060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.minInterval, softbusAdvParam.minInterval); 97060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.maxInterval, softbusAdvParam.maxInterval); 98060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.advType, softbusAdvParam.advType); 99060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.advFilterPolicy, softbusAdvParam.advFilterPolicy); 100060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.ownAddrType, softbusAdvParam.ownAddrType); 101060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.peerAddrType, softbusAdvParam.peerAddrType); 102060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.channelMap, softbusAdvParam.channelMap); 103060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.duration, softbusAdvParam.duration); 104060ff233Sopenharmony_ci EXPECT_EQ(bleAdvParams.txPower, softbusAdvParam.txPower); 105060ff233Sopenharmony_ci} 106060ff233Sopenharmony_ci 107060ff233Sopenharmony_ci/** 108060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_BtScanResultToSoftbus 109060ff233Sopenharmony_ci * @tc.desc: test bt scan result convert to softbus scan result 110060ff233Sopenharmony_ci * @tc.type: FUNC 111060ff233Sopenharmony_ci * @tc.require: 1 112060ff233Sopenharmony_ci */ 113060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, BtScanResultToSoftbus, TestSize.Level3) 114060ff233Sopenharmony_ci{ 115060ff233Sopenharmony_ci BtScanResultData btScanResult = {}; 116060ff233Sopenharmony_ci btScanResult.eventType = 1; 117060ff233Sopenharmony_ci btScanResult.dataStatus = 1; 118060ff233Sopenharmony_ci btScanResult.addrType = 1; 119060ff233Sopenharmony_ci btScanResult.primaryPhy = 1; 120060ff233Sopenharmony_ci btScanResult.secondaryPhy = 1; 121060ff233Sopenharmony_ci btScanResult.advSid = 1; 122060ff233Sopenharmony_ci btScanResult.txPower = 1; 123060ff233Sopenharmony_ci btScanResult.rssi = 1; 124060ff233Sopenharmony_ci 125060ff233Sopenharmony_ci SoftBusBcScanResult softbusScanResult = {}; 126060ff233Sopenharmony_ci BtScanResultToSoftbus(&btScanResult, &softbusScanResult); 127060ff233Sopenharmony_ci 128060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.eventType, btScanResult.eventType); 129060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.dataStatus, btScanResult.dataStatus); 130060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.addrType, btScanResult.addrType); 131060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.primaryPhy, btScanResult.primaryPhy); 132060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.secondaryPhy, btScanResult.secondaryPhy); 133060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.advSid, btScanResult.advSid); 134060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.txPower, btScanResult.txPower); 135060ff233Sopenharmony_ci EXPECT_EQ(softbusScanResult.rssi, btScanResult.rssi); 136060ff233Sopenharmony_ci} 137060ff233Sopenharmony_ci 138060ff233Sopenharmony_ci/** 139060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_SoftbusFilterToBt 140060ff233Sopenharmony_ci * @tc.desc: test softbus scan filter convert to bt scan filter 141060ff233Sopenharmony_ci * @tc.type: FUNC 142060ff233Sopenharmony_ci * @tc.require: 1 143060ff233Sopenharmony_ci */ 144060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, SoftbusFilterToBt, TestSize.Level3) 145060ff233Sopenharmony_ci{ 146060ff233Sopenharmony_ci SoftBusBcScanFilter softBusBcScanFilter = {}; 147060ff233Sopenharmony_ci softBusBcScanFilter.address = (int8_t *)"address"; 148060ff233Sopenharmony_ci softBusBcScanFilter.deviceName = (int8_t *)"deviceName"; 149060ff233Sopenharmony_ci softBusBcScanFilter.serviceUuid = 1; 150060ff233Sopenharmony_ci softBusBcScanFilter.serviceDataLength = 1; 151060ff233Sopenharmony_ci softBusBcScanFilter.manufactureId = 1; 152060ff233Sopenharmony_ci softBusBcScanFilter.manufactureDataLength = 1; 153060ff233Sopenharmony_ci 154060ff233Sopenharmony_ci BleScanNativeFilter bleScanNativeFilter = {}; 155060ff233Sopenharmony_ci SoftbusFilterToBt(&bleScanNativeFilter, &softBusBcScanFilter, 1); 156060ff233Sopenharmony_ci SoftBusFree(bleScanNativeFilter.serviceData); 157060ff233Sopenharmony_ci SoftBusFree(bleScanNativeFilter.serviceDataMask); 158060ff233Sopenharmony_ci 159060ff233Sopenharmony_ci EXPECT_EQ(bleScanNativeFilter.address, (char *)softBusBcScanFilter.address); 160060ff233Sopenharmony_ci EXPECT_EQ(bleScanNativeFilter.deviceName, (char *)softBusBcScanFilter.deviceName); 161060ff233Sopenharmony_ci EXPECT_EQ(bleScanNativeFilter.manufactureId, softBusBcScanFilter.manufactureId); 162060ff233Sopenharmony_ci EXPECT_EQ(bleScanNativeFilter.manufactureDataLength, softBusBcScanFilter.manufactureDataLength); 163060ff233Sopenharmony_ci} 164060ff233Sopenharmony_ci 165060ff233Sopenharmony_ci/** 166060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_FreeBtFilter 167060ff233Sopenharmony_ci * @tc.desc: test free bt scan filter 168060ff233Sopenharmony_ci * @tc.type: FUNC 169060ff233Sopenharmony_ci * @tc.require: 1 170060ff233Sopenharmony_ci */ 171060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, FreeBtFilter, TestSize.Level3) 172060ff233Sopenharmony_ci{ 173060ff233Sopenharmony_ci BleScanNativeFilter *bleScanNativeFilter = (BleScanNativeFilter *)calloc(1, sizeof(BleScanNativeFilter)); 174060ff233Sopenharmony_ci FreeBtFilter(bleScanNativeFilter, 1); 175060ff233Sopenharmony_ci} 176060ff233Sopenharmony_ci 177060ff233Sopenharmony_ci/** 178060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_DumpBleScanFilter 179060ff233Sopenharmony_ci * @tc.desc: test dump scan filter 180060ff233Sopenharmony_ci * @tc.type: FUNC 181060ff233Sopenharmony_ci * @tc.require: 1 182060ff233Sopenharmony_ci */ 183060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, DumpBleScanFilter, TestSize.Level3) 184060ff233Sopenharmony_ci{ 185060ff233Sopenharmony_ci BleScanNativeFilter *bleScanNativeFilter = (BleScanNativeFilter *)calloc(1, sizeof(BleScanNativeFilter)); 186060ff233Sopenharmony_ci DumpBleScanFilter(bleScanNativeFilter, 1); 187060ff233Sopenharmony_ci free(bleScanNativeFilter); 188060ff233Sopenharmony_ci} 189060ff233Sopenharmony_ci 190060ff233Sopenharmony_ci/** 191060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_GetBtScanMode 192060ff233Sopenharmony_ci * @tc.desc: test get bt scan mode 193060ff233Sopenharmony_ci * @tc.type: FUNC 194060ff233Sopenharmony_ci * @tc.require: 1 195060ff233Sopenharmony_ci */ 196060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, GetBtScanMode, TestSize.Level3) 197060ff233Sopenharmony_ci{ 198060ff233Sopenharmony_ci int32_t scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P2, SOFTBUS_BC_SCAN_WINDOW_P2); 199060ff233Sopenharmony_ci EXPECT_EQ(scanMode, OHOS_BLE_SCAN_MODE_OP_P2_60_3000); 200060ff233Sopenharmony_ci 201060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P10, SOFTBUS_BC_SCAN_WINDOW_P10); 202060ff233Sopenharmony_ci EXPECT_EQ(scanMode, OHOS_BLE_SCAN_MODE_OP_P10_30_300); 203060ff233Sopenharmony_ci 204060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P25, SOFTBUS_BC_SCAN_WINDOW_P25); 205060ff233Sopenharmony_ci EXPECT_EQ(scanMode, OHOS_BLE_SCAN_MODE_OP_P25_60_240); 206060ff233Sopenharmony_ci 207060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P100, SOFTBUS_BC_SCAN_WINDOW_P100); 208060ff233Sopenharmony_ci EXPECT_EQ(scanMode, OHOS_BLE_SCAN_MODE_OP_P100_1000_1000); 209060ff233Sopenharmony_ci 210060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P2, SOFTBUS_BC_SCAN_WINDOW_P100); 211060ff233Sopenharmony_ci EXPECT_EQ(scanMode, OHOS_BLE_SCAN_MODE_LOW_POWER); 212060ff233Sopenharmony_ci 213060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P2_FAST, SOFTBUS_BC_SCAN_WINDOW_P2_FAST); 214060ff233Sopenharmony_ci EXPECT_EQ(scanMode, OHOS_BLE_SCAN_MODE_OP_P2_30_1500); 215060ff233Sopenharmony_ci 216060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P2_FAST, SOFTBUS_BC_SCAN_WINDOW_P100); 217060ff233Sopenharmony_ci EXPECT_NE(scanMode, OHOS_BLE_SCAN_MODE_OP_P2_30_1500); 218060ff233Sopenharmony_ci 219060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P10, SOFTBUS_BC_SCAN_WINDOW_P100); 220060ff233Sopenharmony_ci EXPECT_NE(scanMode, OHOS_BLE_SCAN_MODE_OP_P10_30_300); 221060ff233Sopenharmony_ci 222060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P25, SOFTBUS_BC_SCAN_WINDOW_P100); 223060ff233Sopenharmony_ci EXPECT_NE(scanMode, OHOS_BLE_SCAN_MODE_OP_P25_60_240); 224060ff233Sopenharmony_ci 225060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P50, SOFTBUS_BC_SCAN_WINDOW_P100); 226060ff233Sopenharmony_ci EXPECT_NE(scanMode, OHOS_BLE_SCAN_MODE_OP_P50_30_60); 227060ff233Sopenharmony_ci 228060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P75, SOFTBUS_BC_SCAN_WINDOW_P100); 229060ff233Sopenharmony_ci EXPECT_NE(scanMode, OHOS_BLE_SCAN_MODE_OP_P75_30_40); 230060ff233Sopenharmony_ci 231060ff233Sopenharmony_ci scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P100, SOFTBUS_BC_SCAN_WINDOW_P75); 232060ff233Sopenharmony_ci EXPECT_NE(scanMode, OHOS_BLE_SCAN_MODE_OP_P75_30_40); 233060ff233Sopenharmony_ci} 234060ff233Sopenharmony_ci 235060ff233Sopenharmony_ci/** 236060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_AssembleAdvData 237060ff233Sopenharmony_ci * @tc.desc: test assemble ble adv data 238060ff233Sopenharmony_ci * @tc.type: FUNC 239060ff233Sopenharmony_ci * @tc.require: 1 240060ff233Sopenharmony_ci */ 241060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, AssembleAdvData, TestSize.Level3) 242060ff233Sopenharmony_ci{ 243060ff233Sopenharmony_ci SoftbusBroadcastData *data = (SoftbusBroadcastData *)calloc(1, sizeof(SoftbusBroadcastData)); 244060ff233Sopenharmony_ci data->isSupportFlag = true; 245060ff233Sopenharmony_ci data->flag = 1; 246060ff233Sopenharmony_ci SoftbusBroadcastPayload bcData; 247060ff233Sopenharmony_ci bcData.type = BROADCAST_DATA_TYPE_SERVICE; 248060ff233Sopenharmony_ci bcData.id = 1; 249060ff233Sopenharmony_ci uint8_t *payload = (uint8_t *)"00112233445566"; 250060ff233Sopenharmony_ci bcData.payloadLen = 15; 251060ff233Sopenharmony_ci bcData.payload = payload; 252060ff233Sopenharmony_ci data->bcData = bcData; 253060ff233Sopenharmony_ci uint16_t dataLen = 0; 254060ff233Sopenharmony_ci uint8_t *advData = AssembleAdvData(data, &dataLen); 255060ff233Sopenharmony_ci uint16_t expectedDataLen = (data->isSupportFlag) ? 256060ff233Sopenharmony_ci bcData.payloadLen + BC_HEAD_LEN : bcData.payloadLen + BC_HEAD_LEN - BC_FLAG_LEN; 257060ff233Sopenharmony_ci EXPECT_EQ(dataLen, expectedDataLen); 258060ff233Sopenharmony_ci EXPECT_NE(advData, nullptr); 259060ff233Sopenharmony_ci 260060ff233Sopenharmony_ci SoftBusFree(advData); 261060ff233Sopenharmony_ci free(data); 262060ff233Sopenharmony_ci} 263060ff233Sopenharmony_ci 264060ff233Sopenharmony_ci/** 265060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_AssembleRspData 266060ff233Sopenharmony_ci * @tc.desc: test assemble ble rsp data 267060ff233Sopenharmony_ci * @tc.type: FUNC 268060ff233Sopenharmony_ci * @tc.require: 1 269060ff233Sopenharmony_ci */ 270060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, AssembleRspData, TestSize.Level3) 271060ff233Sopenharmony_ci{ 272060ff233Sopenharmony_ci SoftbusBroadcastPayload rspData = {}; 273060ff233Sopenharmony_ci rspData.type = BROADCAST_DATA_TYPE_SERVICE; 274060ff233Sopenharmony_ci rspData.id = 1; 275060ff233Sopenharmony_ci uint8_t *payload = (uint8_t *)"00112233445566"; 276060ff233Sopenharmony_ci rspData.payloadLen = 15; 277060ff233Sopenharmony_ci rspData.payload = payload; 278060ff233Sopenharmony_ci uint16_t dataLen = 0; 279060ff233Sopenharmony_ci 280060ff233Sopenharmony_ci uint8_t *data = AssembleRspData(&rspData, &dataLen); 281060ff233Sopenharmony_ci EXPECT_NE(data, NULL); 282060ff233Sopenharmony_ci uint16_t expectedDataLen = rspData.payloadLen + RSP_HEAD_LEN; 283060ff233Sopenharmony_ci EXPECT_EQ(dataLen, expectedDataLen); 284060ff233Sopenharmony_ci SoftBusFree(data); 285060ff233Sopenharmony_ci} 286060ff233Sopenharmony_ci 287060ff233Sopenharmony_ci/** 288060ff233Sopenharmony_ci * @tc.name: SoftbusBleUtilsTest_ParseScanResult 289060ff233Sopenharmony_ci * @tc.desc: test parse ble scan result as softbus scan result 290060ff233Sopenharmony_ci * @tc.type: FUNC 291060ff233Sopenharmony_ci * @tc.require: 1 292060ff233Sopenharmony_ci */ 293060ff233Sopenharmony_ciHWTEST(SoftbusBleUtilsTest, ParseScanResult, TestSize.Level3) 294060ff233Sopenharmony_ci{ 295060ff233Sopenharmony_ci uint8_t *advData = (uint8_t *)"00112233445566"; 296060ff233Sopenharmony_ci uint8_t advLen = 23; 297060ff233Sopenharmony_ci SoftBusBcScanResult softBusBcScanResult = {}; 298060ff233Sopenharmony_ci int32_t ret = ParseScanResult(advData, advLen, &softBusBcScanResult); 299060ff233Sopenharmony_ci EXPECT_EQ(ret, SOFTBUS_OK); 300060ff233Sopenharmony_ci SoftBusFree(softBusBcScanResult.data.bcData.payload); 301060ff233Sopenharmony_ci SoftBusFree(softBusBcScanResult.data.rspData.payload); 302060ff233Sopenharmony_ci 303060ff233Sopenharmony_ci EXPECT_EQ(softBusBcScanResult.data.isSupportFlag, false); 304060ff233Sopenharmony_ci EXPECT_EQ(softBusBcScanResult.data.bcData.type, BROADCAST_DATA_TYPE_SERVICE); 305060ff233Sopenharmony_ci} 306060ff233Sopenharmony_ci 307060ff233Sopenharmony_ci} // namespace OHOS 308