mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-24 01:09:51 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
7f1a2d125c
@ -76,12 +76,6 @@ static int32_t AddDeviceJsonData(cJSON *data, const DeviceInfo *deviceInfo)
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
|
||||
item = cJSON_CreateString(deviceInfo->version);
|
||||
if (item == NULL || !cJSON_AddItemToObject(data, JSON_HICOM_VERSION, item)) {
|
||||
cJSON_Delete(item);
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
|
||||
item = cJSON_CreateNumber(deviceInfo->mode);
|
||||
if (item == NULL || !cJSON_AddItemToObject(data, JSON_REQUEST_MODE, item)) {
|
||||
cJSON_Delete(item);
|
||||
@ -217,15 +211,6 @@ static int32_t ParseDeviceJsonData(const cJSON *data, DeviceInfo *dev)
|
||||
}
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItemCaseSensitive(data, JSON_HICOM_VERSION);
|
||||
if (!cJSON_IsString(item) || !strlen(item->valuestring)) {
|
||||
DFINDER_LOGD(TAG, "Can't find hicom version");
|
||||
return NSTACKX_EOK;
|
||||
}
|
||||
if (strcpy_s(dev->version, sizeof(dev->version), item->valuestring) != EOK) {
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
|
||||
return NSTACKX_EOK;
|
||||
}
|
||||
|
||||
@ -428,18 +413,6 @@ static int JsonAddStr(cJSON *data, const char *key, const char *value)
|
||||
return NSTACKX_EOK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Service Discover JSON format
|
||||
* {
|
||||
* "deviceId":[device ID, string],
|
||||
* "deviceName":[device name, string],
|
||||
* "type": [device type, number],
|
||||
* "version":[hicom version, string],
|
||||
* "wlanIp":[WLAN IP address, string],
|
||||
* "capabilityBitmap":[bitmap, bitmap, bitmap, ...]
|
||||
* "coapUri":[coap uri for discover, string] <-- optional. When present, means it's broadcast request.
|
||||
* }
|
||||
*/
|
||||
static char *PrepareServiceDiscoverEx(const char *locaIpStr, uint8_t isBroadcast, uint8_t businessType)
|
||||
{
|
||||
cJSON *data = cJSON_CreateObject();
|
||||
|
@ -885,9 +885,8 @@ static int CheckLocalDeviceInfo(const NSTACKX_LocalDeviceInfo *localDeviceInfo)
|
||||
}
|
||||
|
||||
if (!StringHasEOF(localDeviceInfo->deviceId, sizeof(localDeviceInfo->deviceId)) ||
|
||||
!StringHasEOF(localDeviceInfo->name, sizeof(localDeviceInfo->name)) ||
|
||||
!StringHasEOF(localDeviceInfo->version, sizeof(localDeviceInfo->version))) {
|
||||
DFINDER_LOGE(TAG, "device id or device name or version is not ended");
|
||||
!StringHasEOF(localDeviceInfo->name, sizeof(localDeviceInfo->name))) {
|
||||
DFINDER_LOGE(TAG, "device id or device name is not ended");
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
|
||||
@ -910,7 +909,6 @@ static void DeviceInfoV2Init(NSTACKX_LocalDeviceInfoV2 *v2,
|
||||
{
|
||||
v2->name = localDeviceInfo->name;
|
||||
v2->deviceId = localDeviceInfo->deviceId;
|
||||
v2->version = localDeviceInfo->version;
|
||||
v2->deviceType = localDeviceInfo->deviceType;
|
||||
v2->businessType = localDeviceInfo->businessType;
|
||||
v2->hasDeviceHash = hasDeviceHash;
|
||||
@ -1013,8 +1011,7 @@ static void RegisterDeviceV2(void *arg)
|
||||
static int32_t RegisterDeviceWithType(const NSTACKX_LocalDeviceInfoV2 *localDeviceInfo, int registerType)
|
||||
{
|
||||
if (localDeviceInfo == NULL || localDeviceInfo->name == NULL ||
|
||||
localDeviceInfo->deviceId == NULL || localDeviceInfo->version == NULL ||
|
||||
localDeviceInfo->ifNums > NSTACKX_MAX_LOCAL_IFACE_NUM ||
|
||||
localDeviceInfo->deviceId == NULL || localDeviceInfo->ifNums > NSTACKX_MAX_LOCAL_IFACE_NUM ||
|
||||
(localDeviceInfo->ifNums != 0 && localDeviceInfo->localIfInfo == NULL) ||
|
||||
CheckInterfaceInfo(localDeviceInfo->localIfInfo, localDeviceInfo->ifNums) != NSTACKX_EOK) {
|
||||
DFINDER_LOGE(TAG, "invalid args");
|
||||
|
@ -241,10 +241,6 @@ int32_t SetReservedInfoFromDeviceInfo(NSTACKX_DeviceInfo *deviceList, const Devi
|
||||
if (!cJSON_AddStringToObject(item, "hwAccountHashVal", deviceInfo->deviceHash)) {
|
||||
goto L_END;
|
||||
}
|
||||
const char *ver = (strlen(deviceInfo->version) == 0) ? NSTACKX_DEFAULT_VER : deviceInfo->version;
|
||||
if (!cJSON_AddStringToObject(item, "version", ver)) {
|
||||
goto L_END;
|
||||
}
|
||||
if (SetServiceDataFromDeviceInfo(item, deviceInfo) != NSTACKX_EOK) {
|
||||
goto L_END;
|
||||
}
|
||||
@ -269,8 +265,7 @@ L_END:
|
||||
int32_t GetNotifyDeviceInfo(NSTACKX_DeviceInfo *notifyDevice, const DeviceInfo *deviceInfo)
|
||||
{
|
||||
if ((strcpy_s(notifyDevice->deviceId, sizeof(notifyDevice->deviceId), deviceInfo->deviceId) != EOK) ||
|
||||
(strcpy_s(notifyDevice->deviceName, sizeof(notifyDevice->deviceName), deviceInfo->deviceName) != EOK) ||
|
||||
(strcpy_s(notifyDevice->version, sizeof(notifyDevice->version), deviceInfo->version) != EOK)) {
|
||||
(strcpy_s(notifyDevice->deviceName, sizeof(notifyDevice->deviceName), deviceInfo->deviceName) != EOK)) {
|
||||
DFINDER_LOGE(TAG, "strcpy_s fails");
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
|
@ -438,12 +438,6 @@ static int CopyDeviceInfoV2(const NSTACKX_LocalDeviceInfoV2 *devInfo)
|
||||
}
|
||||
}
|
||||
|
||||
if (strcpy_s(g_localDevice.deviceInfo.version, sizeof(g_localDevice.deviceInfo.version),
|
||||
devInfo->version) != EOK) {
|
||||
DFINDER_LOGE(TAG, "copy version %s failed", devInfo->version);
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
|
||||
g_localDevice.deviceInfo.deviceType = devInfo->deviceType;
|
||||
g_localDevice.deviceInfo.businessType = devInfo->businessType;
|
||||
if (devInfo->hasDeviceHash) {
|
||||
|
@ -339,14 +339,6 @@ static int32_t UpdateDeviceInfoInner(DeviceInfo *curInfo, const DeviceInfo *newI
|
||||
*updated = NSTACKX_TRUE;
|
||||
}
|
||||
|
||||
if (strlen(newInfo->version) > 0 && strcmp(curInfo->version, newInfo->version) != 0) {
|
||||
if (strcpy_s(curInfo->version, sizeof(curInfo->version), newInfo->version) != EOK) {
|
||||
DFINDER_LOGE(TAG, "hicom version copy error");
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
*updated = NSTACKX_TRUE;
|
||||
}
|
||||
|
||||
if (UpdateCapabilityBitmap(curInfo, newInfo, updated) != NSTACKX_EOK) {
|
||||
DFINDER_LOGE(TAG, "UpdateCapabilityBitmap fails");
|
||||
return NSTACKX_EFAILED;
|
||||
|
@ -301,7 +301,6 @@ static int32_t UnpackLogToStr(DeviceInfo *dev, char *msg, uint32_t size)
|
||||
DUMP_MSG_ADD_CHECK(ret, msg, wroteLen, size, "deviceId: %s ", anonyDevId);
|
||||
DUMP_MSG_ADD_CHECK(ret, msg, wroteLen, size, "devicename: %s, ", dev->deviceName);
|
||||
DUMP_MSG_ADD_CHECK(ret, msg, wroteLen, size, "type: %u, ", dev->deviceType);
|
||||
DUMP_MSG_ADD_CHECK(ret, msg, wroteLen, size, "hicomversion: %s, ", dev->version);
|
||||
DUMP_MSG_ADD_CHECK(ret, msg, wroteLen, size, "mode: %s, ", GetModeTypeStr(dev->mode));
|
||||
DUMP_MSG_ADD_CHECK(ret, msg, wroteLen, size,
|
||||
"bType: %s, ", GetBusinessTypeStr(dev->businessType));
|
||||
|
@ -32,7 +32,6 @@ extern "C" {
|
||||
#define JSON_DEVICE_WLAN_IP "wlanIp"
|
||||
#define JSON_DEVICE_TYPE "type"
|
||||
#define JSON_DEVICE_TYPE_EXTERN "typeEx"
|
||||
#define JSON_HICOM_VERSION "hicomversion"
|
||||
#define JSON_REQUEST_MODE "mode"
|
||||
#define JSON_DEVICE_HASH "deviceHash"
|
||||
#define JSON_SERVICE_DATA "serviceData"
|
||||
|
@ -127,7 +127,6 @@ typedef struct DeviceInfo {
|
||||
/* Capability data */
|
||||
uint32_t capabilityBitmapNum;
|
||||
uint32_t capabilityBitmap[NSTACKX_MAX_CAPABILITY_NUM];
|
||||
char version[NSTACKX_MAX_HICOM_VERSION];
|
||||
uint8_t mode;
|
||||
uint8_t discoveryType;
|
||||
char deviceHash[DEVICE_HASH_LEN];
|
||||
|
@ -32,7 +32,6 @@ extern "C" {
|
||||
#define NSTACKX_MAX_IP_STRING_LEN 16
|
||||
#define NSTACKX_MAX_CAPABILITY_NUM 2
|
||||
#define NSTACKX_MAX_INTERFACE_NAME_LEN 16
|
||||
#define NSTACKX_MAX_HICOM_VERSION 16
|
||||
#define NSTACKX_MAX_SERVICE_DATA_LEN 64
|
||||
#define NSTACKX_MAX_EXTEND_SERVICE_DATA_LEN 128
|
||||
#ifndef NSTACKX_EXTEND_BUSINESSDATA
|
||||
@ -97,7 +96,6 @@ typedef struct NSTACKX_DeviceInfo {
|
||||
char networkName[NSTACKX_MAX_INTERFACE_NAME_LEN];
|
||||
uint8_t discoveryType;
|
||||
uint8_t businessType;
|
||||
char version[NSTACKX_MAX_HICOM_VERSION];
|
||||
char reservedInfo[NSTACKX_MAX_RESERVED_INFO_LEN];
|
||||
} NSTACKX_DeviceInfo;
|
||||
|
||||
@ -126,7 +124,6 @@ typedef struct {
|
||||
char networkName[NSTACKX_MAX_INTERFACE_NAME_LEN];
|
||||
uint8_t is5GHzBandSupported;
|
||||
uint32_t deviceType;
|
||||
char version[NSTACKX_MAX_HICOM_VERSION];
|
||||
uint8_t businessType;
|
||||
} NSTACKX_LocalDeviceInfo;
|
||||
|
||||
@ -169,7 +166,6 @@ typedef struct {
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *deviceId;
|
||||
const char *version;
|
||||
const NSTACKX_InterfaceInfo *localIfInfo;
|
||||
uint32_t ifNums;
|
||||
uint32_t deviceType;
|
||||
|
@ -304,16 +304,17 @@ static int32_t HbHandleLeaveLnn(void)
|
||||
static void HbDelaySetNormalScanParam(void *para)
|
||||
{
|
||||
(void)para;
|
||||
|
||||
if (g_hbConditionState.screenState == SOFTBUS_SCREEN_OFF) {
|
||||
LNN_LOGD(LNN_HEART_BEAT, "screen off, no need handle");
|
||||
return;
|
||||
LnnHeartbeatMediumParam param;
|
||||
(void)memset_s(¶m, sizeof(LnnHeartbeatMediumParam), 0, sizeof(LnnHeartbeatMediumParam));
|
||||
if (g_hbConditionState.screenState == SOFTBUS_SCREEN_OFF && !LnnIsLocalSupportBurstFeature()) {
|
||||
param.type = HEARTBEAT_TYPE_BLE_V1;
|
||||
param.info.ble.scanInterval = SOFTBUS_BC_SCAN_INTERVAL_P2;
|
||||
param.info.ble.scanWindow = SOFTBUS_BC_SCAN_WINDOW_P2;
|
||||
} else {
|
||||
param.type = HEARTBEAT_TYPE_BLE_V1;
|
||||
param.info.ble.scanInterval = SOFTBUS_BC_SCAN_INTERVAL_P10;
|
||||
param.info.ble.scanWindow = SOFTBUS_BC_SCAN_WINDOW_P10;
|
||||
}
|
||||
LnnHeartbeatMediumParam param = {
|
||||
.type = HEARTBEAT_TYPE_BLE_V1,
|
||||
.info.ble.scanInterval = SOFTBUS_BC_SCAN_INTERVAL_P10,
|
||||
.info.ble.scanWindow = SOFTBUS_BC_SCAN_WINDOW_P10,
|
||||
};
|
||||
LNN_LOGI(LNN_HEART_BEAT, "scanInterval=%{public}d, scanWindow=%{public}d", param.info.ble.scanInterval,
|
||||
param.info.ble.scanWindow);
|
||||
if (LnnSetMediumParamBySpecificType(¶m) != SOFTBUS_OK) {
|
||||
|
@ -72,7 +72,7 @@ static LnnHeartbeatStrategyManager g_hbStrategyMgr[] = {
|
||||
.onProcess = FixedPeriodSendStrategy,
|
||||
},
|
||||
[STRATEGY_HB_SEND_ADJUSTABLE_PERIOD] = {
|
||||
.supportType = HEARTBEAT_TYPE_BLE_V0,
|
||||
.supportType = HEARTBEAT_TYPE_BLE_V0 | HEARTBEAT_TYPE_BLE_V3,
|
||||
.onProcess = AdjustablePeriodSendStrategy,
|
||||
},
|
||||
[STRATEGY_HB_RECV_SINGLE] = {
|
||||
@ -670,7 +670,7 @@ static int32_t AdjustablePeriodSendStrategy(LnnHeartbeatFsm *hbFsm, void *obj)
|
||||
(void)memset_s(&mode, sizeof(GearMode), 0, sizeof(GearMode));
|
||||
LnnProcessSendOnceMsgPara *msgPara = (LnnProcessSendOnceMsgPara *)obj;
|
||||
|
||||
if (msgPara->hbType != HEARTBEAT_TYPE_BLE_V0 || msgPara->strategyType != STRATEGY_HB_SEND_ADJUSTABLE_PERIOD) {
|
||||
if ((msgPara->hbType & HEARTBEAT_TYPE_BLE_V0) == 0 || msgPara->strategyType != STRATEGY_HB_SEND_ADJUSTABLE_PERIOD) {
|
||||
LNN_LOGE(LNN_HEART_BEAT, "HB adjustable send get invaild strategy");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ static void NewBrBleDiscovered(const NodeInfo *oldInfo, NodeInfo *newInfo)
|
||||
LNN_LOGE(LNN_LEDGER, "LnnGetWiFiIp Fail!");
|
||||
return;
|
||||
}
|
||||
if (strcmp(ipAddr, DEFAULT_IP) == 0) {
|
||||
if (strcmp(ipAddr, DEFAULT_IP) == 0 || strcmp(ipAddr, LOCAL_IP) == 0) {
|
||||
LnnSetWiFiIp(newInfo, LnnGetWiFiIp(oldInfo));
|
||||
}
|
||||
|
||||
|
@ -950,8 +950,8 @@ static void BleDataReceived(ConnBleDataReceivedContext *ctx)
|
||||
}
|
||||
|
||||
if (ctx->dataLen < sizeof(ConnPktHead)) {
|
||||
CONN_LOGE(CONN_BLE, "the length of data is less than the length than the length of the header,"
|
||||
"connId=%{public}u, dataLength=%{public}u", ctx->connectionId, ctx->dataLen);
|
||||
CONN_LOGE(CONN_BLE, "dataLength(=%{public}u) is less than header size, connId=%{public}u",
|
||||
ctx->dataLen, ctx->connectionId);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -961,11 +961,6 @@ static void BleDataReceived(ConnBleDataReceivedContext *ctx)
|
||||
"Module=%{public}d, Seq=%{public}" PRId64 "", connection->connectionId, ctx->dataLen, head->flag,
|
||||
head->module, head->seq);
|
||||
uint32_t pktHeadLen = ConnGetHeadSize();
|
||||
if (ctx->dataLen <= pktHeadLen) {
|
||||
CONN_LOGE(CONN_BLE, "the length of data is less than the length than pktHeadLen, connId=%{public}u, "
|
||||
"dataLength=%{public}u, pktHeadLen=%{public}u", ctx->connectionId, ctx->dataLen, pktHeadLen);
|
||||
break;
|
||||
}
|
||||
if (head->module == MODULE_CONNECTION) {
|
||||
ReceivedControlData(connection, ctx->data + pktHeadLen, ctx->dataLen - pktHeadLen);
|
||||
} else if (head->module == MODULE_OLD_NEARBY) {
|
||||
@ -1551,14 +1546,13 @@ static void ConnectRequestFunc(SoftBusMessage *msg)
|
||||
if (g_bleManager.state->connectRequest == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BLE, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BLE, "obj is null");
|
||||
ConnBleConnectRequestContext *ctx = (ConnBleConnectRequestContext *)msg->obj;
|
||||
g_bleManager.state->connectRequest(ctx);
|
||||
}
|
||||
|
||||
static void ClientConnectedFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BLE, "msg is null");
|
||||
if (g_bleManager.state->clientConnected != NULL) {
|
||||
g_bleManager.state->clientConnected((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1578,14 +1572,13 @@ static void ClientConnectFailedFunc(SoftBusMessage *msg)
|
||||
if (g_bleManager.state->clientConnectFailed == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BLE, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BLE, "obj is null");
|
||||
BleStatusContext *ctx = (BleStatusContext *)(msg->obj);
|
||||
g_bleManager.state->clientConnectFailed(ctx->connectionId, ctx->status);
|
||||
}
|
||||
|
||||
static void ServerAcceptedFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BLE, "msg is null");
|
||||
if (g_bleManager.state->serverAccepted != NULL) {
|
||||
g_bleManager.state->serverAccepted((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1594,7 +1587,7 @@ static void ServerAcceptedFunc(SoftBusMessage *msg)
|
||||
|
||||
static void DataReceivedFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BLE, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BLE, "obj is null");
|
||||
ConnBleDataReceivedContext *ctx = (ConnBleDataReceivedContext *)msg->obj;
|
||||
if (g_bleManager.state->dataReceived == NULL) {
|
||||
SoftBusFree(ctx->data);
|
||||
@ -1609,14 +1602,13 @@ static void ConnectionClosedFunc(SoftBusMessage *msg)
|
||||
if (g_bleManager.state->connectionClosed == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BLE, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BLE, "obj is null");
|
||||
BleStatusContext *ctx = (BleStatusContext *)(msg->obj);
|
||||
g_bleManager.state->connectionClosed(ctx->connectionId, ctx->status);
|
||||
}
|
||||
|
||||
static void ConnectionResumeFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BLE, "msg is null");
|
||||
if (g_bleManager.state->connectionResume != NULL) {
|
||||
g_bleManager.state->connectionResume((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1625,7 +1617,6 @@ static void ConnectionResumeFunc(SoftBusMessage *msg)
|
||||
|
||||
static void DisconnectRequestFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BLE, "msg is null");
|
||||
if (g_bleManager.state->disconnectRequest != NULL) {
|
||||
g_bleManager.state->disconnectRequest((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1634,7 +1625,7 @@ static void DisconnectRequestFunc(SoftBusMessage *msg)
|
||||
|
||||
static void PreventTimeoutFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BLE, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BLE, "obj is null");
|
||||
if (g_bleManager.state->preventTimeout != NULL) {
|
||||
char *udid = (char *)msg->obj;
|
||||
g_bleManager.state->preventTimeout(udid);
|
||||
@ -1647,14 +1638,13 @@ static void ResetFunc(SoftBusMessage *msg)
|
||||
if (g_bleManager.state->reset == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BLE, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BLE, "obj is null");
|
||||
BleStatusContext *ctx = (BleStatusContext *)(msg->obj);
|
||||
g_bleManager.state->reset(ctx->status);
|
||||
}
|
||||
|
||||
static void KeepAliveTimeoutFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BLE, "msg is null");
|
||||
if (g_bleManager.state->keepAliveTimeout != NULL) {
|
||||
g_bleManager.state->keepAliveTimeout((uint32_t)msg->arg1, (uint32_t)msg->arg2);
|
||||
return;
|
||||
|
@ -811,8 +811,8 @@ static void ClientConnectTimeoutOnConnectingState(uint32_t connectionId, const c
|
||||
static void DataReceived(ConnBrDataReceivedContext *ctx)
|
||||
{
|
||||
if (ctx->dataLen < sizeof(ConnPktHead)) {
|
||||
CONN_LOGE(CONN_BR, "the length of data is less than the length than the length of the header,"
|
||||
"connId=%{public}u, dataLength=%{public}u", ctx->connectionId, ctx->dataLen);
|
||||
CONN_LOGE(CONN_BR, "dataLength(=%{public}u) is less than header size, connId=%{public}u",
|
||||
ctx->dataLen, ctx->connectionId);
|
||||
SoftBusFree(ctx->data);
|
||||
return;
|
||||
}
|
||||
@ -828,15 +828,8 @@ static void DataReceived(ConnBrDataReceivedContext *ctx)
|
||||
}
|
||||
CONN_LOGD(CONN_BR, "connId=%{public}u, Len=%{public}u, Flg=%{public}d, Module=%{public}d, Seq=%{public}" PRId64 "",
|
||||
ctx->connectionId, ctx->dataLen, head->flag, head->module, head->seq);
|
||||
uint32_t pktHeadLen = ConnGetHeadSize();
|
||||
if (ctx->dataLen <= pktHeadLen) {
|
||||
CONN_LOGE(CONN_BR, "the length of data is less than the length than pktHeadLen, connId=%{public}u, "
|
||||
"dataLength=%{public}u, pktHeadLen=%{public}u", ctx->connectionId, ctx->dataLen, pktHeadLen);
|
||||
SoftBusFree(ctx->data);
|
||||
return;
|
||||
}
|
||||
if (head->module == MODULE_CONNECTION) {
|
||||
ReceivedControlData(connection, ctx->data + pktHeadLen, ctx->dataLen - pktHeadLen);
|
||||
ReceivedControlData(connection, ctx->data + ConnGetHeadSize(), ctx->dataLen - ConnGetHeadSize());
|
||||
} else if (head->module == MODULE_NIP_BR_CHANNEL && head->seq == (int64_t)BR_NIP_SEQ) {
|
||||
NipRecvDataFromBr(ctx->connectionId, (char *)ctx->data, (int32_t)(ctx->dataLen));
|
||||
} else {
|
||||
@ -1102,14 +1095,13 @@ static void ConnectRequestFunc(SoftBusMessage *msg)
|
||||
if (g_brManager.state->connectRequest == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BR, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null");
|
||||
ConnBrConnectRequestContext *ctx = (ConnBrConnectRequestContext *)msg->obj;
|
||||
g_brManager.state->connectRequest(ctx);
|
||||
}
|
||||
|
||||
static void ClientConnectedFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BR, "msg is null");
|
||||
if (g_brManager.state->clientConnected != NULL) {
|
||||
g_brManager.state->clientConnected((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1118,7 +1110,7 @@ static void ClientConnectedFunc(SoftBusMessage *msg)
|
||||
|
||||
static void ClientConnectTimeoutFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BR, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null");
|
||||
if (g_brManager.state->clientConnectTimeout != NULL) {
|
||||
g_brManager.state->clientConnectTimeout((uint32_t)msg->arg1, (char *)msg->obj);
|
||||
return;
|
||||
@ -1130,14 +1122,13 @@ static void ClientConnectFailedFunc(SoftBusMessage *msg)
|
||||
if (g_brManager.state->clientConnectFailed == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BR, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null");
|
||||
ErrorContext *ctx = (ErrorContext *)(msg->obj);
|
||||
g_brManager.state->clientConnectFailed(ctx->connectionId, ctx->error);
|
||||
}
|
||||
|
||||
static void ServerAcceptedFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BR, "msg is null");
|
||||
if (g_brManager.state->serverAccepted != NULL) {
|
||||
g_brManager.state->serverAccepted((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1146,7 +1137,7 @@ static void ServerAcceptedFunc(SoftBusMessage *msg)
|
||||
|
||||
static void DataReceivedFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BR, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null");
|
||||
ConnBrDataReceivedContext *ctx = (ConnBrDataReceivedContext *)msg->obj;
|
||||
if (g_brManager.state->dataReceived == NULL) {
|
||||
SoftBusFree(ctx->data);
|
||||
@ -1161,14 +1152,13 @@ static void ConnectionExceptionFunc(SoftBusMessage *msg)
|
||||
if (g_brManager.state->connectionException == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BR, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null");
|
||||
ErrorContext *ctx = (ErrorContext *)(msg->obj);
|
||||
g_brManager.state->connectionException(ctx->connectionId, ctx->error);
|
||||
}
|
||||
|
||||
static void ConnectionResumeFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BR, "msg is null");
|
||||
if (g_brManager.state->connectionResume != NULL) {
|
||||
g_brManager.state->connectionResume((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1177,7 +1167,6 @@ static void ConnectionResumeFunc(SoftBusMessage *msg)
|
||||
|
||||
static void DisconnectRequestFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL, CONN_BR, "msg is null");
|
||||
if (g_brManager.state->disconnectRequest != NULL) {
|
||||
g_brManager.state->disconnectRequest((uint32_t)msg->arg1);
|
||||
return;
|
||||
@ -1186,7 +1175,7 @@ static void DisconnectRequestFunc(SoftBusMessage *msg)
|
||||
|
||||
static void UnpendFunc(SoftBusMessage *msg)
|
||||
{
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BR, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null");
|
||||
if (g_brManager.state->unpend != NULL) {
|
||||
g_brManager.state->unpend((const char *)msg->obj);
|
||||
return;
|
||||
@ -1198,7 +1187,7 @@ static void ResetFunc(SoftBusMessage *msg)
|
||||
if (g_brManager.state->reset == NULL) {
|
||||
return;
|
||||
}
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg != NULL && msg->obj != NULL, CONN_BR, "msg is null or obj is null");
|
||||
CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null");
|
||||
ErrorContext *ctx = (ErrorContext *)(msg->obj);
|
||||
g_brManager.state->reset(ctx->error);
|
||||
}
|
||||
|
@ -437,8 +437,6 @@ static int32_t SetLocalDeviceInfo(void)
|
||||
g_localDeviceInfo->businessType = (uint8_t)NSTACKX_BUSINESS_TYPE_NULL;
|
||||
if (LnnGetLocalStrInfo(STRING_KEY_WLAN_IP, g_localDeviceInfo->localIfInfo[0].networkIpAddr,
|
||||
sizeof(g_localDeviceInfo->localIfInfo[0].networkIpAddr)) != SOFTBUS_OK ||
|
||||
LnnGetLocalStrInfo(STRING_KEY_HICE_VERSION, g_localDeviceInfo->version, sizeof(g_localDeviceInfo->version)) !=
|
||||
SOFTBUS_OK ||
|
||||
LnnGetLocalStrInfo(STRING_KEY_NET_IF_NAME, g_localDeviceInfo->localIfInfo[0].networkName,
|
||||
sizeof(g_localDeviceInfo->localIfInfo[0].networkName)) != SOFTBUS_OK) {
|
||||
DISC_LOGE(DISC_COAP, "get local device info from lnn failed.");
|
||||
@ -630,7 +628,6 @@ static int32_t NstackxLocalDevInfoDump(int fd)
|
||||
SOFTBUS_DPRINTF(fd, "networkName : %s\n", g_localDeviceInfo->networkName);
|
||||
SOFTBUS_DPRINTF(fd, "is5GHzBandSupported : %d\n", g_localDeviceInfo->is5GHzBandSupported);
|
||||
SOFTBUS_DPRINTF(fd, "deviceType : %d\n", g_localDeviceInfo->deviceType);
|
||||
SOFTBUS_DPRINTF(fd, "version : %s\n", g_localDeviceInfo->version);
|
||||
SOFTBUS_DPRINTF(fd, "businessType : %d\n", g_localDeviceInfo->businessType);
|
||||
|
||||
return SOFTBUS_OK;
|
||||
|
@ -47,6 +47,7 @@ OHOS::sptr<OHOS::IRemoteObject> g_oldServerProxy = nullptr;
|
||||
OHOS::sptr<OHOS::IRemoteObject::DeathRecipient> g_clientDeath = nullptr;
|
||||
std::mutex g_mutex;
|
||||
constexpr uint32_t WAIT_SERVER_INTERVAL = 50;
|
||||
constexpr uint32_t SOFTBUS_MAX_RETRY_TIMES = 25;
|
||||
uint32_t g_getSystemAbilityId = 2;
|
||||
uint32_t g_printRequestFailedCount = 0;
|
||||
constexpr int32_t RANDOM_RANGE_MAX = 501; // range of random numbers is (0, 500ms)
|
||||
@ -241,8 +242,13 @@ int ClientRegisterService(const char *pkgName)
|
||||
COMM_LOGE(COMM_SDK, "serverProxyFrame is nullptr!");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
int sleepCnt = 0;
|
||||
while (serverProxyFrame->SoftbusRegisterService(pkgName, nullptr) != SOFTBUS_OK) {
|
||||
SoftBusSleepMs(WAIT_SERVER_READY_INTERVAL);
|
||||
sleepCnt++;
|
||||
if (sleepCnt >= SOFTBUS_MAX_RETRY_TIMES) {
|
||||
return SOFTBUS_SERVER_NOT_INIT;
|
||||
}
|
||||
}
|
||||
|
||||
COMM_LOGD(COMM_SDK, "softbus server register service success! pkgName=%{public}s", pkgName);
|
||||
|
@ -33,13 +33,13 @@ public:
|
||||
this->identifier = identifier;
|
||||
}
|
||||
|
||||
bool Update(int idParam)
|
||||
bool Update(int32_t idParam)
|
||||
{
|
||||
this->id = idParam;
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int idParam)
|
||||
testing::AssertionResult Expect(int32_t idParam)
|
||||
{
|
||||
testing::AssertionResult result = testing::AssertionSuccess();
|
||||
if (this->id != idParam) {
|
||||
@ -53,14 +53,14 @@ protected:
|
||||
// static c string
|
||||
const char *identifier;
|
||||
private:
|
||||
int id;
|
||||
int32_t id;
|
||||
};
|
||||
|
||||
class StRecordCtx : public RecordCtx {
|
||||
public:
|
||||
explicit StRecordCtx(const char *identifier) : RecordCtx(identifier), st(-1) {}
|
||||
|
||||
bool Update(int id, int stParam)
|
||||
bool Update(int32_t id, int32_t stParam)
|
||||
{
|
||||
if (!RecordCtx::Update(id)) {
|
||||
return false;
|
||||
@ -69,7 +69,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int id, int stParam)
|
||||
testing::AssertionResult Expect(int32_t id, int32_t stParam)
|
||||
{
|
||||
auto result = RecordCtx::Expect(id);
|
||||
if (!result) {
|
||||
@ -86,7 +86,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
int st;
|
||||
int32_t st;
|
||||
};
|
||||
|
||||
class BtAddrRecordCtx : public StRecordCtx {
|
||||
@ -96,7 +96,7 @@ public:
|
||||
Reset();
|
||||
}
|
||||
|
||||
bool Update(int id, const SoftBusBtAddr *addr, int st = 0)
|
||||
bool Update(int32_t id, const SoftBusBtAddr *addr, int32_t st = 0)
|
||||
{
|
||||
if (!StRecordCtx::Update(id, st)) {
|
||||
return false;
|
||||
@ -105,7 +105,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int id, SoftBusBtAddr *addrParam, int st = 0)
|
||||
testing::AssertionResult Expect(int32_t id, SoftBusBtAddr *addrParam, int32_t st = 0)
|
||||
{
|
||||
auto result = StRecordCtx::Expect(id, st);
|
||||
if (!result) {
|
||||
@ -132,7 +132,7 @@ class IntRecordCtx : public StRecordCtx {
|
||||
public:
|
||||
explicit IntRecordCtx(const char *identifier) : StRecordCtx(identifier), val(-1) {}
|
||||
|
||||
bool Update(int id, int st, int valParam)
|
||||
bool Update(int32_t id, int32_t st, int32_t valParam)
|
||||
{
|
||||
if (!StRecordCtx::Update(id, st)) {
|
||||
return false;
|
||||
@ -141,14 +141,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int id, int st, int valParam)
|
||||
testing::AssertionResult Expect(int32_t id, int32_t st, int32_t valParam)
|
||||
{
|
||||
auto result = StRecordCtx::Expect(id, st);
|
||||
if (!result) {
|
||||
goto ClEANUP;
|
||||
}
|
||||
if (this->val != valParam) {
|
||||
result = testing::AssertionFailure() << identifier << " is call by unexpectedly int value,"
|
||||
result = testing::AssertionFailure() << identifier << " is call by unexpectedly int32_t value,"
|
||||
<< "want: " << valParam << ", actual: " << this->val;
|
||||
} else {
|
||||
result = testing::AssertionSuccess();
|
||||
@ -158,7 +158,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
int val;
|
||||
int32_t val;
|
||||
};
|
||||
|
||||
#endif
|
@ -26,13 +26,13 @@ BtGapCallBacks *MockBluetooth::btGapCallback = nullptr;
|
||||
BtGattCallbacks *MockBluetooth::btGattCallback = nullptr;
|
||||
BleScanCallbacks *MockBluetooth::bleScanCallback = nullptr;
|
||||
|
||||
static int ActionGapRegisterCallbacks(BtGapCallBacks *func)
|
||||
static int32_t ActionGapRegisterCallbacks(BtGapCallBacks *func)
|
||||
{
|
||||
MockBluetooth::btGapCallback = func;
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static int ActionBleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
static int32_t ActionBleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
{
|
||||
MockBluetooth::btGattCallback = func;
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
@ -81,160 +81,161 @@ bool SetLocalName(unsigned char *localName, unsigned char length)
|
||||
return MockBluetooth::GetMocker()->SetLocalName(localName, length);
|
||||
}
|
||||
|
||||
int GapRegisterCallbacks(BtGapCallBacks *func)
|
||||
int32_t GapRegisterCallbacks(BtGapCallBacks *func)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->GapRegisterCallbacks(func);
|
||||
}
|
||||
|
||||
bool PairRequestReply(const BdAddr *bdAddr, int transport, bool accept)
|
||||
bool PairRequestReply(const BdAddr *bdAddr, int32_t transport, bool accept)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->PairRequestReply(bdAddr, transport, accept);
|
||||
}
|
||||
|
||||
bool SetDevicePairingConfirmation(const BdAddr *bdAddr, int transport, bool accept)
|
||||
bool SetDevicePairingConfirmation(const BdAddr *bdAddr, int32_t transport, bool accept)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->SetDevicePairingConfirmation(bdAddr, transport, accept);
|
||||
}
|
||||
|
||||
int BleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
int32_t BleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattRegisterCallbacks(func);
|
||||
}
|
||||
|
||||
int BleStartScanEx(int scannerId, BleScanConfigs *configs, BleScanNativeFilter *filter, unsigned int filterSize)
|
||||
int32_t BleStartScanEx(int32_t scannerId, BleScanConfigs *configs, BleScanNativeFilter *filter, unsigned int filterSize)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleStartScanEx(scannerId, configs, filter, filterSize);
|
||||
}
|
||||
|
||||
int BleStopScan(int scannerId)
|
||||
int32_t BleStopScan(int32_t scannerId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleStopScan(scannerId);
|
||||
}
|
||||
|
||||
int BleStartAdvEx(int *advId, const StartAdvRawData rawData, BleAdvParams advParam)
|
||||
int32_t BleStartAdvEx(int32_t *advId, const StartAdvRawData rawData, BleAdvParams advParam)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleStartAdvEx(advId, rawData, advParam);
|
||||
}
|
||||
|
||||
int BleStopAdv(int advId)
|
||||
int32_t BleStopAdv(int32_t advId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleStopAdv(advId);
|
||||
}
|
||||
|
||||
int BleGattcRegister(BtUuid appUuid)
|
||||
int32_t BleGattcRegister(BtUuid appUuid)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcRegister(appUuid);
|
||||
}
|
||||
|
||||
int BleGattcConnect(
|
||||
int clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport)
|
||||
int32_t BleGattcConnect(
|
||||
int32_t clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcConnect(clientId, func, bdAddr, isAutoConnect, transport);
|
||||
}
|
||||
|
||||
int BleGattcDisconnect(int clientId)
|
||||
int32_t BleGattcDisconnect(int32_t clientId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcDisconnect(clientId);
|
||||
}
|
||||
|
||||
int BleGattcSearchServices(int clientId)
|
||||
int32_t BleGattcSearchServices(int32_t clientId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcSearchServices(clientId);
|
||||
}
|
||||
|
||||
bool BleGattcGetService(int clientId, BtUuid serviceUuid)
|
||||
bool BleGattcGetService(int32_t clientId, BtUuid serviceUuid)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcGetService(clientId, serviceUuid);
|
||||
}
|
||||
|
||||
int BleGattcRegisterNotification(int clientId, BtGattCharacteristic characteristic, bool enable)
|
||||
int32_t BleGattcRegisterNotification(int32_t clientId, BtGattCharacteristic characteristic, bool enable)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcRegisterNotification(clientId, characteristic, enable);
|
||||
}
|
||||
|
||||
int BleGattcConfigureMtuSize(int clientId, int mtuSize)
|
||||
int32_t BleGattcConfigureMtuSize(int32_t clientId, int32_t mtuSize)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcConfigureMtuSize(clientId, mtuSize);
|
||||
}
|
||||
|
||||
int BleGattcWriteCharacteristic(
|
||||
int clientId, BtGattCharacteristic characteristic, BtGattWriteType writeType, int len, const char *value)
|
||||
int32_t BleGattcWriteCharacteristic(
|
||||
int32_t clientId, BtGattCharacteristic characteristic, BtGattWriteType writeType, int32_t len, const char *value)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcWriteCharacteristic(clientId, characteristic, writeType, len, value);
|
||||
}
|
||||
|
||||
int BleGattcUnRegister(int clientId)
|
||||
int32_t BleGattcUnRegister(int32_t clientId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcUnRegister(clientId);
|
||||
}
|
||||
|
||||
int BleGattcSetFastestConn(int clientId, bool fastestConnFlag)
|
||||
int32_t BleGattcSetFastestConn(int32_t clientId, bool fastestConnFlag)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcSetFastestConn(clientId, fastestConnFlag);
|
||||
}
|
||||
|
||||
int BleGattcSetPriority(int clientId, const BdAddr *bdAddr, BtGattPriority priority)
|
||||
int32_t BleGattcSetPriority(int32_t clientId, const BdAddr *bdAddr, BtGattPriority priority)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcSetPriority(clientId, bdAddr, priority);
|
||||
}
|
||||
|
||||
int BleGattsRegisterCallbacks(BtGattServerCallbacks *func)
|
||||
int32_t BleGattsRegisterCallbacks(BtGattServerCallbacks *func)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsRegisterCallbacks(func);
|
||||
}
|
||||
|
||||
int BleGattsRegister(BtUuid appUuid)
|
||||
int32_t BleGattsRegister(BtUuid appUuid)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsRegister(appUuid);
|
||||
}
|
||||
|
||||
int BleGattsAddService(int serverId, BtUuid srvcUuid, bool isPrimary, int number)
|
||||
int32_t BleGattsAddService(int32_t serverId, BtUuid srvcUuid, bool isPrimary, int32_t number)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsAddService(serverId, srvcUuid, isPrimary, number);
|
||||
}
|
||||
|
||||
int BleGattsUnRegister(int serverId)
|
||||
int32_t BleGattsUnRegister(int32_t serverId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsUnRegister(serverId);
|
||||
}
|
||||
|
||||
int BleGattsAddCharacteristic(int serverId, int srvcHandle, BtUuid characUuid, int properties, int permissions)
|
||||
int32_t BleGattsAddCharacteristic(int32_t serverId, int32_t srvcHandle,
|
||||
BtUuid characUuid, int32_t properties, int32_t permissions)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsAddCharacteristic(
|
||||
serverId, srvcHandle, characUuid, properties, permissions);
|
||||
}
|
||||
|
||||
int BleGattsAddDescriptor(int serverId, int srvcHandle, BtUuid descUuid, int permissions)
|
||||
int32_t BleGattsAddDescriptor(int32_t serverId, int32_t srvcHandle, BtUuid descUuid, int32_t permissions)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsAddDescriptor(serverId, srvcHandle, descUuid, permissions);
|
||||
}
|
||||
|
||||
int BleGattsStartService(int serverId, int srvcHandle)
|
||||
int32_t BleGattsStartService(int32_t serverId, int32_t srvcHandle)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsStartService(serverId, srvcHandle);
|
||||
}
|
||||
|
||||
int BleGattsStopService(int serverId, int srvcHandle)
|
||||
int32_t BleGattsStopService(int32_t serverId, int32_t srvcHandle)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsStopService(serverId, srvcHandle);
|
||||
}
|
||||
|
||||
int BleGattsDeleteService(int serverId, int srvcHandle)
|
||||
int32_t BleGattsDeleteService(int32_t serverId, int32_t srvcHandle)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsDeleteService(serverId, srvcHandle);
|
||||
}
|
||||
|
||||
int BleGattsDisconnect(int serverId, BdAddr bdAddr, int connId)
|
||||
int32_t BleGattsDisconnect(int32_t serverId, BdAddr bdAddr, int32_t connId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsDisconnect(serverId, bdAddr, connId);
|
||||
}
|
||||
|
||||
int BleGattsSendResponse(int serverId, GattsSendRspParam *param)
|
||||
int32_t BleGattsSendResponse(int32_t serverId, GattsSendRspParam *param)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsSendResponse(serverId, param);
|
||||
}
|
||||
|
||||
int BleGattsSendIndication(int serverId, GattsSendIndParam *param)
|
||||
int32_t BleGattsSendIndication(int32_t serverId, GattsSendIndParam *param)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsSendIndication(serverId, param);
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,12 @@ static int32_t g_advId = 0;
|
||||
static int32_t g_listenerId = 0;
|
||||
static void ActionOfSoftbusBleAdapterInit(void);
|
||||
|
||||
int ActionOfSoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
int32_t ActionOfSoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
{
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int ActionOfSoftBusRemoveBtStateListener(int listenerId)
|
||||
int32_t ActionOfSoftBusRemoveBtStateListener(int32_t listenerId)
|
||||
{
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -69,12 +69,12 @@ static int32_t MockDeInit(void)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int SoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
int32_t SoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
{
|
||||
return ManagerMock::GetMock()->SoftBusAddBtStateListener(listener);
|
||||
}
|
||||
|
||||
int SoftBusRemoveBtStateListener(int listenerId)
|
||||
int32_t SoftBusRemoveBtStateListener(int32_t listenerId)
|
||||
{
|
||||
return ManagerMock::GetMock()->SoftBusRemoveBtStateListener(listenerId);
|
||||
}
|
||||
|
@ -26,8 +26,8 @@
|
||||
class BleGattInterface {
|
||||
public:
|
||||
virtual void SoftbusBleAdapterInit() = 0;
|
||||
virtual int SoftBusAddBtStateListener(const SoftBusBtStateListener *listener) = 0;
|
||||
virtual int SoftBusRemoveBtStateListener(int listenerId) = 0;
|
||||
virtual int32_t SoftBusAddBtStateListener(const SoftBusBtStateListener *listener) = 0;
|
||||
virtual int32_t SoftBusRemoveBtStateListener(int32_t listenerId) = 0;
|
||||
};
|
||||
|
||||
class ManagerMock : public BleGattInterface {
|
||||
@ -39,7 +39,7 @@ public:
|
||||
|
||||
MOCK_METHOD(void, SoftbusBleAdapterInit, (), (override));
|
||||
MOCK_METHOD(int, SoftBusAddBtStateListener, (const SoftBusBtStateListener *listener), (override));
|
||||
MOCK_METHOD(int, SoftBusRemoveBtStateListener, (int listenerId), (override));
|
||||
MOCK_METHOD(int, SoftBusRemoveBtStateListener, (int32_t listenerId), (override));
|
||||
|
||||
static const SoftbusBroadcastCallback *broadcastCallback;
|
||||
static const SoftbusScanCallback *scanCallback;
|
||||
|
@ -99,7 +99,7 @@ static BcScanFilter *GetBcScanFilter(void)
|
||||
{
|
||||
unsigned char serviceData[] = {0x04, 0x05, 0x90};
|
||||
unsigned char serviceDataMask[] = {0xFF, 0xFF, 0xFF};
|
||||
int serviceDataLength = sizeof(serviceData);
|
||||
int32_t serviceDataLength = sizeof(serviceData);
|
||||
|
||||
BcScanFilter *filter = static_cast<BcScanFilter *>(SoftBusCalloc(sizeof(BcScanFilter)));
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(filter != nullptr, nullptr, DISC_TEST, "malloc filter failed");
|
||||
@ -128,41 +128,41 @@ EXIT:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void BleBcEnableCallback(int channel, int status)
|
||||
static void BleBcEnableCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
DISC_LOGI(DISC_TEST, "channel=%{public}d, status=%{public}d", channel, status);
|
||||
}
|
||||
|
||||
static void BleBcDisableCallback(int channel, int status)
|
||||
static void BleBcDisableCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
DISC_LOGI(DISC_TEST, "channel=%{public}d, status=%{public}d", channel, status);
|
||||
}
|
||||
|
||||
static void BleBcUpdateCallback(int channel, int status)
|
||||
static void BleBcUpdateCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
DISC_LOGI(DISC_TEST, "channel=%{public}d, status=%{public}d", channel, status);
|
||||
}
|
||||
|
||||
static void BleBcDataCallback(int channel, int status)
|
||||
static void BleBcDataCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
DISC_LOGI(DISC_TEST, "channel=%{public}d, status=%{public}d", channel, status);
|
||||
}
|
||||
|
||||
static void BleOnScanStart(int listenerId, int status)
|
||||
static void BleOnScanStart(int32_t listenerId, int32_t status)
|
||||
{
|
||||
(void)listenerId;
|
||||
(void)status;
|
||||
DISC_LOGI(DISC_TEST, "BleOnScanStart");
|
||||
}
|
||||
|
||||
static void BleOnScanStop(int listenerId, int status)
|
||||
static void BleOnScanStop(int32_t listenerId, int32_t status)
|
||||
{
|
||||
(void)listenerId;
|
||||
(void)status;
|
||||
DISC_LOGI(DISC_TEST, "BleOnScanStop");
|
||||
}
|
||||
|
||||
static void BleScanResultCallback(int listenerId, const BroadcastReportInfo *reportInfo)
|
||||
static void BleScanResultCallback(int32_t listenerId, const BroadcastReportInfo *reportInfo)
|
||||
{
|
||||
(void)listenerId;
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ public:
|
||||
Reset();
|
||||
}
|
||||
|
||||
bool Update(int id, int st, SoftBusGattcNotify *param);
|
||||
testing::AssertionResult Expect(int id, int st, SoftBusGattcNotify *param);
|
||||
bool Update(int32_t id, int32_t st, SoftBusGattcNotify *param);
|
||||
testing::AssertionResult Expect(int32_t id, int32_t st, SoftBusGattcNotify *param);
|
||||
private:
|
||||
SoftBusGattcNotify notify;
|
||||
void Reset();
|
||||
@ -61,15 +61,15 @@ public:
|
||||
|
||||
static SoftBusGattcCallback *GetStubGattcCallback();
|
||||
|
||||
int ActionBleGattcRegister(BtUuid appUuid)
|
||||
int32_t ActionBleGattcRegister(BtUuid appUuid)
|
||||
{
|
||||
(void)appUuid;
|
||||
static int idGenerator = 0;
|
||||
static int32_t idGenerator = 0;
|
||||
return ++idGenerator;
|
||||
}
|
||||
|
||||
int ActionBleGattcConnect(
|
||||
int clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport)
|
||||
int32_t ActionBleGattcConnect(
|
||||
int32_t clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport)
|
||||
{
|
||||
(void)clientId;
|
||||
(void)bdAddr;
|
||||
@ -352,7 +352,7 @@ HWTEST_F(AdapterBleGattClientTest, GattClientConnectCycle1, TestSize.Level3)
|
||||
gattClientCallback->registerNotificationCb(clientId, OHOS_BT_STATUS_SUCCESS);
|
||||
ASSERT_TRUE(registNotificationCtx.Expect(clientId, OHOS_BT_STATUS_SUCCESS));
|
||||
|
||||
int mtu = 512;
|
||||
int32_t mtu = 512;
|
||||
ASSERT_EQ(SoftbusGattcConfigureMtuSize(clientId, mtu), SOFTBUS_OK);
|
||||
gattClientCallback->configureMtuSizeCb(clientId, mtu, OHOS_BT_STATUS_SUCCESS);
|
||||
ASSERT_TRUE(configureMtuSizeCtx.Expect(clientId, OHOS_BT_STATUS_SUCCESS, mtu));
|
||||
@ -476,7 +476,7 @@ void GattcNotifyRecordCtx::Reset()
|
||||
(void)memset_s(¬ify, sizeof(SoftBusGattcNotify), 0, sizeof(SoftBusGattcNotify));
|
||||
}
|
||||
|
||||
bool GattcNotifyRecordCtx::Update(int id, int st, SoftBusGattcNotify *param)
|
||||
bool GattcNotifyRecordCtx::Update(int32_t id, int32_t st, SoftBusGattcNotify *param)
|
||||
{
|
||||
if (!StRecordCtx::Update(id, st)) {
|
||||
return false;
|
||||
@ -503,7 +503,7 @@ bool GattcNotifyRecordCtx::Update(int id, int st, SoftBusGattcNotify *param)
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult GattcNotifyRecordCtx::Expect(int id, int st, SoftBusGattcNotify *param)
|
||||
testing::AssertionResult GattcNotifyRecordCtx::Expect(int32_t id, int32_t st, SoftBusGattcNotify *param)
|
||||
{
|
||||
auto result = StRecordCtx::Expect(id, st);
|
||||
if (!result) {
|
||||
@ -543,7 +543,7 @@ void StubServiceCompleteCallback(int32_t clientId, int32_t status)
|
||||
AdapterBleGattClientTest::serviceCompleteStateCtx.Update(clientId, status);
|
||||
}
|
||||
|
||||
void StubRegistNotificationCallback(int32_t clientId, int status)
|
||||
void StubRegistNotificationCallback(int32_t clientId, int32_t status)
|
||||
{
|
||||
AdapterBleGattClientTest::registNotificationCtx.Update(clientId, status);
|
||||
}
|
||||
@ -553,7 +553,7 @@ void StubNotificationReceiveCallback(int32_t clientId, SoftBusGattcNotify *param
|
||||
AdapterBleGattClientTest::notificationReceiveCtx.Update(clientId, status, param);
|
||||
}
|
||||
|
||||
void StubConfigureMtuSizeCallback(int clientId, int mtuSize, int status)
|
||||
void StubConfigureMtuSizeCallback(int32_t clientId, int32_t mtuSize, int32_t status)
|
||||
{
|
||||
AdapterBleGattClientTest::configureMtuSizeCtx.Update(clientId, status, mtuSize);
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ class BtUuidRecordCtx : public StRecordCtx {
|
||||
public:
|
||||
explicit BtUuidRecordCtx(const char *identifier);
|
||||
~BtUuidRecordCtx();
|
||||
bool Update(int id, int st, SoftBusBtUuid *param);
|
||||
testing::AssertionResult Expect(int id, int st, SoftBusBtUuid *param);
|
||||
bool Update(int32_t id, int32_t st, SoftBusBtUuid *param);
|
||||
testing::AssertionResult Expect(int32_t id, int32_t st, SoftBusBtUuid *param);
|
||||
private:
|
||||
SoftBusBtUuid uuid;
|
||||
void Reset();
|
||||
@ -48,10 +48,10 @@ private:
|
||||
class BtGattRecordCtx : public BtUuidRecordCtx {
|
||||
public:
|
||||
explicit BtGattRecordCtx(const char *identifier);
|
||||
bool Update(int id, int st, int handle, SoftBusBtUuid *param);
|
||||
testing::AssertionResult Expect(int id, int st, int handle, SoftBusBtUuid *param);
|
||||
bool Update(int32_t id, int32_t st, int32_t handle, SoftBusBtUuid *param);
|
||||
testing::AssertionResult Expect(int32_t id, int32_t st, int32_t handle, SoftBusBtUuid *param);
|
||||
private:
|
||||
int handle;
|
||||
int32_t handle;
|
||||
};
|
||||
|
||||
class AdapterBleGattServerTest : public testing::Test {
|
||||
@ -76,14 +76,14 @@ static SoftBusGattsCallback *GetStubGattsCallback();
|
||||
static testing::AssertionResult ExpectGattReadRequest(SoftBusGattReadRequest actual, SoftBusGattReadRequest want);
|
||||
static testing::AssertionResult ExpectGattWriteRequest(SoftBusGattWriteRequest actual, SoftBusGattWriteRequest want);
|
||||
|
||||
int ActionBleGattsRegisterCallbacks(BtGattServerCallbacks *func)
|
||||
int32_t ActionBleGattsRegisterCallbacks(BtGattServerCallbacks *func)
|
||||
{
|
||||
AdapterBleGattServerTest::gattServerCallback = func;
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// 回绕到注册通知中
|
||||
int ActionBleGattsRegister(BtUuid appUuid)
|
||||
int32_t ActionBleGattsRegister(BtUuid appUuid)
|
||||
{
|
||||
AdapterBleGattServerTest::gattServerCallback->registerServerCb(0, MOCK_GATT_SERVER_HANDLE, &appUuid);
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
@ -218,10 +218,10 @@ HWTEST_F(AdapterBleGattServerTest, SoftBusGattsAddCharacteristic, TestSize.Level
|
||||
.uuidLen = 0,
|
||||
.uuid = nullptr,
|
||||
};
|
||||
int properties = SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_READ | SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP |
|
||||
int32_t properties = SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_READ | SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP |
|
||||
SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_WRITE | SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_NOTIFY |
|
||||
SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_INDICATE;
|
||||
int permissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
int32_t permissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
ASSERT_EQ(
|
||||
SoftBusGattsAddCharacteristic(MOCK_GATT_SERVICE_HANDLE, characteristic, properties, permissions),
|
||||
SOFTBUS_INVALID_PARAM);
|
||||
@ -260,7 +260,7 @@ HWTEST_F(AdapterBleGattServerTest, SoftBusGattsAddDescriptor, TestSize.Level3)
|
||||
.uuidLen = 0,
|
||||
.uuid = nullptr,
|
||||
};
|
||||
int permissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
int32_t permissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
ASSERT_EQ(SoftBusGattsAddDescriptor(MOCK_GATT_SERVICE_HANDLE, desciptor, permissions), SOFTBUS_INVALID_PARAM);
|
||||
|
||||
const char *connDesciptor = "00002902-0000-1000-8000-00805F9B34FB";
|
||||
@ -363,7 +363,7 @@ HWTEST_F(AdapterBleGattServerTest, SoftBusGattsDisconnect, TestSize.Level3)
|
||||
MockAll(mocker);
|
||||
ASSERT_EQ(SoftBusRegisterGattsCallbacks(GetStubGattsCallback(), service), SOFTBUS_OK);
|
||||
|
||||
int connId = 1;
|
||||
int32_t connId = 1;
|
||||
SoftBusBtAddr addr = {
|
||||
.addr = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66},
|
||||
};
|
||||
@ -456,10 +456,10 @@ HWTEST_F(AdapterBleGattServerTest, GattServerLifeCycle1, TestSize.Level3)
|
||||
.uuidLen = strlen(netCharacteristic),
|
||||
.uuid = (char *)netCharacteristic,
|
||||
};
|
||||
int properties = SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_READ | SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP |
|
||||
int32_t properties = SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_READ | SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP |
|
||||
SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_WRITE | SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_NOTIFY |
|
||||
SOFTBUS_GATT_CHARACTER_PROPERTY_BIT_INDICATE;
|
||||
int charaPermissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
int32_t charaPermissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
ASSERT_EQ(SoftBusGattsAddCharacteristic(MOCK_GATT_SERVICE_HANDLE, characteristic, properties, charaPermissions),
|
||||
SOFTBUS_OK);
|
||||
BtUuid btCharacteristic = {
|
||||
@ -491,7 +491,7 @@ HWTEST_F(AdapterBleGattServerTest, GattServerLifeCycle2, TestSize.Level3)
|
||||
|
||||
// 注册desciptor
|
||||
const char *connDesciptor = "00002902-0000-1000-8000-00805F9B34FB";
|
||||
int descriptorPermissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
int32_t descriptorPermissions = SOFTBUS_GATT_PERMISSION_READ | SOFTBUS_GATT_PERMISSION_WRITE;
|
||||
SoftBusBtUuid descriptor = {
|
||||
.uuidLen = strlen(connDesciptor),
|
||||
.uuid = (char *)connDesciptor,
|
||||
@ -642,7 +642,7 @@ void BtUuidRecordCtx::Reset()
|
||||
uuid.uuidLen = 0;
|
||||
}
|
||||
|
||||
bool BtUuidRecordCtx::Update(int id, int st, SoftBusBtUuid *param)
|
||||
bool BtUuidRecordCtx::Update(int32_t id, int32_t st, SoftBusBtUuid *param)
|
||||
{
|
||||
if (!StRecordCtx::Update(id, st)) {
|
||||
return false;
|
||||
@ -658,7 +658,7 @@ bool BtUuidRecordCtx::Update(int id, int st, SoftBusBtUuid *param)
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult BtUuidRecordCtx::Expect(int id, int st, SoftBusBtUuid *param)
|
||||
testing::AssertionResult BtUuidRecordCtx::Expect(int32_t id, int32_t st, SoftBusBtUuid *param)
|
||||
{
|
||||
auto result = StRecordCtx::Expect(id, st);
|
||||
if (!result) {
|
||||
@ -679,7 +679,7 @@ BtGattRecordCtx::BtGattRecordCtx(const char *identifier) : BtUuidRecordCtx(ident
|
||||
handle = -1;
|
||||
}
|
||||
|
||||
bool BtGattRecordCtx::Update(int id, int st, int handleParam, SoftBusBtUuid *param)
|
||||
bool BtGattRecordCtx::Update(int32_t id, int32_t st, int32_t handleParam, SoftBusBtUuid *param)
|
||||
{
|
||||
if (!BtUuidRecordCtx::Update(id, st, param)) {
|
||||
return false;
|
||||
@ -688,7 +688,7 @@ bool BtGattRecordCtx::Update(int id, int st, int handleParam, SoftBusBtUuid *par
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult BtGattRecordCtx::Expect(int id, int st, int handleParam, SoftBusBtUuid *param)
|
||||
testing::AssertionResult BtGattRecordCtx::Expect(int32_t id, int32_t st, int32_t handleParam, SoftBusBtUuid *param)
|
||||
{
|
||||
auto result = BtUuidRecordCtx::Expect(id, st, param);
|
||||
if (!result) {
|
||||
@ -720,42 +720,43 @@ StRecordCtx AdapterBleGattServerTest::responseConfirmationCtx("ResponseConfirmat
|
||||
StRecordCtx AdapterBleGattServerTest::notifySentCtx("NotifySentCallback");
|
||||
StRecordCtx AdapterBleGattServerTest::mtuChangeCtx("MtuChangeCallback");
|
||||
|
||||
static void StubServiceAddCallback(int status, SoftBusBtUuid *uuid, int srvcHandle)
|
||||
static void StubServiceAddCallback(int32_t status, SoftBusBtUuid *uuid, int32_t srvcHandle)
|
||||
{
|
||||
AdapterBleGattServerTest::serviceAddCtx.Update(srvcHandle, status, uuid);
|
||||
}
|
||||
|
||||
static void StubCharacteristicAddCallback(int status, SoftBusBtUuid *uuid, int srvcHandle, int characteristicHandle)
|
||||
static void StubCharacteristicAddCallback(int32_t status, SoftBusBtUuid *uuid,
|
||||
int32_t srvcHandle, int32_t characteristicHandle)
|
||||
{
|
||||
AdapterBleGattServerTest::characteristicAddCtx.Update(srvcHandle, status, characteristicHandle, uuid);
|
||||
}
|
||||
|
||||
static void StubDescriptorAddCallback(int status, SoftBusBtUuid *uuid, int srvcHandle, int descriptorHandle)
|
||||
static void StubDescriptorAddCallback(int32_t status, SoftBusBtUuid *uuid, int32_t srvcHandle, int32_t descriptorHandle)
|
||||
{
|
||||
AdapterBleGattServerTest::descriptorAddCtx.Update(srvcHandle, status, descriptorHandle, uuid);
|
||||
}
|
||||
|
||||
static void StubServiceStartCallback(int status, int srvcHandle)
|
||||
static void StubServiceStartCallback(int32_t status, int32_t srvcHandle)
|
||||
{
|
||||
AdapterBleGattServerTest::serviceStartCtx.Update(srvcHandle, status);
|
||||
}
|
||||
|
||||
static void StubServiceStopCallback(int status, int srvcHandle)
|
||||
static void StubServiceStopCallback(int32_t status, int32_t srvcHandle)
|
||||
{
|
||||
AdapterBleGattServerTest::serviceStopCtx.Update(srvcHandle, status);
|
||||
}
|
||||
|
||||
static void StubServiceDeleteCallback(int status, int srvcHandle)
|
||||
static void StubServiceDeleteCallback(int32_t status, int32_t srvcHandle)
|
||||
{
|
||||
AdapterBleGattServerTest::serviceDeleteCtx.Update(srvcHandle, status);
|
||||
}
|
||||
|
||||
static void StubConnectServerCallback(int connId, const SoftBusBtAddr *btAddr)
|
||||
static void StubConnectServerCallback(int32_t connId, const SoftBusBtAddr *btAddr)
|
||||
{
|
||||
AdapterBleGattServerTest::connectServerCtx.Update(connId, btAddr);
|
||||
}
|
||||
|
||||
static void StubDisconnectServerCallback(int connId, const SoftBusBtAddr *btAddr)
|
||||
static void StubDisconnectServerCallback(int32_t connId, const SoftBusBtAddr *btAddr)
|
||||
{
|
||||
AdapterBleGattServerTest::disconnectServerCtx.Update(connId, btAddr);
|
||||
}
|
||||
@ -770,15 +771,15 @@ static void StubRequestWriteCallback(SoftBusGattWriteRequest writeCbPara)
|
||||
AdapterBleGattServerTest::requestWriteCtx = writeCbPara;
|
||||
}
|
||||
|
||||
static void StubResponseConfirmationCallback(int status, int handle)
|
||||
static void StubResponseConfirmationCallback(int32_t status, int32_t handle)
|
||||
{
|
||||
AdapterBleGattServerTest::responseConfirmationCtx.Update(handle, status);
|
||||
}
|
||||
static void StubNotifySentCallback(int connId, int status)
|
||||
static void StubNotifySentCallback(int32_t connId, int32_t status)
|
||||
{
|
||||
AdapterBleGattServerTest::notifySentCtx.Update(connId, status);
|
||||
}
|
||||
static void StubMtuChangeCallback(int connId, int mtu)
|
||||
static void StubMtuChangeCallback(int32_t connId, int32_t mtu)
|
||||
{
|
||||
AdapterBleGattServerTest::mtuChangeCtx.Update(connId, mtu);
|
||||
}
|
||||
@ -832,4 +833,4 @@ static testing::AssertionResult ExpectGattReadRequest(SoftBusGattReadRequest act
|
||||
return testing::AssertionSuccess();
|
||||
}
|
||||
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -111,7 +111,7 @@ HWTEST(AdapterBtCommonTest, SoftBusSetBtName, TestSize.Level3)
|
||||
EXPECT_EQ(SoftBusSetBtName(name), SOFTBUS_COMM_BLUETOOTH_UNDERLAY_SET_NAME_ERR);
|
||||
}
|
||||
|
||||
static testing::AssertionResult PrepareBtStateListener(MockBluetooth &mocker, int *outlistenerId)
|
||||
static testing::AssertionResult PrepareBtStateListener(MockBluetooth &mocker, int32_t *outlistenerId)
|
||||
{
|
||||
EXPECT_CALL(mocker, BleStopScan).WillRepeatedly(Return(OHOS_BT_STATUS_SUCCESS));
|
||||
auto listenerId = SoftBusAddBtStateListener(GetMockBtStateListener());
|
||||
@ -137,7 +137,7 @@ static testing::AssertionResult PrepareBtStateListener(MockBluetooth &mocker, in
|
||||
*/
|
||||
HWTEST(AdapterBtCommonTest, StateChangeCallback, TestSize.Level3)
|
||||
{
|
||||
int listenerId = -1;
|
||||
int32_t listenerId = -1;
|
||||
MockBluetooth mocker;
|
||||
auto prepareResult = PrepareBtStateListener(mocker, &listenerId);
|
||||
ASSERT_TRUE(prepareResult);
|
||||
@ -186,7 +186,7 @@ HWTEST(AdapterBtCommonTest, StateChangeCallback, TestSize.Level3)
|
||||
*/
|
||||
HWTEST(AdapterBtCommonTest, AclStateChangedCallbak, TestSize.Level3)
|
||||
{
|
||||
int listenerId = -1;
|
||||
int32_t listenerId = -1;
|
||||
MockBluetooth mocker;
|
||||
auto prepareResult = PrepareBtStateListener(mocker, &listenerId);
|
||||
ASSERT_TRUE(prepareResult);
|
||||
@ -240,7 +240,7 @@ HWTEST(AdapterBtCommonTest, PairRequestedCallback, TestSize.Level3)
|
||||
.WillOnce(Return(false))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
int listenerId = -1;
|
||||
int32_t listenerId = -1;
|
||||
auto prepareResult = PrepareBtStateListener(mocker, &listenerId);
|
||||
ASSERT_TRUE(prepareResult);
|
||||
|
||||
@ -266,7 +266,7 @@ HWTEST(AdapterBtCommonTest, PairConfiremedCallback, TestSize.Level3)
|
||||
.Times(AtLeast(2))
|
||||
.WillOnce(Return(false))
|
||||
.WillRepeatedly(Return(true));
|
||||
int listenerId = -1;
|
||||
int32_t listenerId = -1;
|
||||
auto prepareResult = PrepareBtStateListener(mocker, &listenerId);
|
||||
ASSERT_TRUE(prepareResult);
|
||||
|
||||
|
@ -28,13 +28,13 @@ public:
|
||||
this->identifier = identifier;
|
||||
}
|
||||
|
||||
bool Update(int idParam)
|
||||
bool Update(int32_t idParam)
|
||||
{
|
||||
this->id = idParam;
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int idParam)
|
||||
testing::AssertionResult Expect(int32_t idParam)
|
||||
{
|
||||
testing::AssertionResult result = testing::AssertionSuccess();
|
||||
if (this->id != idParam) {
|
||||
@ -48,14 +48,14 @@ protected:
|
||||
// static c string
|
||||
const char *identifier;
|
||||
private:
|
||||
int id;
|
||||
int32_t id;
|
||||
};
|
||||
|
||||
class StRecordCtx : public RecordCtx {
|
||||
public:
|
||||
explicit StRecordCtx(const char *identifier) : RecordCtx(identifier), st(-1) {}
|
||||
|
||||
bool Update(int id, int stParam)
|
||||
bool Update(int32_t id, int32_t stParam)
|
||||
{
|
||||
if (!RecordCtx::Update(id)) {
|
||||
return false;
|
||||
@ -64,7 +64,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int id, int stParam)
|
||||
testing::AssertionResult Expect(int32_t id, int32_t stParam)
|
||||
{
|
||||
auto result = RecordCtx::Expect(id);
|
||||
if (!result) {
|
||||
@ -81,7 +81,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
int st;
|
||||
int32_t st;
|
||||
};
|
||||
|
||||
class BtAddrRecordCtx : public StRecordCtx {
|
||||
@ -91,7 +91,7 @@ public:
|
||||
Reset();
|
||||
}
|
||||
|
||||
bool Update(int id, const SoftbusMacAddr *addr, int st = 0)
|
||||
bool Update(int32_t id, const SoftbusMacAddr *addr, int32_t st = 0)
|
||||
{
|
||||
if (!StRecordCtx::Update(id, st)) {
|
||||
return false;
|
||||
@ -100,7 +100,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int id, SoftbusMacAddr *addrParam, int st = 0)
|
||||
testing::AssertionResult Expect(int32_t id, SoftbusMacAddr *addrParam, int32_t st = 0)
|
||||
{
|
||||
auto result = StRecordCtx::Expect(id, st);
|
||||
if (!result) {
|
||||
@ -127,7 +127,7 @@ class IntRecordCtx : public StRecordCtx {
|
||||
public:
|
||||
explicit IntRecordCtx(const char *identifier) : StRecordCtx(identifier), val(-1) {}
|
||||
|
||||
bool Update(int id, int st, int valParam)
|
||||
bool Update(int32_t id, int32_t st, int32_t valParam)
|
||||
{
|
||||
if (!StRecordCtx::Update(id, st)) {
|
||||
return false;
|
||||
@ -136,14 +136,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult Expect(int id, int st, int valParam)
|
||||
testing::AssertionResult Expect(int32_t id, int32_t st, int32_t valParam)
|
||||
{
|
||||
auto result = StRecordCtx::Expect(id, st);
|
||||
if (!result) {
|
||||
goto ClEANUP;
|
||||
}
|
||||
if (this->val != valParam) {
|
||||
result = testing::AssertionFailure() << identifier << " is call by unexpectedly int value,"
|
||||
result = testing::AssertionFailure() << identifier << " is call by unexpectedly int32_t value,"
|
||||
<< "want: " << valParam << ", actual: " << this->val;
|
||||
} else {
|
||||
result = testing::AssertionSuccess();
|
||||
@ -153,7 +153,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
int val;
|
||||
int32_t val;
|
||||
};
|
||||
|
||||
#endif
|
@ -23,25 +23,25 @@ BtGattCallbacks *MockBluetooth::btGattCallback = nullptr;
|
||||
BleScanCallbacks *MockBluetooth::bleScanCallback = nullptr;
|
||||
const SoftbusBroadcastMediumInterface *MockBluetooth::interface = nullptr;
|
||||
|
||||
static int ActionGapRegisterCallbacks(BtGapCallBacks *func)
|
||||
static int32_t ActionGapRegisterCallbacks(BtGapCallBacks *func)
|
||||
{
|
||||
MockBluetooth::btGapCallback = func;
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static int ActionBleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
static int32_t ActionBleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
{
|
||||
MockBluetooth::btGattCallback = func;
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static int ActionBleRegisterScanCallbacks(BleScanCallbacks *func, int32_t *scannerId)
|
||||
static int32_t ActionBleRegisterScanCallbacks(BleScanCallbacks *func, int32_t *scannerId)
|
||||
{
|
||||
MockBluetooth::bleScanCallback = func;
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static int ActionBleDeregisterScanCallbacks(int32_t scannerId)
|
||||
static int32_t ActionBleDeregisterScanCallbacks(int32_t scannerId)
|
||||
{
|
||||
MockBluetooth::bleScanCallback = nullptr;
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
@ -100,197 +100,198 @@ bool SetLocalName(unsigned char *localName, unsigned char length)
|
||||
return MockBluetooth::GetMocker()->SetLocalName(localName, length);
|
||||
}
|
||||
|
||||
int GapRegisterCallbacks(BtGapCallBacks *func)
|
||||
int32_t GapRegisterCallbacks(BtGapCallBacks *func)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->GapRegisterCallbacks(func);
|
||||
}
|
||||
|
||||
bool PairRequestReply(const BdAddr *bdAddr, int transport, bool accept)
|
||||
bool PairRequestReply(const BdAddr *bdAddr, int32_t transport, bool accept)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->PairRequestReply(bdAddr, transport, accept);
|
||||
}
|
||||
|
||||
bool SetDevicePairingConfirmation(const BdAddr *bdAddr, int transport, bool accept)
|
||||
bool SetDevicePairingConfirmation(const BdAddr *bdAddr, int32_t transport, bool accept)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->SetDevicePairingConfirmation(bdAddr, transport, accept);
|
||||
}
|
||||
|
||||
int BleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
int32_t BleGattRegisterCallbacks(BtGattCallbacks *func)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattRegisterCallbacks(func);
|
||||
}
|
||||
|
||||
int BleRegisterScanCallbacks(BleScanCallbacks *func, int32_t *scannerId)
|
||||
int32_t BleRegisterScanCallbacks(BleScanCallbacks *func, int32_t *scannerId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleRegisterScanCallbacks(func, scannerId);
|
||||
}
|
||||
|
||||
int BleDeregisterScanCallbacks(int32_t scannerId)
|
||||
int32_t BleDeregisterScanCallbacks(int32_t scannerId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleDeregisterScanCallbacks(scannerId);
|
||||
}
|
||||
|
||||
int BleStartScanEx(int32_t scannerId, const BleScanConfigs *configs, const BleScanNativeFilter *filter,
|
||||
int32_t BleStartScanEx(int32_t scannerId, const BleScanConfigs *configs, const BleScanNativeFilter *filter,
|
||||
uint32_t filterSize)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleStartScanEx(scannerId, configs, filter, filterSize);
|
||||
}
|
||||
|
||||
int BleStopScan(int scannerId)
|
||||
int32_t BleStopScan(int32_t scannerId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleStopScan(scannerId);
|
||||
}
|
||||
|
||||
int GetAdvHandle(int32_t btAdvId, int32_t *bcHandle)
|
||||
int32_t GetAdvHandle(int32_t btAdvId, int32_t *bcHandle)
|
||||
{
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int EnableSyncDataToLpDevice()
|
||||
int32_t EnableSyncDataToLpDevice()
|
||||
{
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int DisableSyncDataToLpDevice()
|
||||
int32_t DisableSyncDataToLpDevice()
|
||||
{
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int SetLpDeviceAdvParam(int32_t duration, int32_t maxExtAdvEvents, int32_t window,
|
||||
int32_t SetLpDeviceAdvParam(int32_t duration, int32_t maxExtAdvEvents, int32_t window,
|
||||
int32_t interval, int32_t bcHandle)
|
||||
{
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int BleStartAdvEx(int *advId, const StartAdvRawData rawData, BleAdvParams advParam)
|
||||
int32_t BleStartAdvEx(int32_t *advId, const StartAdvRawData rawData, BleAdvParams advParam)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleStartAdvEx(advId, rawData, advParam);
|
||||
}
|
||||
|
||||
int BleStopAdv(int advId)
|
||||
int32_t BleStopAdv(int32_t advId)
|
||||
{
|
||||
return OHOS_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int BleGattcRegister(BtUuid appUuid)
|
||||
int32_t BleGattcRegister(BtUuid appUuid)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcRegister(appUuid);
|
||||
}
|
||||
|
||||
int BleGattcConnect(
|
||||
int clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport)
|
||||
int32_t BleGattcConnect(
|
||||
int32_t clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcConnect(clientId, func, bdAddr, isAutoConnect, transport);
|
||||
}
|
||||
|
||||
int BleGattcDisconnect(int clientId)
|
||||
int32_t BleGattcDisconnect(int32_t clientId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcDisconnect(clientId);
|
||||
}
|
||||
|
||||
int BleGattcSearchServices(int clientId)
|
||||
int32_t BleGattcSearchServices(int32_t clientId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcSearchServices(clientId);
|
||||
}
|
||||
|
||||
bool BleGattcGetService(int clientId, BtUuid serviceUuid)
|
||||
bool BleGattcGetService(int32_t clientId, BtUuid serviceUuid)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcGetService(clientId, serviceUuid);
|
||||
}
|
||||
|
||||
int BleGattcRegisterNotification(int clientId, BtGattCharacteristic characteristic, bool enable)
|
||||
int32_t BleGattcRegisterNotification(int32_t clientId, BtGattCharacteristic characteristic, bool enable)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcRegisterNotification(clientId, characteristic, enable);
|
||||
}
|
||||
|
||||
int BleGattcConfigureMtuSize(int clientId, int mtuSize)
|
||||
int32_t BleGattcConfigureMtuSize(int32_t clientId, int32_t mtuSize)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcConfigureMtuSize(clientId, mtuSize);
|
||||
}
|
||||
|
||||
int BleGattcWriteCharacteristic(
|
||||
int clientId, BtGattCharacteristic characteristic, BtGattWriteType writeType, int len, const char *value)
|
||||
int32_t BleGattcWriteCharacteristic(
|
||||
int32_t clientId, BtGattCharacteristic characteristic, BtGattWriteType writeType, int32_t len, const char *value)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcWriteCharacteristic(clientId, characteristic, writeType, len, value);
|
||||
}
|
||||
|
||||
int BleGattcUnRegister(int clientId)
|
||||
int32_t BleGattcUnRegister(int32_t clientId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcUnRegister(clientId);
|
||||
}
|
||||
|
||||
int BleGattcSetFastestConn(int clientId, bool fastestConnFlag)
|
||||
int32_t BleGattcSetFastestConn(int32_t clientId, bool fastestConnFlag)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcSetFastestConn(clientId, fastestConnFlag);
|
||||
}
|
||||
|
||||
int BleGattcSetPriority(int clientId, const BdAddr *bdAddr, BtGattPriority priority)
|
||||
int32_t BleGattcSetPriority(int32_t clientId, const BdAddr *bdAddr, BtGattPriority priority)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattcSetPriority(clientId, bdAddr, priority);
|
||||
}
|
||||
|
||||
int BleGattsRegisterCallbacks(BtGattServerCallbacks *func)
|
||||
int32_t BleGattsRegisterCallbacks(BtGattServerCallbacks *func)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsRegisterCallbacks(func);
|
||||
}
|
||||
|
||||
int BleGattsRegister(BtUuid appUuid)
|
||||
int32_t BleGattsRegister(BtUuid appUuid)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsRegister(appUuid);
|
||||
}
|
||||
|
||||
int BleGattsAddService(int serverId, BtUuid srvcUuid, bool isPrimary, int number)
|
||||
int32_t BleGattsAddService(int32_t serverId, BtUuid srvcUuid, bool isPrimary, int32_t number)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsAddService(serverId, srvcUuid, isPrimary, number);
|
||||
}
|
||||
|
||||
int BleGattsUnRegister(int serverId)
|
||||
int32_t BleGattsUnRegister(int32_t serverId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsUnRegister(serverId);
|
||||
}
|
||||
|
||||
int BleGattsAddCharacteristic(int serverId, int srvcHandle, BtUuid characUuid, int properties, int permissions)
|
||||
int32_t BleGattsAddCharacteristic(int32_t serverId, int32_t srvcHandle,
|
||||
BtUuid characUuid, int32_t properties, int32_t permissions)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsAddCharacteristic(
|
||||
serverId, srvcHandle, characUuid, properties, permissions);
|
||||
}
|
||||
|
||||
int BleGattsAddDescriptor(int serverId, int srvcHandle, BtUuid descUuid, int permissions)
|
||||
int32_t BleGattsAddDescriptor(int32_t serverId, int32_t srvcHandle, BtUuid descUuid, int32_t permissions)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsAddDescriptor(serverId, srvcHandle, descUuid, permissions);
|
||||
}
|
||||
|
||||
int BleGattsStartService(int serverId, int srvcHandle)
|
||||
int32_t BleGattsStartService(int32_t serverId, int32_t srvcHandle)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsStartService(serverId, srvcHandle);
|
||||
}
|
||||
|
||||
int BleGattsStopService(int serverId, int srvcHandle)
|
||||
int32_t BleGattsStopService(int32_t serverId, int32_t srvcHandle)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsStopService(serverId, srvcHandle);
|
||||
}
|
||||
|
||||
int BleGattsDeleteService(int serverId, int srvcHandle)
|
||||
int32_t BleGattsDeleteService(int32_t serverId, int32_t srvcHandle)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsDeleteService(serverId, srvcHandle);
|
||||
}
|
||||
|
||||
int BleGattsDisconnect(int serverId, BdAddr bdAddr, int connId)
|
||||
int32_t BleGattsDisconnect(int32_t serverId, BdAddr bdAddr, int32_t connId)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsDisconnect(serverId, bdAddr, connId);
|
||||
}
|
||||
|
||||
int BleGattsSendResponse(int serverId, GattsSendRspParam *param)
|
||||
int32_t BleGattsSendResponse(int32_t serverId, GattsSendRspParam *param)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsSendResponse(serverId, param);
|
||||
}
|
||||
|
||||
int BleGattsSendIndication(int serverId, GattsSendIndParam *param)
|
||||
int32_t BleGattsSendIndication(int32_t serverId, GattsSendIndParam *param)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->BleGattsSendIndication(serverId, param);
|
||||
}
|
||||
|
||||
int SoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
int32_t SoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
{
|
||||
return MockBluetooth::GetMocker()->SoftBusAddBtStateListener(listener);
|
||||
}
|
||||
|
@ -34,58 +34,60 @@ public:
|
||||
virtual bool IsBleEnabled() = 0;
|
||||
virtual bool GetLocalAddr(unsigned char *mac, unsigned int len) = 0;
|
||||
virtual bool SetLocalName(unsigned char *localName, unsigned char length) = 0;
|
||||
virtual int GapRegisterCallbacks(BtGapCallBacks *func) = 0;
|
||||
virtual bool PairRequestReply(const BdAddr *bdAddr, int transport, bool accept) = 0;
|
||||
virtual bool SetDevicePairingConfirmation(const BdAddr *bdAddr, int transport, bool accept) = 0;
|
||||
virtual int32_t GapRegisterCallbacks(BtGapCallBacks *func) = 0;
|
||||
virtual bool PairRequestReply(const BdAddr *bdAddr, int32_t transport, bool accept) = 0;
|
||||
virtual bool SetDevicePairingConfirmation(const BdAddr *bdAddr, int32_t transport, bool accept) = 0;
|
||||
|
||||
// BLE广播相关
|
||||
virtual int BleGattRegisterCallbacks(BtGattCallbacks *func) = 0;
|
||||
virtual int BleRegisterScanCallbacks(BleScanCallbacks *func, int32_t *scannerId) = 0;
|
||||
virtual int BleDeregisterScanCallbacks(int32_t scannerId) = 0;
|
||||
virtual int BleStartScanEx(int32_t scannerId, const BleScanConfigs *configs, const BleScanNativeFilter *filter,
|
||||
virtual int32_t BleGattRegisterCallbacks(BtGattCallbacks *func) = 0;
|
||||
virtual int32_t BleRegisterScanCallbacks(BleScanCallbacks *func, int32_t *scannerId) = 0;
|
||||
virtual int32_t BleDeregisterScanCallbacks(int32_t scannerId) = 0;
|
||||
virtual int32_t BleStartScanEx(int32_t scannerId, const BleScanConfigs *configs, const BleScanNativeFilter *filter,
|
||||
uint32_t filterSize) = 0;
|
||||
virtual int BleStopScan(int scannerId) = 0;
|
||||
virtual int BleStartAdvEx(int *advId, const StartAdvRawData rawData, BleAdvParams advParam) = 0;
|
||||
virtual int BleStopAdv(int advId) = 0;
|
||||
virtual int GetAdvHandle(int32_t btAdvId, int32_t *bcHandle) = 0;
|
||||
virtual int EnableSyncDataToLpDevice() = 0;
|
||||
virtual int DisableSyncDataToLpDevice() = 0;
|
||||
virtual int SetLpDeviceAdvParam(
|
||||
virtual int32_t BleStopScan(int32_t scannerId) = 0;
|
||||
virtual int32_t BleStartAdvEx(int32_t *advId, const StartAdvRawData rawData, BleAdvParams advParam) = 0;
|
||||
virtual int32_t BleStopAdv(int32_t advId) = 0;
|
||||
virtual int32_t GetAdvHandle(int32_t btAdvId, int32_t *bcHandle) = 0;
|
||||
virtual int32_t EnableSyncDataToLpDevice() = 0;
|
||||
virtual int32_t DisableSyncDataToLpDevice() = 0;
|
||||
virtual int32_t SetLpDeviceAdvParam(
|
||||
int32_t duration, int32_t maxExtAdvEvents, int32_t window, int32_t interval, int32_t bcHandle) = 0;
|
||||
|
||||
// GATT Client相关
|
||||
virtual int BleGattcRegister(BtUuid appUuid) = 0;
|
||||
virtual int BleGattcConnect(int clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect,
|
||||
BtTransportType transport) = 0;
|
||||
virtual int BleGattcDisconnect(int clientId) = 0;
|
||||
virtual int BleGattcSearchServices(int clientId) = 0;
|
||||
virtual bool BleGattcGetService(int clientId, BtUuid serviceUuid) = 0;
|
||||
virtual int BleGattcRegisterNotification(int clientId, BtGattCharacteristic characteristic, bool enable) = 0;
|
||||
virtual int BleGattcConfigureMtuSize(int clientId, int mtuSize) = 0;
|
||||
virtual int BleGattcWriteCharacteristic(
|
||||
int clientId, BtGattCharacteristic characteristic, BtGattWriteType writeType, int len, const char *value) = 0;
|
||||
virtual int BleGattcUnRegister(int clientId) = 0;
|
||||
virtual int BleGattcSetFastestConn(int clientId, bool fastestConnFlag) = 0;
|
||||
virtual int BleGattcSetPriority(int clientId, const BdAddr *bdAddr, BtGattPriority priority) = 0;
|
||||
virtual int32_t BleGattcRegister(BtUuid appUuid) = 0;
|
||||
virtual int32_t BleGattcConnect(int32_t clientId, BtGattClientCallbacks *func,
|
||||
const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport) = 0;
|
||||
virtual int32_t BleGattcDisconnect(int32_t clientId) = 0;
|
||||
virtual int32_t BleGattcSearchServices(int32_t clientId) = 0;
|
||||
virtual bool BleGattcGetService(int32_t clientId, BtUuid serviceUuid) = 0;
|
||||
virtual int32_t BleGattcRegisterNotification(int32_t clientId,
|
||||
BtGattCharacteristic characteristic, bool enable) = 0;
|
||||
virtual int32_t BleGattcConfigureMtuSize(int32_t clientId, int32_t mtuSize) = 0;
|
||||
virtual int32_t BleGattcWriteCharacteristic(int32_t clientId, BtGattCharacteristic characteristic,
|
||||
BtGattWriteType writeType, int32_t len, const char *value) = 0;
|
||||
virtual int32_t BleGattcUnRegister(int32_t clientId) = 0;
|
||||
virtual int32_t BleGattcSetFastestConn(int32_t clientId, bool fastestConnFlag) = 0;
|
||||
virtual int32_t BleGattcSetPriority(int32_t clientId, const BdAddr *bdAddr, BtGattPriority priority) = 0;
|
||||
|
||||
// GATT Server相关
|
||||
virtual int BleGattsRegisterCallbacks(BtGattServerCallbacks *func) = 0;
|
||||
virtual int BleGattsRegister(BtUuid appUuid);
|
||||
virtual int BleGattsAddService(int serverId, BtUuid srvcUuid, bool isPrimary, int number) = 0;
|
||||
virtual int BleGattsUnRegister(int serverId);
|
||||
virtual int BleGattsAddCharacteristic(
|
||||
int serverId, int srvcHandle, BtUuid characUuid, int properties, int permissions) = 0;
|
||||
virtual int BleGattsAddDescriptor(int serverId, int srvcHandle, BtUuid descUuid, int permissions) = 0;
|
||||
virtual int BleGattsStartService(int serverId, int srvcHandle) = 0;
|
||||
virtual int BleGattsStopService(int serverId, int srvcHandle) = 0;
|
||||
virtual int BleGattsDeleteService(int serverId, int srvcHandle) = 0;
|
||||
virtual int BleGattsDisconnect(int serverId, BdAddr bdAddr, int connId) = 0;
|
||||
virtual int BleGattsSendResponse(int serverId, GattsSendRspParam *param) = 0;
|
||||
virtual int BleGattsSendIndication(int serverId, GattsSendIndParam *param) = 0;
|
||||
virtual int32_t BleGattsRegisterCallbacks(BtGattServerCallbacks *func) = 0;
|
||||
virtual int32_t BleGattsRegister(BtUuid appUuid);
|
||||
virtual int32_t BleGattsAddService(int32_t serverId, BtUuid srvcUuid, bool isPrimary, int32_t number) = 0;
|
||||
virtual int32_t BleGattsUnRegister(int32_t serverId);
|
||||
virtual int32_t BleGattsAddCharacteristic(
|
||||
int32_t serverId, int32_t srvcHandle, BtUuid characUuid, int32_t properties, int32_t permissions) = 0;
|
||||
virtual int32_t BleGattsAddDescriptor(int32_t serverId,
|
||||
int32_t srvcHandle, BtUuid descUuid, int32_t permissions) = 0;
|
||||
virtual int32_t BleGattsStartService(int32_t serverId, int32_t srvcHandle) = 0;
|
||||
virtual int32_t BleGattsStopService(int32_t serverId, int32_t srvcHandle) = 0;
|
||||
virtual int32_t BleGattsDeleteService(int32_t serverId, int32_t srvcHandle) = 0;
|
||||
virtual int32_t BleGattsDisconnect(int32_t serverId, BdAddr bdAddr, int32_t connId) = 0;
|
||||
virtual int32_t BleGattsSendResponse(int32_t serverId, GattsSendRspParam *param) = 0;
|
||||
virtual int32_t BleGattsSendIndication(int32_t serverId, GattsSendIndParam *param) = 0;
|
||||
|
||||
virtual int32_t RegisterBroadcastMediumFunction(SoftbusMediumType type,
|
||||
const SoftbusBroadcastMediumInterface *interface) = 0;
|
||||
virtual int SoftBusAddBtStateListener(const SoftBusBtStateListener *listener) = 0;
|
||||
virtual int32_t SoftBusAddBtStateListener(const SoftBusBtStateListener *listener) = 0;
|
||||
};
|
||||
|
||||
class MockBluetooth : public BluetoothInterface {
|
||||
@ -99,17 +101,17 @@ public:
|
||||
MOCK_METHOD(bool, GetLocalAddr, (unsigned char *mac, unsigned int len), (override));
|
||||
MOCK_METHOD(bool, SetLocalName, (unsigned char *localName, unsigned char length), (override));
|
||||
MOCK_METHOD(int, GapRegisterCallbacks, (BtGapCallBacks *func), (override));
|
||||
MOCK_METHOD(bool, PairRequestReply, (const BdAddr *bdAddr, int transport, bool accept), (override));
|
||||
MOCK_METHOD(bool, SetDevicePairingConfirmation, (const BdAddr *bdAddr, int transport, bool accept), (override));
|
||||
MOCK_METHOD(bool, PairRequestReply, (const BdAddr *bdAddr, int32_t transport, bool accept), (override));
|
||||
MOCK_METHOD(bool, SetDevicePairingConfirmation, (const BdAddr *bdAddr, int32_t transport, bool accept), (override));
|
||||
|
||||
MOCK_METHOD(int, BleGattRegisterCallbacks, (BtGattCallbacks *func), (override));
|
||||
MOCK_METHOD(int, BleRegisterScanCallbacks, (BleScanCallbacks *func, int32_t *scannerId), (override));
|
||||
MOCK_METHOD(int, BleDeregisterScanCallbacks, (int32_t scannerId), (override));
|
||||
MOCK_METHOD(int, BleStartScanEx, (int32_t scannerId, const BleScanConfigs *configs,
|
||||
const BleScanNativeFilter *filter, uint32_t filterSize), (override));
|
||||
MOCK_METHOD(int, BleStopScan, (int scannerId), (override));
|
||||
MOCK_METHOD(int, BleStartAdvEx, (int *advId, const StartAdvRawData rawData, BleAdvParams advParam), (override));
|
||||
MOCK_METHOD(int, BleStopAdv, (int advId), (override));
|
||||
MOCK_METHOD(int, BleStopScan, (int32_t scannerId), (override));
|
||||
MOCK_METHOD(int, BleStartAdvEx, (int32_t *advId, const StartAdvRawData rawData, BleAdvParams advParam), (override));
|
||||
MOCK_METHOD(int, BleStopAdv, (int32_t advId), (override));
|
||||
MOCK_METHOD(int, GetAdvHandle, (int32_t btAdvId, int32_t *bcHandle), (override));
|
||||
MOCK_METHOD(int, EnableSyncDataToLpDevice, (), (override));
|
||||
MOCK_METHOD(int, DisableSyncDataToLpDevice, (), (override));
|
||||
@ -118,36 +120,40 @@ public:
|
||||
|
||||
MOCK_METHOD(int, BleGattcRegister, (BtUuid appUuid), (override));
|
||||
MOCK_METHOD(int, BleGattcConnect,
|
||||
(int clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect,
|
||||
(int32_t clientId, BtGattClientCallbacks *func, const BdAddr *bdAddr, bool isAutoConnect,
|
||||
BtTransportType transport),
|
||||
(override));
|
||||
MOCK_METHOD(int, BleGattcDisconnect, (int clientId), (override));
|
||||
MOCK_METHOD(int, BleGattcSearchServices, (int clientId), (override));
|
||||
MOCK_METHOD(bool, BleGattcGetService, (int clientId, BtUuid serviceUuid), (override));
|
||||
MOCK_METHOD(int, BleGattcRegisterNotification, (int clientId, BtGattCharacteristic characteristic, bool enable),
|
||||
MOCK_METHOD(int, BleGattcDisconnect, (int32_t clientId), (override));
|
||||
MOCK_METHOD(int, BleGattcSearchServices, (int32_t clientId), (override));
|
||||
MOCK_METHOD(bool, BleGattcGetService, (int32_t clientId, BtUuid serviceUuid), (override));
|
||||
MOCK_METHOD(int, BleGattcRegisterNotification, (int32_t clientId, BtGattCharacteristic characteristic, bool enable),
|
||||
(override));
|
||||
MOCK_METHOD(int, BleGattcConfigureMtuSize, (int clientId, int mtuSize), (override));
|
||||
MOCK_METHOD(int, BleGattcConfigureMtuSize, (int32_t clientId, int32_t mtuSize), (override));
|
||||
MOCK_METHOD(int, BleGattcWriteCharacteristic,
|
||||
(int clientId, BtGattCharacteristic characteristic, BtGattWriteType writeType, int len, const char *value),
|
||||
(int32_t clientId, BtGattCharacteristic characteristic, BtGattWriteType writeType,
|
||||
int32_t len, const char *value),
|
||||
(override));
|
||||
MOCK_METHOD(int, BleGattcUnRegister, (int clientId), (override));
|
||||
MOCK_METHOD(int, BleGattcSetFastestConn, (int clientId, bool fastestConnFlag), (override));
|
||||
MOCK_METHOD(int, BleGattcSetPriority, (int clientId, const BdAddr *bdAddr, BtGattPriority priority), (override));
|
||||
MOCK_METHOD(int, BleGattcUnRegister, (int32_t clientId), (override));
|
||||
MOCK_METHOD(int, BleGattcSetFastestConn, (int32_t clientId, bool fastestConnFlag), (override));
|
||||
MOCK_METHOD(int, BleGattcSetPriority, (int32_t clientId,
|
||||
const BdAddr *bdAddr, BtGattPriority priority), (override));
|
||||
|
||||
MOCK_METHOD(int, BleGattsRegisterCallbacks, (BtGattServerCallbacks *func), (override));
|
||||
MOCK_METHOD(int, BleGattsRegister, (BtUuid appUuid), (override));
|
||||
MOCK_METHOD(int, BleGattsAddService, (int serverId, BtUuid srvcUuid, bool isPrimary, int number), (override));
|
||||
MOCK_METHOD(int, BleGattsUnRegister, (int serverId), (override));
|
||||
MOCK_METHOD(int, BleGattsAddService, (int32_t serverId, BtUuid srvcUuid,
|
||||
bool isPrimary, int32_t number), (override));
|
||||
MOCK_METHOD(int, BleGattsUnRegister, (int32_t serverId), (override));
|
||||
MOCK_METHOD(int, BleGattsAddCharacteristic,
|
||||
(int serverId, int srvcHandle, BtUuid characUuid, int properties, int permissions), (override));
|
||||
MOCK_METHOD(
|
||||
int, BleGattsAddDescriptor, (int serverId, int srvcHandle, BtUuid descUuid, int permissions), (override));
|
||||
MOCK_METHOD(int, BleGattsStartService, (int serverId, int srvcHandle), (override));
|
||||
MOCK_METHOD(int, BleGattsStopService, (int serverId, int srvcHandle), (override));
|
||||
MOCK_METHOD(int, BleGattsDeleteService, (int serverId, int srvcHandle), (override));
|
||||
MOCK_METHOD(int, BleGattsDisconnect, (int serverId, BdAddr bdAddr, int connId), (override));
|
||||
MOCK_METHOD(int, BleGattsSendResponse, (int serverId, GattsSendRspParam *param), (override));
|
||||
MOCK_METHOD(int, BleGattsSendIndication, (int serverId, GattsSendIndParam *param), (override));
|
||||
(int32_t serverId, int32_t srvcHandle, BtUuid characUuid,
|
||||
int32_t properties, int32_t permissions), (override));
|
||||
MOCK_METHOD(int, BleGattsAddDescriptor,
|
||||
(int32_t serverId, int32_t srvcHandle, BtUuid descUuid, int32_t permissions), (override));
|
||||
MOCK_METHOD(int, BleGattsStartService, (int32_t serverId, int32_t srvcHandle), (override));
|
||||
MOCK_METHOD(int, BleGattsStopService, (int32_t serverId, int32_t srvcHandle), (override));
|
||||
MOCK_METHOD(int, BleGattsDeleteService, (int32_t serverId, int32_t srvcHandle), (override));
|
||||
MOCK_METHOD(int, BleGattsDisconnect, (int32_t serverId, BdAddr bdAddr, int32_t connId), (override));
|
||||
MOCK_METHOD(int, BleGattsSendResponse, (int32_t serverId, GattsSendRspParam *param), (override));
|
||||
MOCK_METHOD(int, BleGattsSendIndication, (int32_t serverId, GattsSendIndParam *param), (override));
|
||||
MOCK_METHOD(int32_t, RegisterBroadcastMediumFunction, (SoftbusMediumType type,
|
||||
const SoftbusBroadcastMediumInterface *interface), (override));
|
||||
MOCK_METHOD(int, SoftBusAddBtStateListener, (const SoftBusBtStateListener *listener), (override));
|
||||
@ -162,4 +168,4 @@ private:
|
||||
static MockBluetooth *targetMocker;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
static StRecordCtx advDisableCtx;
|
||||
static StRecordCtx advDataCtx;
|
||||
static StRecordCtx advUpdateCtx;
|
||||
static int btInnerAdvId;
|
||||
static int32_t btInnerAdvId;
|
||||
|
||||
static void SetUpTestCase(void);
|
||||
};
|
||||
@ -64,7 +64,7 @@ StRecordCtx SoftbusBleGattTest::advEnableCtx("AdvEnableCallback");
|
||||
StRecordCtx SoftbusBleGattTest::advDisableCtx("AdvDisableCallback");
|
||||
StRecordCtx SoftbusBleGattTest::advDataCtx("AdvDataCallback");
|
||||
StRecordCtx SoftbusBleGattTest::advUpdateCtx("AdvUpdateCallback");
|
||||
int SoftbusBleGattTest::btInnerAdvId = -1;
|
||||
int32_t SoftbusBleGattTest::btInnerAdvId = -1;
|
||||
|
||||
void SoftbusBleGattTest::SetUpTestCase()
|
||||
{
|
||||
@ -89,22 +89,22 @@ static SoftbusScanCallback *GetStubScanListener()
|
||||
return &listener;
|
||||
}
|
||||
|
||||
static void StubAdvEnableCallback(int advId, int status)
|
||||
static void StubAdvEnableCallback(int32_t advId, int32_t status)
|
||||
{
|
||||
SoftbusBleGattTest::advEnableCtx.Update(advId, status);
|
||||
}
|
||||
|
||||
static void StubAdvDisableCallback(int advId, int status)
|
||||
static void StubAdvDisableCallback(int32_t advId, int32_t status)
|
||||
{
|
||||
SoftbusBleGattTest::advDisableCtx.Update(advId, status);
|
||||
}
|
||||
|
||||
static void StubAdvUpdateCallback(int advId, int status)
|
||||
static void StubAdvUpdateCallback(int32_t advId, int32_t status)
|
||||
{
|
||||
SoftbusBleGattTest::advUpdateCtx.Update(advId, status);
|
||||
}
|
||||
|
||||
static void StubAdvDataCallback(int advId, int status)
|
||||
static void StubAdvDataCallback(int32_t advId, int32_t status)
|
||||
{
|
||||
SoftbusBleGattTest::advDataCtx.Update(advId, status);
|
||||
}
|
||||
@ -120,7 +120,7 @@ SoftbusBroadcastCallback *GetStubAdvCallback()
|
||||
return &callback;
|
||||
}
|
||||
|
||||
static testing::AssertionResult PrepareScanListener(int *scannerId)
|
||||
static testing::AssertionResult PrepareScanListener(int32_t *scannerId)
|
||||
{
|
||||
int32_t ret = MockBluetooth::interface->RegisterScanListener(scannerId, GetStubScanListener());
|
||||
if (ret != SOFTBUS_OK) {
|
||||
@ -135,7 +135,7 @@ static testing::AssertionResult PrepareScanListener(int *scannerId)
|
||||
static SoftBusBcScanFilter *CreateScanFilter()
|
||||
{
|
||||
unsigned char serviceData[] = {0xE, 0xE, 0xF, 0xF, 0x04, 0x05};
|
||||
int len = sizeof(serviceData);
|
||||
int32_t len = sizeof(serviceData);
|
||||
|
||||
SoftBusBcScanFilter *filter = static_cast<SoftBusBcScanFilter *>(SoftBusCalloc(sizeof(SoftBusBcScanFilter)));
|
||||
unsigned char *serviceDataPtr = static_cast<unsigned char *>(SoftBusCalloc(len));
|
||||
@ -1122,7 +1122,7 @@ HWTEST_F(SoftbusBleGattTest, TestSoftbusSetLpParam, TestSize.Level1)
|
||||
HWTEST_F(SoftbusBleGattTest, RegisterScanListener, TestSize.Level3)
|
||||
{
|
||||
MockBluetooth mocker;
|
||||
int scannerId = -1;
|
||||
int32_t scannerId = -1;
|
||||
ASSERT_EQ(MockBluetooth::interface->RegisterScanListener(&scannerId, nullptr), SOFTBUS_INVALID_PARAM);
|
||||
int32_t scanListerIds[GATT_SCAN_MAX_NUM] = {};
|
||||
int32_t ret = SOFTBUS_ERR;
|
||||
@ -1148,7 +1148,7 @@ HWTEST_F(SoftbusBleGattTest, RegisterScanListener, TestSize.Level3)
|
||||
HWTEST_F(SoftbusBleGattTest, UnRegisterScanListener, TestSize.Level3)
|
||||
{
|
||||
MockBluetooth mocker;
|
||||
int scannerId = -1;
|
||||
int32_t scannerId = -1;
|
||||
auto result = PrepareScanListener(&scannerId);
|
||||
|
||||
ASSERT_EQ(MockBluetooth::interface->UnRegisterScanListener(-1), SOFTBUS_INVALID_PARAM);
|
||||
@ -1165,7 +1165,7 @@ HWTEST_F(SoftbusBleGattTest, UnRegisterScanListener, TestSize.Level3)
|
||||
HWTEST_F(SoftbusBleGattTest, ScanLifecycle, TestSize.Level3)
|
||||
{
|
||||
MockBluetooth mocker;
|
||||
int scannerId = -1;
|
||||
int32_t scannerId = -1;
|
||||
auto result = PrepareScanListener(&scannerId);
|
||||
|
||||
auto filter = CreateScanFilter();
|
||||
@ -1197,7 +1197,7 @@ HWTEST_F(SoftbusBleGattTest, ScanLifecycle, TestSize.Level3)
|
||||
HWTEST_F(SoftbusBleGattTest, ScanResultCb, TestSize.Level3)
|
||||
{
|
||||
MockBluetooth mocker;
|
||||
int scannerId = -1;
|
||||
int32_t scannerId = -1;
|
||||
auto result = PrepareScanListener(&scannerId);
|
||||
|
||||
auto filter = CreateScanFilter();
|
||||
@ -1252,9 +1252,9 @@ HWTEST_F(SoftbusBleGattTest, ScanResultCb, TestSize.Level3)
|
||||
*/
|
||||
HWTEST_F(SoftbusBleGattTest, RegisterBroadcaster, TestSize.Level3)
|
||||
{
|
||||
int advId = -1;
|
||||
int32_t advId = -1;
|
||||
ASSERT_EQ(MockBluetooth::interface->RegisterBroadcaster(&advId, nullptr), SOFTBUS_INVALID_PARAM);
|
||||
int advIds[GATT_ADV_MAX_NUM];
|
||||
int32_t advIds[GATT_ADV_MAX_NUM];
|
||||
for (size_t i = 0; i < GATT_ADV_MAX_NUM; i++) {
|
||||
ASSERT_EQ(MockBluetooth::interface->RegisterBroadcaster(&advIds[i], GetStubAdvCallback()), SOFTBUS_LOCK_ERR);
|
||||
}
|
||||
@ -1282,7 +1282,7 @@ void ScanResultCtx::Reset()
|
||||
scanResult.data.rspData.payload = nullptr;
|
||||
}
|
||||
|
||||
bool ScanResultCtx::Update(int id, const SoftBusBcScanResult *scanResult)
|
||||
bool ScanResultCtx::Update(int32_t id, const SoftBusBcScanResult *scanResult)
|
||||
{
|
||||
if (!RecordCtx::Update(id)) {
|
||||
return false;
|
||||
@ -1304,7 +1304,7 @@ bool ScanResultCtx::Update(int id, const SoftBusBcScanResult *scanResult)
|
||||
return true;
|
||||
}
|
||||
|
||||
testing::AssertionResult ScanResultCtx::Expect(int id, const SoftBusBcScanResult *scanResultParam)
|
||||
testing::AssertionResult ScanResultCtx::Expect(int32_t id, const SoftBusBcScanResult *scanResultParam)
|
||||
{
|
||||
auto result = RecordCtx::Expect(id);
|
||||
if (!result) {
|
||||
|
@ -195,7 +195,7 @@ HWTEST(SoftbusBleUtilsTest, DumpBleScanFilter, TestSize.Level3)
|
||||
*/
|
||||
HWTEST(SoftbusBleUtilsTest, GetBtScanMode, TestSize.Level3)
|
||||
{
|
||||
int scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P2, SOFTBUS_BC_SCAN_WINDOW_P2);
|
||||
int32_t scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P2, SOFTBUS_BC_SCAN_WINDOW_P2);
|
||||
EXPECT_EQ(scanMode, OHOS_BLE_SCAN_MODE_OP_P2_60_3000);
|
||||
|
||||
scanMode = GetBtScanMode(SOFTBUS_BC_SCAN_INTERVAL_P10, SOFTBUS_BC_SCAN_WINDOW_P10);
|
||||
|
@ -53,7 +53,7 @@ void SoftBusAdapterHiSysEventFuzzTest(const uint8_t* data, size_t size)
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
return 0;
|
||||
|
@ -44,7 +44,7 @@ static void SoftBusAdapterRangeFuzzTest(const uint8_t* data, size_t size)
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
return 0;
|
||||
|
@ -145,7 +145,7 @@ bool SoftBusAesCfbEncryptFuzzTest(const uint8_t *data, size_t size)
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return 0;
|
||||
|
@ -160,25 +160,25 @@ static LpScanParam BuildLpScanParam(const uint8_t* data, size_t size)
|
||||
return lpScanParam;
|
||||
}
|
||||
|
||||
static void BleAdvEnableCallback(int channel, int status)
|
||||
static void BleAdvEnableCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
(void)channel;
|
||||
(void)status;
|
||||
}
|
||||
|
||||
static void BleAdvDisableCallback(int channel, int status)
|
||||
static void BleAdvDisableCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
(void)channel;
|
||||
(void)status;
|
||||
}
|
||||
|
||||
static void BleAdvDataCallback(int channel, int status)
|
||||
static void BleAdvDataCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
(void)channel;
|
||||
(void)status;
|
||||
}
|
||||
|
||||
static void BleAdvUpdateCallback(int channel, int status)
|
||||
static void BleAdvUpdateCallback(int32_t channel, int32_t status)
|
||||
{
|
||||
(void)channel;
|
||||
(void)status;
|
||||
@ -191,19 +191,19 @@ static BroadcastCallback g_advCallback = {
|
||||
.OnSetBroadcastingCallback = BleAdvDataCallback,
|
||||
};
|
||||
|
||||
static void BleOnScanStart(int listenerId, int status)
|
||||
static void BleOnScanStart(int32_t listenerId, int32_t status)
|
||||
{
|
||||
(void)listenerId;
|
||||
(void)status;
|
||||
}
|
||||
|
||||
static void BleOnScanStop(int listenerId, int status)
|
||||
static void BleOnScanStop(int32_t listenerId, int32_t status)
|
||||
{
|
||||
(void)listenerId;
|
||||
(void)status;
|
||||
}
|
||||
|
||||
static void BleScanResultCallback(int listenerId, const BroadcastReportInfo *reportInfo)
|
||||
static void BleScanResultCallback(int32_t listenerId, const BroadcastReportInfo *reportInfo)
|
||||
{
|
||||
(void)listenerId;
|
||||
(void)reportInfo;
|
||||
@ -306,7 +306,7 @@ void BroadcastSetLpAdvParamFuzzTest()
|
||||
|
||||
} // OHOS namespace
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (size < MIN_DATA_LEN) {
|
||||
return 0;
|
||||
|
@ -34,7 +34,7 @@ namespace OHOS {
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::SoftBusDecryptDataTest(data, size);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "softbus_adapter_mem.h"
|
||||
|
||||
namespace OHOS {
|
||||
const int PROTOCOL_MAXLEN = 100;
|
||||
const int32_t PROTOCOL_MAXLEN = 100;
|
||||
|
||||
struct SocketProtocol {
|
||||
unsigned int cmd;
|
||||
@ -160,7 +160,7 @@ void SoftBusSocketSendToFuzzTest(const uint8_t* data, size_t size)
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::SoftBusSocketRecvFuzzTest(data, size);
|
||||
|
@ -74,7 +74,7 @@ HWTEST_F(AdapterDsoftbusRangeTest, SoftBusBleRange001, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusRangeTest, SoftBusGetBlePower001, TestSize.Level0)
|
||||
{
|
||||
int8_t power = 0;
|
||||
int ret = SoftBusGetBlePower(nullptr);
|
||||
int32_t ret = SoftBusGetBlePower(nullptr);
|
||||
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
|
||||
ret = SoftBusGetBlePower(&power);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
@ -25,16 +25,16 @@ using namespace std;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
const int PROTOCOL_MAXLEN = 100;
|
||||
const int TEST_BUF_SIZE = 10;
|
||||
const int TEST_PORT = 8888;
|
||||
const int TEST_IPV6_PORT = 8089;
|
||||
const int LOCAL_HOST_VALUE = 16777343;
|
||||
const int CMD_EXIT = 0x11001100;
|
||||
const int CMD_RECV = 0x22002200;
|
||||
const int CMD_REPLY = 0x33003300;
|
||||
const int SET_SIZE = 100;
|
||||
const int WLAN_INDEX = 4;
|
||||
const int32_t PROTOCOL_MAXLEN = 100;
|
||||
const int32_t TEST_BUF_SIZE = 10;
|
||||
const int32_t TEST_PORT = 8888;
|
||||
const int32_t TEST_IPV6_PORT = 8089;
|
||||
const int32_t LOCAL_HOST_VALUE = 16777343;
|
||||
const int32_t CMD_EXIT = 0x11001100;
|
||||
const int32_t CMD_RECV = 0x22002200;
|
||||
const int32_t CMD_REPLY = 0x33003300;
|
||||
const int32_t SET_SIZE = 100;
|
||||
const int32_t WLAN_INDEX = 4;
|
||||
|
||||
SoftBusSockAddrIn g_serAddr = {
|
||||
.sinFamily = SOFTBUS_AF_INET,
|
||||
@ -73,13 +73,13 @@ void AdapterDsoftbusSocketTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
static void SocketServiceStart(int localFlag)
|
||||
static void SocketServiceStart(int32_t localFlag)
|
||||
{
|
||||
int32_t socketFd = -1;
|
||||
int32_t optVal = 1;
|
||||
int32_t backLog = 2;
|
||||
SoftBusSockAddrIn cliAddr = {0};
|
||||
int acceptFd = -1;
|
||||
int32_t acceptFd = -1;
|
||||
struct SocketProtocol buf = {0};
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(0, ret);
|
||||
@ -135,7 +135,7 @@ static void SocketIpv6ServiceStart(int localFlag)
|
||||
int32_t optVal = 1;
|
||||
int32_t backLog = 2;
|
||||
SoftBusSockAddrIn cliAddr = {0};
|
||||
int acceptFd = -1;
|
||||
int32_t acceptFd = -1;
|
||||
struct SocketProtocol buf = {0};
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET6, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(0, ret);
|
||||
@ -335,11 +335,11 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest002, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
int optVal = 1;
|
||||
int optValLen = sizeof(int);
|
||||
int32_t optVal = 1;
|
||||
int32_t optValLen = sizeof(int);
|
||||
ret = SoftBusSocketSetOpt(socketFd, SOFTBUS_IPPROTO_IP, SOFTBUS_IP_TOS, &optVal, optValLen);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
|
||||
@ -355,12 +355,12 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest003, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
|
||||
int optVal = 1;
|
||||
int optValLen = sizeof(int);
|
||||
int32_t optVal = 1;
|
||||
int32_t optValLen = sizeof(int);
|
||||
ret = SoftBusSocketSetOpt(socketFd, SOFTBUS_SOL_SOCKET, SOFTBUS_SO_KEEPALIVE, &optVal, optValLen);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
@ -376,9 +376,9 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest003, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest004, TestSize.Level0)
|
||||
{
|
||||
int optVal = 1;
|
||||
int optValLen = sizeof(int);
|
||||
int ret = SoftBusSocketSetOpt(-1, SOFTBUS_SOL_SOCKET, SOFTBUS_SO_REUSEADDR, &optVal, optValLen);
|
||||
int32_t optVal = 1;
|
||||
int32_t optValLen = sizeof(int);
|
||||
int32_t ret = SoftBusSocketSetOpt(-1, SOFTBUS_SOL_SOCKET, SOFTBUS_SO_REUSEADDR, &optVal, optValLen);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_ERR, ret);
|
||||
}
|
||||
|
||||
@ -390,11 +390,11 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest004, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest005, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
int optVal = 10;
|
||||
int optValLen = sizeof(int);
|
||||
int32_t optVal = 10;
|
||||
int32_t optValLen = sizeof(int);
|
||||
ret = SoftBusSocketSetOpt(socketFd, SOFTBUS_IPPROTO_IP, -1, &optVal, optValLen);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_ERR, ret);
|
||||
|
||||
@ -410,10 +410,10 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest005, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest006, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
int optValLen = sizeof(int);
|
||||
int32_t optValLen = sizeof(int);
|
||||
ret = SoftBusSocketSetOpt(socketFd, SOFTBUS_IPPROTO_IP, SOFTBUS_IP_TOS, NULL, optValLen);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_ERR, ret);
|
||||
|
||||
@ -430,10 +430,10 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest006, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest007, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
int optVal = 1;
|
||||
int32_t optVal = 1;
|
||||
ret = SoftBusSocketSetOpt(socketFd, SOFTBUS_IPPROTO_IP, SOFTBUS_IP_TOS, &optVal, -1);
|
||||
EXPECT_EQ(-1, ret);
|
||||
|
||||
@ -450,10 +450,10 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSetOptTest007, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetOptTest001, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int on = 1;
|
||||
int onLen = sizeof(on);
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t on = 1;
|
||||
int32_t onLen = sizeof(on);
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
ret = SoftBusSocketGetOpt(socketFd, SOFTBUS_SOL_SOCKET, SOFTBUS_SO_REUSEADDR, &on, &onLen);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
@ -469,9 +469,9 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetOptTest001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetOptTest002, TestSize.Level0)
|
||||
{
|
||||
int on = 1;
|
||||
int onLen = sizeof(on);
|
||||
int rc = SoftBusSocketGetOpt(-1, SOFTBUS_SOL_SOCKET, SOFTBUS_SO_REUSEADDR, &on, &onLen);
|
||||
int32_t on = 1;
|
||||
int32_t onLen = sizeof(on);
|
||||
int32_t rc = SoftBusSocketGetOpt(-1, SOFTBUS_SOL_SOCKET, SOFTBUS_SO_REUSEADDR, &on, &onLen);
|
||||
EXPECT_TRUE(rc == -1);
|
||||
}
|
||||
|
||||
@ -484,7 +484,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetOptTest002, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest001, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(1);
|
||||
return;
|
||||
@ -521,7 +521,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest002, TestSize.L
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest003, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -547,7 +547,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest003, TestSize.L
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest004, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -573,8 +573,8 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest004, TestSize.L
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest005, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
SoftBusSockAddrIn clientAddr;
|
||||
ret = SoftBusSocketGetLocalName(socketFd, (SoftBusSockAddr *)&clientAddr);
|
||||
@ -607,7 +607,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest006, TestSize.L
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest007, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketIpv6ServiceStart(0);
|
||||
return;
|
||||
@ -634,7 +634,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetLocalNameTest007, TestSize.L
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest001, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -666,7 +666,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest001, TestSize.Le
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest002, TestSize.Level0)
|
||||
{
|
||||
SoftBusSockAddr addr;
|
||||
int rc = SoftBusSocketGetPeerName(-1, &addr);
|
||||
int32_t rc = SoftBusSocketGetPeerName(-1, &addr);
|
||||
EXPECT_TRUE(rc == -1);
|
||||
}
|
||||
|
||||
@ -679,7 +679,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest002, TestSize.Le
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest003, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -705,7 +705,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest003, TestSize.Le
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest004, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -732,8 +732,8 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest004, TestSize.Le
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest005, TestSize.Level0)
|
||||
{
|
||||
int socketFd;
|
||||
int ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
int32_t socketFd;
|
||||
int32_t ret = SoftBusSocketCreate(SOFTBUS_AF_INET, SOFTBUS_SOCK_STREAM, 0, &socketFd);
|
||||
EXPECT_EQ(SOFTBUS_ADAPTER_OK, ret);
|
||||
SoftBusSockAddrIn serviceAddr;
|
||||
ret = SoftBusSocketGetPeerName(socketFd, (SoftBusSockAddr *)&serviceAddr);
|
||||
@ -752,7 +752,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest005, TestSize.Le
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketGetPeerNameTest006, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketIpv6ServiceStart(0);
|
||||
return;
|
||||
@ -976,7 +976,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketListen004, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketAccept001, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1052,7 +1052,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketAccept003, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketConnect001, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(1);
|
||||
return;
|
||||
@ -1219,7 +1219,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketFdIssetTest001, TestSize.Level0
|
||||
{
|
||||
SoftBusFdSet set;
|
||||
SoftBusSocketFdSet(1, &set);
|
||||
int ret = SoftBusSocketFdIsset(1, &set);
|
||||
int32_t ret = SoftBusSocketFdIsset(1, &set);
|
||||
EXPECT_TRUE(ret == 1);
|
||||
}
|
||||
|
||||
@ -1233,7 +1233,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketFdIssetTest002, TestSize.Level0
|
||||
{
|
||||
SoftBusFdSet set = {0};
|
||||
SoftBusSocketFdClr(1, &set);
|
||||
int ret = SoftBusSocketFdIsset(1, &set);
|
||||
int32_t ret = SoftBusSocketFdIsset(1, &set);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
}
|
||||
|
||||
@ -1245,7 +1245,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketFdIssetTest002, TestSize.Level0
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketFdIssetTest003, TestSize.Level0)
|
||||
{
|
||||
int ret = SoftBusSocketFdIsset(1, NULL);
|
||||
int32_t ret = SoftBusSocketFdIsset(1, NULL);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
}
|
||||
|
||||
@ -1482,7 +1482,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendTest001, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendTest002, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1520,7 +1520,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendTest002, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendTest003, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1560,7 +1560,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendTest003, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendTest004, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1604,7 +1604,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest001, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest002, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1634,7 +1634,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest002, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest003, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1662,7 +1662,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest003, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest004, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1687,7 +1687,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest004, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest005, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1716,7 +1716,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest005, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest006, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketServiceStart(0);
|
||||
return;
|
||||
@ -1744,7 +1744,7 @@ HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendToTest006, TestSize.Level0)
|
||||
HWTEST_F(AdapterDsoftbusSocketTest, SoftBusSocketSendTest007, TestSize.Level0)
|
||||
{
|
||||
sleep(1);
|
||||
int pid = -1;
|
||||
int32_t pid = -1;
|
||||
if ((pid = fork()) == 0) {
|
||||
SocketIpv6ServiceStart(0);
|
||||
return;
|
||||
|
@ -40,7 +40,7 @@ void AdapterDsoftbusWifiTest::SetUpTestCase(void) { }
|
||||
void AdapterDsoftbusWifiTest::TearDownTestCase(void) { }
|
||||
void AdapterDsoftbusWifiTest::SetUp() { }
|
||||
void AdapterDsoftbusWifiTest::TearDown() { }
|
||||
void OnSoftBusWifiScanResult(int state, int size) { }
|
||||
void OnSoftBusWifiScanResult(int32_t state, int32_t size) { }
|
||||
/*
|
||||
* @tc.name: SoftBusGetWifiDeviceConfig
|
||||
* @tc.desc: softbus wifi test
|
||||
|
@ -54,7 +54,7 @@ bool SoftBusRsaDecryptFuzzTest(const uint8_t *data, size_t size)
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return 0;
|
||||
|
@ -263,12 +263,12 @@ HWTEST_F(AdapterDsoftbusRsaCryptoTest, SoftBusRsaDecrypt003, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AdapterDsoftbusRsaCryptoTest, DataBusNativeVirtual001, TestSize.Level0)
|
||||
{
|
||||
int channelId = 0;
|
||||
int32_t channelId = 0;
|
||||
int32_t ret = NotifyNearByUpdateMigrateOption(channelId);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
|
||||
const char *peerDeviceId = NULL;
|
||||
int routeType = 0;
|
||||
int32_t routeType = 0;
|
||||
bool isUpgrade = true;
|
||||
ret = NotifyNearByOnMigrateEvents(peerDeviceId, routeType, isUpgrade);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
|
@ -30,6 +30,7 @@ constexpr int32_t MAX_STRING_LEN = 4096;
|
||||
constexpr int32_t MIN_STRING_LEN = 1;
|
||||
constexpr int32_t APP_ID_LEN = 8;
|
||||
constexpr int32_t STORE_ID_LEN = 19;
|
||||
constexpr int32_t MIN_DBID_COUNT = 1;
|
||||
const std::string APP_ID = "dsoftbus";
|
||||
const std::string STORE_ID = "dsoftbus_kv_db_test";
|
||||
}
|
||||
@ -343,4 +344,503 @@ HWTEST_F(KVAdapterWrapperTest, LnnCreateKvAdapter_InvalidStoreIdLen_GreaterThanM
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDestroyKvAdapter_Dbid_LessThanMin
|
||||
* @tc.desc: Test LnnDestroyKvAdapter with dbId being less than MIN_DBID_COUNT.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDestroyKvAdapter_Dbid_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = MIN_DBID_COUNT - 1;
|
||||
int32_t ret = LnnDestroyKvAdapter(dbId);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnPutDBData_InvalidKey
|
||||
* @tc.desc: Test LnnPutDBData with key being nullptr.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnPutDBData_InvalidKey, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = nullptr;
|
||||
int32_t keyLen = 10;
|
||||
const char *value = "validValue";
|
||||
int32_t valueLen = strlen(value);
|
||||
int32_t ret = LnnPutDBData(dbId, key, keyLen, value, valueLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnPutDBData_KeyLen_LessThanMin
|
||||
* @tc.desc: Test LnnPutDBData with keyLen being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnPutDBData_KeyLen_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = MIN_STRING_LEN - 1;
|
||||
const char *value = "validValue";
|
||||
int32_t valueLen = strlen(value);
|
||||
int32_t ret = LnnPutDBData(dbId, key, keyLen, value, valueLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnPutDBData_KeyLen_GreaterThanMax
|
||||
* @tc.desc: Test LnnPutDBData with keyLen being greater than MAX_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnPutDBData_KeyLen_GreaterThanMax, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = MAX_STRING_LEN + 1;
|
||||
const char *value = "validValue";
|
||||
int32_t valueLen = strlen(value);
|
||||
int32_t ret = LnnPutDBData(dbId, key, keyLen, value, valueLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnPutDBData_InvalidValue
|
||||
* @tc.desc: Test LnnPutDBData with value being nullptr.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnPutDBData_InvalidValue, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = strlen(key);
|
||||
const char *value = nullptr;
|
||||
int32_t valueLen = 10;
|
||||
int32_t ret = LnnPutDBData(dbId, key, keyLen, value, valueLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnPutDBData_ValueLen_LessThanMin
|
||||
* @tc.desc: Test LnnPutDBData with valueLen being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnPutDBData_ValueLen_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = strlen(key);
|
||||
const char *value = "validValue";
|
||||
int32_t valueLen = MIN_STRING_LEN - 1;
|
||||
int32_t ret = LnnPutDBData(dbId, key, keyLen, value, valueLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnPutDBData_ValueLen_GreaterThanMax
|
||||
* @tc.desc: Test LnnPutDBData with valueLen being greater than MAX_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnPutDBData_ValueLen_GreaterThanMax, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = strlen(key);
|
||||
const char *value = "validValue";
|
||||
int32_t valueLen = MAX_STRING_LEN + 1;
|
||||
int32_t ret = LnnPutDBData(dbId, key, keyLen, value, valueLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnPutDBData_Dbid_LessThanMin
|
||||
* @tc.desc: Test LnnPutDBData with dbid being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnPutDBData_Dbid_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = MIN_DBID_COUNT - 1;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = strlen(key);
|
||||
const char *value = "validValue";
|
||||
int32_t valueLen = strlen(value);
|
||||
int32_t ret = LnnPutDBData(dbId, key, keyLen, value, valueLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBData_InvalidKey
|
||||
* @tc.desc: Test LnnDeleteDBData with key being nullptr.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBData_InvalidKey, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = nullptr;
|
||||
int32_t keyLen = 10;
|
||||
int32_t ret = LnnDeleteDBData(dbId, key, keyLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBData_KeyLen_LessThanMin
|
||||
* @tc.desc: Test LnnDeleteDBData with keyLen being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBData_KeyLen_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = MIN_STRING_LEN - 1;
|
||||
int32_t ret = LnnDeleteDBData(dbId, key, keyLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBData_KeyLen_GreaterThanMax
|
||||
* @tc.desc: Test LnnDeleteDBData with keyLen being greater than MAX_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBData_KeyLen_GreaterThanMax, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = MAX_STRING_LEN + 1;
|
||||
int32_t ret = LnnDeleteDBData(dbId, key, keyLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBData_Dbid_LessThanMin
|
||||
* @tc.desc: Test LnnDeleteDBData with dbid being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBData_Dbid_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = MIN_DBID_COUNT-1;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = strlen(key);
|
||||
int32_t ret = LnnDeleteDBData(dbId, key, keyLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnGetDBData_InvalidValue
|
||||
* @tc.desc: Test LnnGetDBData with value being nullptr.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnGetDBData_InvalidValue, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = strlen(key);
|
||||
char **value = nullptr;
|
||||
int32_t ret = LnnGetDBData(dbId, key, keyLen, value);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnGetDBData_InvalidKey
|
||||
* @tc.desc: Test LnnGetDBData with key being nullptr.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnGetDBData_InvalidKey, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = nullptr;
|
||||
int32_t keyLen = 10;
|
||||
const int32_t num = 3;
|
||||
char **value = new (std::nothrow) char *[num];
|
||||
if (value == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string strValue0 = "value";
|
||||
value[0] = new (std::nothrow) char[strValue0.size() + 1];
|
||||
if (value[0] == nullptr) {
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue0.c_str(), strValue0.size(), value[0]);
|
||||
value[0][strValue0.size()] = '\0';
|
||||
std::string strValue1 = "test";
|
||||
value[1] = new (std::nothrow) char[strValue1.size() + 1];
|
||||
if (value[1] == nullptr) {
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue1.c_str(), strValue1.size(), value[1]);
|
||||
value[1][strValue1.size()] = '\0';
|
||||
std::string strValue2 = "char";
|
||||
value[2] = new (std::nothrow) char[strValue2.size() + 1];
|
||||
if (value[2] == nullptr) {
|
||||
delete[] value[1];
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue2.c_str(), strValue2.size(), value[2]);
|
||||
value[2][strValue2.size()] = '\0';
|
||||
int32_t ret = LnnGetDBData(dbId, key, keyLen, value);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
delete[] value[i];
|
||||
}
|
||||
delete[] value;
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnGetDBData_KeyLen_LessThanMin
|
||||
* @tc.desc: Test LnnGetDBData with keyLen being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnGetDBData_KeyLen_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = MIN_STRING_LEN - 1;
|
||||
const int32_t num = 3;
|
||||
char **value = new (std::nothrow) char *[num];
|
||||
if (value == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string strValue0 = "value";
|
||||
value[0] = new (std::nothrow) char[strValue0.size() + 1];
|
||||
if (value[0] == nullptr) {
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue0.c_str(), strValue0.size(), value[0]);
|
||||
value[0][strValue0.size()] = '\0';
|
||||
std::string strValue1 = "test";
|
||||
value[1] = new (std::nothrow) char[strValue1.size() + 1];
|
||||
if (value[1] == nullptr) {
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue1.c_str(), strValue1.size(), value[1]);
|
||||
value[1][strValue1.size()] = '\0';
|
||||
std::string strValue2 = "char";
|
||||
value[2] = new (std::nothrow) char[strValue2.size() + 1];
|
||||
if (value[2] == nullptr) {
|
||||
delete[] value[1];
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue2.c_str(), strValue2.size(), value[2]);
|
||||
value[2][strValue2.size()] = '\0';
|
||||
int32_t ret = LnnGetDBData(dbId, key, keyLen, value);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
delete[] value[i];
|
||||
}
|
||||
delete[] value;
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnGetDBData_KeyLen_GreaterThanMax
|
||||
* @tc.desc: Test LnnGetDBData with keyLen being greater than MAX_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnGetDBData_KeyLen_GreaterThanMax, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = MAX_STRING_LEN + 1;
|
||||
const int32_t num = 3;
|
||||
char **value = new (std::nothrow) char *[num];
|
||||
if (value == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string strValue0 = "value";
|
||||
value[0] = new (std::nothrow) char[strValue0.size() + 1];
|
||||
if (value[0] == nullptr) {
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue0.c_str(), strValue0.size(), value[0]);
|
||||
value[0][strValue0.size()] = '\0';
|
||||
std::string strValue1 = "test";
|
||||
value[1] = new (std::nothrow) char[strValue1.size() + 1];
|
||||
if (value[1] == nullptr) {
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue1.c_str(), strValue1.size(), value[1]);
|
||||
value[1][strValue1.size()] = '\0';
|
||||
std::string strValue2 = "char";
|
||||
value[2] = new (std::nothrow) char[strValue2.size() + 1];
|
||||
if (value[2] == nullptr) {
|
||||
delete[] value[1];
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue2.c_str(), strValue2.size(), value[2]);
|
||||
value[2][strValue2.size()] = '\0';
|
||||
int32_t ret = LnnGetDBData(dbId, key, keyLen, value);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
delete[] value[i];
|
||||
}
|
||||
delete[] value;
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnGetDBData_Dbid_LessThanMin
|
||||
* @tc.desc: Test LnnGetDBData with dbid being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnGetDBData_Dbid_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = MIN_DBID_COUNT - 1;
|
||||
const char *key = "validKey";
|
||||
int32_t keyLen = strlen(key);
|
||||
const int32_t num = 3;
|
||||
char **value = new (std::nothrow) char *[num];
|
||||
if (value == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string strValue0 = "value";
|
||||
value[0] = new (std::nothrow) char[strValue0.size() + 1];
|
||||
if (value[0] == nullptr) {
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue0.c_str(), strValue0.size(), value[0]);
|
||||
value[0][strValue0.size()] = '\0';
|
||||
std::string strValue1 = "test";
|
||||
value[1] = new (std::nothrow) char[strValue1.size() + 1];
|
||||
if (value[1] == nullptr) {
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue1.c_str(), strValue1.size(), value[1]);
|
||||
value[1][strValue1.size()] = '\0';
|
||||
std::string strValue2 = "char";
|
||||
value[2] = new (std::nothrow) char[strValue2.size() + 1];
|
||||
if (value[2] == nullptr) {
|
||||
delete[] value[1];
|
||||
delete[] value[0];
|
||||
delete[] value;
|
||||
return;
|
||||
}
|
||||
std::copy_n(strValue2.c_str(), strValue2.size(), value[2]);
|
||||
value[2][strValue2.size()] = '\0';
|
||||
int32_t ret = LnnGetDBData(dbId, key, keyLen, value);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
delete[] value[i];
|
||||
}
|
||||
delete[] value;
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBDataByPrefix_InvalidKeyPrefix
|
||||
* @tc.desc: Test LnnDeleteDBDataByPrefix with keyPrefix being nullptr.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBDataByPrefix_InvalidKeyPrefix, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *keyPrefix = nullptr;
|
||||
int32_t keyPrefixLen = 10;
|
||||
int32_t ret = LnnDeleteDBDataByPrefix(dbId, keyPrefix, keyPrefixLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBDataByPrefix_KeyPrefixLen_LessThanMin
|
||||
* @tc.desc: Test LnnDeleteDBDataByPrefix with keyPrefixLen being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBDataByPrefix_KeyPrefixLen_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *keyPrefix = "validKeyPrefix";
|
||||
int32_t keyPrefixLen = MIN_STRING_LEN - 1;
|
||||
int32_t ret = LnnDeleteDBDataByPrefix(dbId, keyPrefix, keyPrefixLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBDataByPrefix_KeyPrefixLen_GreaterThanMax
|
||||
* @tc.desc: Test LnnDeleteDBDataByPrefix with keyPrefixLen being greater than MAX_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBDataByPrefix_KeyPrefixLen_GreaterThanMax, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = g_dbId;
|
||||
const char *keyPrefix = "validKeyPrefix";
|
||||
int32_t keyPrefixLen = MAX_STRING_LEN + 1;
|
||||
int32_t ret = LnnDeleteDBDataByPrefix(dbId, keyPrefix, keyPrefixLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnDeleteDBDataByPrefix_Dbid_LessThanMin
|
||||
* @tc.desc: Test LnnDeleteDBDataByPrefix with dbid being less than MIN_STRING_LEN.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnDeleteDBDataByPrefix_Dbid_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = MIN_DBID_COUNT - 1;
|
||||
const char *keyPrefix = "validKeyPrefix";
|
||||
int32_t keyPrefixLen = strlen(keyPrefix);
|
||||
int32_t ret = LnnDeleteDBDataByPrefix(dbId, keyPrefix, keyPrefixLen);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnCloudSync_Dbid_LessThanMin
|
||||
* @tc.desc: Test LnnCloudSync with dbId being less than MIN_DBID_COUNT.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnCloudSync_Dbid_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = MIN_DBID_COUNT - 1;
|
||||
int32_t ret = LnnCloudSync(dbId);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LnnSetCloudAbilityInner_Dbid_LessThanMin
|
||||
* @tc.desc: Test LnnSetCloudAbilityInner with dbId being less than MIN_DBID_COUNT.
|
||||
* @tc.type: Functional Test
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(KVAdapterWrapperTest, LnnSetCloudAbilityInner_Dbid_LessThanMin, TestSize.Level1)
|
||||
{
|
||||
int32_t dbId = MIN_DBID_COUNT - 1;
|
||||
const bool isEnableCloud = true;
|
||||
int32_t ret = LnnSetCloudAbilityInner(dbId, isEnableCloud);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
} // namespace OHOS
|
||||
|
@ -74,7 +74,7 @@ OHOS::ErrCode OHOS::AccountSA::OsAccountManager::QueryActiveOsAccountIds(std::ve
|
||||
return mock->QueryActiveOsAccountIds(ids);
|
||||
}
|
||||
|
||||
OHOS::ErrCode OHOS::AccountSA::OsAccountManager::IsOsAccountVerified(const int id, bool &isVerified)
|
||||
OHOS::ErrCode OHOS::AccountSA::OsAccountManager::IsOsAccountVerified(const int32_t id, bool &isVerified)
|
||||
{
|
||||
auto mock = OHOS::AccountSA::OsAccountManagerMock::GetMock();
|
||||
if (mock == nullptr) {
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
virtual ~OsAccountManager() = default;
|
||||
|
||||
virtual OHOS::ErrCode QueryActiveOsAccountIds(std::vector<int32_t> &ids);
|
||||
virtual OHOS::ErrCode IsOsAccountVerified(const int id, bool &isVerified);
|
||||
virtual OHOS::ErrCode IsOsAccountVerified(const int32_t id, bool &isVerified);
|
||||
};
|
||||
|
||||
class OsAccountManagerMock : public AccountSA::OsAccountManager {
|
||||
@ -65,7 +65,7 @@ public:
|
||||
OsAccountManagerMock();
|
||||
~OsAccountManagerMock() override;
|
||||
MOCK_METHOD1(QueryActiveOsAccountIds, OHOS::ErrCode(std::vector<int32_t> &ids));
|
||||
MOCK_METHOD2(IsOsAccountVerified, OHOS::ErrCode(const int id, bool &isVerified));
|
||||
MOCK_METHOD2(IsOsAccountVerified, OHOS::ErrCode(const int32_t id, bool &isVerified));
|
||||
|
||||
static OsAccountManagerMock *GetMock()
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ static SettingDataEventMonitorDepsInterface *GetSettingDataEventMonitorDepsInter
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
SoftBusLooper *GetLooper(int looper)
|
||||
SoftBusLooper *GetLooper(int32_t looper)
|
||||
{
|
||||
return GetSettingDataEventMonitorDepsInterface()->GetLooper(looper);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
SettingDataEventMonitorDepsInterface() {};
|
||||
virtual ~SettingDataEventMonitorDepsInterface() {};
|
||||
|
||||
virtual SoftBusLooper *GetLooper(int looper) = 0;
|
||||
virtual SoftBusLooper *GetLooper(int32_t looper) = 0;
|
||||
virtual int32_t LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para) = 0;
|
||||
virtual int32_t GetActiveOsAccountIds(void) = 0;
|
||||
virtual void UpdateDeviceName(void *p) = 0;
|
||||
|
@ -72,7 +72,7 @@ void LnnSettingdataEventMonitorTest::TearDown(void)
|
||||
*/
|
||||
HWTEST_F(LnnSettingdataEventMonitorTest, LnnGetSettingDeviceNameTest001, TestSize.Level1)
|
||||
{
|
||||
int ret = LnnGetSettingDeviceName(DEVICE_NAME1, DEVICE_NAME_BUF_LEN);
|
||||
int32_t ret = LnnGetSettingDeviceName(DEVICE_NAME1, DEVICE_NAME_BUF_LEN);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ HWTEST_F(LnnSettingdataEventMonitorTest, LnnGetSettingDeviceNameTest001, TestSiz
|
||||
HWTEST_F(LnnSettingdataEventMonitorTest, LnnGetSettingDeviceNameTest002, TestSize.Level1)
|
||||
{
|
||||
LnnDeviceNameHandler handler = NULL;
|
||||
int ret = LnnInitGetDeviceName(handler);
|
||||
int32_t ret = LnnInitGetDeviceName(handler);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ void AuthMetaStartVerifyFuzzTest(const uint8_t* data, size_t size)
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::AuthDataFuzzTest(data, size);
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
static bool isFirst = true;
|
||||
|
@ -35,7 +35,7 @@ namespace OHOS {
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::UnpackAuthDataFuzzTest(data, size);
|
||||
|
@ -140,7 +140,7 @@ HWTEST_F(AuthHichainTest, ON_DEVICE_NOT_TRUSTED_TEST_001, TestSize.Level1)
|
||||
HWTEST_F(AuthHichainTest, ON_REQUEST_TEST_001, TestSize.Level1)
|
||||
{
|
||||
int64_t authSeq = 0;
|
||||
int operationCode = 0;
|
||||
int32_t operationCode = 0;
|
||||
const char *reqParams = "testdata";
|
||||
|
||||
char *msgStr = OnRequest(authSeq, operationCode, reqParams);
|
||||
|
@ -27,7 +27,7 @@ static const std::string DATA_TAG = "TEData";
|
||||
static const std::string DEVICE_ID_TAG = "TEDeviceId";
|
||||
static const std::string DATA_BUF_SIZE_TAG = "DataBufSize";
|
||||
static const std::string SOFT_BUS_VERSION_TAG = "softbusVersion";
|
||||
static const int PACKET_SIZE = (64 * 1024);
|
||||
static const int32_t PACKET_SIZE = (64 * 1024);
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
@ -639,7 +639,7 @@ HWTEST_F(AuthOtherTest, ON_COMM_DATA_RECEIVED_TEST_001, TestSize.Level1)
|
||||
ConnModule moduleId = MODULE_DEVICE_AUTH;
|
||||
int64_t seq = 0;
|
||||
char *data = reinterpret_cast<char *>(malloc(1024));
|
||||
const int SEND_DATA_SIZE_1KB = 1024;
|
||||
const int32_t SEND_DATA_SIZE_1KB = 1024;
|
||||
ASSERT_NE(data, nullptr);
|
||||
const char *testData = "{\"data\":\"open session test!!!\"}";
|
||||
int32_t len = 2;
|
||||
@ -705,7 +705,7 @@ HWTEST_F(AuthOtherTest, ON_COMM_DATA_RECEVIED_TEST_001, TestSize.Level1)
|
||||
ASSERT_NE(data, nullptr);
|
||||
OnCommDataReceived(connectionId, moduleId, seq, data, len);
|
||||
|
||||
const int SEND_DATA_SIZE_1KB = 1024;
|
||||
const int32_t SEND_DATA_SIZE_1KB = 1024;
|
||||
const char *testData = "{\"data\":\"open session test!!!\"}";
|
||||
len = 2;
|
||||
moduleId = MODULE_CONNECTION;
|
||||
|
@ -85,7 +85,7 @@ HWTEST_F(AuthSessionMessageTest, PackFastAuthValue_TEST_001, TestSize.Level1)
|
||||
JSON_AddStringToObject(json, FAST_AUTH, "jsontest");
|
||||
OptString(json, DEVICE_ID, target, 10, "");
|
||||
OptString(json, FAST_AUTH, target, 10, "");
|
||||
int val = 0;
|
||||
int32_t val = 0;
|
||||
OptInt(json, P2P_ROLE, &val, 0);
|
||||
JSON_AddInt32ToObject(json, SOFTBUS_VERSION_TAG, 123);
|
||||
OptInt(json, SOFTBUS_VERSION_TAG, &val, 0);
|
||||
|
@ -2155,7 +2155,7 @@ HWTEST_F(AuthTest, AUTH_SET_TCP_KEEPALIVE_OPTION_Test_003, TestSize.Level1)
|
||||
const SocketInterface *tcp = GetTcpProtocol();
|
||||
ASSERT_NE(tcp, nullptr);
|
||||
|
||||
int port = CLIENT_PORT;
|
||||
int32_t port = CLIENT_PORT;
|
||||
char ipAddress[] = "127.0.0.1";
|
||||
LocalListenerInfo info = {};
|
||||
info.type = CONNECT_TCP;
|
||||
@ -2163,7 +2163,7 @@ HWTEST_F(AuthTest, AUTH_SET_TCP_KEEPALIVE_OPTION_Test_003, TestSize.Level1)
|
||||
info.socketOption.moduleId = DIRECT_CHANNEL_SERVER_WIFI;
|
||||
info.socketOption.protocol = LNN_PROTOCOL_IP;
|
||||
(void)strcpy_s(info.socketOption.addr, sizeof(info.socketOption.addr), ipAddress);
|
||||
int fd = tcp->OpenServerSocket(&info);
|
||||
int32_t fd = tcp->OpenServerSocket(&info);
|
||||
|
||||
int32_t ret = AuthSetTcpKeepaliveOption(fd, HIGH_FREQ_CYCLE);
|
||||
EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
|
||||
|
@ -60,7 +60,7 @@ const AuthConnCallback g_connCallback = {
|
||||
.onConnOpened = LnnConnectInterfaceMock::onConnOpened,
|
||||
.onConnOpenFailed = LnnConnectInterfaceMock::onConnOpenFailed,
|
||||
};
|
||||
static const int MILLIS = 15;
|
||||
static const int32_t MILLIS = 15;
|
||||
|
||||
class AuthEnhanceMockTest : public testing::Test {
|
||||
public:
|
||||
|
@ -58,8 +58,8 @@ static const ConnModule MODULE_ID = MODULE_DEVICE_AUTH;
|
||||
static const uint8_t DEVICE_INFO[5] = { 0x10, 0x2, 0x14, 0x08, 0x06 };
|
||||
uint8_t g_sessionKey[SESSION_KEY_LENGTH];
|
||||
static const int32_t TEST_DATA_LEN = 600;
|
||||
static const int OPER_CODE = 0;
|
||||
static const int DELAY_TIME = 15;
|
||||
static const int32_t OPER_CODE = 0;
|
||||
static const int32_t DELAY_TIME = 15;
|
||||
static const char *g_retData = nullptr;
|
||||
static uint64_t g_connId = 8590065691;
|
||||
const AuthConnInfo g_connInfo = {
|
||||
@ -203,7 +203,7 @@ bool WaitForSignal()
|
||||
return false;
|
||||
}
|
||||
if (!AuthNetLedgertInterfaceMock::isRuned) {
|
||||
int ret = SoftBusCondWait(&LnnHichainInterfaceMock::cond, &LnnHichainInterfaceMock::mutex, &tv);
|
||||
int32_t ret = SoftBusCondWait(&LnnHichainInterfaceMock::cond, &LnnHichainInterfaceMock::mutex, &tv);
|
||||
(void)SoftBusMutexUnlock(&LnnHichainInterfaceMock::mutex);
|
||||
return (ret == SOFTBUS_OK);
|
||||
} else {
|
||||
|
@ -64,7 +64,7 @@ void LnnNotifyDiscoveryDeviceFuzzTest(const uint8_t* data, size_t size)
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::LnnNotifyDiscoveryDeviceFuzzTest(data, size);
|
||||
|
@ -83,7 +83,7 @@ void LnnSendP2pSyncInfoMsgFuzzTest(const uint8_t* data, size_t size)
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::LnnSendSyncInfoMsgFuzzTest(data, size);
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
virtual int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
|
||||
virtual int32_t AuthOpenConn(const AuthConnInfo *info, uint32_t requestId,
|
||||
const AuthConnCallback *callback, bool isMeta) = 0;
|
||||
virtual int SoftBusFrequencyToChannel(int frequency) = 0;
|
||||
virtual int32_t SoftBusFrequencyToChannel(int32_t frequency) = 0;
|
||||
virtual NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type) = 0;
|
||||
virtual const NodeInfo *LnnGetLocalNodeInfo(void) = 0;
|
||||
virtual void AuthCloseConn(AuthHandle authHandle) = 0;
|
||||
@ -110,7 +110,7 @@ public:
|
||||
virtual void AuthDeviceGetLatestIdByUuid(const char *uuid, AuthLinkType type, AuthHandle *authHandle) = 0;
|
||||
virtual int32_t LnnGetOsTypeByNetworkId(const char *networkId, int32_t *osType) = 0;
|
||||
virtual void DeleteNetworkResourceByLaneId(uint64_t laneId) = 0;
|
||||
virtual int SoftBusGetBtState() = 0;
|
||||
virtual int32_t SoftBusGetBtState() = 0;
|
||||
virtual int32_t LnnGetAllOnlineNodeInfo(NodeBasicInfo **info, int32_t *infoNum) = 0;
|
||||
virtual void AddNetworkResource(NetworkResource *networkResource) = 0;
|
||||
virtual int32_t LnnRequestCheckOnlineStatus(const char *networkId, uint64_t timeout) = 0;
|
||||
@ -132,7 +132,7 @@ public:
|
||||
MOCK_METHOD3(AuthGetP2pConnInfo, int32_t (const char*, AuthConnInfo*, bool));
|
||||
MOCK_METHOD3(AuthGetHmlConnInfo, int32_t (const char*, AuthConnInfo*, bool));
|
||||
MOCK_METHOD4(AuthOpenConn, int32_t (const AuthConnInfo*, uint32_t, const AuthConnCallback*, bool));
|
||||
MOCK_METHOD1(SoftBusFrequencyToChannel, int (int));
|
||||
MOCK_METHOD1(SoftBusFrequencyToChannel, int32_t (int));
|
||||
MOCK_METHOD2(LnnGetLocalNumInfo, int32_t (InfoKey, int32_t*));
|
||||
MOCK_METHOD3(LnnGetRemoteNumInfo, int32_t (const char*, InfoKey, int32_t*));
|
||||
MOCK_METHOD2(LnnGetNodeInfoById, NodeInfo* (const char*, IdCategory));
|
||||
@ -175,7 +175,7 @@ public:
|
||||
MOCK_METHOD3(AuthDeviceGetLatestIdByUuid, void (const char *uuid, AuthLinkType type, AuthHandle *authHandle));
|
||||
MOCK_METHOD2(LnnGetOsTypeByNetworkId, int32_t (const char *, int32_t *));
|
||||
MOCK_METHOD1(DeleteNetworkResourceByLaneId, void (uint64_t laneId));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int (void));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int32_t (void));
|
||||
MOCK_METHOD2(LnnGetAllOnlineNodeInfo, int32_t (NodeBasicInfo **info, int32_t *infoNum));
|
||||
MOCK_METHOD1(AddNetworkResource, void (NetworkResource *));
|
||||
MOCK_METHOD2(LnnRequestCheckOnlineStatus, int32_t (const char *networkId, uint64_t timeout));
|
||||
|
@ -218,7 +218,7 @@ int32_t AuthOpenConn(const AuthConnInfo *info, uint32_t requestId,
|
||||
return GetLaneDepsInterface()->AuthOpenConn(info, requestId, callback, isMeta);
|
||||
}
|
||||
|
||||
int SoftBusFrequencyToChannel(int frequency)
|
||||
int32_t SoftBusFrequencyToChannel(int32_t frequency)
|
||||
{
|
||||
return GetLaneDepsInterface()->SoftBusFrequencyToChannel(frequency);
|
||||
}
|
||||
@ -426,7 +426,7 @@ void DeleteNetworkResourceByLaneId(uint64_t laneId)
|
||||
GetLaneDepsInterface()->DeleteNetworkResourceByLaneId(laneId);
|
||||
}
|
||||
|
||||
int SoftBusGetBtState(void)
|
||||
int32_t SoftBusGetBtState(void)
|
||||
{
|
||||
return GetLaneDepsInterface()->SoftBusGetBtState();
|
||||
}
|
||||
|
@ -1844,6 +1844,9 @@ HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_009, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_010, TestSize.Level1)
|
||||
{
|
||||
const char *networkId = "testnetworkid123";
|
||||
const char *ipAddr = "127.0.0.1";
|
||||
uint16_t port = 1022;
|
||||
NiceMock<LaneDepsInterfaceMock> mock;
|
||||
LinkRequest reqInfo = {};
|
||||
int32_t ret;
|
||||
@ -1862,6 +1865,9 @@ HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_010, TestSize.Level1)
|
||||
if (strcpy_s(reqInfo.peerBleMac, MAX_MAC_LEN, bleMac) != EOK) {
|
||||
return;
|
||||
}
|
||||
LaneAddP2pAddress(networkId, ipAddr, port);
|
||||
LaneAddP2pAddressByIp(ipAddr, port);
|
||||
LaneUpdateP2pAddressByIp(ipAddr, networkId);
|
||||
ON_CALL(mock, ConnBleGetConnectionByUdid).WillByDefault(Return(connection));
|
||||
ON_CALL(mock, ConnBleReturnConnection).WillByDefault(Return());
|
||||
EXPECT_CALL(mock, LnnConvertDLidToUdid).WillRepeatedly(Return(udid));
|
||||
@ -1876,22 +1882,6 @@ HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_010, TestSize.Level1)
|
||||
SoftBusFree(connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LANE_ADD_P2P_ADDRESS_TEST_001
|
||||
* @tc.desc: LANE ADD P2P ADDRESS TEST
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LNNLaneMockTest, LANE_ADD_P2P_ADDRESS_TEST_001, TestSize.Level1)
|
||||
{
|
||||
const char *networkId = "testnetworkid123";
|
||||
const char *ipAddr = "127.0.0.1";
|
||||
uint16_t port = 1022;
|
||||
LaneAddP2pAddress(networkId, ipAddr, port);
|
||||
LaneAddP2pAddressByIp(ipAddr, port);
|
||||
LaneUpdateP2pAddressByIp(ipAddr, networkId);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_SELECT_EXPECT_LANES_BY_QOS_001
|
||||
* @tc.desc: SelectExpectLanesByQos
|
||||
@ -2944,37 +2934,6 @@ HWTEST_F(LNNLaneMockTest, LNN_LANE_SELECT_RULE_05, TestSize.Level1)
|
||||
EXPECT_EQ(ret, SOFTBUS_LANE_WIFI_OFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_LANE_01
|
||||
* @tc.desc: SelectLaneRule
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LNNLaneMockTest, LNN_LANE_01, TestSize.Level1)
|
||||
{
|
||||
ILaneIdStateListener listener;
|
||||
RegisterLaneIdListener(nullptr);
|
||||
|
||||
listener.OnLaneIdEnabled = nullptr;
|
||||
listener.OnLaneIdDisabled = nullptr;
|
||||
RegisterLaneIdListener(&listener);
|
||||
UnregisterLaneIdListener(nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_LANE_02
|
||||
* @tc.desc: SelectLaneRule
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LNNLaneMockTest, LNN_LANE_02, TestSize.Level1)
|
||||
{
|
||||
uint32_t laneReqId = 0;
|
||||
FreeLaneReqId(laneReqId);
|
||||
laneReqId = 0xfffffff;
|
||||
FreeLaneReqId(laneReqId);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_LANE_03
|
||||
* @tc.desc: SelectLaneRule
|
||||
@ -2983,8 +2942,19 @@ HWTEST_F(LNNLaneMockTest, LNN_LANE_02, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(LNNLaneMockTest, LNN_LANE_03, TestSize.Level1)
|
||||
{
|
||||
uint32_t laneReqId = 0;
|
||||
LaneRequestOption request;
|
||||
ILaneListener listener;
|
||||
ILaneIdStateListener laneListener;
|
||||
|
||||
RegisterLaneIdListener(nullptr);
|
||||
laneListener.OnLaneIdEnabled = nullptr;
|
||||
laneListener.OnLaneIdDisabled = nullptr;
|
||||
RegisterLaneIdListener(&laneListener);
|
||||
UnregisterLaneIdListener(nullptr);
|
||||
FreeLaneReqId(laneReqId);
|
||||
laneReqId = 0xfffffff;
|
||||
FreeLaneReqId(laneReqId);
|
||||
request.type = LANE_TYPE_BUTT;
|
||||
int32_t ret = LnnRequestLane(0, &request, &listener);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
|
@ -40,7 +40,7 @@ constexpr char PEER_IP_HML[] = "127.30.0.1";
|
||||
constexpr char PEER_IP_P2P[] = "127.31.0.1";
|
||||
constexpr uint64_t LANE_ID_P2P = 0x1000000000000001;
|
||||
constexpr uint64_t LANE_ID_HML = 0x1000000000000002;
|
||||
constexpr int CHANNEL_ID = 10;
|
||||
constexpr int32_t CHANNEL_ID = 10;
|
||||
constexpr char MAC_TEST[] = "testMac";
|
||||
|
||||
class LNNLaneListenerTest : public testing::Test {
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
virtual void AuthHandleLeaveLNN(AuthHandle authHandle) = 0;
|
||||
virtual LnnConnectionFsm *LnnCreateConnectionFsm(const ConnectionAddr *target,
|
||||
const char *pkgName, bool isNeedConnect);
|
||||
virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len);
|
||||
virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len);
|
||||
virtual int32_t LnnSetLocalStrInfo(InfoKey key, const char *info);
|
||||
virtual int32_t LnnSetLocalNumInfo(InfoKey key, int32_t info);
|
||||
virtual int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len);
|
||||
@ -86,7 +86,7 @@ public:
|
||||
virtual bool LnnConvertAuthConnInfoToAddr(ConnectionAddr *addr,
|
||||
const AuthConnInfo *connInfo, ConnectionAddrType hintType);
|
||||
virtual bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value);
|
||||
virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int num);
|
||||
virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num);
|
||||
virtual int32_t LnnSendSyncInfoMsg(LnnSyncInfoType type, const char *networkId,
|
||||
const uint8_t *msg, uint32_t len, LnnSyncInfoMsgComplete complete);
|
||||
virtual NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type);
|
||||
@ -112,7 +112,7 @@ public:
|
||||
LnnSyncInfoMsgComplete complete);
|
||||
virtual int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
|
||||
void *para, uint64_t delayMillis);
|
||||
virtual SoftBusLooper *GetLooper(int looper);
|
||||
virtual SoftBusLooper *GetLooper(int32_t looper);
|
||||
virtual int32_t ConnDisconnectDeviceAllConn(const ConnectOption *option);
|
||||
virtual int32_t LnnGenLocalIrk(unsigned char *irk, uint32_t len);
|
||||
virtual int32_t LnnGenLocalUuid(char *uuid, uint32_t len);
|
||||
@ -201,7 +201,7 @@ public:
|
||||
MOCK_METHOD0(AuthGenRequestId, uint32_t ());
|
||||
MOCK_METHOD0(LnnSetUnlockState, void ());
|
||||
MOCK_METHOD1(AuthHandleLeaveLNN, void (AuthHandle));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int32_t (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD2(LnnSetLocalStrInfo, int32_t (InfoKey, const char *));
|
||||
MOCK_METHOD2(LnnSetLocalNumInfo, int32_t (InfoKey, int32_t));
|
||||
MOCK_METHOD3(LnnGetLocalStrInfo, int32_t (InfoKey, char *, uint32_t));
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
LnnConnFsmInterface() {};
|
||||
virtual ~LnnConnFsmInterface() {};
|
||||
virtual void LnnNotifyDeviceVerified(const char *udid) = 0;
|
||||
virtual int SoftBusGetBtState(void) = 0;
|
||||
virtual int32_t SoftBusGetBtState(void) = 0;
|
||||
virtual int32_t LnnGenerateBtMacHash(const char *btMac, int32_t brMacLen, char *brMacHash, int32_t hashLen) = 0;
|
||||
virtual void DeleteFromProfile(const char *udid) = 0;
|
||||
virtual void SendDeviceStateToMlps(void *para) = 0;
|
||||
@ -69,7 +69,7 @@ public:
|
||||
LnnConnFsmInterfaceMock();
|
||||
~LnnConnFsmInterfaceMock() override;
|
||||
MOCK_METHOD1(LnnNotifyDeviceVerified, void (const char *));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int (void));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int32_t (void));
|
||||
MOCK_METHOD4(LnnGenerateBtMacHash, int32_t (const char *, int32_t, char *, int32_t));
|
||||
MOCK_METHOD1(DeleteFromProfile, void (const char *));
|
||||
MOCK_METHOD1(SendDeviceStateToMlps, void (void *));
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
virtual void AuthHandleLeaveLNN(AuthHandle authHandle) = 0;
|
||||
virtual LnnConnectionFsm *LnnCreateConnectionFsm(const ConnectionAddr *target,
|
||||
const char *pkgName, bool isNeedConnect);
|
||||
virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len);
|
||||
virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len);
|
||||
virtual int32_t LnnSetLocalStrInfo(InfoKey key, const char *info);
|
||||
virtual int32_t LnnSetLocalNumInfo(InfoKey key, int32_t info);
|
||||
virtual int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len);
|
||||
@ -86,7 +86,7 @@ public:
|
||||
virtual bool LnnConvertAuthConnInfoToAddr(ConnectionAddr *addr,
|
||||
const AuthConnInfo *connInfo, ConnectionAddrType hintType);
|
||||
virtual bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value);
|
||||
virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int num);
|
||||
virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num);
|
||||
virtual int32_t LnnSendSyncInfoMsg(LnnSyncInfoType type, const char *networkId,
|
||||
const uint8_t *msg, uint32_t len, LnnSyncInfoMsgComplete complete);
|
||||
virtual NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type);
|
||||
@ -112,7 +112,7 @@ public:
|
||||
LnnSyncInfoMsgComplete complete);
|
||||
virtual int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
|
||||
void *para, uint64_t delayMillis);
|
||||
virtual SoftBusLooper *GetLooper(int looper);
|
||||
virtual SoftBusLooper *GetLooper(int32_t looper);
|
||||
virtual int32_t ConnDisconnectDeviceAllConn(const ConnectOption *option);
|
||||
virtual int32_t LnnGenLocalIrk(unsigned char *irk, uint32_t len);
|
||||
virtual int32_t LnnGenLocalUuid(char *uuid, uint32_t len);
|
||||
@ -203,7 +203,7 @@ public:
|
||||
MOCK_METHOD0(AuthGenRequestId, uint32_t ());
|
||||
MOCK_METHOD0(LnnSetUnlockState, void ());
|
||||
MOCK_METHOD1(AuthHandleLeaveLNN, void (AuthHandle));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int32_t (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD2(LnnSetLocalStrInfo, int32_t (InfoKey, const char *));
|
||||
MOCK_METHOD2(LnnSetLocalNumInfo, int32_t (InfoKey, int32_t));
|
||||
MOCK_METHOD3(LnnGetLocalStrInfo, int32_t (InfoKey, char *, uint32_t));
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
virtual void AuthHandleLeaveLNN(AuthHandle authHandle) = 0;
|
||||
virtual LnnConnectionFsm *LnnCreateConnectionFsm(const ConnectionAddr *target,
|
||||
const char *pkgName, bool isNeedConnect);
|
||||
virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len);
|
||||
virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len);
|
||||
virtual int32_t LnnSetLocalStrInfo(InfoKey key, const char *info);
|
||||
virtual int32_t LnnSetLocalNumInfo(InfoKey key, int32_t info);
|
||||
virtual int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len);
|
||||
@ -89,7 +89,7 @@ public:
|
||||
virtual bool LnnConvertAuthConnInfoToAddr(ConnectionAddr *addr,
|
||||
const AuthConnInfo *connInfo, ConnectionAddrType hintType);
|
||||
virtual bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value);
|
||||
virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int num);
|
||||
virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num);
|
||||
virtual int32_t LnnSendSyncInfoMsg(LnnSyncInfoType type, const char *networkId,
|
||||
const uint8_t *msg, uint32_t len, LnnSyncInfoMsgComplete complete);
|
||||
virtual NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type);
|
||||
@ -115,7 +115,7 @@ public:
|
||||
LnnSyncInfoMsgComplete complete);
|
||||
virtual int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
|
||||
void *para, uint64_t delayMillis);
|
||||
virtual SoftBusLooper *GetLooper(int looper);
|
||||
virtual SoftBusLooper *GetLooper(int32_t looper);
|
||||
virtual int32_t ConnDisconnectDeviceAllConn(const ConnectOption *option);
|
||||
virtual int32_t LnnGenLocalIrk(unsigned char *irk, uint32_t len);
|
||||
virtual int32_t LnnGenLocalUuid(char *uuid, uint32_t len);
|
||||
@ -213,7 +213,7 @@ public:
|
||||
MOCK_METHOD0(AuthGenRequestId, uint32_t ());
|
||||
MOCK_METHOD0(LnnSetUnlockState, void ());
|
||||
MOCK_METHOD1(AuthHandleLeaveLNN, void (AuthHandle));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int32_t (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD2(LnnSetLocalStrInfo, int32_t (InfoKey, const char *));
|
||||
MOCK_METHOD2(LnnSetLocalNumInfo, int32_t (InfoKey, int32_t));
|
||||
MOCK_METHOD3(LnnGetLocalStrInfo, int32_t (InfoKey, char *, uint32_t));
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
virtual void LnnRemoveNode(const char *udid) = 0;
|
||||
virtual int32_t LnnGetNetworkIdByBtMac(const char *btMac, char *buf, uint32_t len) = 0;
|
||||
virtual int32_t LnnSetLocalNum64Info(InfoKey key, int64_t info) = 0;
|
||||
virtual int32_t LnnGetNodeKeyInfo(const char *networkId, int key, uint8_t *info, uint32_t infoLen) = 0;
|
||||
virtual int32_t LnnGetNodeKeyInfo(const char *networkId, int32_t key, uint8_t *info, uint32_t infoLen) = 0;
|
||||
virtual int32_t LnnGetRemoteNumInfo(const char *netWorkId, InfoKey key, int32_t *info) = 0;
|
||||
virtual int32_t LnnGetLocalDeviceInfo(NodeBasicInfo *info) = 0;
|
||||
virtual int32_t LnnGetLocalByteInfo(InfoKey key, uint8_t *info, uint32_t len) = 0;
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
virtual void LnnNotifyLocalNetworkIdChanged(void);
|
||||
virtual int32_t LnnGetSettingNickName(const char *defaultName,
|
||||
const char *unifiedName, char *nickName, uint32_t len);
|
||||
virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0;
|
||||
virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0;
|
||||
virtual int32_t LnnSubscribeAccountBootEvent(AccountEventHandle handle) = 0;
|
||||
};
|
||||
|
||||
@ -140,7 +140,7 @@ public:
|
||||
MOCK_METHOD1(LnnSetLocalUnifiedName, int32_t (const char *));
|
||||
MOCK_METHOD0(LnnNotifyLocalNetworkIdChanged, void ());
|
||||
MOCK_METHOD4(LnnGetSettingNickName, int32_t (const char *, const char *, char *, uint32_t));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int32_t (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD1(LnnSubscribeAccountBootEvent, int32_t (AccountEventHandle handle));
|
||||
static int32_t ActionOfLnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler);
|
||||
static int32_t ActionOfLnnInitGetDeviceName(LnnDeviceNameHandler handler);
|
||||
|
@ -98,7 +98,7 @@ void AuthHandleLeaveLNN(AuthHandle authHandle)
|
||||
return GetNetBuilderDepsInterface()->AuthHandleLeaveLNN(authHandle);
|
||||
}
|
||||
|
||||
int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->SoftbusGetConfig(type, val, len);
|
||||
}
|
||||
@ -178,7 +178,7 @@ bool AddStringToJsonObject(cJSON *json, const char * const string, const char *v
|
||||
return GetNetBuilderDepsInterface()->AddStringToJsonObject(json, string, value);
|
||||
}
|
||||
|
||||
bool AddNumberToJsonObject(cJSON *json, const char * const string, int num)
|
||||
bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->AddNumberToJsonObject(json, string, num);
|
||||
}
|
||||
@ -286,7 +286,7 @@ int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc
|
||||
return GetNetBuilderDepsInterface()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
|
||||
}
|
||||
|
||||
SoftBusLooper *GetLooper(int looper)
|
||||
SoftBusLooper *GetLooper(int32_t looper)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->GetLooper(looper);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ void AuthHandleLeaveLNN(AuthHandle authHandle)
|
||||
return GetNetBuilderDepsInterface()->AuthHandleLeaveLNN(authHandle);
|
||||
}
|
||||
|
||||
int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->SoftbusGetConfig(type, val, len);
|
||||
}
|
||||
@ -178,7 +178,7 @@ bool AddStringToJsonObject(cJSON *json, const char * const string, const char *v
|
||||
return GetNetBuilderDepsInterface()->AddStringToJsonObject(json, string, value);
|
||||
}
|
||||
|
||||
bool AddNumberToJsonObject(cJSON *json, const char * const string, int num)
|
||||
bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->AddNumberToJsonObject(json, string, num);
|
||||
}
|
||||
@ -286,7 +286,7 @@ int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc
|
||||
return GetNetBuilderDepsInterface()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
|
||||
}
|
||||
|
||||
SoftBusLooper *GetLooper(int looper)
|
||||
SoftBusLooper *GetLooper(int32_t looper)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->GetLooper(looper);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void LnnNotifyDeviceVerified(const char *udid)
|
||||
return GetLnnConnInterface()->LnnNotifyDeviceVerified(udid);
|
||||
}
|
||||
|
||||
int SoftBusGetBtState(void)
|
||||
int32_t SoftBusGetBtState(void)
|
||||
{
|
||||
return GetLnnConnInterface()->SoftBusGetBtState();
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void AuthHandleLeaveLNN(AuthHandle authHandle)
|
||||
return GetNetBuilderDepsInterface()->AuthHandleLeaveLNN(authHandle);
|
||||
}
|
||||
|
||||
int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->SoftbusGetConfig(type, val, len);
|
||||
}
|
||||
@ -197,7 +197,7 @@ bool AddStringToJsonObject(cJSON *json, const char * const string, const char *v
|
||||
return GetNetBuilderDepsInterface()->AddStringToJsonObject(json, string, value);
|
||||
}
|
||||
|
||||
bool AddNumberToJsonObject(cJSON *json, const char * const string, int num)
|
||||
bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->AddNumberToJsonObject(json, string, num);
|
||||
}
|
||||
@ -305,7 +305,7 @@ int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc
|
||||
return GetNetBuilderDepsInterface()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
|
||||
}
|
||||
|
||||
SoftBusLooper *GetLooper(int looper)
|
||||
SoftBusLooper *GetLooper(int32_t looper)
|
||||
{
|
||||
return GetNetBuilderDepsInterface()->GetLooper(looper);
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ int32_t LnnSetLocalNum64Info(InfoKey key, int64_t info)
|
||||
return GetNetLedgerInterface()->LnnSetLocalNum64Info(key, info);
|
||||
}
|
||||
|
||||
int32_t LnnGetNodeKeyInfo(const char *networkId, int key, uint8_t *info, uint32_t infoLen)
|
||||
int32_t LnnGetNodeKeyInfo(const char *networkId, int32_t key, uint8_t *info, uint32_t infoLen)
|
||||
{
|
||||
return GetNetLedgerInterface()->LnnGetNodeKeyInfo(networkId, key, info, infoLen);
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ int32_t LnnGetSettingNickName(const char *defaultName, const char *unifiedName,
|
||||
return GetServiceInterface()->LnnGetSettingNickName(defaultName, unifiedName, nickName, len);
|
||||
}
|
||||
|
||||
int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
{
|
||||
return GetServiceInterface()->SoftbusGetConfig(type, val, len);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ HWTEST_F(LNNTopoManagerTest, LNN_INIT_TOPO_MANAGER_TEST_001, TestSize.Level1)
|
||||
HWTEST_F(LNNTopoManagerTest, LNN_GET_RELATION_TEST_001, TestSize.Level1)
|
||||
{
|
||||
uint8_t relation[CONNECTION_ADDR_MAX + 1] = { 0 };
|
||||
int ret = LnnGetRelation(UDID, PEER_UDID, relation, CONNECTION_ADDR_MAX + 1);
|
||||
int32_t ret = LnnGetRelation(UDID, PEER_UDID, relation, CONNECTION_ADDR_MAX + 1);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnGetRelation(nullptr, PEER_UDID, relation, CONNECTION_ADDR_MAX);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
|
@ -59,12 +59,12 @@ int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen)
|
||||
return GetLnnBtNetworkImplInterface()->LnnRequestLeaveByAddrType(type, typeLen);
|
||||
}
|
||||
|
||||
int SoftBusGetBtState(void)
|
||||
int32_t SoftBusGetBtState(void)
|
||||
{
|
||||
return GetLnnBtNetworkImplInterface()->SoftBusGetBtState();
|
||||
}
|
||||
|
||||
int SoftBusGetBtMacAddr(SoftBusBtAddr *mac)
|
||||
int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac)
|
||||
{
|
||||
return GetLnnBtNetworkImplInterface()->SoftBusGetBtMacAddr(mac);
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ public:
|
||||
virtual ~LnnBtNetworkImplInterface() {};
|
||||
virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0;
|
||||
virtual int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) = 0;
|
||||
virtual int SoftBusGetBtState(void) = 0;
|
||||
virtual int SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0;
|
||||
virtual int32_t SoftBusGetBtState(void) = 0;
|
||||
virtual int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0;
|
||||
virtual int32_t ConvertBtMacToStr(char *strMac, uint32_t strMacLen, const uint8_t *binMac, uint32_t binMacLen) = 0;
|
||||
virtual int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler) = 0;
|
||||
virtual int32_t LnnGetNetIfTypeByName(const char *ifName, LnnNetIfType *type) = 0;
|
||||
@ -49,8 +49,8 @@ public:
|
||||
~LnnBtNetworkImplInterfaceMock() override;
|
||||
MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t (const char *, ConnectionAddrType));
|
||||
MOCK_METHOD2(LnnRequestLeaveByAddrType, int32_t (const bool *, uint32_t));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int (void));
|
||||
MOCK_METHOD1(SoftBusGetBtMacAddr, int (SoftBusBtAddr *));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int32_t (void));
|
||||
MOCK_METHOD1(SoftBusGetBtMacAddr, int32_t (SoftBusBtAddr *));
|
||||
MOCK_METHOD4(ConvertBtMacToStr, int32_t (char *, uint32_t, const uint8_t *, uint32_t));
|
||||
MOCK_METHOD2(LnnRegisterEventHandler, int32_t (LnnEventType, LnnEventHandler));
|
||||
MOCK_METHOD2(LnnGetNetIfTypeByName, int32_t (const char *, LnnNetIfType *));
|
||||
|
@ -71,7 +71,7 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_001, TestSize.Level1
|
||||
NiceMock<LnnBtNetworkImplInterfaceMock> btMock;
|
||||
EXPECT_CALL(btMock, LnnRegisterEventHandler(_, _)).WillOnce(Return(SOFTBUS_ERR)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int ret = LnnInitBtProtocol(nullptr);
|
||||
int32_t ret = LnnInitBtProtocol(nullptr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
ret = LnnInitBtProtocol(nullptr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
@ -149,7 +149,7 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_004, TestSize.Level1
|
||||
LnnNetIfMgr netifMgr = {
|
||||
.ifName = "name",
|
||||
};
|
||||
int ret = LnnEnableBtProtocol(&self, nullptr);
|
||||
int32_t ret = LnnEnableBtProtocol(&self, nullptr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnEnableBtProtocol(&self, &netifMgr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
@ -227,7 +227,7 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_007, TestSize.Level1
|
||||
EXPECT_CALL(btMock, SoftBusGetBtMacAddr).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, ConvertBtMacToStr).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
|
||||
int ret = GetAvailableBtMac(macStr, NETWORK_ID_BUF_LEN);
|
||||
int32_t ret = GetAvailableBtMac(macStr, NETWORK_ID_BUF_LEN);
|
||||
EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
|
||||
|
||||
ret = GetAvailableBtMac(macStr, BT_MAC_LEN);
|
||||
|
@ -92,7 +92,7 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_001, TestSize.Level1
|
||||
memset_s(&self, sizeof(LnnProtocolManager), 0, sizeof(LnnProtocolManager));
|
||||
memset_s(&netifMgr, sizeof(LnnNetIfMgr), 0, sizeof(LnnNetIfMgr));
|
||||
strcpy_s(netifMgr.ifName, sizeof("name"), "name");
|
||||
int res = LnnEnableIpProtocol(nullptr, nullptr);
|
||||
int32_t res = LnnEnableIpProtocol(nullptr, nullptr);
|
||||
EXPECT_TRUE(res == SOFTBUS_ERR);
|
||||
res = LnnEnableIpProtocol(&self, &netifMgr);
|
||||
EXPECT_TRUE(res == SOFTBUS_ERR);
|
||||
@ -165,7 +165,7 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_003, TestSize.Level1
|
||||
NiceMock<LnnIpNetworkImplInterfaceMock> ipMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(ipMock, GetNetworkIpByIfName).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int ret = GetAvailableIpAddr(IFNAME_TEST0, const_cast<char *>(WLAN_IP1), SIZE);
|
||||
int32_t ret = GetAvailableIpAddr(IFNAME_TEST0, const_cast<char *>(WLAN_IP1), SIZE);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
ret = GetAvailableIpAddr(IFNAME_TEST1, const_cast<char *>(WLAN_IP2), SIZE);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
@ -199,7 +199,7 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_004, TestSize.Level1
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).
|
||||
WillRepeatedly(LnnNetLedgertInterfaceMock::ActionOfLnnGetLocalStrInfo2);
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int ret = RequestMainPort("lo", "127.0.0.1");
|
||||
int32_t ret = RequestMainPort("lo", "127.0.0.1");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
ret = RequestMainPort("lol", "127.0.0.1");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
@ -251,7 +251,7 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_005, TestSize.Level1
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).
|
||||
WillRepeatedly(LnnNetLedgertInterfaceMock::ActionOfLnnGetLocalStrInfo2);
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int ret = ReleaseMainPort("deviceName");
|
||||
int32_t ret = ReleaseMainPort("deviceName");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
ret = ReleaseMainPort("deviceName1");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
|
@ -61,7 +61,7 @@ int32_t LnnStartDiscovery(void)
|
||||
return GetNetworkManagerInterface()->LnnStartDiscovery();
|
||||
}
|
||||
|
||||
int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
{
|
||||
return GetNetworkManagerInterface()->SoftbusGetConfig(type, val, len);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
virtual void LnnOnOhosAccountChanged(void) =0;
|
||||
virtual void LnnStopDiscovery(void) = 0;
|
||||
virtual int32_t LnnStartDiscovery(void) = 0;
|
||||
virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0;
|
||||
virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0;
|
||||
virtual void DiscLinkStatusChanged(LinkStatus status, ExchangeMedium medium) = 0;
|
||||
virtual void LnnStopPublish(void) = 0;
|
||||
virtual int32_t LnnStartPublish(void) = 0;
|
||||
@ -68,7 +68,7 @@ public:
|
||||
MOCK_METHOD0(LnnOnOhosAccountChanged, void (void));
|
||||
MOCK_METHOD0(LnnStopDiscovery, void (void));
|
||||
MOCK_METHOD0(LnnStartDiscovery, int32_t (void));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD3(SoftbusGetConfig, int32_t (ConfigType, unsigned char *, uint32_t));
|
||||
MOCK_METHOD2(DiscLinkStatusChanged, void (LinkStatus, ExchangeMedium));
|
||||
MOCK_METHOD0(LnnStopPublish, void (void));
|
||||
MOCK_METHOD0(LnnStartPublish, int32_t (void));
|
||||
|
@ -125,7 +125,7 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_001, TestSize.Level
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalNum64Info).WillOnce(Return(SOFTBUS_ERR)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int ret = LnnInitNetworkManager();
|
||||
int32_t ret = LnnInitNetworkManager();
|
||||
EXPECT_TRUE(ret != SOFTBUS_OK);
|
||||
ret = LnnInitNetworkManager();
|
||||
EXPECT_TRUE(ret != SOFTBUS_OK);
|
||||
@ -180,7 +180,7 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_003, TestSize.Level
|
||||
{
|
||||
NiceMock<LnnNetworkManagerInterfaceMock> managerMock;
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int ret = LnnRegistProtocol(nullptr);
|
||||
int32_t ret = LnnRegistProtocol(nullptr);
|
||||
EXPECT_TRUE(ret != SOFTBUS_OK);
|
||||
|
||||
LnnProtocolManager protocolMgr;
|
||||
@ -233,7 +233,7 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_003, TestSize.Level
|
||||
*/
|
||||
HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_004, TestSize.Level1)
|
||||
{
|
||||
int len = 0;
|
||||
int32_t len = 0;
|
||||
char buf[] = "nullptr";
|
||||
NiceMock<LnnNetworkManagerInterfaceMock> managerMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
@ -246,7 +246,7 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_004, TestSize.Level
|
||||
EXPECT_TRUE(ret == false);
|
||||
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int res = LnnInitManagerByConfig();
|
||||
int32_t res = LnnInitManagerByConfig();
|
||||
EXPECT_TRUE(res != SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
|
@ -75,7 +75,7 @@ HWTEST_F(LNNPhysicalSubnetManagerTest, LNN_REGIST_PHYSICAL_SUBNET_001, TestSize.
|
||||
HWTEST_F(LNNPhysicalSubnetManagerTest, LNN_REGIST_PHYSICAL_SUBNET_002, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = SOFTBUS_OK;
|
||||
for (int i = 0; i <= 6; i++)
|
||||
for (int32_t i = 0; i <= 6; i++)
|
||||
{
|
||||
LnnProtocolManager lnnProtocolManager = {
|
||||
.id = LNN_PROTOCOL_IP,
|
||||
|
@ -116,7 +116,7 @@ int32_t UpdateDbPassword(DbContext *ctx, const uint8_t *password, uint32_t len)
|
||||
return GetDecisionDbDepsInterface()->UpdateDbPassword(ctx, password, len);
|
||||
}
|
||||
|
||||
int32_t QueryRecordByKey(DbContext *ctx, TableNameID id, uint8_t *data, uint8_t **replyInfo, int infoNum)
|
||||
int32_t QueryRecordByKey(DbContext *ctx, TableNameID id, uint8_t *data, uint8_t **replyInfo, int32_t infoNum)
|
||||
{
|
||||
return GetDecisionDbDepsInterface()->QueryRecordByKey(ctx, id, data, replyInfo, infoNum);
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ public:
|
||||
virtual int32_t GetRecordNumByKey(DbContext *ctx, TableNameID id, uint8_t *data);
|
||||
virtual int32_t EncryptedDb(DbContext *ctx, const uint8_t *password, uint32_t len);
|
||||
virtual int32_t UpdateDbPassword(DbContext *ctx, const uint8_t *password, uint32_t len);
|
||||
virtual int32_t QueryRecordByKey(DbContext *ctx, TableNameID id, uint8_t *data, uint8_t **replyInfo, int infoNum);
|
||||
virtual int32_t QueryRecordByKey(DbContext *ctx, TableNameID id, uint8_t *data,
|
||||
uint8_t **replyInfo, int32_t infoNum);
|
||||
virtual int32_t LnnGetFullStoragePath(LnnFileId id, char *path, uint32_t len);
|
||||
virtual int32_t SoftBusReadFullFile(const char *fileName, char *readBuf, uint32_t maxLen);
|
||||
virtual int32_t SoftBusWriteFile(const char *fileName, const char *writeBuf, uint32_t len);
|
||||
|
@ -570,22 +570,18 @@ HWTEST_F(LNNDisctributedLedgerTest, IS_META_NODE_Test_001, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == true);
|
||||
}
|
||||
|
||||
HWTEST_F(LNNDisctributedLedgerTest, POST_ONLINE_NODESTOCB_Test_001, TestSize.Level1)
|
||||
HWTEST_F(LNNDisctributedLedgerTest, LNN_GET_NODEINFO_BYID_Test_001, TestSize.Level1)
|
||||
{
|
||||
INodeStateCb callBack;
|
||||
IdCategory type = CATEGORY_UDID;
|
||||
NodeInfo *ret = LnnGetNodeInfoById(nullptr, type);
|
||||
EXPECT_TRUE(ret == nullptr);
|
||||
callBack.onNodeOnline = nullptr;
|
||||
(void)PostOnlineNodesToCb(&callBack);
|
||||
callBack.onNodeOnline = TestFunc;
|
||||
(void)PostOnlineNodesToCb(&callBack);
|
||||
}
|
||||
|
||||
HWTEST_F(LNNDisctributedLedgerTest, LNN_GET_NODEINFO_BYID_Test_001, TestSize.Level1)
|
||||
{
|
||||
IdCategory type = CATEGORY_UDID;
|
||||
NodeInfo *ret = LnnGetNodeInfoById(nullptr, type);
|
||||
EXPECT_TRUE(ret == nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(LNNDisctributedLedgerTest, LNN_GET_REMOTE_NODE_Test_001, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = LnnGetRemoteNodeInfoByKey(nullptr, nullptr);
|
||||
|
@ -143,12 +143,12 @@ int32_t GetDeviceSecurityLevel(int32_t *level)
|
||||
return GetLocalLedgerDepsInterface()->GetDeviceSecurityLevel(level);
|
||||
}
|
||||
|
||||
int SoftBusGetBtState(void)
|
||||
int32_t SoftBusGetBtState(void)
|
||||
{
|
||||
return GetLocalLedgerDepsInterface()->SoftBusGetBtState();
|
||||
}
|
||||
|
||||
int SoftBusGetBtMacAddr(SoftBusBtAddr *mac)
|
||||
int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac)
|
||||
{
|
||||
return GetLocalLedgerDepsInterface()->SoftBusGetBtMacAddr(mac);
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public:
|
||||
virtual int32_t GetCommonOsVersion(char *value, uint32_t len);
|
||||
virtual int32_t GetCommonDeviceVersion(char *value, uint32_t len);
|
||||
virtual int32_t GetDeviceSecurityLevel(int32_t *level);
|
||||
virtual int SoftBusGetBtState(void) = 0;
|
||||
virtual int SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0;
|
||||
virtual int32_t SoftBusGetBtState(void) = 0;
|
||||
virtual int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0;
|
||||
};
|
||||
class LocalLedgerDepsInterfaceMock : public LocalLedgerDepsInterface {
|
||||
public:
|
||||
@ -67,8 +67,8 @@ public:
|
||||
MOCK_METHOD2(GetCommonOsVersion, int32_t (char *, uint32_t));
|
||||
MOCK_METHOD2(GetCommonDeviceVersion, int32_t (char *, uint32_t));
|
||||
MOCK_METHOD1(GetDeviceSecurityLevel, int32_t (int32_t *));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int (void));
|
||||
MOCK_METHOD1(SoftBusGetBtMacAddr, int (SoftBusBtAddr *));
|
||||
MOCK_METHOD0(SoftBusGetBtState, int32_t (void));
|
||||
MOCK_METHOD1(SoftBusGetBtMacAddr, int32_t (SoftBusBtAddr *));
|
||||
|
||||
static int32_t LedgerGetCommonDevInfo(const CommonDeviceKey key, char *value, uint32_t len);
|
||||
static int32_t LedgerSoftBusRegBusCenterVarDump(char *dumpVar, SoftBusVarDumpCb cb);
|
||||
|
@ -110,7 +110,7 @@ static void ConstructRemoteNode(void)
|
||||
LnnSetNetCapability(&cap, BIT_WIFI_24G);
|
||||
LnnSetNetCapability(&cap, BIT_WIFI_5G);
|
||||
g_nodeInfo.netCapacity = cap;
|
||||
int ret = strncpy_s(g_nodeInfo.networkId, NETWORK_ID_BUF_LEN, NODE_NETWORK_ID, strlen(NODE_NETWORK_ID));
|
||||
int32_t ret = strncpy_s(g_nodeInfo.networkId, NETWORK_ID_BUF_LEN, NODE_NETWORK_ID, strlen(NODE_NETWORK_ID));
|
||||
EXPECT_TRUE(ret == EOK);
|
||||
ret = LnnSetDeviceUdid(&g_nodeInfo, NODE_UDID);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
|
@ -238,7 +238,7 @@ static void GetWiFiLocalInfo(void)
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, SOFTBUS_DUMP_PRINT_NET_CAPACITY_Test_001, TestSize.Level1)
|
||||
{
|
||||
int fd = 0;
|
||||
int32_t fd = 0;
|
||||
NodeBasicInfo nodeInfo;
|
||||
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
@ -261,7 +261,7 @@ HWTEST_F(LedgerLaneHubTest, SOFTBUS_DUMP_PRINT_NET_CAPACITY_Test_001, TestSize.L
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, SOFTBUS_DUMP_PRINT_NET_TYPE_Test_001, TestSize.Level1)
|
||||
{
|
||||
int fd = 0;
|
||||
int32_t fd = 0;
|
||||
NodeBasicInfo nodeInfo;
|
||||
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
@ -427,7 +427,7 @@ HWTEST_F(LedgerLaneHubTest, LEDGER_DistributedLedgerChangeName_Test_001, TestSiz
|
||||
bool result = LnnSetDLDeviceInfoName(NODE2_UDID, CHANGE_DEVICE_NAME);
|
||||
EXPECT_TRUE(result);
|
||||
// STRING_KEY_DEV_NAME
|
||||
int ret = LnnGetRemoteStrInfo(NODE2_NETWORK_ID, STRING_KEY_DEV_NAME, deviceName, DEVICE_NAME_BUF_LEN);
|
||||
int32_t ret = LnnGetRemoteStrInfo(NODE2_NETWORK_ID, STRING_KEY_DEV_NAME, deviceName, DEVICE_NAME_BUF_LEN);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
EXPECT_TRUE(strcmp(deviceName, CHANGE_DEVICE_NAME) == 0);
|
||||
LnnRemoveNode(NODE2_UDID);
|
||||
|
@ -48,7 +48,7 @@
|
||||
namespace OHOS {
|
||||
using namespace testing::ext;
|
||||
|
||||
static int InitServer()
|
||||
static int32_t InitServer()
|
||||
{
|
||||
if (ConnServerInit() == SOFTBUS_ERR) {
|
||||
printf("softbus conn server init failed.");
|
||||
@ -109,9 +109,9 @@ void NetBusCenterTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
static int SetIpaddr(const std::string &ip)
|
||||
static int32_t SetIpaddr(const std::string &ip)
|
||||
{
|
||||
int sockFd = -1;
|
||||
int32_t sockFd = -1;
|
||||
struct sockaddr_in addr;
|
||||
struct ifreq ifr;
|
||||
if (memset_s((void *)&addr, sizeof(addr), 0, sizeof(addr)) != EOK) {
|
||||
@ -157,9 +157,9 @@ static int SetIpaddr(const std::string &ip)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int SetIpDown()
|
||||
static int32_t SetIpDown()
|
||||
{
|
||||
int sockFd = -1;
|
||||
int32_t sockFd = -1;
|
||||
struct ifreq ifr;
|
||||
if (memset_s((void *)&ifr, sizeof(ifr), 0, sizeof(ifr)) != EOK) {
|
||||
printf("memset_s 1 fail\n");
|
||||
|
@ -53,11 +53,11 @@ public:
|
||||
int32_t osAccountId, int64_t authReqId, const char *authParams, const DeviceAuthCallback *gaCallback);
|
||||
static int32_t InvokeDataChangeListener(const char *appId, const DataChangeListener *listener);
|
||||
static int32_t InvokeGetJoinedGroups1(
|
||||
int32_t osAccountId, const char *appId, int groupType, char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t osAccountId, const char *appId, int32_t groupType, char **returnGroupVec, uint32_t *groupNum);
|
||||
static int32_t InvokeGetJoinedGroups2(
|
||||
int32_t osAccountId, const char *appId, int groupType, char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t osAccountId, const char *appId, int32_t groupType, char **returnGroupVec, uint32_t *groupNum);
|
||||
static int32_t InvokeGetJoinedGroups3(
|
||||
int32_t osAccountId, const char *appId, int groupType, char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t osAccountId, const char *appId, int32_t groupType, char **returnGroupVec, uint32_t *groupNum);
|
||||
static int32_t ActionofunRegDataChangeListener(const char *appId);
|
||||
static int32_t ActionOfProcessData(
|
||||
int64_t authSeq, const uint8_t *data, uint32_t len, const DeviceAuthCallback *gaCallback);
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
LnnTransInterface() {};
|
||||
virtual ~LnnTransInterface() {};
|
||||
|
||||
virtual int TransRegisterNetworkingChannelListener(const INetworkingListener *listener) = 0;
|
||||
virtual int32_t TransRegisterNetworkingChannelListener(const INetworkingListener *listener) = 0;
|
||||
virtual int32_t TransOpenNetWorkingChannel(const char *sessionName, const char *peerNetworkId) = 0;
|
||||
virtual int32_t TransSendNetworkingMessage(
|
||||
int32_t channelId, const char *data, uint32_t dataLen, int32_t priority) = 0;
|
||||
|
@ -54,8 +54,8 @@ public:
|
||||
virtual int32_t LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para) = 0;
|
||||
virtual void LnnNotifyBtAclStateChangeEvent(const char *btMac, SoftBusBtAclState state) = 0;
|
||||
virtual int32_t ConvertBtMacToStr(char *strMac, uint32_t strMacLen, const uint8_t *binMac, uint32_t binMacLen) = 0;
|
||||
virtual int SoftBusAddBtStateListener(const SoftBusBtStateListener *listener) = 0;
|
||||
virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0;
|
||||
virtual int32_t SoftBusAddBtStateListener(const SoftBusBtStateListener *listener) = 0;
|
||||
virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0;
|
||||
virtual void LnnNotifyBtStateChangeEvent(void *state) = 0;
|
||||
};
|
||||
class NetworkInterfaceMock : public NetworkInterface {
|
||||
|
@ -36,10 +36,10 @@ public:
|
||||
virtual WifiErrorCode RegisterWifiEvent(WifiEvent *event) = 0;
|
||||
virtual WifiErrorCode GetScanInfoList(WifiScanInfo *result, unsigned int *size) = 0;
|
||||
virtual WifiErrorCode UnRegisterWifiEvent(WifiEvent *event) = 0;
|
||||
virtual WifiErrorCode Hid2dGetChannelListFor5G(int *chanList, int len) = 0;
|
||||
virtual WifiErrorCode Hid2dGetChannelListFor5G(int32_t *chanList, int32_t len) = 0;
|
||||
virtual WifiErrorCode GetLinkedInfo(WifiLinkedInfo *info) = 0;
|
||||
virtual WifiErrorCode GetCurrentGroup(WifiP2pGroupInfo* groupInfo) = 0;
|
||||
virtual int IsWifiActive(void) = 0;
|
||||
virtual int32_t IsWifiActive(void) = 0;
|
||||
virtual WifiErrorCode GetWifiDetailState(WifiDetailState *state) = 0;
|
||||
virtual WifiErrorCode GetP2pEnableStatus(P2pState *state) = 0;
|
||||
};
|
||||
@ -54,7 +54,7 @@ public:
|
||||
MOCK_METHOD1(RegisterWifiEvent, WifiErrorCode(WifiEvent *));
|
||||
MOCK_METHOD2(GetScanInfoList, WifiErrorCode(WifiScanInfo *, unsigned int *));
|
||||
MOCK_METHOD1(UnRegisterWifiEvent, WifiErrorCode(WifiEvent *));
|
||||
MOCK_METHOD2(Hid2dGetChannelListFor5G, WifiErrorCode(int *, int));
|
||||
MOCK_METHOD2(Hid2dGetChannelListFor5G, WifiErrorCode(int32_t *, int));
|
||||
MOCK_METHOD1(GetLinkedInfo, WifiErrorCode(WifiLinkedInfo *));
|
||||
MOCK_METHOD1(GetCurrentGroup, WifiErrorCode(WifiP2pGroupInfo*));
|
||||
MOCK_METHOD0(IsWifiActive, int(void));
|
||||
|
@ -111,7 +111,7 @@ int32_t LnnHichainInterfaceMock::InvokeDataChangeListener(const char *appId, con
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups1(int32_t osAccountId, const char *appId, int groupType,
|
||||
int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups1(int32_t osAccountId, const char *appId, int32_t groupType,
|
||||
char **returnGroupVec, uint32_t *groupNum)
|
||||
{
|
||||
(void)osAccountId;
|
||||
@ -131,7 +131,7 @@ int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups1(int32_t osAccountId, con
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups2(int32_t osAccountId, const char *appId, int groupType,
|
||||
int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups2(int32_t osAccountId, const char *appId, int32_t groupType,
|
||||
char **returnGroupVec, uint32_t *groupNum)
|
||||
{
|
||||
(void)osAccountId;
|
||||
@ -143,7 +143,7 @@ int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups2(int32_t osAccountId, con
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
|
||||
int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups3(int32_t osAccountId, const char *appId, int groupType,
|
||||
int32_t LnnHichainInterfaceMock::InvokeGetJoinedGroups3(int32_t osAccountId, const char *appId, int32_t groupType,
|
||||
char **returnGroupVec, uint32_t *groupNum)
|
||||
{
|
||||
(void)osAccountId;
|
||||
|
@ -39,7 +39,7 @@ static LnnTransInterfaceMock *GetTransInterface()
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
int TransRegisterNetworkingChannelListener(const char *sessionName, const INetworkingListener *listener)
|
||||
int32_t TransRegisterNetworkingChannelListener(const char *sessionName, const INetworkingListener *listener)
|
||||
{
|
||||
return GetTransInterface()->TransRegisterNetworkingChannelListener(listener);
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ void LnnNotifyBtAclStateChangeEvent(const char *btMac, SoftBusBtAclState state)
|
||||
return GetNetworkInterface()->LnnNotifyBtAclStateChangeEvent(btMac, state);
|
||||
}
|
||||
|
||||
int SoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
int32_t SoftBusAddBtStateListener(const SoftBusBtStateListener *listener)
|
||||
{
|
||||
return GetNetworkInterface()->SoftBusAddBtStateListener(listener);
|
||||
}
|
||||
|
||||
int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
{
|
||||
return GetNetworkInterface()->SoftbusGetConfig(type, val, len);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ WifiErrorCode UnRegisterWifiEvent(WifiEvent *event)
|
||||
return GetWifiInterface()->UnRegisterWifiEvent(event);
|
||||
}
|
||||
|
||||
WifiErrorCode Hid2dGetChannelListFor5G(int *chanList, int len)
|
||||
WifiErrorCode Hid2dGetChannelListFor5G(int32_t *chanList, int32_t len)
|
||||
{
|
||||
return GetWifiInterface()->Hid2dGetChannelListFor5G(chanList, len);
|
||||
}
|
||||
@ -83,7 +83,7 @@ WifiErrorCode GetCurrentGroup(WifiP2pGroupInfo* groupInfo)
|
||||
return GetWifiInterface()->GetCurrentGroup(groupInfo);
|
||||
}
|
||||
|
||||
int IsWifiActive(void)
|
||||
int32_t IsWifiActive(void)
|
||||
{
|
||||
return GetWifiInterface()->IsWifiActive();
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ bool LnnNotifySingleOffLineEventFuzzTest(const uint8_t* data, size_t size)
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::LnnNotifyOnlineStateFuzzTest(data, size);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user