提交 fe243e5c 编写于 作者: Q q00313334 提交者: 权力
上级 489ee545
...@@ -29,7 +29,7 @@ async function tryToEnableWifi(){ ...@@ -29,7 +29,7 @@ async function tryToEnableWifi(){
console.info("wifi_test/wifi status:" + wifi.isWifiActive()); console.info("wifi_test/wifi status:" + wifi.isWifiActive());
} }
var GroupOwnerBand = { let GroupOwnerBand = {
GO_BAND_AUTO : 0, GO_BAND_AUTO : 0,
GO_BAND_2GHZ : 1, GO_BAND_2GHZ : 1,
GO_BAND_5GHZ : 2, GO_BAND_5GHZ : 2,
...@@ -50,7 +50,7 @@ describe('ACTS_WifiTest', function () { ...@@ -50,7 +50,7 @@ describe('ACTS_WifiTest', function () {
it('SUB_Communication_WiFi_P2P_Setting_0001', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Setting_0001', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
console.info("[wifi_test] test setDeviceName start."); console.info("[wifi_test] test setDeviceName start.");
var devName = wifi.setDeviceName("P2PTest"); let devName = wifi.setDeviceName("P2PTest");
console.info("[wifi_test] test start setDeviceName->" + devName); console.info("[wifi_test] test start setDeviceName->" + devName);
expect(devName).assertTrue(); expect(devName).assertTrue();
done(); done();
...@@ -63,7 +63,7 @@ describe('ACTS_WifiTest', function () { ...@@ -63,7 +63,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0001', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0001', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var WifiP2PConfig = { let WifiP2PConfig = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -1, netId : -1,
passphrase : "12345678", passphrase : "12345678",
...@@ -73,12 +73,12 @@ describe('ACTS_WifiTest', function () { ...@@ -73,12 +73,12 @@ describe('ACTS_WifiTest', function () {
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
var addConfig = wifi.createGroup(WifiP2PConfig); let addConfig = wifi.createGroup(WifiP2PConfig);
await sleep(2000); await sleep(2000);
expect(addConfig).assertTrue(); expect(addConfig).assertTrue();
await wifi.getCurrentGroup() await wifi.getCurrentGroup()
.then((data) => { .then((data) => {
var resultLength = Object.keys(data).length; let resultLength = Object.keys(data).length;
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(resultLength!=0); expect(true).assertEqual(resultLength!=0);
}).catch((error) => { }).catch((error) => {
...@@ -96,7 +96,7 @@ describe('ACTS_WifiTest', function () { ...@@ -96,7 +96,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0002', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0002', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var WifiP2PConfig = { let WifiP2PConfig = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -1, netId : -1,
passphrase : "12345678", passphrase : "12345678",
...@@ -106,7 +106,7 @@ describe('ACTS_WifiTest', function () { ...@@ -106,7 +106,7 @@ describe('ACTS_WifiTest', function () {
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
var addConfig = wifi.createGroup(WifiP2PConfig); let addConfig = wifi.createGroup(WifiP2PConfig);
await sleep(2000); await sleep(2000);
expect(addConfig).assertTrue(); expect(addConfig).assertTrue();
...@@ -127,7 +127,7 @@ describe('ACTS_WifiTest', function () { ...@@ -127,7 +127,7 @@ describe('ACTS_WifiTest', function () {
+ "groupName: " + result.groupName + + "groupName: " + result.groupName +
"clientDevices: " + result.clientDevices +"networkId: " + result.networkId "clientDevices: " + result.clientDevices +"networkId: " + result.networkId
+ "frequency: " + result.frequency + "goIpAddress: " + result.goIpAddress); + "frequency: " + result.frequency + "goIpAddress: " + result.goIpAddress);
var removeConfig = wifi.removeGroup(); let removeConfig = wifi.removeGroup();
expect(removeConfig).assertTrue(); expect(removeConfig).assertTrue();
done(); done();
}); });
...@@ -140,7 +140,7 @@ describe('ACTS_WifiTest', function () { ...@@ -140,7 +140,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0003', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0003', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var WifiP2PConfig2 = { let WifiP2PConfig2 = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -1, netId : -1,
passphrase : "12345678", passphrase : "12345678",
...@@ -150,19 +150,19 @@ describe('ACTS_WifiTest', function () { ...@@ -150,19 +150,19 @@ describe('ACTS_WifiTest', function () {
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
var addConfig = wifi.createGroup(WifiP2PConfig2); let addConfig = wifi.createGroup(WifiP2PConfig2);
await sleep(2000); await sleep(2000);
expect(addConfig).assertTrue(); expect(addConfig).assertTrue();
await wifi.getCurrentGroup() await wifi.getCurrentGroup()
.then((data) => { .then((data) => {
var resultLength = Object.keys(data).length; let resultLength = Object.keys(data).length;
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(resultLength!=0); expect(true).assertEqual(resultLength!=0);
}).catch((error) => { }).catch((error) => {
console.info("[wifi_test]getCurrentGroup promise then error." + JSON.stringify(error)); console.info("[wifi_test]getCurrentGroup promise then error." + JSON.stringify(error));
expect(error).assertFail(); expect(error).assertFail();
}); });
var removeConfig = wifi.removeGroup(); let removeConfig = wifi.removeGroup();
expect(removeConfig).assertTrue(); expect(removeConfig).assertTrue();
done(); done();
}) })
...@@ -174,7 +174,7 @@ describe('ACTS_WifiTest', function () { ...@@ -174,7 +174,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0004', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0004', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var WifiP2PConfig = { let WifiP2PConfig = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -2, netId : -2,
passphrase : "12345678", passphrase : "12345678",
...@@ -184,19 +184,19 @@ describe('ACTS_WifiTest', function () { ...@@ -184,19 +184,19 @@ describe('ACTS_WifiTest', function () {
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
var addConfig = wifi.createGroup(WifiP2PConfig); let addConfig = wifi.createGroup(WifiP2PConfig);
await sleep(2000); await sleep(2000);
expect(addConfig).assertTrue(); expect(addConfig).assertTrue();
await wifi.getCurrentGroup() await wifi.getCurrentGroup()
.then((data) => { .then((data) => {
var resultLength = Object.keys(data).length; let resultLength = Object.keys(data).length;
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(resultLength!=0); expect(true).assertEqual(resultLength!=0);
var removePConfig = wifi.deletePersistentGroup(data.networkId); let removePConfig = wifi.deletePersistentGroup(data.networkId);
expect(removePConfig).assertTrue(); expect(removePConfig).assertTrue();
var removeConfig = wifi.removeGroup(); let removeConfig = wifi.removeGroup();
expect(removeConfig).assertTrue(); expect(removeConfig).assertTrue();
}); });
done(); done();
...@@ -209,7 +209,7 @@ describe('ACTS_WifiTest', function () { ...@@ -209,7 +209,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0005', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0005', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var WifiP2PConfig3 = { let WifiP2PConfig3 = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -2, netId : -2,
passphrase : "12345678", passphrase : "12345678",
...@@ -219,14 +219,14 @@ describe('ACTS_WifiTest', function () { ...@@ -219,14 +219,14 @@ describe('ACTS_WifiTest', function () {
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
var scanConfig = wifi.startDiscoverDevices(); let scanConfig = wifi.startDiscoverDevices();
await sleep(2000); await sleep(2000);
expect(scanConfig).assertTrue(); expect(scanConfig).assertTrue();
var connConfig = wifi.p2pConnect(WifiP2PConfig3); let connConfig = wifi.p2pConnect(WifiP2PConfig3);
console.info("[wifi_test] test p2pConnect result." + connConfig); console.info("[wifi_test] test p2pConnect result." + connConfig);
expect(connConfig).assertTrue(); expect(connConfig).assertTrue();
var stopScan = wifi.stopDiscoverDevices(); let stopScan = wifi.stopDiscoverDevices();
console.info("[wifi_test] test stopDiscoverDevices result." + stopScan); console.info("[wifi_test] test stopDiscoverDevices result." + stopScan);
done() done()
}) })
...@@ -238,13 +238,13 @@ describe('ACTS_WifiTest', function () { ...@@ -238,13 +238,13 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0006', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0006', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var P2pConnectState = { let P2pConnectState = {
DISCONNECTED :0, DISCONNECTED :0,
CONNECTED : 1, CONNECTED : 1,
}; };
await wifi.getP2pLinkedInfo() await wifi.getP2pLinkedInfo()
.then((data) => { .then((data) => {
var resultLength = Object.keys(data).length; let resultLength = Object.keys(data).length;
console.info("[wifi_test] getP2pLinkedInfo [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getP2pLinkedInfo [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(resultLength!=0); expect(true).assertEqual(resultLength!=0);
}).catch((error) => { }).catch((error) => {
...@@ -262,7 +262,7 @@ describe('ACTS_WifiTest', function () { ...@@ -262,7 +262,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0007', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0007', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var P2pConnectState = { let P2pConnectState = {
DISCONNECTED :0, DISCONNECTED :0,
CONNECTED : 1, CONNECTED : 1,
}; };
...@@ -288,11 +288,11 @@ describe('ACTS_WifiTest', function () { ...@@ -288,11 +288,11 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0008', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0008', 0, async function(done) {
await tryToEnableWifi(); await tryToEnableWifi();
var disConn = wifi.p2pCancelConnect(); let disConn = wifi.p2pCancelConnect();
await sleep(2000); await sleep(2000);
console.info("[wifi_test] test p2pCancelConnect result." + disConn); console.info("[wifi_test] test p2pCancelConnect result." + disConn);
expect(disConn).assertTrue(); expect(disConn).assertTrue();
var removeConfig = wifi.removeGroup(); let removeConfig = wifi.removeGroup();
console.info("[wifi_test] test start removeGroup" + removeConfig); console.info("[wifi_test] test start removeGroup" + removeConfig);
expect(removeConfig).assertTrue(); expect(removeConfig).assertTrue();
done(); done();
...@@ -305,7 +305,7 @@ describe('ACTS_WifiTest', function () { ...@@ -305,7 +305,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0009', 0, async function(done){ it('SUB_Communication_WiFi_P2P_Config_0009', 0, async function(done){
await tryToEnableWifi(); await tryToEnableWifi();
var P2pDeviceStatus = { let P2pDeviceStatus = {
CONNECTED : 0, CONNECTED : 0,
INVITED : 1, INVITED : 1,
FAILED : 2, FAILED : 2,
...@@ -315,12 +315,12 @@ describe('ACTS_WifiTest', function () { ...@@ -315,12 +315,12 @@ describe('ACTS_WifiTest', function () {
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
var scanConfig = wifi.startDiscoverDevices(); let scanConfig = wifi.startDiscoverDevices();
await sleep(2000); await sleep(2000);
expect(scanConfig).assertTrue(); expect(scanConfig).assertTrue();
await wifi.getP2pPeerDevices() await wifi.getP2pPeerDevices()
.then((data) => { .then((data) => {
var resultLength = Object.keys(data).length; let resultLength = Object.keys(data).length;
console.info("[wifi_test] getP2pPeerDevices [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getP2pPeerDevices [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(resultLength >= 0); expect(true).assertEqual(resultLength >= 0);
}).catch((error) => { }).catch((error) => {
...@@ -338,7 +338,7 @@ describe('ACTS_WifiTest', function () { ...@@ -338,7 +338,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_Config_0010', 0, async function(done){ it('SUB_Communication_WiFi_P2P_Config_0010', 0, async function(done){
await tryToEnableWifi(); await tryToEnableWifi();
var P2pDeviceStatus = { let P2pDeviceStatus = {
CONNECTED : 0, CONNECTED : 0,
INVITED : 1, INVITED : 1,
FAILED : 2, FAILED : 2,
...@@ -348,7 +348,7 @@ describe('ACTS_WifiTest', function () { ...@@ -348,7 +348,7 @@ describe('ACTS_WifiTest', function () {
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
var scanConfig = wifi.startDiscoverDevices(); let scanConfig = wifi.startDiscoverDevices();
await sleep(2000); await sleep(2000);
expect(scanConfig).assertTrue(); expect(scanConfig).assertTrue();
...@@ -358,8 +358,8 @@ describe('ACTS_WifiTest', function () { ...@@ -358,8 +358,8 @@ describe('ACTS_WifiTest', function () {
return; return;
} }
console.info("[wifi_test] getP2pPeerDevices [callback] -> " + JSON.stringify(result)); console.info("[wifi_test] getP2pPeerDevices [callback] -> " + JSON.stringify(result));
var len = Object.keys(result).length; let len = Object.keys(result).length;
for (var j = 0; j < len; ++j) { for (let j = 0; j < len; ++j) {
console.info("deviceName: " + result[j].deviceName + console.info("deviceName: " + result[j].deviceName +
"deviceAddress: " + result[j].deviceAddress + "deviceAddress: " + result[j].deviceAddress +
"primaryDeviceType: " + result[j].primaryDeviceType + "primaryDeviceType: " + result[j].primaryDeviceType +
...@@ -381,7 +381,7 @@ describe('ACTS_WifiTest', function () { ...@@ -381,7 +381,7 @@ describe('ACTS_WifiTest', function () {
console.info("deviceStatus: " + result[j].deviceStatus); console.info("deviceStatus: " + result[j].deviceStatus);
} }
} }
var stopScan = wifi.stopDiscoverDevices(); let stopScan = wifi.stopDiscoverDevices();
expect(stopScan).assertTrue(); expect(stopScan).assertTrue();
done(); done();
}); });
...@@ -460,7 +460,7 @@ describe('ACTS_WifiTest', function () { ...@@ -460,7 +460,7 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_p2pPeerDeviceChange_0004', 0, async function (done) { it('SUB_Communication_WiFi_P2P_p2pPeerDeviceChange_0004', 0, async function (done) {
await tryToEnableWifi(); await tryToEnableWifi();
var recvP2pPeerDeviceChangeFunc = result => { let recvP2pPeerDeviceChangeFunc = result => {
console.info("wifi_test / p2p peer device change receive event: " + JSON.stringify(result)); console.info("wifi_test / p2p peer device change receive event: " + JSON.stringify(result));
wifi.getP2pDevices((err, data) => { wifi.getP2pDevices((err, data) => {
if (err) { if (err) {
...@@ -468,12 +468,12 @@ describe('ACTS_WifiTest', function () { ...@@ -468,12 +468,12 @@ describe('ACTS_WifiTest', function () {
return; return;
} }
console.info("wifi_test / getP2pDevices [callback] -> " + JSON.stringify(data)); console.info("wifi_test / getP2pDevices [callback] -> " + JSON.stringify(data));
var len = Object.keys(data).length; let len = Object.keys(data).length;
console.log("getP2pDevices number: " + len); console.log("getP2pDevices number: " + len);
for (var i = 0; i < len; ++i) { for (let i = 0; i < len; ++i) {
if (data[i].deviceName === "GRE") { if (data[i].deviceName === "GRE") {
console.info("wifi_test / p2pConnect: -> " + data[i].deviceAddress); console.info("wifi_test / p2pConnect: -> " + data[i].deviceAddress);
var config = { let config = {
"deviceAddress":data[i].deviceAddress, "deviceAddress":data[i].deviceAddress,
"netId":-1, "netId":-1,
"passphrase":"", "passphrase":"",
...@@ -506,16 +506,16 @@ describe('ACTS_WifiTest', function () { ...@@ -506,16 +506,16 @@ describe('ACTS_WifiTest', function () {
*/ */
it('SUB_Communication_WiFi_P2P_p2pPersistentGroupChange_0005', 0, async function (done) { it('SUB_Communication_WiFi_P2P_p2pPersistentGroupChange_0005', 0, async function (done) {
await tryToEnableWifi(); await tryToEnableWifi();
var recvP2pPersistentGroupChangeFunc = result => { let recvP2pPersistentGroupChangeFunc = result => {
console.info("wifi_test / p2p persistent group change receive event" + JSON.stringify(result)); console.info("wifi_test / p2p persistent group change receive event" + JSON.stringify(result));
var config = { let config = {
"deviceAddress" : "02:11:65:f2:0d:6e", "deviceAddress" : "02:11:65:f2:0d:6e",
"netId":-2, "netId":-2,
"passphrase":"", "passphrase":"",
"groupName":"", "groupName":"",
"goBand":0, "goBand":0,
}; };
var addConfig = wifi.createGroup(config); let addConfig = wifi.createGroup(config);
expect(addConfig).assertTrue(); expect(addConfig).assertTrue();
wifi.getCurrentGroup((err, data) => { wifi.getCurrentGroup((err, data) => {
if (err) { if (err) {
...@@ -563,3 +563,4 @@ describe('ACTS_WifiTest', function () { ...@@ -563,3 +563,4 @@ describe('ACTS_WifiTest', function () {
console.log("*************[wifi_test] start wifi js unit test end*************"); 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.
先完成此消息的编辑!
想要评论请 注册