Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
a06b3953
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a06b3953
编写于
2月 18, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1968 【communication】修改WIFI Rk3568 L2测试用例和补充蓝牙用例
Merge pull request !1968 from 权力/myfeature
上级
57c8eb6f
b282aac9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
669 addition
and
73 deletion
+669
-73
communication/bluetooth_standard/Test.json
communication/bluetooth_standard/Test.json
+1
-1
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
...tooth_standard/src/main/js/default/test/Bluetooth.test.js
+574
-51
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
...on/wifi_standard/src/main/js/default/test/WifiSta.test.js
+94
-21
未找到文件。
communication/bluetooth_standard/Test.json
浏览文件 @
a06b3953
...
...
@@ -2,7 +2,7 @@
"description"
:
"Configuration for bluetooth js api Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"
18
00000"
,
"test-timeout"
:
"
6
00000"
,
"package"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
,
"shell-timeout"
:
"60000"
},
...
...
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
浏览文件 @
a06b3953
...
...
@@ -62,8 +62,8 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
bluetooth enable register
'
);
await
bluetooth
.
on
(
"
stateChange
"
,
onReceiveEvent
);
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] enable
bluetooth
data =
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js] state:
'
+
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_ON
));
console
.
info
(
'
[bluetooth_js] enable data =
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js] state
on
:
'
+
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_ON
));
if
(
data
==
bluetooth
.
BluetoothState
.
STATE_ON
)
{
console
.
info
(
'
enable bluetooth
'
);
done
()
...
...
@@ -105,7 +105,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
set localname start
'
);
var
enable
=
bluetooth
.
setLocalName
(
'
bluetooth_test
'
);
console
.
info
(
'
set localname end
'
);
console
.
info
(
'
[bluetooth_js] appInfoTest enable bluetooth result
'
+
JSON
.
stringify
(
enable
));
console
.
info
(
'
[bluetooth_js] appInfoTest enable bluetooth result
=
'
+
JSON
.
stringify
(
enable
));
expect
(
enable
).
assertEqual
(
true
);
done
();
...
...
@@ -205,7 +205,7 @@ describe('bluetoothhostTest', function() {
await
bluetooth
.
on
(
"
bluetoothDeviceFind
"
,
onReceiveEvent
)
console
.
info
(
'
bluetooth bluetoothDeviceFind register
'
);
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js]
start bluetooth discovery bluetoothDeviceFind
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js]
bluetooth discovery bluetoothDeviceFind
'
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] bluetooth discovery length ->
"
+
data
.
length
);
expect
(
data
.
length
).
assertLarger
(
0
);
done
()
...
...
@@ -229,7 +229,7 @@ describe('bluetoothhostTest', function() {
bluetooth
.
stopBluetoothDiscovery
();
await
bluetooth
.
off
(
"
bluetoothDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] stop bluetooth discovery result =
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js] stop bluetooth discovery result =
'
+
JSON
.
stringify
(
data
))
;
expect
(
data
).
assertNull
();
done
()
}
...
...
@@ -257,6 +257,40 @@ describe('bluetoothhostTest', function() {
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_PAIR_DEVICE_0001
* @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_DEVICE_JS_PAIR_DEVICE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
pair device start
'
);
await
bluetooth
.
on
(
"
pinRequired
"
,
onReceiveEvent
)
await
bluetooth
.
on
(
"
bondStateChange
"
,
onReceivePairStateEvent
)
var
device
;
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
pin required =
'
+
JSON
.
stringify
(
data
))
bluetooth
.
setDevicePariringConfirmation
(
data
,
false
);
}
function
onReceivePairStateEvent
(
data
)
{
console
.
info
(
'
pair state =
'
+
JSON
.
stringify
(
data
));
if
(
data
==
0
)
{
done
()
}
}
var
enable
=
bluetooth
.
pairDevice
(
"
32:15:00:19:42:F6
"
);
console
.
info
(
"
[bluetooth_js] pairDevice result is ->
"
+
JSON
.
stringify
(
result
));
expect
(
JSON
.
stringify
(
result
)).
assertTrue
();
setTimeout
(
function
(){
console
.
debug
(
'
========bluetooth_classic_pair_device=======timeout
'
);
},
500
);
console
.
info
(
'
pair device end
'
);
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_GET_CONNECTED_BLEDEVICES_0001
* @tc.name testGetConnectedBLEDevices
...
...
@@ -291,6 +325,7 @@ describe('bluetoothhostTest', function() {
expect
(
result
).
assertNull
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan .
"
);
}
catch
(
error
){
expect
(
null
).
assertFail
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan error
"
+
JSON
.
stringify
(
error
));
}
})
...
...
@@ -310,7 +345,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
"
[bluetooth_js] createGattServer ->
"
+
JSON
.
stringify
(
result
));
var
resultLength
=
Object
.
keys
(
result
).
length
;
console
.
info
(
"
[bluetooth_js] createGattServer length ->
"
+
resultLength
);
expect
(
resultLength
).
assertEqual
(
0
);
expect
(
resultLength
).
assertEqual
(
1
);
})
/**
...
...
@@ -326,22 +361,34 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
BLE scan start
'
);
await
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result1
=
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js] BLE scan device find result1
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertLarger
(
0
);
done
()
}
bluetooth
.
BLE
.
startBLEScan
(
[{
deviceId
:
"
789
"
,
name
:
"
test
"
,
serviceUuid
:
"
1234564
"
}],
{
interval
:
500
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
);
let
ScanFilter
=
[{
deviceId
:
"
789
"
,
name
:
"
test
"
,
serviceUuid
:
"
1234564
"
}];
for
(
var
key
in
ScanFilter
){
console
.
info
(
'
[bluetooth_js] ScanFilter:
'
+
ScanFilter
[
key
]);
}
let
ScanOptions
=
{
interval
:
500
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
};
for
(
var
key
in
ScanOptions
){
console
.
info
(
'
[bluetooth_js] ScanOptions:
'
+
ScanOptions
[
key
]);
}
bluetooth
.
BLE
.
startBLEScan
(
ScanFilter
,
ScanOptions
);
console
.
info
(
'
[bluetooth_js] BLEDevFind callback data ->
'
);
console
.
info
(
'
[bluetooth_js] BLEDevFind deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] BLEDevFind rssi:
'
+
data
.
rssi
);
console
.
info
(
'
[bluetooth_js] BLEDevFind data:
'
+
data
.
data
);
console
.
info
(
'
[bluetooth_js] BLE scan end
'
);
setTimeout
(
function
(){
console
.
debug
(
'
========bluetooth_ble_start_scan=======timeout
'
)
...
...
@@ -361,7 +408,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
BLE scan start
'
);
await
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result2 =
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js] BLE scan device find result2 =
'
+
JSON
.
stringify
(
data
))
;
expect
(
data
.
length
).
assertLarger
(
0
);
done
()
}
...
...
@@ -454,21 +501,25 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
manufactureValueBuffer =
'
+
JSON
.
stringify
(
manufactureValueBuffer
))
console
.
info
(
'
serviceValueBuffer =
'
+
JSON
.
stringify
(
serviceValueBuffer
))
var
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
await
gattServer
.
startAdvertising
(
{
let
setting
=
{
interval
:
150
,
txPower
:
60
,
connectable
:
true
,
},{
};
for
(
var
key
in
setting
){
console
.
info
(
'
[bluetooth_js] startAdv:
'
+
setting
[
key
]);
}
let
advData
=
{
serviceUuids
:[
"
12
"
],
manufactureData
:[{
manufactureId
:
4567
,
manufactureValue
:
manufactureValueBuffer
.
buffer
}],
serviceData
:[{
serviceUuid
:
"
1234
"
,
serviceValue
:
serviceValueBuffer
.
buffer
}],
},{
manufactureData
:[{
manufactureId
:
4567
,
manufactureValue
:
manufactureValueBuffer
.
buffer
}],
serviceData
:[{
serviceUuid
:
"
1234
"
,
serviceValue
:
serviceValueBuffer
.
buffer
}],
};
for
(
var
key
in
advData
){
console
.
info
(
'
[bluetooth_js] startAdv:
'
+
advData
[
key
]);
}
await
gattServer
.
startAdvertising
(
setting
,
advData
,{
serviceUuids
:[
"
12
"
],
manufactureData
:[{
manufactureId
:
1789
,
...
...
@@ -614,9 +665,9 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] pin required =
'
+
JSON
.
stringify
(
data
))
}
bluetooth
.
off
(
"
bon
e
StateChange
"
,
onBoneStateReceiveEvent
)
bluetooth
.
off
(
"
bon
d
StateChange
"
,
onBoneStateReceiveEvent
)
function
onBoneStateReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] bon
e
StateChange =
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js] bon
d
StateChange =
'
+
JSON
.
stringify
(
data
))
}
bluetooth
.
off
(
"
stateChange
"
,
onReceiveEvent
);
...
...
@@ -651,6 +702,7 @@ describe('bluetoothhostTest', function() {
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_DISCONNRCT_0001
* @tc.name testDisConnect
...
...
@@ -693,7 +745,6 @@ describe('bluetoothhostTest', function() {
done
();
}).
catch
(
err
=>
{
console
.
error
(
`bluetooth getServices has error:
${
err
}
`
);
// expect(null).assertFail();
expect
(
true
).
assertEqual
(
true
);
done
();
});
...
...
@@ -724,9 +775,11 @@ describe('bluetoothhostTest', function() {
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
32
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
for
(
var
key
in
characteristic
){
console
.
info
(
'
[bluetooth_js] readCharValue:
'
+
characteristic
[
key
]);
}
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
console
.
info
(
'
[bluetooth_js] bluetooth BLECharacteristic is null
'
);
...
...
@@ -738,7 +791,6 @@ describe('bluetoothhostTest', function() {
done
();
}).
catch
(
err
=>
{
console
.
error
(
`bluetooth readCharacteristicValue has error:
${
err
}
`
);
// expect(null).assertFail();
expect
(
true
).
assertEqual
(
true
);
done
();
});
...
...
@@ -775,7 +827,6 @@ describe('bluetoothhostTest', function() {
done
();
}).
catch
(
err
=>
{
console
.
error
(
`bluetooth readDescriptorValue has error:
${
err
}
`
);
// expect(null).assertFail();
expect
(
true
).
assertEqual
(
true
);
done
();
});
...
...
@@ -808,7 +859,9 @@ describe('bluetoothhostTest', function() {
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
for
(
var
key
in
characteristic
){
console
.
info
(
'
[bluetooth_js] writeCharValue:
'
+
characteristic
[
key
]);
}
let
ret
=
gattClient
.
writeCharacteristicValue
(
characteristic
);
console
.
info
(
'
[bluetooth_js] bluetooth writeCharacteristicValue ret :
'
+
ret
);
...
...
@@ -907,7 +960,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
bluetooth setNotifyCharacteristicChanged end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_ADD_SERVICE_0001
* @tc.name testAddService
...
...
@@ -930,7 +983,6 @@ describe('bluetoothhostTest', function() {
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptors
[
0
]
=
descriptor
;
let
characteristics
=
[];
...
...
@@ -944,7 +996,9 @@ describe('bluetoothhostTest', function() {
let
service
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
isPrimary
:
true
,
characteristics
:
characteristics
,
includeServices
:
[]};
for
(
var
key
in
service
){
console
.
info
(
'
[bluetooth_js] addService:
'
+
service
[
key
]);
}
let
ret
=
gattServer
.
addService
(
service
);
console
.
info
(
'
[bluetooth_js] bluetooth addService ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
...
...
@@ -995,10 +1049,12 @@ describe('bluetoothhostTest', function() {
let
descNotifyValue
=
new
Uint8Array
(
arrayBufferNotifyDesc
);
descNotifyValue
[
0
]
=
1
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
desValue
};
let
descriptorNotify
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00002902-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
descNotifyValue
};
descriptorUuid
:
'
00002902-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
descNotifyValue
};
descriptors
[
0
]
=
descriptor
;
descriptors
[
1
]
=
descriptorNotify
;
...
...
@@ -1007,8 +1063,11 @@ describe('bluetoothhostTest', function() {
cccValue
[
0
]
=
1
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
cccValue
,
descriptors
:
descriptors
};
characteristicValue
:
cccValue
,
descriptors
:
descriptors
,
confirm
:
'
false
'
};
for
(
var
key
in
characteristic
){
console
.
info
(
'
[bluetooth_js] notifyCharChanged:
'
+
characteristic
[
key
]);
}
let
ret
=
gattServer
.
notifyCharacteristicChanged
(
'
00:00:00:00:00:00
'
,
characteristic
);
console
.
info
(
'
[bluetooth_js] bluetooth notifyCharacteristicChanged ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
...
...
@@ -1035,7 +1094,9 @@ describe('bluetoothhostTest', function() {
let
serverResponse
=
{
deviceId
:
'
00:00:00:00:00
'
,
transId
:
1
,
status
:
0
,
offset
:
0
,
value
:
arrayBuffer
};
for
(
var
key
in
serverResponse
){
console
.
info
(
'
[bluetooth_js] serverResponse:
'
+
serverResponse
[
key
]);
}
let
ret
=
gattServer
.
sendResponse
(
serverResponse
);
console
.
info
(
'
[bluetooth_js] bluetooth sendResponse ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
...
...
@@ -1056,6 +1117,9 @@ describe('bluetoothhostTest', function() {
console
.
log
(
"
bluetooth: spp listen start
"
);
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
true
,
type
:
0
};
for
(
var
key
in
sppOption
){
console
.
info
(
'
[bluetooth_js] sppListen:
'
+
sppOption
[
key
]);
}
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
function
(
code
,
serverSocketNumber
)
{
if
(
code
.
code
==
0
)
{
...
...
@@ -1119,8 +1183,6 @@ describe('bluetoothhostTest', function() {
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SPP_CONNECT_0001
* @tc.name testSppConnect
...
...
@@ -1171,5 +1233,466 @@ describe('bluetoothhostTest', function() {
done
();
})
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CHARAC_READ_ON_0001
* @tc.name testonCharacteristicReadOn
* @tc.desc Test CharacteristicReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetoothble_CharacteristicReadOn_test_001
'
,
0
,
function
()
{
console
.
info
(
'
bluetoothble onCharacteristicReadOn test start ...
'
);
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] onBlePerManager: please click onCreateGattServer first!
"
);
}
gattServer
.
on
(
'
characteristicRead
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
[bluetooth_js] charaRead callback error ->
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
[bluetooth_js] charRead callback data ->
'
);
console
.
info
(
'
[bluetooth_js] CharRedReq deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] CharRedReq transId:
'
+
data
.
transId
);
console
.
info
(
'
[bluetooth_js] CharRedReq offset:
'
+
data
.
offset
);
console
.
info
(
'
[bluetooth_js] CharRedReq charUuid:
'
+
data
.
characteristicUuid
);
console
.
info
(
'
[bluetooth_js] CharRedReq serviceUuid:
'
+
data
.
serviceUuid
);
var
serverResponse
=
{
"
deviceId
"
:
data
.
deviceId
,
"
transId
"
:
data
.
transId
,
"
status
"
:
0
,
"
offset
"
:
data
.
offset
,
"
value
"
:
str2ab
(
"
characteristic read response
"
,
data
.
offset
),
};
var
result
=
gattServer
.
sendResponse
(
serverResponse
);
console
.
info
(
"
[bluetooth_js] sendResponse ->
"
+
JSON
.
stringify
(
result
));
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
"
true
"
);
console
.
info
(
"
[bluetooth_js] onBlePeripheralManagerClose .
"
);
}
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CHARAC_READ_OFF_0001
* @tc.name testCharacteristicReadOff
* @tc.desc Test CharacteristicReadOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetoothble_CharacteristicReadOff_test_001
'
,
0
,
function
()
{
console
.
info
(
'
bluetoothble CharacteristicReadOff test start ...
'
);
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] CharacteristicReadOn: please click onCreateGattServer first!
"
);
}
console
.
info
(
'
gattServer is--<-!!!->
'
+
JSON
.
stringify
(
gattServer
));
var
result
=
gattServer
.
off
();
console
.
info
(
"
[bluetooth_js] CharacteristicReadOff ->
"
+
JSON
.
stringify
(
result
));
var
resultLength
=
Object
.
keys
(
result
).
length
;
console
.
info
(
"
[bluetooth_js] CharacteristicReadOff length ->
"
+
resultLength
);
expect
(
resultLength
).
assertEqual
(
0
);
console
.
info
(
"
[bluetooth_js] CharacteristicReadOff .
"
);
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CHARAC_WRITE_ON_0001
* @tc.name testonCharacteristicwriteOn
* @tc.desc Test CharacteristicwriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetoothble_CharacteristicwriteOn_test_001
'
,
0
,
function
()
{
console
.
info
(
'
bluetoothble CharacteristicwriteOn test start ...
'
);
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] CharacteristicwriteOn: please click onCreateGattServer first!
"
);
}
gattServer
.
on
(
'
characteristicWrite
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
[bluetooth_js] characteristicWrite callback error ->
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
[bluetooth_js] characteristicWrite callback data ->
'
);
console
.
info
(
'
[bluetooth_js] CharWriReq deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] CharWriReq transId:
'
+
data
.
transId
);
console
.
info
(
'
[bluetooth_js] CharWriReq offset:
'
+
data
.
offset
);
console
.
info
(
'
[bluetooth_js] CharWriReq isPrep:
'
+
data
.
isPrep
);
console
.
info
(
'
[bluetooth_js] CharWriReq chaticUuid:
'
+
data
.
characteristicUuid
);
console
.
info
(
'
[bluetooth_js] CharWriReq serviceUuid:
'
+
data
.
serviceUuid
);
console
.
info
(
'
[bluetooth_js] CharWriReq value:
'
+
data
.
value
);
console
.
info
(
'
[bluetooth_js] CharWriReq needRsp:
'
+
data
.
needRsp
);
if
(
data
.
value
instanceof
ArrayBuffer
)
{
console
.
log
(
`[bluetooth_js] value:
${
ab2hex
(
data
.
value
)}
`
)
}
console
.
info
(
'
[bluetooth_js] characteristicUuid:
'
+
data
.
characteristicUuid
);
console
.
info
(
'
[bluetooth_js] serviceUuid:
'
+
data
.
serviceUuid
);
if
(
data
.
needRsp
==
false
)
{
return
;
}
console
.
log
(
`data.value is ArraryBuffer:
${
ab2hex
(
data
.
value
)}
`
)
var
serverResponse
=
{
"
deviceId
"
:
data
.
deviceId
,
"
transId
"
:
data
.
transId
,
"
status
"
:
0
,
"
offset
"
:
data
.
offset
,
"
value
"
:
data
.
value
,
};
var
result
=
gattServer
.
sendResponse
(
serverResponse
);
console
.
info
(
"
[bluetooth_js] sendResponse ->
"
+
JSON
.
stringify
(
result
));
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
"
true
"
);
console
.
info
(
"
[bluetooth_js] characteristicWrite .
"
);
}
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_READ_ON_0001
* @tc.name testDescriptorReadOn
* @tc.desc Test DescriptorReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_descriptorRead_On_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!
"
);
}
gattServer
.
on
(
'
descriptorRead
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] DesRedon jsondata:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] DesRedon data:
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
'
[bluetooth_js] desRead callback data ->
'
);
console
.
info
(
'
[bluetooth_js] DesRedReq deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] DesRedReq transId:
'
+
data
.
transId
);
console
.
info
(
'
[bluetooth_js] DesRedReq offset:
'
+
data
.
offset
);
console
.
info
(
'
[bluetooth_js] DesRedReq desUuid:
'
+
data
.
descriptorUuid
);
console
.
info
(
'
[bluetooth_js] DesRedReq charUuid:
'
+
data
.
characteristicUuid
);
console
.
info
(
'
[bluetooth_js] DesRedReq serUuid:
'
+
data
.
serviceUuid
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_READ_OFF_0001
* @tc.name testDescriptorReadOff
* @tc.desc Test DescriptorReadOff api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_descriptorRead_Off_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!
"
);
}
gattServer
.
off
(
'
descriptorRead
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] descriptorRead_off json_data->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] descriptorRead_off data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_WRITE_ON_0001
* @tc.name testDescriptorWriteOn
* @tc.desc Test DescriptorWriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_descriptorWrite_On_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!
"
);
}
gattServer
.
on
(
'
descriptorWrite
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] desWriOn jsondata:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] desWriOn data:
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
'
[bluetooth_js] desWrite callback data ->
'
);
console
.
info
(
'
[bluetooth_js] desWriOn deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] desWriOn transId:
'
+
data
.
transId
);
console
.
info
(
'
[bluetooth_js] desWriOn offset:
'
+
data
.
offset
);
console
.
info
(
'
[bluetooth_js] desWriOn desUuid:
'
+
data
.
descriptorUuid
);
console
.
info
(
'
[bluetooth_js] desWriOn serUuid:
'
+
data
.
serviceUuid
);
console
.
info
(
'
[bluetooth_js] desWriOn charUuid:
'
+
data
.
characteristicUuid
);
console
.
info
(
'
[bluetooth_js] desWriOn value:
'
+
data
.
value
);
console
.
info
(
'
[bluetooth_js] desWriOn needRsp:
'
+
data
.
needRsp
);
console
.
info
(
'
[bluetooth_js] desWriOn isPrep:
'
+
data
.
isPrep
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_WRITE_OFF_0001
* @tc.name testDescriptorWriteOff
* @tc.desc Test DescriptorWriteOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_descriptorWrite_Off_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] onAddServiceHelper: please click CreateGattServer first!
"
);
}
gattServer
.
off
(
'
descriptorWrite
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] desWriOff jsonData->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] desWriOff data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_CONNE_STATE_CHANGE_ON_0001
* @tc.name testConnectStateChangeOn
* @tc.desc Test ConnectStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_connectStateChange_On_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] onAddServiceHelper: please click CreateGattServer first!
"
);
}
gattServer
.
on
(
'
connectStateChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] connectStaOn jsonData ->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] connectStaOn data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
'
[bluetooth_js] connectStaOn callback data ->
'
);
console
.
info
(
'
[bluetooth_js] connectStaOn deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] connectStaOn state:
'
+
data
.
state
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_CONNE_STATE_CHANGE_OFF_0001
* @tc.name testConnectStateChangeOff
* @tc.desc Test ConnectStateChangeOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_connectStateChange_Off_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattServer
==
null
)
{
console
.
info
(
"
[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!
"
);
}
gattServer
.
off
(
'
connectStateChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] connectStateChange_off jsonData->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] connectStateChange_off data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CHAR_CHANGE_ON_0001
* @tc.name testBLECharacteristicChangeOn
* @tc.desc Test BLECharacteristicChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_BLECharacteristicChange_On_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattClient
==
null
)
{
console
.
info
(
"
[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!
"
);
}
gattClient
.
on
(
'
BLECharacteristicChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] BLECharacteristicChange_on json_data ->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] BLECharacteristicChange_on data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CHAR_CHANGE_OFF_0001
* @tc.name testBLECharacteristicChangeOff
* @tc.desc Test BLECharacteristicChangeOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_BLECharacteristicChange_Off_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattClient
==
null
)
{
console
.
info
(
"
[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!
"
);
}
gattClient
.
off
(
'
BLECharacteristicChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] BLECharacteristicChange_off json_data->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] BLECharacteristicChange_off data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CONNE_STATE_CHANGE_ON_0001
* @tc.name testBLEConnectionStateChangeOn
* @tc.desc Test BLEConnectionStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_BLEConnectionStateChange_On_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattClient
==
null
)
{
console
.
info
(
"
[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!
"
);
}
gattClient
.
on
(
'
BLEConnectionStateChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] BLEConnectionStateChange_on json_data ->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] BLEConnectionStateChange_on data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
'
[bluetooth_js] BLEConnectionStateChange deviceId :
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] BLEConnectionStateChange state :
'
+
data
.
state
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CONNE_STATE_CHANGE_OFF_0001
* @tc.name testBLEConnectionStateChangeOff
* @tc.desc Test BLEConnectionStateChangeOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_BLEConnectionStateChange_Off_test_001
'
,
0
,
async
function
(
done
)
{
try
{
if
(
gattClient
==
null
)
{
console
.
info
(
"
[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!
"
);
}
gattClient
.
on
(
'
BLEConnectionStateChange
'
,
function
(
result
)
{
console
.
info
(
"
[bluetooth_js] BLEConnectionStateChange_on1 json_result ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] BLEConnectionStateChange_on1 result ->
"
+
result
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
gattClient
.
off
(
'
BLEConnectionStateChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] BLEConnectionStateChange_off json_data->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] BLEConnectionStateChange_off data ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_SPP_READ_ON_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetoothble_sppReadOn_test_001
'
,
0
,
function
()
{
console
.
info
(
'
bluetoothble sppReadOn test start ...
'
);
function
dataRead
(
dataBuffer
)
{
let
data
=
new
Uint8Array
(
dataBuffer
);
console
.
log
(
'
bluetooth data is:
'
+
data
[
0
]);
}
bluetooth
.
on
(
'
sppRead
'
,
-
1
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
[bluetooth_js] sppReadOn error ->
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
[bluetooth_js] sppReadOn data ->
'
+
data
);
console
.
info
(
"
[bluetooth_js] sppReadOn data->
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertEqual
(
true
);
console
.
info
(
"
[bluetooth_js] onsppRead.
"
);
done
();
}
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CHARAC_READ_OFF_0001
* @tc.name testsppReadOff
* @tc.desc Test sppReadOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetoothble_sppReadOff_test_001
'
,
0
,
function
()
{
console
.
info
(
'
bluetoothble sppReadOff test start ...
'
);
bluetooth
.
off
(
'
sppRead
'
,
-
1
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
[bluetooth_js] sppReadOff error ->
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
[bluetooth_js] sppReadOff data ->
'
+
data
);
console
.
info
(
"
[bluetooth_js] sppReadOff data->
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertEqual
(
true
);
console
.
info
(
"
[bluetooth_js] offsppRead.
"
);
done
();
}
});
})
})
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
浏览文件 @
a06b3953
...
...
@@ -86,13 +86,13 @@ describe('ACTS_WifiTest', function() {
*/
it
(
'
SUB_Communication_WiFi_Sta_Scan_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Scan_0001]
"
);
if
(
!
wifi
.
isWifiActive
())
{
var
active1
=
wifi
.
isWifiActive
();
if
(
!
active1
)
{
var
enable
=
wifi
.
enableWifi
();
sleep
(
3
000
);
sleep
(
5
000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
var
scan
=
wifi
.
scan
();
sleep
(
3000
);
console
.
log
(
"
[wifi_test] open wifi scan result:
"
+
scan
);
...
...
@@ -109,7 +109,10 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
[wifi_test] Wifi getScanInfos callback test[2].
"
);
wifi
.
getScanInfos
(
(
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test] wifi getScanInfos failed
"
+
err
);
}
var
clen
=
Object
.
keys
(
result
).
length
;
console
.
log
(
"
[wifi_test] wifi getScanInfos callback result length:
"
+
clen
);
if
(
!
(
clen
==
0
&&
i
<
3
))
{
...
...
@@ -129,7 +132,6 @@ describe('ACTS_WifiTest', function() {
}
done
()
});
})
/**
...
...
@@ -199,7 +201,11 @@ describe('ACTS_WifiTest', function() {
});
wifi
.
addDeviceConfig
(
wifiDeviceConfig1
,
(
netWorkId
)
=>
{
(
err
,
netWorkId
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]add OPEN callback failed :
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
[wifi_test]add OPEN Deviceconfig callback :
"
+
JSON
.
stringify
(
netWorkId
));
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
console
.
info
(
"
[wifi_test] check add device configs successfully
"
);
...
...
@@ -265,7 +271,6 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test remove all wifi device config
*/
it
(
'
SUB_Communication_WiFi_Sta_Config_0005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Config_0005]
"
);
console
.
info
(
"
[wifi_test] create multiple valid wifi device config and add it.
"
);
var
wifiDeviceConfig1
=
{
"
ssid
"
:
"
TESTWgr1
"
,
...
...
@@ -283,7 +288,9 @@ describe('ACTS_WifiTest', function() {
};
let
promiseOne
=
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
addDeviceConfig
(
wifiDeviceConfig1
,
(
netWorkId1
)
=>
{
(
err
,
netWorkId1
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]add callback failed :
"
+
JSON
.
stringify
(
err
));
}
console
.
info
(
"
[wifi_test] wifi addDeviceconfig1 callback:
"
+
JSON
.
stringify
(
netWorkId1
));
expect
(
true
).
assertEqual
(
netWorkId1
!=
-
1
);
console
.
info
(
"
[wifi_test] check add device configs successfully
"
);
...
...
@@ -293,10 +300,11 @@ describe('ACTS_WifiTest', function() {
resolve
()
});
})
let
promiseTwo
=
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
addDeviceConfig
(
wifiDeviceConfig2
,
(
netWorkId2
)
=>
{
(
err
,
netWorkId2
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]add callback failed :
"
+
JSON
.
stringify
(
err
));
}
console
.
info
(
"
[wifi_test] wifi addDeviceconfig2 callback :
"
+
JSON
.
stringify
(
netWorkId2
));
expect
(
true
).
assertEqual
(
netWorkId2
!=
-
1
);
console
.
info
(
"
[wifi_test] check add device configs successfully
"
);
...
...
@@ -336,6 +344,12 @@ describe('ACTS_WifiTest', function() {
.
then
(
netWorkId
=>
{
console
.
info
(
"
[wifi_test]add PSK Deviceconfig promise :
"
+
JSON
.
stringify
(
netWorkId
));
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
console
.
info
(
"
[wifi_test]connectdevice result:
"
+
wifi
.
connectToNetwork
(
netWorkId
));
expect
(
wifi
.
connectToNetwork
(
netWorkId
)).
assertTrue
();
console
.
info
(
"
[wifi_test] get empty linked information and getIpInfo.
"
);
var
disconNet
=
wifi
.
disableNetwork
(
netWorkId
);
console
.
log
(
"
[wifi_test] wifi disableNetwork result:
"
+
disconNet
);
expect
(
disconNet
).
assertTrue
();
console
.
info
(
"
[wifi_test] check add device configs successfully
"
);
var
configs
=
wifi
.
getDeviceConfigs
();
console
.
info
(
"
[wifi_test] wifi getDeviceConfigs result1 :
"
+
JSON
.
stringify
(
configs
));
...
...
@@ -378,18 +392,26 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
[wifi_test] getCountryCode ->
"
+
JSON
.
stringify
(
countryCode
));
expect
(
JSON
.
stringify
(
countryCode
)).
assertEqual
(
'
"CN"
'
);
})
/**
* @tc.number Conn_Info_0005
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
* @tc.desc Test get empty linked information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
async
function
()
{
console
.
info
(
"
[wifi_test] get empty linked information and getIpInfo.
"
);
var
discon2
=
wifi
.
disconnect
();
console
.
log
(
"
[wifi_test] wifi disconnect result:
"
+
discon2
);
expect
(
discon2
).
assertTrue
();
sleep
(
2000
);
* @tc.number Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
* @tc.desc Test cnnnection a PSK SecurityType wifi deviceconfig
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
async
function
()
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Config_0002]
"
);
console
.
info
(
"
[wifi_test] create a PSK SecurityType wifi device config start.
"
);
var
wifiDeviceConfigConn
=
{
"
ssid
"
:
"
TEST_CONN
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
console
.
info
(
"
[wifi_test] connect wifi start.
"
);
var
conn1
=
wifi
.
connectToDevice
(
wifiDeviceConfigConn
);
sleep
(
5000
);
console
.
info
(
"
[wifi_test] isconnected wifi
"
);
var
isConnected
=
wifi
.
isConnected
();
console
.
log
(
"
[wifi_test] wifi isConnected result:
"
+
isConnected
);
expect
(
isConnected
).
assertFalse
();
...
...
@@ -398,8 +420,41 @@ describe('ACTS_WifiTest', function() {
return
console
.
error
(
'
failed to get link infos callback because
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
[wifi_test] get wifi link [callback] ->
"
+
JSON
.
stringify
(
data
));
for
(
var
j
=
0
;
j
<
JSON
.
stringify
(
data
).
length
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
);
console
.
info
(
"
bssid:
"
+
result
[
j
].
bssid
);
console
.
info
(
"
band:
"
+
result
[
j
].
band
);
console
.
info
(
"
isHidden:
"
+
result
[
j
].
isHidden
);
console
.
info
(
"
isRestricted:
"
+
result
[
j
].
isRestricted
);
console
.
info
(
"
chload:
"
+
result
[
j
].
chload
);
console
.
info
(
"
rssi
"
+
result
[
j
].
rssi
);
console
.
info
(
"
netWorkId:
"
+
result
[
j
].
netWorkId
);
console
.
info
(
"
linkSpeed:
"
+
result
[
j
].
linkSpeed
);
console
.
info
(
"
frequency:
"
+
result
[
j
].
frequency
);
console
.
info
(
"
snr:
"
+
result
[
j
].
snr
);
console
.
info
(
"
macAddress:
"
+
result
[
j
].
macAddress
);
console
.
info
(
"
ipAddress:
"
+
result
[
j
].
ipAddress
);
console
.
info
(
"
suppState:
"
+
result
[
j
].
suppState
);
console
.
info
(
"
connState:
"
+
result
[
j
].
connState
);
}
}
});
console
.
info
(
"
[wifi_test] get empty linked information and getIpInfo.
"
);
var
discon2
=
wifi
.
disconnect
();
console
.
log
(
"
[wifi_test] wifi disconnect result:
"
+
discon2
);
expect
(
discon2
).
assertTrue
();
})
/**
* @tc.number Conn_Info_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
* @tc.desc Test get IpInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0002
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test] get IpInfo.
"
);
var
ipInfo
=
wifi
.
getIpInfo
();
console
.
info
(
"
[wifi_test] getIpInfo ->
"
+
JSON
.
stringify
(
ipInfo
));
...
...
@@ -412,5 +467,23 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
secondDns:
"
+
ipInfo
.
secondDns
);
console
.
info
(
"
serverIp:
"
+
ipInfo
.
serverIp
);
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0004
* @tc.name testFeatureSupported
* @tc.desc Test FeatureSupported api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_info_0004
'
,
0
,
function
()
{
console
.
info
(
'
[wifi_test]FeatureSupported test start ...
'
);
var
result
=
wifi
.
getSupportedFeatures
();
console
.
info
(
"
[wifi_test] getFeatureSupported ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[wifi_test] isFeatureSupported:
"
+
result
+
"
->
"
+
wifi
.
isFeatureSupported
(
result
));
expect
(
wifi
.
isFeatureSupported
(
result
)).
assertTrue
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录