Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7caee5bf
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看板
未验证
提交
7caee5bf
编写于
8月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5253 【communication】修改WIFI JS L2测试用例
Merge pull request !5253 from 权力/myfeature
上级
621fbe9a
eda1d847
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
1411 addition
and
2173 deletion
+1411
-2173
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
...ation/bluetooth_on/src/main/js/test/BleScanResult.test.js
+1
-1
communication/bluetooth_on/src/main/js/test/BluetoothADD.test.js
...cation/bluetooth_on/src/main/js/test/BluetoothADD.test.js
+0
-1772
communication/wifi_p2p/src/main/js/test/List.test.js
communication/wifi_p2p/src/main/js/test/List.test.js
+4
-5
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
+0
-115
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
+225
-0
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
...ication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
+831
-0
communication/wifi_standard/src/main/js/test/List.test.js
communication/wifi_standard/src/main/js/test/List.test.js
+7
-4
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
...fi_standard/src/main/js/test/WifiCandidateNetWork.test.js
+92
-96
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
...n/wifi_standard/src/main/js/test/WifiStationEvent.test.js
+206
-0
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
...fi_standard/src/main/js/test/WifiStationFunctions.test.js
+45
-180
未找到文件。
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
浏览文件 @
7caee5bf
...
...
@@ -475,7 +475,7 @@ describe('bluetoothhostTest', function() {
}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE scan off14
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
(
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
onReceiveEvent
);
done
();
...
...
communication/bluetooth_on/src/main/js/test/BluetoothADD.test.js
已删除
100644 → 0
浏览文件 @
621fbe9a
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
BluetoothState
=
{
STATE_OFF
:
0
,
STATE_TURNING_ON
:
1
,
STATE_ON
:
2
,
STATE_TURNING_OFF
:
3
,
STATE_BLE_TURNING_ON
:
4
,
STATE_BLE_ON
:
5
,
STATE_BLE_TURNING_OFF
:
6
,
}
let
ScanMode
=
{
SCAN_MODE_NONE
:
0
,
SCAN_MODE_CONNECTABLE
:
1
,
SCAN_MODE_GENERAL_DISCOVERABLE
:
2
,
SCAN_MODE_LIMITED_DISCOVERABLE
:
3
,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
:
4
,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
:
5
,
}
export
default
function
bluetoothTEST
()
{
describe
(
'
bluetoothTEST
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll called
'
)
})
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
async
function
tryToEnableBt
()
{
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
case
2
:
console
.
info
(
'
[bluetooth_js] bt turn on:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0500
* @tc.name setLocalName
* @tc.desc Test setLocalName api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0500
'
,
0
,
async
function
(
done
)
{
await
sleep
(
1000
);
await
tryToEnableBt
();
let
localName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0500 localName =
'
+
JSON
.
stringify
(
localName
));
expect
(
true
).
assertEqual
(
localName
!=
null
);
let
newName
=
'
my bluetooth
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0500 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
result
=
bluetooth
.
setLocalName
(
localName
);
expect
(
result
).
assertTrue
();
let
getLocalName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0500 localName =
'
+
JSON
.
stringify
(
getLocalName
));
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0600
* @tc.name TEST setLocalName
* @tc.desc Test setLocalName api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0600
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
localName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0600 localName =
'
+
JSON
.
stringify
(
localName
));
expect
(
true
).
assertEqual
(
localName
!=
null
);
let
newName
=
'
bluetooth123
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0600 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
result
=
bluetooth
.
setLocalName
(
localName
);
expect
(
result
).
assertTrue
();
let
getLocalName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0600 localName =
'
+
JSON
.
stringify
(
getLocalName
));
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0700
* @tc.name TEST setLocalName
* @tc.desc TEST setLocalName api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0700
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
localName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0700 localName =
'
+
JSON
.
stringify
(
localName
));
expect
(
true
).
assertEqual
(
localName
!=
null
);
let
newName
=
'
蓝牙设备bluetooth
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0700 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
result
=
bluetooth
.
setLocalName
(
localName
);
expect
(
result
).
assertTrue
();
let
getLocalName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0700 localName =
'
+
JSON
.
stringify
(
getLocalName
));
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1100
* @tc.name TEST setLocalName
* @tc.desc TEST setLocalName api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1100
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
localName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1100 localName =
'
+
JSON
.
stringify
(
localName
));
expect
(
true
).
assertEqual
(
localName
!=
null
);
let
newName
=
'
蓝牙设备123
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1100 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
result
=
bluetooth
.
setLocalName
(
localName
);
expect
(
result
).
assertTrue
();
let
getLocalName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1100 localName =
'
+
JSON
.
stringify
(
getLocalName
));
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1200
* @tc.name TEST setLocalName
* @tc.desc TEST setLocalName api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1200
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
localName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1200 localName =
'
+
JSON
.
stringify
(
localName
));
expect
(
true
).
assertEqual
(
localName
!=
null
);
let
newName
=
'
蓝牙设备bluetooth12
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1200 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
result
=
bluetooth
.
setLocalName
(
localName
);
expect
(
result
).
assertTrue
();
let
getLocalName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1200 localName =
'
+
JSON
.
stringify
(
getLocalName
));
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1400
* @tc.name TEST setLocalName
* @tc.desc TEST setLocalName api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1400
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
localName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1400 localName =
'
+
JSON
.
stringify
(
localName
));
expect
(
true
).
assertEqual
(
localName
!=
null
);
let
newName
=
'
蓝牙设备*{bluetooth}
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1400 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
result
=
bluetooth
.
setLocalName
(
localName
);
expect
(
result
).
assertTrue
();
let
getLocalName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1400 localName =
'
+
JSON
.
stringify
(
getLocalName
));
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0100
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0100
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_NONE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 newscanmode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_NONE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 setoldscanmode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0200
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0200
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 newscanmode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 setoldscanmode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0300
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0300
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
40000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0400
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0400
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
40000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0500
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0500
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0600
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0600
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0700
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0700
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
20000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0800
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0800
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0900
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0900
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
30000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_1000
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 4
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_1000
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_1000 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
-
1
,
0
);
expect
(
result
).
assertFalse
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_1000 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
oldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0400
* @tc.name testGetRemoteDeviceClass
* @tc.desc Test GetRemoteDeviceClass api 8.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] getRemoteDeviceClass start
'
);
await
tryToEnableBt
();
let
ret
=
bluetooth
.
getRemoteDeviceClass
(
"
00:11:22:33:44:55
"
);
console
.
info
(
'
[bluetooth_js] getRemoteDeviceClass ret2 :
'
+
JSON
.
stringify
(
ret
)
+
'
majorClass:
'
+
ret
.
majorClass
+
'
majorMinorClass:
'
+
ret
.
majorMinorClass
+
'
classOfDevice:
'
+
ret
.
classOfDevice
);
expect
(
ret
.
majorClass
).
assertEqual
(
0
);
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
* @tc.name testSppListen
* @tc.desc Test SppListen api 8 by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[bluetooth_js]: spp listen start
"
);
await
tryToEnableBt
();
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
true
,
type
:
0
};
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
function
(
code
,
serverSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
expect
(
true
).
assertEqual
(
true
);
done
();
}
else
{
expect
(
true
).
assertEqual
(
false
);
done
();
}
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0200
* @tc.name testSppListen
* @tc.desc Test SppListen api 8 by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0200
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[bluetooth_js]: spp listen start
"
);
await
tryToEnableBt
();
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
false
,
type
:
0
};
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
number
);
serverNumber
=
number
;
}
}
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0300
* @tc.name testSppListen
* @tc.desc Test SppListen api 8 by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0300
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[bluetooth_js]: spp listen start
"
);
await
tryToEnableBt
();
let
sppOption
=
{
uuid
:
'
00000000
'
,
secure
:
true
,
type
:
0
};
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
number
);
serverNumber
=
number
;
}
}
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0400
* @tc.name testSppListen
* @tc.desc Test SppListen api 8 by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0400
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[bluetooth_js]: spp listen start
"
);
await
tryToEnableBt
();
let
sppOption
=
{
uuid
:
'
00000000-0000-1000-8000-00805F9B34FB
'
,
secure
:
false
,
type
:
0
};
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
number
);
serverNumber
=
number
;
}
}
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0500
* @tc.name testSppAccept
* @tc.desc Test SppAccept api 8 by callbck.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0500
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[bluetooth_js] spp accept start
"
);
await
tryToEnableBt
();
function
acceptClientSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
console
.
log
(
'
[bluetooth_js] clientSocket Number:
'
+
number
);
}
}
bluetooth
.
sppAccept
(
0
,
acceptClientSocket
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0600
* @tc.name testSppAccept
* @tc.desc Test SppAccept api 8 by callbck.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0600
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[bluetooth_js] spp accept start
"
);
await
tryToEnableBt
();
bluetooth
.
sppAccept
(
-
1
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
expect
(
true
).
assertEqual
(
false
);
}
});
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0700
* @tc.name testSppConnect
* @tc.desc Test SppConnect api 8 by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] spp_connect start
'
);
await
tryToEnableBt
();
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
true
,
type
:
0
};
bluetooth
.
sppConnect
(
'
00:11:22:33:44:55
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
expect
(
true
).
assertEqual
(
false
);
}
});
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0800
* @tc.name testSppConnect
* @tc.desc Test SppConnect api 8 by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0800
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] spp_connect start
'
);
await
tryToEnableBt
();
let
sppOption
=
{
uuid
:
'
0000
'
,
secure
:
false
,
type
:
0
};
bluetooth
.
sppConnect
(
'
ABC
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
expect
(
true
).
assertEqual
(
false
);
}
});
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0100
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
60
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0200
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
20
,
txPower
:
60
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0300
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
16385
,
txPower
:
60
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0400
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
16400
,
txPower
:
60
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0500
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
19
,
txPower
:
60
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0800
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0800
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
10
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0900
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0900
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
127
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1000
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1000
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
1
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1100
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
10
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1200
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
130
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1400
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
1
,
connectable
:
false
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1500
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1600
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1700
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb-010203
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
gattServer
.
stopAdvertising
();
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1800
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1800
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
""
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1900
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1900
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2000
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2000
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
""
,
serviceValue
:
""
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2400
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising end
'
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0200
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
-
70
,
connectable
:
true
,
}
let
advData
=
{
serviceUuids
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
"
4567
"
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
let
advResponse
=
{
serviceUuids
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
manufactureData
:
{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
,
},
serviceData
:{
serviceUuid
:
"
00001889-0000-1000-8000-00805f9b34fb
"
,
serviceValue
:
serviceValueBuffer
.
buffer
,
}
}
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
startAdvertising
(
setting
,
advData
,
advResponse
);
gattServer
.
stopAdvertising
();
console
.
info
(
'
[bluetooth_js] BLE advertising 第
'
+
JSON
.
stringify
(
i
)
+
'
次 end
'
);
}
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0400
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
stopAdvertising
();
done
();
})
})
}
communication/wifi_p2p/src/main/js/test/List.test.js
浏览文件 @
7caee5bf
...
...
@@ -12,10 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
actsWifi
TestNew
from
'
./WifiP2P.testsame
.js
'
import
actsWifi
Test
from
'
./WifiP2P.test2
.js
'
import
actsWifi
FunctionTest
from
'
./WifiP2PFunction.test
.js
'
import
actsWifi
EventTest
from
'
./WifiP2PEvent.test
.js
'
export
default
function
testsuite
()
{
actsWifi
TestNew
()
actsWifiTest
()
actsWifi
FunctionTest
()
actsWifi
Event
Test
()
}
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
已删除
100644 → 0
浏览文件 @
621fbe9a
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
function
checkWifiPowerOn
(){
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
}
export
default
function
actsWifiTestNew
()
{
describe
(
'
actsWifiTestNew
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
afterEach
(
function
()
{
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0009
* @tc.name testp2pCancelConnect
* @tc.desc Test p2pCancelConnect Group API functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0009
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
0
};
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test p2pConnect result.
"
+
addConfig
);
let
disConn
=
wifi
.
p2pCancelConnect
();
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test p2pCancelConnect result.
"
+
disConn
);
expect
(
disConn
).
assertTrue
();
let
removeConfig
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0011
* @tc.name testremoveGroup
* @tc.desc Test remove error Group functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0011
'
,
0
,
async
function
(
done
)
{
let
isRemoved
=
wifi
.
removeGroup
(
10000
);
console
.
info
(
"
[wifi_test]removeGroup(10000) result :
"
+
JSON
.
stringify
(
isRemoved
));
expect
(
isRemoved
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0002
* @tc.name testP2pLocalDevice
* @tc.desc Test get TO P2pLocalDevice API functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0002
'
,
0
,
async
function
(
done
)
{
await
wifi
.
getP2pLocalDevice
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getP2pLocalDevice [promise] result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
>=
0
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice promise error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
function
getP2pLocal
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getP2pLocalDevice
(
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice callback failed :
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
[wifi_test] getP2pLocalDevice callback result:
"
+
JSON
.
stringify
(
ret
));
console
.
info
(
"
deviceName:
"
+
ret
.
deviceName
+
"
deviceAddress:
"
+
ret
.
deviceAddress
+
"
primaryDeviceType:
"
+
ret
.
primaryDeviceType
+
"
deviceStatus:
"
+
ret
.
deviceStatus
+
"
groupCapabilitys:
"
+
ret
.
groupCapabilitys
);
resolve
();
});
});
}
await
getP2pLocal
();
done
();
})
})
}
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
0 → 100644
浏览文件 @
7caee5bf
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
function
checkWifiPowerOn
(){
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
}
let
GroupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
}
export
default
function
actsWifiEventTest
()
{
describe
(
'
actsWifiEventTest
'
,
function
()
{
beforeEach
(
function
()
{
console
.
info
(
"
beforeEach start
"
);
checkWifiPowerOn
();
})
afterEach
(
async
function
()
{
console
.
info
(
"
afterEach start
"
);
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0008
* @tc.name testp2pStateChange
* @tc.desc Test p2pStateChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0008
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pStateChange
'
,
result
=>
{
console
.
info
(
"
onP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
setTimeout
(
function
()
{
wifi
.
off
(
'
p2pStateChange
'
,
result
=>
{
console
.
info
(
"
offP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0009
* @tc.name testp2pConnectionChange
* @tc.desc Test p2pConnectionChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0009
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pConnectionChange
'
,
recvP2pConnectionChangeFunc
=>
{
console
.
info
(
"
[wifi_test] p2pConnectionChange result ->
"
+
recvP2pConnectionChangeFunc
);
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
done
();
});
setTimeout
(
function
()
{
console
.
info
(
'
[wifi_test] offP2pStateChange test start ...
'
);
wifi
.
off
(
'
p2pConnectionChange
'
,
recvP2pConnectionChangeFunc
=>
{
console
.
info
(
"
p2pConnectionChange callback
"
+
JSON
.
stringify
(
recvP2pConnectionChangeFunc
));
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0012
* @tc.name testp2pDeviceChange
* @tc.desc Test p2pDeviceChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0012
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[wifi_test] Onp2pDeviceChange test start ...
'
);
await
wifi
.
on
(
'
p2pDeviceChange
'
,
result
=>
{
console
.
info
(
"
onP2pDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
setTimeout
(
function
()
{
console
.
info
(
'
[wifi_test] offP2pDeviceChange test start ...
'
);
wifi
.
off
(
'
p2pDeviceChange
'
,
result
=>
{
console
.
info
(
"
offP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0010
* @tc.name testp2pDeviceChange
* @tc.desc Test p2pDeviceChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0010
'
,
0
,
async
function
(
done
)
{
let
recvP2pPeerDeviceChangeFunc
=
result
=>
{
console
.
info
(
"
wifi_test / p2p peer device change receive event:
"
+
JSON
.
stringify
(
result
));
wifi
.
getP2pDevices
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
wifi_test / failed to get getP2pDevices:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
wifi_test / getP2pDevices [callback] ->
"
+
JSON
.
stringify
(
data
));
let
len
=
Object
.
keys
(
data
).
length
;
console
.
log
(
"
getP2pDevices number:
"
+
len
);
for
(
let
i
=
0
;
i
<
len
;
++
i
)
{
if
(
data
[
i
].
deviceName
===
"
GRE
"
)
{
console
.
info
(
"
wifi_test / p2pConnect: ->
"
+
data
[
i
].
deviceAddress
);
let
config
=
{
"
deviceAddress
"
:
data
[
i
].
deviceAddress
,
"
netId
"
:
-
1
,
"
passphrase
"
:
""
,
"
groupName
"
:
""
,
"
goBand
"
:
0
,
}
wifi
.
p2pConnect
(
config
);
}
}
});
}
await
wifi
.
on
(
'
p2pPeerDeviceChange
'
,
result
=>
{
console
.
info
(
"
onP2pPeerDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
setTimeout
(
function
()
{
wifi
.
off
(
'
p2pPeerDeviceChange
'
,
result
=>
{
console
.
info
(
"
offP2pPeerDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0013
* @tc.name testp2pPersistentGroupChange
* @tc.desc Test p2pPersistentGroupChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0013
'
,
0
,
async
function
(
done
)
{
let
recvP2pPersistentGroupChangeFunc
=
()
=>
{
console
.
info
(
"
wifi_test / p2p persistent group change receive event
"
);
let
config
=
{
"
deviceAddress
"
:
"
02:11:65:f2:0d:6e
"
,
"
netId
"
:
-
2
,
"
passphrase
"
:
""
,
"
groupName
"
:
""
,
"
goBand
"
:
0
,
};
let
addConfig
=
wifi
.
createGroup
(
config
);
expect
(
addConfig
).
assertTrue
();
wifi
.
getCurrentGroup
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
wifi_test / failed to get getCurrentGroup:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
wifi_test / get getCurrentGroup [callback] ->
"
+
JSON
.
stringify
(
data
));
});
};
wifi
.
on
(
"
p2pPersistentGroupChange
"
,
recvP2pPersistentGroupChangeFunc
);
setTimeout
(
async
function
()
{
wifi
.
off
(
'
p2pPersistentGroupChange
'
,
result
=>
{
console
.
info
(
"
offP2pPersistentGroupChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0011
* @tc.name testpp2pDiscoveryChange
* @tc.desc Test p2pDiscoveryChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0011
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pDiscoveryChange
'
,
result
=>
{
console
.
info
(
"
onp2pDiscoveryChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
result
!=
null
));
done
();
});
setTimeout
(
function
()
{
wifi
.
off
(
'
p2pDiscoveryChange
'
,
result
=>
{
console
.
info
(
"
offp2pDiscoveryChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
communication/wifi_p2p/src/main/js/test/WifiP2P
.testsame
.js
→
communication/wifi_p2p/src/main/js/test/WifiP2P
Function.test
.js
浏览文件 @
7caee5bf
...
...
@@ -17,11 +17,8 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
// delay x ms
var
start
=
(
new
Date
()).
getTime
();
while
((
new
Date
()).
getTime
()
-
start
>
delay
)
{
break
;
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
function
checkWifiPowerOn
(){
...
...
@@ -34,8 +31,8 @@ let GroupOwnerBand = {
GO_BAND_5GHZ
:
2
,
}
export
default
function
actsWifiTest
()
{
describe
(
'
actsWifiTest
'
,
function
()
{
export
default
function
actsWifi
Function
Test
()
{
describe
(
'
actsWifi
Function
Test
'
,
function
()
{
beforeEach
(
function
()
{
console
.
info
(
"
beforeEach start
"
);
checkWifiPowerOn
();
...
...
@@ -45,14 +42,13 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_Config_0001
* @tc.name SUB_Communication_WiFi_P2P_Config_0001
* @tc.desc Test createGroup and getCurrentGroup promise infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_P2P_0003
* @tc.name testcreateGroup
* @tc.desc Test createGroup and getCurrentGroup infos
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
P2P_Config_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
XTS_P2P_0003
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
...
...
@@ -63,42 +59,15 @@ export default function actsWifiTest() {
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test createGroup end.
"
+
addConfig
);
sleep
(
2000
);
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
JSON
.
stringify
(
addConfig
)
);
await
sleep
(
2000
);
expect
(
addConfig
).
assertTrue
();
wifi
.
getCurrentGroup
()
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
()
})
/**
* @tc.number P2P_Config_0002
* @tc.name SUB_Communication_WiFi_P2P_Config_0002
* @tc.desc Test getCurrentGroup callback infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0002
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
0
};
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
JSON
.
stringify
(
wifi
.
isWifiActive
()));
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
sleep
(
2000
);
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
(
addConfig
));
expect
(
addConfig
).
assertTrue
();
wifi
.
getCurrentGroup
(
(
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -115,33 +84,156 @@ export default function actsWifiTest() {
"
passphrase:
"
+
result
.
passphrase
+
"
interface:
"
+
result
.
interface
+
"
groupName:
"
+
result
.
groupName
+
"
frequency:
"
+
result
.
frequency
+
"
goIpAddress:
"
+
result
.
goIpAddress
);
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
}
done
();
});
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0004
* @tc.name testcreateGroup
* @tc.desc Test set password createGroup API Function.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
1234567
"
,
groupName
:
"
test_pass
"
,
goBand
:
0
,
};
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test createGroup end.
"
+
JSON
.
stringify
(
addConfig
));
await
sleep
(
2000
);
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0104
* @tc.name testcreateGroup
* @tc.desc Test set password createGroup API Function.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0104
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
WifiP2PConfig1
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
123@%abcD
"
,
groupName
:
"
test_pass1
"
,
goBand
:
0
,
};
let
addConfig1
=
wifi
.
createGroup
(
WifiP2PConfig1
);
console
.
info
(
"
[wifi_test] test createGroup end.
"
+
JSON
.
stringify
(
addConfig1
));
await
sleep
(
2000
);
expect
(
addConfig1
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
()
})
/**
* @tc.number P2P_Config_0003
* @tc.name SUB_Communication_WiFi_P2P_Config_0003
* @tc.desc Test createGroup 2.4G band and getCurrentGroup infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_P2P_0204
* @tc.name testcreateGroup
* @tc.desc Test set password createGroup API Function.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0003
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_XTS_P2P_0204
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
WifiP2PConfig2
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc3456789012345678901234567890123456789012345678901234567890123
"
,
groupName
:
"
test_pass2
"
,
goBand
:
0
,
};
let
addConfig2
=
wifi
.
createGroup
(
WifiP2PConfig2
);
console
.
info
(
"
[wifi_test] test createGroup end.
"
+
JSON
.
stringify
(
addConfig2
));
await
sleep
(
2000
);
expect
(
addConfig2
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
()
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0304
* @tc.name testcreateGroup
* @tc.desc Test set password createGroup API Function.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0304
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
WifiP2PConfig3
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc34567890123456789012345678901234567890123456789012345678901234
"
,
groupName
:
"
test_pass3
"
,
goBand
:
0
,
};
let
addConfig3
=
wifi
.
createGroup
(
WifiP2PConfig3
);
console
.
info
(
"
[wifi_test] test createGroup end.
"
+
JSON
.
stringify
(
addConfig3
));
await
sleep
(
2000
);
expect
(
addConfig3
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0007
* @tc.name testsethotspot
* @tc.desc Test createGroup band setting infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0007
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig2
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
1
goBand
:
1
,
};
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig2
);
sleep
(
2000
);
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test createGroup3 result.
"
+
addConfig
)
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
...
...
@@ -152,33 +244,32 @@ export default function actsWifiTest() {
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
()
done
()
;
})
/**
* @tc.number P2P_Config_0004
* @tc.name SUB_Communication_WiFi_P2P_Config_0004
* @tc.desc Test create PersistentGroup infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_P2P_0107
* @tc.name testsethotspot
* @tc.desc Test createGroup band setting infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_
P2P_Config_0004
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
=
{
it
(
'
SUB_Communication_WiFi_
XTS_P2P_0107
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
2
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
2
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
0
goBand
:
2
,
};
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test
p2pConnect result.
"
+
addConfig
);
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
2
);
await
(
2000
);
console
.
info
(
"
[wifi_test] test
createGroup3 result.
"
+
addConfig
)
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
(
data
)
=>
{
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
...
...
@@ -189,66 +280,269 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_Config_0005
* @tc.name SUB_Communication_WiFi_P2P_Config_0005
* @tc.desc Test p2pConnect infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION
* @tc.number SUB_Communication_WiFi_XTS_P2P_0207
* @tc.name testsethotspot
* @tc.desc Test createGroup band setting infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_
P2P_Config_0005
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
3
=
{
it
(
'
SUB_Communication_WiFi_
XTS_P2P_0207
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
2
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
2
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ
"
,
goBand
:
2
groupName
:
"
AAAZZZ
123
"
,
goBand
:
0
,
};
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
scanConfig
=
wifi
.
startDiscoverDevices
();
sleep
(
2000
);
expect
(
scanConfig
).
assertTrue
();
let
connConfig
=
wifi
.
p2pConnect
(
WifiP2PConfig3
);
console
.
info
(
"
[wifi_test] test p2pConnect result.
"
+
connConfig
);
expect
(
connConfig
).
assertTrue
();
let
stopScan
=
wifi
.
stopDiscoverDevices
();
console
.
info
(
"
[wifi_test] test stopDiscoverDevices result.
"
+
stopScan
);
done
()
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig2
);
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test createGroup3 result.
"
+
addConfig
)
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
* @tc.number P2P_Config_0006
* @tc.name SUB_Communication_WiFi_P2P_Config_0006
* @tc.desc Test getP2pLinkedInfo promise infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_P2P_0307
* @tc.name testsethotspot
* @tc.desc Test createGroup band setting infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0006
'
,
0
,
async
function
(
done
)
{
await
wifi
.
getP2pLinkedInfo
()
it
(
'
SUB_Communication_WiFi_XTS_P2P_0307
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig2
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
3
,
};
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig2
);
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test createGroup3 result.
"
+
addConfig
)
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] get
P2pLinkedInfo
[promise] result ->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[wifi_test] get
CurrentGroup
[promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
done
()
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0008
* @tc.name testsethotspot
* @tc.desc Test create P2P error SSID Group functionality.
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0008
'
,
0
,
async
function
(
done
)
{
let
GroupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
}
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
""
,
goBand
:
0
,
};
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test createGroup result:
"
+
JSON
.
stringify
(
addConfig
));
await
sleep
(
2000
);
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
* @tc.number P2P_Config_0007
* @tc.name SUB_Communication_WiFi_P2P_Config_0007
* @tc.desc Test getP2pLinkedInfo callback infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_P2P_0108
* @tc.name testsethotspot
* @tc.desc Test create P2P error SSID Group functionality.
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0007
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_XTS_P2P_0108
'
,
0
,
async
function
(
done
)
{
let
GroupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
}
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
"
,
goBand
:
0
,
};
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test createGroup result:
"
+
JSON
.
stringify
(
addConfig
));
await
sleep
(
2000
);
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0308
* @tc.name testsethotspot
* @tc.desc Test create P2P error SSID Group functionality.
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0308
'
,
0
,
async
function
(
done
)
{
let
GroupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
}
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
"
,
groupName
:
"
testpassword
"
,
goBand
:
0
,
};
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test createGroup result:
"
+
JSON
.
stringify
(
addConfig
));
await
sleep
(
2000
);
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
let
removeConfig
=
wifi
.
removeGroup
();
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0009
* @tc.name testp2pCancelConnect
* @tc.desc Test p2pCancelConnect Group API functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0009
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ456
"
,
goBand
:
0
};
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test p2pConnect result.
"
+
addConfig
);
let
disConn
=
wifi
.
p2pCancelConnect
();
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test p2pCancelConnect result.
"
+
disConn
);
expect
(
disConn
).
assertTrue
();
let
removeConfig
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test] test start removeGroup:
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0011
* @tc.name testremoveGroup
* @tc.desc Test remove error Group functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0011
'
,
0
,
async
function
(
done
)
{
let
isRemoved
=
wifi
.
removeGroup
(
10000
);
console
.
info
(
"
[wifi_test]removeGroup(10000) result :
"
+
JSON
.
stringify
(
isRemoved
));
expect
(
isRemoved
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0002
* @tc.name testP2pLocalDevice
* @tc.desc Test get TO P2pLocalDevice API functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0002
'
,
0
,
async
function
(
done
)
{
await
wifi
.
getP2pLocalDevice
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getP2pLocalDevice [promise] result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
>=
0
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice promise error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
function
getP2pLocal
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getP2pLocalDevice
(
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice callback failed :
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
[wifi_test] getP2pLocalDevice callback result:
"
+
JSON
.
stringify
(
ret
));
console
.
info
(
"
deviceName:
"
+
ret
.
deviceName
+
"
deviceAddress:
"
+
ret
.
deviceAddress
+
"
primaryDeviceType:
"
+
ret
.
primaryDeviceType
+
"
deviceStatus:
"
+
ret
.
deviceStatus
+
"
groupCapabilitys:
"
+
ret
.
groupCapabilitys
);
resolve
();
});
});
}
await
getP2pLocal
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0010
* @tc.name testgetP2pLinkedInfo
* @tc.desc Test Test getP2pLinkedInfo infos
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0010
'
,
0
,
async
function
(
done
)
{
let
P2pConnectState
=
{
DISCONNECTED
:
0
,
CONNECTED
:
1
,
};
await
wifi
.
getP2pLinkedInfo
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getP2pLinkedInfo [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
done
()
});
function
getP2pInfo
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getP2pLinkedInfo
(
...
...
@@ -272,37 +566,17 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_Config_0008
* @tc.name SUB_Communication_WiFi_P2P_Config_0008
* @tc.desc Test p2pCancelConnect infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_P2P_0001
* @tc.name testgetP2pPeerDevices
* @tc.desc Test getP2pPeerDevices promise infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0008
'
,
0
,
async
function
(
done
)
{
let
disConn
=
wifi
.
p2pCancelConnect
();
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test p2pCancelConnect result.
"
+
disConn
);
expect
(
disConn
).
assertTrue
();
let
removeConfig
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
done
();
})
/**
* @tc.number P2P_Config_0009
* @tc.name SUB_Communication_WiFi_P2P_Config_0009
* @tc.desc Test getP2pPeerDevices promise infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0009
'
,
0
,
async
function
(
done
){
it
(
'
SUB_Communication_WiFi_XTS_P2P_0001
'
,
0
,
async
function
(
done
){
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
scanConfig
=
wifi
.
startDiscoverDevices
();
sleep
(
2000
);
await
sleep
(
2000
);
expect
(
scanConfig
).
assertTrue
();
await
wifi
.
getP2pPeerDevices
()
.
then
((
data
)
=>
{
...
...
@@ -313,18 +587,19 @@ export default function actsWifiTest() {
console
.
info
(
"
[wifi_test]getP2pPeerDevices promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
let
stopScan
=
wifi
.
stopDiscoverDevices
();
console
.
info
(
"
[wifi_test] test stopDiscoverDevices result.
"
+
stopScan
);
done
();
})
/**
* @tc.number P2P_Config_0010
* @tc.name SUB_Communication_WiFi_P2P_Config_0010
* @tc.desc Test getP2pPeerDevices callback infos
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION
* @tc.number SUB_Communication_WiFi_XTS_P2P_0101
* @tc.name testgetP2pPeerDevices
* @tc.desc Test getP2pPeerDevices callback infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_
P2P_Config_0010
'
,
0
,
async
function
(
done
){
it
(
'
SUB_Communication_WiFi_
XTS_P2P_0101
'
,
0
,
async
function
(
done
){
let
P2pDeviceStatus
=
{
CONNECTED
:
0
,
INVITED
:
1
,
...
...
@@ -335,7 +610,7 @@ export default function actsWifiTest() {
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
scanConfig
=
wifi
.
startDiscoverDevices
();
sleep
(
2000
);
await
sleep
(
2000
);
expect
(
scanConfig
).
assertTrue
();
await
wifi
.
getP2pPeerDevices
((
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -373,14 +648,13 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_P2pStateChange_0001
* @tc.name SUB_Communication_WiFi_P2P_P2pStateChange_0001
* @tc.desc Test p2pStateChange callback
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_Event_Test_0008
* @tc.name testp2pStateChange
* @tc.desc Test p2pStateChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
P2P_P2pStateChange_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
Event_Test_0008
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pStateChange
'
,
result
=>
{
console
.
info
(
"
onP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
...
...
@@ -396,14 +670,13 @@ export default function actsWifiTest() {
})
/**
* @tc.number p2pConnectionChange_0002
* @tc.name SUB_Communication_WiFi_P2P_p2pConnectionChange_0002
* @tc.desc Test p2pConnectionChange callback
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_Event_Test_0009
* @tc.name testp2pConnectionChange
* @tc.desc Test p2pConnectionChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
P2P_p2pConnectionChange_0002
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
Event_Test_0009
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pConnectionChange
'
,
recvP2pConnectionChangeFunc
=>
{
console
.
info
(
"
[wifi_test] p2pConnectionChange result ->
"
+
recvP2pConnectionChangeFunc
);
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
...
...
@@ -420,14 +693,13 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_p2pDeviceChange_0003
* @tc.name SUB_Communication_WiFi_P2P_p2pDeviceChange_0003
* @tc.desc Test p2pDeviceChange callback
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION
* @tc.number SUB_Communication_WiFi_Event_Test_0012
* @tc.name testp2pDeviceChange
* @tc.desc Test p2pDeviceChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
P2P_p2pDeviceChange_0003
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
Event_Test_0012
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[wifi_test] Onp2pDeviceChange test start ...
'
);
await
wifi
.
on
(
'
p2pDeviceChange
'
,
result
=>
{
console
.
info
(
"
onP2pDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
...
...
@@ -445,14 +717,13 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_p2pPeerDeviceChange_0004
* @tc.name SUB_Communication_WiFi_P2P_p2pPeerDeviceChange_0004
* @tc.desc Test p2pDeviceChange callback
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION
* @tc.number SUB_Communication_WiFi_Event_Test_0010
* @tc.name testp2pDeviceChange
* @tc.desc Test p2pDeviceChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
P2P_p2pPeerDeviceChange_0004
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
Event_Test_0010
'
,
0
,
async
function
(
done
)
{
let
recvP2pPeerDeviceChangeFunc
=
result
=>
{
console
.
info
(
"
wifi_test / p2p peer device change receive event:
"
+
JSON
.
stringify
(
result
));
wifi
.
getP2pDevices
((
err
,
data
)
=>
{
...
...
@@ -493,14 +764,13 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_p2pPersistentGroupChange_0005
* @tc.name SUB_Communication_WiFi_P2P_p2pPersistentGroupChange_0005
* @tc.desc Test p2pPersistentGroupChange callback
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_Event_Test_0013
* @tc.name testp2pPersistentGroupChange
* @tc.desc Test p2pPersistentGroupChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
P2P_p2pPersistentGroupChange_0005
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
Event_Test_0013
'
,
0
,
async
function
(
done
)
{
let
recvP2pPersistentGroupChangeFunc
=
()
=>
{
console
.
info
(
"
wifi_test / p2p persistent group change receive event
"
);
let
config
=
{
...
...
@@ -531,14 +801,13 @@ export default function actsWifiTest() {
})
/**
* @tc.number P2P_p2pDiscoveryChange_0006
* @tc.name SUB_Communication_WiFi_P2P_p2pDiscoveryChange_0006
* @tc.desc Test p2pDiscoveryChange callback
* @since 8
* @syscap SystemCapability.Communication.WiFi.P2P
* @permission ohos.permission.GET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_Event_Test_0011
* @tc.name testpp2pDiscoveryChange
* @tc.desc Test p2pDiscoveryChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
P2P_p2pDiscoveryChange_0006
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
Event_Test_0011
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pDiscoveryChange
'
,
result
=>
{
console
.
info
(
"
onp2pDiscoveryChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
result
!=
null
));
...
...
@@ -555,3 +824,8 @@ export default function actsWifiTest() {
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
communication/wifi_standard/src/main/js/test/List.test.js
浏览文件 @
7caee5bf
...
...
@@ -12,10 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
actsWifiTestNew
from
'
./WifiJsunit.test1.js
'
import
actsWifiTest
from
'
./WifiJsunit.testsame.js
'
import
actsWifiCandidateNetWorkTest
from
'
./WifiCandidateNetWork.test.js
'
import
actsWifiFunctionsTest
from
'
./WifiStationFunctions.test.js
'
import
actsWifiEventTest
from
'
./WifiStationEvent.test.js
'
export
default
function
testsuite
()
{
actsWifiTestNew
()
actsWifiTest
()
actsWifiCandidateNetWorkTest
()
actsWifiFunctionsTest
()
actsWifiEventTest
()
}
communication/wifi_standard/src/main/js/test/Wifi
Jsunit.test1
.js
→
communication/wifi_standard/src/main/js/test/Wifi
CandidateNetWork.test
.js
浏览文件 @
7caee5bf
...
...
@@ -56,8 +56,8 @@ let WifiChannelWidth = {
WIDTH_INVALID
:
null
,
}
export
default
function
actsWifi
TestNew
()
{
describe
(
'
actsWifi
TestNew
'
,
function
()
{
export
default
function
actsWifi
CandidateNetWorkTest
()
{
describe
(
'
actsWifi
CandidateNetWorkTest
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
@@ -65,12 +65,11 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0001
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0001
* @since 9
* @tc.desc Test add OPEN and WEP CandidateConfig Promise API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0001
* @tc.name testaddCandidateConfig
* @tc.desc Test add OPEN and WEP CandidateConfig Promise API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0001
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -113,12 +112,11 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0001
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0002
* @since 8
* @tc.desc Test add PSK CandidateConfig and removeCandidateConfig Promise API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0002
* @tc.name testaddCandidateConfig
* @tc.desc Test add PSK CandidateConfig and removeCandidateConfig Promise API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0002
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -156,12 +154,11 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0003
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0003
* @since 8
* @tc.desc Test add SAE CandidateConfig Promise API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0003
* @tc.name testaddCandidateConfig
* @tc.desc Test add SAE CandidateConfig Promise API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0003
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -198,12 +195,72 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0005
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0005
* @since 8
* @tc.desc Test add CandidateConfig and removeCandidateConfig callback API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0004
* @tc.name testaddCandidateConfig
* @tc.desc Test add MAX CandidateConfig and removeall CandidateConfig.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0004
'
,
0
,
async
function
(
done
)
{
let
SSID
=
"
TYPE_PSK
"
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
SSID
=
"
TYPE_PSK
"
+
i
console
.
info
(
"
[wifi_test] get canshu result :
"
);
let
wifiDeviceConfig
=
{
"
ssid
"
:
SSID
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
console
.
info
(
"
[wifi_test] get wifiDeviceConfig ssid result :
"
+
JSON
.
stringify
(
wifiDeviceConfig
.
ssid
));
await
wifi
.
addCandidateConfig
(
wifiDeviceConfig
)
.
then
(
netWorkId
=>
{
console
.
info
(
"
[wifi_test]add 16th CandidateConfig promise :
"
+
JSON
.
stringify
(
netWorkId
));
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js] add 16th CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
}
let
wifiDeviceConfig1
=
{
"
ssid
"
:
"
TYPE_17
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
await
wifi
.
addCandidateConfig
(
wifiDeviceConfig1
)
.
then
(
netWorkId
=>
{
console
.
info
(
"
[wifi_test]add 17th CandidateConfig promise :
"
+
JSON
.
stringify
(
netWorkId
));
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js] add 17th CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
let
getconfig
=
wifi
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test] wifi get 16 CandidateConfigs result :
"
+
JSON
.
stringify
(
getconfig
));
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
var
networkId
=
getconfig
[
i
].
netId
;
console
.
info
(
"
[wifi_test] wifi get networkId result :
"
+
JSON
.
stringify
(
networkId
));
await
wifi
.
removeCandidateConfig
(
networkId
)
.
then
(
ret
=>
{
console
.
info
(
"
[wifi_test]remove CandidateConfig promise
"
+
JSON
.
stringify
(
ret
));
let
getconfig1
=
wifi
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test] wifi get CandidateConfigs result :
"
+
JSON
.
stringify
(
getconfig1
));
console
.
info
(
"
[wifi_test] wifi getconfiglength result :
"
+
JSON
.
stringify
(
getconfig1
.
length
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js] remove CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
}
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0005
* @tc.name testaddCandidateConfig
* @tc.desc Test add CandidateConfig and removeCandidateConfig callback API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0005
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -249,18 +306,16 @@ export default function actsWifiTestNew() {
});
});
}
await
removeCandidate
();
done
();
})
/**
* @tc.number CandidateNetWork_0006
* @tc.name SUB_Communication_WiFi_XTS_SUB_Communication_WiFi_XTS_CandidateNetWork_0006
* @tc.desc Test connect To CandidateConfig API functionality.
* @since 9
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0006
* @tc.name testaddCandidateConfig
* @tc.desc Test connect To CandidateConfig API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0006
'
,
0
,
async
function
(
done
)
{
let
WifiSecurityType
=
{
...
...
@@ -302,69 +357,6 @@ export default function actsWifiTestNew() {
done
();
})
/**
* @tc.number Sta_0002
* @tc.name SUB_Communication_WiFi_XTS_Sta_0002
* @tc.desc Test get to ScanInfos promise and callback API functionality.
* @since 6
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION)
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0002
'
,
0
,
async
function
(
done
)
{
await
wifi
.
getScanInfos
()
.
then
(
result
=>
{
let
clen
=
Object
.
keys
(
result
).
length
;
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos promise result
"
+
JSON
.
stringify
(
result
));
});
function
getScanInfos
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getScanInfos
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test] wifi getScanInfos failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
if
(
!
(
clen
==
0
))
{
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos callback result:
"
+
JSON
.
stringify
(
result
));
for
(
let
j
=
0
;
j
<
clen
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
+
"
bssid:
"
+
result
[
j
].
bssid
+
"
securityType:
"
+
result
[
j
].
securityType
+
"
rssi:
"
+
result
[
j
].
rssi
+
"
band:
"
+
result
[
j
].
band
+
"
frequency:
"
+
result
[
j
].
frequency
+
"
channelWidth:
"
+
result
[
j
].
channelWidth
+
"
timestamp
"
+
result
[
j
].
timestamp
+
"
capabilities
"
+
result
[
j
].
capabilities
+
"
centerFrequency0:
"
+
result
[
j
].
centerFrequency0
+
"
centerFrequency1:
"
+
result
[
j
].
centerFrequency1
+
"
infoElems:
"
+
result
[
j
].
infoElems
);
}
}
resolve
();
});
});
}
await
getScanInfos
();
done
();
})
/**
* @tc.number Sta_0034
* @tc.name SUB_Communication_WiFi_XTS_Sta_0034
* @tc.desc Test get to ScanInfos Sync API functionality.
* @since 9
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION)
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0034
'
,
0
,
async
function
(
done
)
{
let
getScanInfos
=
wifi
.
getScanInfosSync
();
console
.
info
(
"
[wifi_test] wifi get to ScanInfosSync result :
"
+
JSON
.
stringify
(
getScanInfos
));
let
lenth
=
Object
.
keys
(
getScanInfos
).
length
;
console
.
info
(
"
[wifi_test] wifi ScanInfosSync length result :
"
+
JSON
.
stringify
(
lenth
));
expect
(
lenth
).
assertLarger
(
0
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_UntrustedConfig_0001
* @tc.name testaddUntrustedConfig
...
...
@@ -448,3 +440,7 @@ export default function actsWifiTestNew() {
})
})
}
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
0 → 100644
浏览文件 @
7caee5bf
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
function
checkWifiPowerOn
(){
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
}
function
resolveIP
(
ip
)
{
return
(
ip
>>
24
&
0xFF
)
+
"
.
"
+
(
ip
>>
16
&
0xFF
)
+
"
.
"
+
(
ip
>>
8
&
0xFF
)
+
"
.
"
+
(
ip
&
0xFF
);
}
let
WifiSecurityType
=
{
WIFI_SEC_TYPE_INVALID
:
0
,
WIFI_SEC_TYPE_OPEN
:
1
,
WIFI_SEC_TYPE_WEP
:
2
,
WIFI_SEC_TYPE_PSK
:
3
,
WIFI_SEC_TYPE_SAE
:
4
,
}
let
ConnState
=
{
SCANNING
:
0
,
CONNECTING
:
1
,
AUTHENTICATING
:
2
,
OBTAINING_IPADDR
:
3
,
CONNECTED
:
4
,
DISCONNECTING
:
5
,
DISCONNECTED
:
6
,
UNKNOWN
:
7
,
}
let
untrustedDeviceConfig
=
{
"
ssid
"
:
"
untrusted_ssid
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
}
let
WifiChannelWidth
=
{
WIDTH_20MHZ
:
0
,
WIDTH_40MHZ
:
1
,
WIDTH_80MHZ
:
2
,
WIDTH_160MHZ
:
3
,
WIDTH_80MHZ_PLUS
:
4
,
WIDTH_INVALID
:
null
,
}
export
default
function
actsWifiEventTest
()
{
describe
(
'
actsWifiEventTest
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
afterEach
(
function
()
{
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0001
* @tc.name testwifiStateChange
* @tc.desc Test wifiStateChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0001
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiStateChange
'
,
async
result
=>
{
console
.
info
(
"
wifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
wifi
.
off
(
'
wifiStateChange
'
,
result
=>
{
console
.
info
(
"
offwifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0002
* @tc.name testwifiConnectionChange
* @tc.desc Test wifiConnectionChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0002
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiConnectionChange
'
,
async
result
=>
{
console
.
info
(
"
wifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiConnectionChange test start ...
'
);
wifi
.
off
(
'
wifiConnectionChange
'
,
result
=>
{
console
.
info
(
"
offwifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0003
* @tc.name testwifiScanStateChange
* @tc.desc Test Test wifiScanStateChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0003
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiScanStateChange
'
,
async
result
=>
{
console
.
info
(
"
wifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiScanStateChange test start ...
'
);
wifi
.
off
(
'
wifiScanStateChange
'
,
result
=>
{
console
.
info
(
"
offwifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
scan
=
wifi
.
scan
();
await
sleep
(
3000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0004
* @tc.name testwifiRssiChange
* @tc.desc Test wifiRssiChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0004
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiRssiChange
'
,
async
result
=>
{
console
.
info
(
"
wifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiRssiChange test start ...
'
);
wifi
.
off
(
'
wifiRssiChange
'
,
result
=>
{
console
.
info
(
"
offwifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0005
* @tc.name testhotspotStateChange
* @tc.desc Test hotspotStateChange api.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]hotspotStateChange On test
"
);
try
{
await
wifi
.
on
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange On ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
console
.
info
(
"
[wifi_test]hotspotStateChange Off test
"
);
try
{
await
wifi
.
off
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange Off ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
communication/wifi_standard/src/main/js/test/Wifi
Jsunit.testsame
.js
→
communication/wifi_standard/src/main/js/test/Wifi
StationFunctions.test
.js
浏览文件 @
7caee5bf
...
...
@@ -66,8 +66,8 @@ let WifiChannelWidth = {
WIDTH_INVALID
:
null
,
}
export
default
function
actsWifiTest
()
{
describe
(
'
actsWifiTest
'
,
function
()
{
export
default
function
actsWifi
Functions
Test
()
{
describe
(
'
actsWifi
Functions
Test
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
@@ -77,43 +77,47 @@ export default function actsWifiTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0002
* @tc.name testgetScanInfos
* @tc.desc Test get
ScanInfos callback API functionality.
.
* @tc.desc Test get
to ScanInfos promise and callback API functionality
.
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0002
'
,
0
,
async
function
(
done
)
{
let
scan
=
wifi
.
scan
();
sleep
(
3000
);
console
.
log
(
"
[wifi_test] open wifi scan result:
"
+
scan
);
await
sleep
(
3000
);
await
wifi
.
getScanInfos
()
.
then
(
result
=>
{
let
clen
=
Object
.
keys
(
result
).
length
;
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos promise result
"
+
JSON
.
stringify
(
result
));
});
wifi
.
getScanInfos
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test] wifi getScanInfos failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
if
(
!
(
clen
==
0
))
{
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos callback result:
"
+
JSON
.
stringify
(
result
));
for
(
let
j
=
0
;
j
<
clen
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
+
"
bssid:
"
+
result
[
j
].
bssid
+
"
securityType:
"
+
result
[
j
].
securityType
+
"
rssi:
"
+
result
[
j
].
rssi
+
"
band:
"
+
result
[
j
].
band
+
"
frequency:
"
+
result
[
j
].
frequency
+
"
timestamp
"
+
result
[
j
].
timestamp
+
"
capabilities
"
+
result
[
j
].
capabilities
+
"
channelWidth:
"
+
result
[
j
].
channelWidth
+
"
centerFrequency0:
"
+
result
[
j
].
centerFrequency0
+
"
centerFrequency1:
"
+
result
[
j
].
centerFrequency1
+
"
infoElems:
"
+
result
[
j
].
infoElems
);
}
}
done
()
function
getScanInfos
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getScanInfos
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test] wifi getScanInfos failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
if
(
!
(
clen
==
0
))
{
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos callback result:
"
+
JSON
.
stringify
(
result
));
for
(
let
j
=
0
;
j
<
clen
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
+
"
bssid:
"
+
result
[
j
].
bssid
+
"
securityType:
"
+
result
[
j
].
securityType
+
"
rssi:
"
+
result
[
j
].
rssi
+
"
band:
"
+
result
[
j
].
band
+
"
frequency:
"
+
result
[
j
].
frequency
+
"
channelWidth:
"
+
result
[
j
].
channelWidth
+
"
timestamp
"
+
result
[
j
].
timestamp
+
"
capabilities
"
+
result
[
j
].
capabilities
+
"
centerFrequency0:
"
+
result
[
j
].
centerFrequency0
+
"
centerFrequency1:
"
+
result
[
j
].
centerFrequency1
+
"
infoElems:
"
+
result
[
j
].
infoElems
);
}
}
resolve
();
});
});
}
await
getScanInfos
();
done
();
})
/**
...
...
@@ -297,163 +301,24 @@ export default function actsWifiTest() {
});
})
/**
* @tc.number Conn_Info_0003
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0003
* @since 7
* @tc.desc Test get IpInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
function
()
{
let
isConnected
=
wifi
.
isConnected
();
expect
(
isConnected
).
assertFalse
();
let
ipInfo
=
wifi
.
getIpInfo
();
expect
(
JSON
.
stringify
(
ipInfo
)).
assertContain
(
"
gateway
"
);
let
ipAddress
=
resolveIP
(
ipInfo
.
ipAddress
);
console
.
info
(
"
ipAddress result:
"
+
ipAddress
);
console
.
info
(
"
gateway:
"
+
ipInfo
.
gateway
+
"
ipAddress:
"
+
ipInfo
.
ipAddress
+
"
leaseDuration:
"
+
ipInfo
.
leaseDuration
+
"
leaseDuration:
"
+
ipInfo
.
leaseDuration
+
"
netmask:
"
+
ipInfo
.
netmask
+
"
primaryDns:
"
+
ipInfo
.
primaryDns
+
"
secondDns:
"
+
ipInfo
.
secondDns
+
"
serverIp:
"
+
ipInfo
.
serverIp
);
})
/**
* @tc.number wifiStateChange_0001
* @tc.name SUB_Communication_WiFi_Sta_wifiStateChange_0001
* @since 7
* @tc.desc Test wifiStateChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiStateChange_0001
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiStateChange
'
,
async
result
=>
{
console
.
info
(
"
wifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
wifi
.
off
(
'
wifiStateChange
'
,
result
=>
{
console
.
info
(
"
offwifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number wifiConnectionChange_0002
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
* @since 7
* @tc.desc Test wifiStateChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiConnectionChange
'
,
async
result
=>
{
console
.
info
(
"
wifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiConnectionChange test start ...
'
);
wifi
.
off
(
'
wifiConnectionChange
'
,
result
=>
{
console
.
info
(
"
offwifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number wifiScanStateChange_0003
* @tc.name SUB_Communication_WiFi_Sta_wifiScanStateChange_0003
* @since 7
* @tc.desc Test wifiScanStateChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiScanStateChange_0003
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiScanStateChange
'
,
async
result
=>
{
console
.
info
(
"
wifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiScanStateChange test start ...
'
);
wifi
.
off
(
'
wifiScanStateChange
'
,
result
=>
{
console
.
info
(
"
offwifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
scan
=
wifi
.
scan
();
sleep
(
3000
);
done
();
})
/**
* @tc.number wifiRssiChange_0004
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0004
* @since 7
* @tc.desc Test wifiRssiChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiRssiChange_0004
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiRssiChange
'
,
async
result
=>
{
console
.
info
(
"
wifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiRssiChange test start ...
'
);
wifi
.
off
(
'
wifiRssiChange
'
,
result
=>
{
console
.
info
(
"
offwifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0001
* @tc.name testhotspotStateChangeOn
* @since 7
* @tc.desc Test hotspotStateChangeOn api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Hotspot_ON_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]hotspotStateChange On test
"
);
try
{
await
wifi
.
on
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange On ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_Off_0002
* @tc.name testhotspotStateChangeOff
* @since 7
* @tc.desc Test hotspotStateChange api.
* @tc.size MEDIUM
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0034
* @tc.name testgetScanInfosSync
* @tc.desc Test get to ScanInfos Sync API functionality.
* @tc.type Function
* @tc.level Level
3
* @tc.level Level
0
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Off_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]hotspotStateChange Off test
"
);
try
{
await
wifi
.
off
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange Off ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
it
(
'
SUB_Communication_WiFi_XTS_Sta_0034
'
,
0
,
async
function
(
done
)
{
let
getScanInfos
=
wifi
.
getScanInfosSync
();
console
.
info
(
"
[wifi_test] wifi get to ScanInfosSync result :
"
+
JSON
.
stringify
(
getScanInfos
));
let
lenth
=
Object
.
keys
(
getScanInfos
).
length
;
console
.
info
(
"
[wifi_test] wifi ScanInfosSync length result :
"
+
JSON
.
stringify
(
lenth
));
expect
(
lenth
).
assertLarger
(
0
);
done
();
})
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录