diff --git a/communication/wifi_standard/src/main/js/default/test/List.test.js b/communication/wifi_standard/src/main/js/default/test/List.test.js index 90356dd4c6b49f69d36410b1613e87058a26f38c..e6a246718e54f768278aaff2611e41722710a443 100755 --- a/communication/wifi_standard/src/main/js/default/test/List.test.js +++ b/communication/wifi_standard/src/main/js/default/test/List.test.js @@ -14,4 +14,5 @@ */ require('./WifiSta.test.js') require('./WifiSoftAP.test.js') +require('./WifiP2P.test.js') diff --git a/communication/wifi_standard/src/main/js/default/test/WifiP2P.test.js b/communication/wifi_standard/src/main/js/default/test/WifiP2P.test.js new file mode 100644 index 0000000000000000000000000000000000000000..882917971c3ecc8af71d4d585999a1bd190292ed --- /dev/null +++ b/communication/wifi_standard/src/main/js/default/test/WifiP2P.test.js @@ -0,0 +1,584 @@ +/* + * Copyright (C) 2021 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 'deccjsunit/index' + +import wifi from '@ohos.wifi' + +// delay x ms +function sleep(delay) { + var start = (new Date()).getTime(); + while(true){ + if((new Date()).getTime() - start > delay) { + break; + } + } +} + +var GroupOwnerBand = { + GO_BAND_AUTO : 0, + GO_BAND_2GHZ : 1, + GO_BAND_5GHZ : 2, +} + +describe('ACTS_WifiTest', function () { + beforeEach(function () { + }) + + afterEach(function () { + }) + + /** + * @tc.number Setting_0001 + * @tc.name SUB_Communication_WiFi_P2P_Setting_0001 + * @tc.author wudangping wwx1075776 + * @tc.desc Test setDeviceName infos + */ + it('SUB_Communication_WiFi_P2P_Setting_0001', 0, function() { + console.info("[wifi_test] check the state of wifi, if it's close, open it."); + var devName = wifi.setDeviceName("P2PTest"); + console.info("[wifi_test] test start setDeviceName->" + devName); + expect(devName).assertTrue(); + }) + + /** + * @tc.number config_0001 + * @tc.name SUB_Communication_WiFi_P2P_Config_0001 + * @tc.author wudangping wwx1075776 + * @tc.desc Test createGroup and getCurrentGroup infos + */ + it('SUB_Communication_WiFi_P2P_Config_0001', 0, async function(done) { + var WifiP2PConfig = { + deviceAddress : "02:11:65:f2:0d:6e", + netId : -1, + passphrase : "12345678", + groupName : "AAAZZZ", + goBand : 0 + }; + console.info("[wifi_test] check the state of wifi, if it's close, open it."); + var active = wifi.isWifiActive(); + if(!active){ + var enable = wifi.enableWifi(); + sleep(5000); + console.log("[wifi_test] wifi open result: " + enable); + expect(enable).assertTrue(); + } + console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); + expect(wifi.isWifiActive()).assertTrue(); + console.info("[wifi_test] test start createGroup ."); + var addConfig = wifi.createGroup(WifiP2PConfig); + sleep(3000); + console.info("[wifi_test] test start createGroup result." + addConfig); + expect(addConfig).assertTrue(); + await wifi.getCurrentGroup() + .then((data) => { + console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); + expect(true).assertEqual(data.length!=0); + }).catch((error) => { + console.info("[wifi_js]getCurrentGroup promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + wifi.getCurrentGroup( + (err, result) => { + if (err) { + console.error('wifi_test / failed to get getCurrentGroup: ' + JSON.stringify(err)); + return; + } + console.info("[wifi_test] getCurrentGroup [callback] -> " + JSON.stringify(result)); + console.info("isP2pGo: " + result.isP2pGo); + console.info("deviceName: " + result.ownerInfo.deviceName); + console.info("deviceAddress: " + result.ownerInfo.deviceAddress); + console.info("primaryDeviceType: " + result.ownerInfo.primaryDeviceType); + console.info("deviceStatus: " + result.ownerInfo.deviceStatus); + console.info("groupCapabilitys: " + result.ownerInfo.groupCapabilitys); + console.info("passphrase: " + result.passphrase); + console.info("interface: " + result.interface); + console.info("groupName: " + result.groupName); + console.info("clientDevices: " + result.clientDevices); + console.info("networkId: " + result.networkId); + console.info("frequency: " + result.frequency); + console.info("goIpAddress: " + result.goIpAddress); + console.info("[wifi_test] test start removeGroup"); + var removeConfig = wifi.removeGroup(); + console.info("[wifi_test] test start removeGroup" + removeConfig); + expect(removeConfig).assertTrue(); + done(); + }); + }) + + /** + * @tc.number config_0002 + * @tc.name SUB_Communication_WiFi_P2P_Config_0002 + * @tc.author wudangping wwx1075776 + * @tc.desc Test createGroup 2.4G band and getCurrentGroup infos + */ + it('SUB_Communication_WiFi_P2P_Config_0002', 0, async function(done) { + var WifiP2PConfig2 = { + deviceAddress : "02:11:65:f2:0d:6e", + netId : -1, + passphrase : "12345678", + groupName : "AAAZZZ", + goBand : 1 + }; + console.info("[wifi_test] check the state of wifi, if it's close, open it."); + var active = wifi.isWifiActive(); + if(!active){ + var enable = wifi.enableWifi(); + sleep(5000); + console.log("[wifi_test] wifi open result: " + enable); + expect(enable).assertTrue(); + } + console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); + expect(wifi.isWifiActive()).assertTrue(); + console.info("[wifi_test] test start create 2.4G band Group ."); + var addConfig = wifi.createGroup(WifiP2PConfig2); + sleep(3000); + console.info("[wifi_test] test start createGroup result." + addConfig); + expect(addConfig).assertTrue(); + await wifi.getCurrentGroup() + .then((data) => { + console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); + expect(true).assertEqual(data.length!=0); + }).catch((error) => { + console.info("[wifi_js]getCurrentGroup promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + console.info("[wifi_test] test start removeGroup"); + var removeConfig = wifi.removeGroup(); + console.info("[wifi_test] test start removeGroup" + removeConfig); + expect(removeConfig).assertTrue(); + done(); + }) + + /** + * @tc.number config_0003 + * @tc.name SUB_Communication_WiFi_P2P_Config_0003 + * @tc.author wudangping wwx1075776 + * @tc.desc Test createGroup and deletePersistentGroup infos + */ + it('SUB_Communication_WiFi_P2P_Config_0003', 0, async function(done) { + console.info("[wifi_test] check the state of wifi, if it's close, open it."); + var WifiP2PConfig = { + deviceAddress : "02:11:65:f2:0d:6e", + netId : -2, + passphrase : "12345678", + groupName : "AAAZZZ", + goBand : 0 + }; + var active = wifi.isWifiActive(); + if(!active){ + var enable = wifi.enableWifi(); + sleep(5000); + console.log("[wifi_test] wifi open result: " + enable); + expect(enable).assertTrue(); + } + console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); + expect(wifi.isWifiActive()).assertTrue(); + console.info("[wifi_test] test start createGroup [promise]."); + var addConfig = wifi.createGroup(WifiP2PConfig); + sleep(3000); + console.info("[wifi_test] test start createGroup [promise]." + addConfig); + expect(addConfig).assertTrue(); + await wifi.getCurrentGroup() + .then((data) => { + console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); + expect(true).assertEqual(data.length!=0); + console.info("[wifi_test] test start deletePersistentGroup"); + var removePConfig = wifi.deletePersistentGroup(data.networkId); + console.info("[wifi_test] test start deletePersistentGroup" + removePConfig); + expect(removePConfig).assertTrue(); + console.info("[wifi_test] test start removeGroup"); + var removeConfig = wifi.removeGroup(); + console.info("[wifi_test] test start removeGroup" + removeConfig); + expect(removeConfig).assertTrue(); + }); + done(); + }) + + /** + * @tc.number config_0004 + * @tc.name SUB_Communication_WiFi_P2P_Config_0004 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pConnect infos + */ + it('SUB_Communication_WiFi_P2P_Config_0004', 0, function() { + var WifiP2PConfig3 = { + deviceAddress : "02:11:65:f2:0d:6e", + netId : -2, + passphrase : "12345678", + groupName : "AAAZZZ", + goBand : 0 + }; + console.info("[wifi_test] check the state of wifi, if it's close, open it."); + var active = wifi.isWifiActive(); + if(!active){ + var enable = wifi.enableWifi(); + sleep(5000); + console.log("[wifi_test] wifi open result: " + enable); + expect(enable).assertTrue(); + } + console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); + expect(wifi.isWifiActive()).assertTrue(); + console.info("[wifi_test] test start startDiscoverDevices."); + var scanConfig = wifi.startDiscoverDevices(); + sleep(3000); + console.info("[wifi_test] test startDiscoverDevices result." + scanConfig); + expect(scanConfig).assertTrue(); + console.info("[wifi_test] test start p2pConnect."); + var connConfig = wifi.p2pConnect(WifiP2PConfig3); + sleep(5000); + console.info("[wifi_test] test p2pConnect result." + connConfig); + expect(connConfig).assertTrue(); + console.info("[wifi_test] test start stopDiscoverDevices."); + var stopScan = wifi.stopDiscoverDevices(); + }) + + /** + * @tc.number config_0005 + * @tc.name SUB_Communication_WiFi_P2P_Config_0005 + * @tc.author wudangping wwx1075776 + * @tc.desc Test getP2pLinkedInfo infos + */ + it('SUB_Communication_WiFi_P2P_Config_0005', 0, async function(done) { + var P2pConnectState = { + DISCONNECTED :0, + CONNECTED : 1, + }; + await wifi.getP2pLinkedInfo() + .then((data) => { + console.info("[wifi_test] getP2pLinkedInfo [promise] result -> " + JSON.stringify(data)); + expect(true).assertEqual(data.length!=0); + }).catch((error) => { + console.info("[wifi_test]getP2pLinkedInfo promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + wifi.getP2pLinkedInfo((err, result) => { + if (err) { + console.error('failed to getP2pLinkedInfo callback ' + JSON.stringify(err)); + return; + } + console.info("[wifi_test] getP2pLinkedInfo [callback] -> " + JSON.stringify(result)); + console.info("connectState: " + result.connectState); + console.info("isGroupOwner: " + result.isGroupOwner); + console.info("groupOwnerAddr: " + result.groupOwnerAddr); + + expect(false).assertEqual(result.connectState ==P2pConnectState.CONNECTED); + expect(false).assertEqual(result.connectState ==P2pConnectState.DISCONNECTED); + done(); + }); + + }) + + /** + * @tc.number config_0006 + * @tc.name SUB_Communication_WiFi_P2P_Config_0006 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pCancelConnect infos + */ + it('SUB_Communication_WiFi_P2P_Config_0006', 0, function() { + console.info("[wifi_test] test start p2pCancelConnect."); + var disConn = wifi.p2pCancelConnect(); + sleep(5000); + console.info("[wifi_test] test p2pCancelConnect result." + disConn); + expect(disConn).assertTrue(); + console.info("[wifi_test] test start removeGroup"); + var removeConfig = wifi.removeGroup(); + console.info("[wifi_test] test start removeGroup" + removeConfig); + expect(removeConfig).assertTrue(); + }) + + /** + * @tc.number config_0007 + * @tc.name SUB_Communication_WiFi_P2P_Config_0007 + * @tc.author wudangping wwx1075776 + * @tc.desc Test getP2pDevices infos + */ + it('SUB_Communication_WiFi_P2P_Config_0007', 0, async function(done) { + var P2pDeviceStatus = { + CONNECTED : 0, + INVITED : 1, + FAILED : 2, + AVAILABLE : 3, + UNAVAILABLE : 4, + }; + console.info("[wifi_test] check the state of wifi, if it's close, open it."); + var active = wifi.isWifiActive(); + if(!active){ + var enable = wifi.enableWifi(); + sleep(5000); + console.log("[wifi_test] wifi open result: " + enable); + expect(enable).assertTrue(); + } + console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); + expect(wifi.isWifiActive()).assertTrue(); + console.info("[wifi_test] test start startDiscoverDevices."); + var scanConfig = wifi.startDiscoverDevices(); + sleep(10000); + console.info("[wifi_test] test startDiscoverDevices result." + scanConfig); + expect(scanConfig).assertTrue(); + await wifi.getP2pDevices() + .then((data) => { + console.info("[wifi_test] getP2pDevices [promise] result -> " + JSON.stringify(data)); + expect(true).assertEqual(data.length!=0); + }).catch((error) => { + console.info("[wifi_test]getP2pDevices promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + wifi.getP2pDevices((err, result) => { + if (err) { + console.error('failed to getP2pDevices infos callback because ' + JSON.stringify(err)); + return; + } + console.info("[wifi_test] getP2pDevices [callback] -> " + JSON.stringify(result)); + var len = Object.keys(result).length; + for (var j = 0; j < len; ++j) { + console.info("deviceName: " + result[j].deviceName); + console.info("deviceAddress: " + result[j].deviceAddress); + console.info("primaryDeviceType: " + result[j].primaryDeviceType); + console.info("deviceStatus: " + result[j].deviceStatus); + console.info("groupCapabilitys: " + result[j].groupCapabilitys); + if(result[j].deviceStatus ==P2pDeviceStatus.UNAVAILABLE){ + console.info("deviceStatus: " + result[j].deviceStatus); + } + if(result[j].deviceStatus ==P2pDeviceStatus.CONNECTED){ + console.info("deviceStatus: " + result[j].deviceStatus); + } + if(result[j].deviceStatus ==P2pDeviceStatus.INVITED){ + console.info("deviceStatus: " + result[j].deviceStatus); + } + if(result[j].deviceStatus ==P2pDeviceStatus.FAILED){ + console.info("deviceStatus: " + result[j].deviceStatus); + } + if(result[j].deviceStatus ==P2pDeviceStatus.AVAILABLE){ + console.info("deviceStatus: " + result[j].deviceStatus); + } + } + console.info("[wifi_test] test stopDiscoverDevices."); + var stopScan = wifi.stopDiscoverDevices(); + sleep(3000); + console.info("[wifi_test] test stopDiscoverDevices result." + stopScan); + expect(stopScan).assertTrue(); + done(); + }); + + }) + + /** + * @tc.number p2pStateChange_0001 + * @tc.name SUB_Communication_WiFi_P2P_P2pStateChange_0001 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pStateChange callback + */ + it('SUB_Communication_WiFi_P2P_P2pStateChange_0001', 0, async function (done) { + console.info('[wifi_test] OnP2pStateChange test start ...'); + await wifi.on('p2pStateChange', result => { + console.info("onP2pStateChange callback, result:" + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + done(); + }); + setTimeout(function() { + console.info('[wifi_test] offP2pStateChange test start ...'); + wifi.off('p2pStateChange', result => { + console.info("offP2pStateChange callback, result: " + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + }); + }, 10 * 1000); + done(); + }) + + /** + * @tc.number p2pConnectionChange_0002 + * @tc.name SUB_Communication_WiFi_P2P_p2pConnectionChange_0002 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pConnectionChange callback + */ + it('SUB_Communication_WiFi_P2P_p2pConnectionChange_0002', 0, async function (done) { + console.info('[wifi_test] p2pConnectionChange test start ...'); + var recvP2pConnectionChangeFunc = result => { + console.info("wifi_test / p2p connection change receive event: " + JSON.stringify(result)); + + wifi.getP2pLinkedInfo((err, data) => { + if (err) { + console.error('wifi_test / failed to get getP2pLinkedInfo: ' + JSON.stringify(err)); + return; + } + console.info("wifi_test / get getP2pLinkedInfo [callback] -> " + JSON.stringify(data)); + }); + 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)); + }); + }; + 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); + }); + }, 10 * 1000); + done(); + }) + + /** + * @tc.number p2pDeviceChange_0003 + * @tc.name SUB_Communication_WiFi_P2P_p2pDeviceChange_0003 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pDeviceChange callback + */ + it('SUB_Communication_WiFi_P2P_p2pDeviceChange_0003', 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); + }); + }, 10 * 1000); + done(); + }) + + /** + * @tc.number p2pPeerDeviceChange_0004 + * @tc.name SUB_Communication_WiFi_P2P_p2pPeerDeviceChange_0004 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pPeerDeviceChange callback + */ + it('SUB_Communication_WiFi_P2P_p2pPeerDeviceChange_0004', 0, async function (done) { + console.info('[wifi_test] Onp2pDeviceChange test start ...'); + var 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 getCurrentGroup: ' + JSON.stringify(err)); + return; + } + console.info("wifi_test / getP2pDevices [callback] -> " + JSON.stringify(data)); + var len = Object.keys(data).length; + console.log("getP2pDevices number: " + len); + for (var i = 0; i < len; ++i) { + if (data[i].deviceName === "GRE") { + console.info("wifi_test / p2pConnect: -> " + data[i].deviceAddress); + var 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() { + console.info('[wifi_test] offP2pPeerDeviceChange test start ...'); + wifi.off('p2pPeerDeviceChange', result => { + console.info("offP2pPeerDeviceChange callback, result: " + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + }); + }, 10 * 1000); + done(); + }) + + /** + * @tc.number p2pPersistentGroupChange_0005 + * @tc.name SUB_Communication_WiFi_P2P_p2pPersistentGroupChange_0005 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pPersistentGroupChange callback + */ + it('SUB_Communication_WiFi_P2P_p2pPersistentGroupChange_0005', 0, async function (done) { + console.info('[wifi_test] OnP2pPersistentGroupChange test start ...'); + var recvP2pPersistentGroupChangeFunc = result => { + console.info("wifi_test / p2p persistent group change receive event" + JSON.stringify(result)); + var config = { + "deviceAddress" : "02:11:65:f2:0d:6e", + "netId":-2, + "passphrase":"", + "groupName":"", + "goBand":0, + }; + console.info("[wifi_test] test start createGroup ."); + var addConfig = wifi.createGroup(config); + console.info("[wifi_test] test start createGroup result." + addConfig); + 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)); + }); + }; + await wifi.on('p2pPersistentGroupChange', result => { + console.info("p2pPersistentGroupChange callback, result:" + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + done(); + }); + setTimeout(function() { + console.info('[wifi_test] offP2pPersistentGroupChange test start ...'); + wifi.off('p2pPersistentGroupChange', result => { + console.info("offP2pPersistentGroupChange callback, result: " + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + }); + }, 10 * 1000); + done(); + }) + + /** + * @tc.number p2pDiscoveryChange_0006 + * @tc.name SUB_Communication_WiFi_P2P_p2pDiscoveryChange_0006 + * @tc.author wudangping wwx1075776 + * @tc.desc Test p2pDiscoveryChange callback + */ + it('SUB_Communication_WiFi_P2P_p2pDiscoveryChange_0006', 0, async function (done) { + console.info('[wifi_test] Onp2pDiscoveryChange test start ...'); + await wifi.on('p2pDiscoveryChange', result => { + console.info("onp2pDiscoveryChange callback, result:" + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + done(); + }); + setTimeout(function() { + console.info('[wifi_test] offp2pDiscoveryChange test start ...'); + wifi.off('p2pDiscoveryChange', result => { + console.info("offp2pDiscoveryChange callback, result: " + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + }); + }, 10 * 1000); + done(); + }) + + console.log("*************[wifi_test] start wifi js unit test end*************"); +}) + + + diff --git a/communication/wifi_standard/src/main/js/default/test/WifiSoftAP.test.js b/communication/wifi_standard/src/main/js/default/test/WifiSoftAP.test.js index 47159f32f8cba396f4f9d17b3a58b35830254e5d..786c646367a13dbfce542e45355e2432ff8500fb 100755 --- a/communication/wifi_standard/src/main/js/default/test/WifiSoftAP.test.js +++ b/communication/wifi_standard/src/main/js/default/test/WifiSoftAP.test.js @@ -55,6 +55,7 @@ describe('ACTS_WifiTest', function() { * @tc.number OPEN_0002 * @tc.name SUB_Communication_WiFi_Hotspot_Open_0002 * @tc.desc Test wifi.enableHotspot and wifi.disableHotspot API functionality1. + * @tc.author wudangping wwx1075776 * @tc.level Level 0 */ it('SUB_Communication_WiFi_Hotspot_Open_0002', 0, function () { @@ -91,6 +92,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number OPEN_0003 * @tc.name SUB_Communication_WiFi_Hotspot_Open_0003 + * @tc.author wudangping wwx1075776 * @tc.desc Test open Hotspot after open wifi * @tc.level Level 1 */ @@ -115,6 +117,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0001 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0001 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a valid 2.4G hotspot config * @tc.level Level 0 */ @@ -153,6 +156,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0002 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0002 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a valid 5G hotspot config * @tc.level Level 1 */ @@ -196,6 +200,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0003 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0003 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a invalid hotspot config * @tc.level Level 2 */ @@ -220,10 +225,10 @@ describe('ACTS_WifiTest', function() { }) - /** * @tc.number CONFIG_0004 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0004 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a max preSharedKey is hotspot config * @tc.level Level 2 */ @@ -274,6 +279,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0005 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0005 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a min preSharedKey is hotspot config * @tc.level Level 2 */ @@ -322,6 +328,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0006 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0006 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a max ssid for hotspot config * @tc.level Level 2 */ @@ -373,6 +380,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0007 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0007 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a null ssid invalid hotspot config * @tc.level Level 2 */ @@ -398,6 +406,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0008 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0008 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a contains Chinese.special.digits valid hotspot config * @tc.level Level 2 */ @@ -429,6 +438,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0009 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0009 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a invalid preSharedKey hotspot config * @tc.level Level 2 */ @@ -479,6 +489,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0010 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0010 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a valid PSK preSharedKey hotspot config * @tc.level Level 2 */ @@ -521,6 +532,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0011 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0011 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a valid OPEN preSharedKey hotspot config * @tc.level Level 2 */ @@ -560,6 +572,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONFIG_0012 * @tc.name SUB_Communication_WiFi_Hotspot_Config_0012 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a valid hotspot config after open Hotspot * @tc.level Level 2 */ @@ -607,6 +620,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONN_0001 * @tc.name SUB_Communication_WiFi_Hotspot_Conn_0001 + * @tc.author wudangping wwx1075776 * @tc.desc Test set a maxConn and more maxConn hotspot config * @tc.level Level 2 */ @@ -657,6 +671,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number CONN_0002 * @tc.name SUB_Communication_WiFi_Hotspot_Conn_0002 + * @tc.author wudangping wwx1075776 * @tc.desc Test Obtains the list of clients that are connected to a Wi-Fi hotspot. * @tc.level Level 2 */ @@ -686,6 +701,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number SUB_Communication_WiFi_Hotspot_ON_0001 * @tc.name testhotspotStateChangeOn + * @tc.author wudangping wwx1075776 * @tc.desc Test hotspotStateChangeOn api. * @tc.size MEDIUM * @tc.type Function @@ -709,6 +725,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Hotspot_Off_0002 * @tc.name testhotspotStateChangeOff * @tc.desc Test hotspotStateChange api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -731,6 +748,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Hotspot_ON_0003 * @tc.name testhotspotStaJoinOn * @tc.desc Test hotspotStaJoinOn api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -753,6 +771,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Hotspot_Off_0004 * @tc.name testhotspotStaJoinOff * @tc.desc Test hotspotStaJoin api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -775,6 +794,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Hotspot_ON_0005 * @tc.name testhotspotStaLeaveOn * @tc.desc Test hotspotStaLeaveOn api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -797,6 +817,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Hotspot_Off_0006 * @tc.name testhotspotStaLeaveOff * @tc.desc Test hotspotStaLeave api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 diff --git a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js index 4339d87443c4146b944369a80def98447b1134bd..41661e8f3d7c9b32dce12bc3366435609b6ea0cf 100755 --- a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js +++ b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js @@ -27,6 +27,7 @@ function sleep(delay) { } } + var WifiSecurityType = { WIFI_SEC_TYPE_INVALID: 0, WIFI_SEC_TYPE_OPEN: 1, @@ -84,6 +85,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number open_0001 * @tc.name SUB_Communication_WiFi_Sta_Open_0001 + * @tc.author wudangping wwx1075776 * @tc.desc Test wifi.isWifiEnable API functionality. */ it('SUB_Communication_WiFi_Sta_Open_0001', 0, function() { @@ -92,7 +94,7 @@ describe('ACTS_WifiTest', function() { var active = wifi.isWifiActive(); if (!active) { var enable = wifi.enableWifi(); - sleep(3000); + sleep(5000); console.log("[wifi_test] wifi open result: " + enable); expect(enable).assertTrue(); } @@ -108,6 +110,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Scan_0001 * @tc.name SUB_Communication_WiFi_Sta_Scan_0001 + * @tc.author wudangping wwx1075776 * @tc.desc Test get ScanInfos callback API functionality. */ it('SUB_Communication_WiFi_Sta_Scan_0001', 0, async function(done) { @@ -163,6 +166,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Scan_0004 * @tc.name SUB_Communication_WiFi_Sta_Scan_0004 + * @tc.author wudangping wwx1075776 * @tc.desc Test wifi.getSignalLevel API functionality. */ it('SUB_Communication_WiFi_Sta_Scan_0004', 0, function() { @@ -201,6 +205,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Config_0001 * @tc.name SUB_Communication_WiFi_Sta_Config_0001 + * @tc.author wudangping wwx1075776 * @tc.desc Test create a OPEN SecurityType wifi device config */ it('SUB_Communication_WiFi_Sta_Config_0001', 0, async function(done) { @@ -255,6 +260,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Config_0002 * @tc.name SUB_Communication_WiFi_Sta_Config_0002 + * @tc.author wudangping wwx1075776 * @tc.desc Test create a PSK SecurityType wifi device config */ it('SUB_Communication_WiFi_Sta_Config_0002', 0, async function(done) { @@ -294,6 +300,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Config_0005 * @tc.name SUB_Communication_WiFi_Sta_Config_0005 + * @tc.author wudangping wwx1075776 * @tc.desc Test remove all wifi device config */ it('SUB_Communication_WiFi_Sta_Config_0005', 0, async function(done) { @@ -359,6 +366,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Config_0007 * @tc.name SUB_Communication_WiFi_Sta_Config_0007 + * @tc.author wudangping wwx1075776 * @tc.desc Test update wifi device config */ it('SUB_Communication_WiFi_Sta_Config_0007', 0, async function(done) { @@ -411,6 +419,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_info_0001 * @tc.name testgetMacAddress * @tc.desc Test getMacAddress api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -432,6 +441,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_info_0002 * @tc.name testgetCountryCode * @tc.desc Test getCountryCode api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -453,6 +463,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_info_0004 * @tc.name testFeatureSupported * @tc.desc Test FeatureSupported api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -469,6 +480,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Conn_Info_0001 * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001 + * @tc.author wudangping wwx1075776 * @tc.desc Test reconnect wifi */ it('SUB_Communication_WiFi_Sta_Conn_Info_0001', 0, function () { @@ -514,6 +526,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number conn_Config_0002 * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002 + * @tc.author wudangping wwx1075776 * @tc.desc Test getLinkedInfo information */ it('SUB_Communication_WiFi_Sta_Conn_Info_0001', 0, async function(done) { @@ -559,6 +572,7 @@ describe('ACTS_WifiTest', function() { /** * @tc.number Conn_Info_0003 * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0003 + * @tc.author wudangping wwx1075776 * @tc.desc Test get IpInfo information */ it('SUB_Communication_WiFi_Sta_Conn_Info_0002', 0, function () { @@ -600,6 +614,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_ON_0001 * @tc.name testwifiStateChangeOn * @tc.desc Test wifiStateChangeOn api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -622,6 +637,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_Off_0002 * @tc.name testwifiStateChangeOff * @tc.desc Test wifiStateChangeOff api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -644,6 +660,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_ON_0003 * @tc.name testwifiConnectionChnageOn * @tc.desc Test wifiConnectionChnageOn api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -666,6 +683,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_Off_0004 * @tc.name testwifiConnectionChangeOff * @tc.desc Test wifiConnectionChangeOff api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -688,6 +706,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_ON_0005 * @tc.name testwifiScanStateChangeOn * @tc.desc Test wifiwifiScanStateChangeOn api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -710,6 +729,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_Off_0006 * @tc.name testwifiScanStateChangeOff * @tc.desc Test wifiScanStateChangeOff api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -732,6 +752,7 @@ describe('ACTS_WifiTest', function() { * @tc.number SUB_Communication_WiFi_Sta_ON_0007 * @tc.name testwifiRssiChangeOn * @tc.desc Test wifiRssiChangeOn api. + * @tc.author wudangping wwx1075776 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 @@ -753,7 +774,8 @@ describe('ACTS_WifiTest', function() { /** * @tc.number SUB_Communication_WiFi_Sta_Off_0008 * @tc.name testwifiRssiChangeOff - * @tc.desc Test wifiRssiChange api. + * @tc.desc Test wifiRssiChange api + * @tc.author wudangping wwx1075776. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 3 diff --git a/location/geolocation_standard/src/main/js/default/test/Geolocation.test.js b/location/geolocation_standard/src/main/js/default/test/Geolocation.test.js index 439811ae485adb4a77c71360636365004ba102f2..c37f41b4bad8feaf7b2a5efb8ac5ca8593c7f930 100644 --- a/location/geolocation_standard/src/main/js/default/test/Geolocation.test.js +++ b/location/geolocation_standard/src/main/js/default/test/Geolocation.test.js @@ -17,6 +17,12 @@ import geolocation from '@ohos.geolocation'; import { LocationEventListener } from '@ohos.geolocation'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 , + TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, + DAILY_LIFE_SERIVICE : 0x304 ,NO_POWER : 0x305} +var LocationRequestPriority = {UNSET : 0x200 ,ACCURACY : 0x201 ,LOW_POWER : 0x202 ,FIRST_FIX :0x203} + + describe('geolocationTest', function () { beforeAll(function () { console.info('beforeAll called') @@ -33,7 +39,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_PROMISE_0001 + * @tc.number geolocation_enableLocation_promise_test_001 * @tc.name testenableLocation promise * @tc.desc Test enableLocation api . * @tc.author wangsilu wwx1075324 @@ -52,11 +58,11 @@ describe('geolocationTest', function () { console.info("[lbs_js] promise then error." + error.message); expect().assertFail(); }) - done() + done() }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_PROMISE_0001 + * @tc.number geolocation_isLocationEnabled_promise_test_001 * @tc.name testisLocationEnabled promise * @tc.desc Test isLocationEnabled api . * @tc.author wangsilu wwx1075324 @@ -88,7 +94,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001 + * @tc.number geolocation_getAddressesFromLocationName_callback_test_001 * @tc.name testgetAddressesFromLocationName callback * @tc.desc Test getAddressesFromLocationName api . * @tc.author wangsilu wwx1075324 @@ -97,7 +103,7 @@ describe('geolocationTest', function () { * @tc.level Level 2 */ it('geolocation_getAddressesFromLocationName_callback_test_001', 0, async function (done) { - console.info('LBS enableLocation promise test start ...'); + console.info('LBS enableLocation promise test start ...'); await geolocation.enableLocation().then((result) => { console.info('[lbs_js] testenableLocation result: ' + result); expect(result).assertTrue(); @@ -109,7 +115,8 @@ describe('geolocationTest', function () { console.info('LBS getAddressesFromLocationName callback test start ...'); var geocodeRequest = {"description": "上海市浦东新区金穗路1800号", - "maxItems": 1,"locale":"zh"}; + "maxItems": 1,"locale":"zh",minLatitude:"",minLongitude:"", + maxLatitude:"",maxLongitude:""}; geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { if (err) { @@ -150,7 +157,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_CALLBACK_0001 + * @tc.number geolocation_getAddressesFromLocation_callback_test_001 * @tc.name testgetAddressesFromLocation callback * @tc.desc Test getAddressesFromLocation api . * @tc.author wangsilu wwx1075324 @@ -205,7 +212,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001 + * @tc.number geolocation_isGeoServiceAvailable_promise_test_001 * @tc.name testisGeoServiceAvailable promise * @tc.desc Test isGeoServiceAvailable api . * @tc.author wangsilu wwx1075324 @@ -237,7 +244,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_CALLBACK_0001 + * @tc.number geolocation_isLocationEnabled_callback_test_001 * @tc.name testisLocationEnabled callback * @tc.desc Test isLocationEnabled api . * @tc.author wangsilu wwx1075324 @@ -280,7 +287,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_PROMISE_0001 + * @tc.number geolocation_getAddressesFromLocationName_promise_test_001 * @tc.name testgetAddressesFromLocationName promise * @tc.desc Test getAddressesFromLocationName api . * @tc.author wangsilu wwx1075324 @@ -314,7 +321,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_CALLBACK_0001 + * @tc.number geolocation_requestEnableLocation_callback_test_001 * @tc.name testrequestEnableLocation callback * @tc.desc Test requestEnableLocation api . * @tc.author wangsilu wwx1075324 @@ -338,7 +345,7 @@ describe('geolocationTest', function () { /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_PROMISE_0001 + * @tc.number geolocation_requestEnableLocation_promise_test_001 * @tc.name testrequestEnableLocation promise * @tc.desc Test requestEnableLocation api . * @tc.author wangsilu wwx1075324 @@ -360,7 +367,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_CALLBACK_0001 + * @tc.number geolocation_enableLocation_callback_test_001 * @tc.name testEnableLocation callback * @tc.desc Test enableLocation api . * @tc.author wangsilu wwx1075324 @@ -383,7 +390,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_CALLBACK_0001 + * @tc.number geolocation_disableLocation_callback_test_001 * @tc.name testdisableLocation callback * @tc.desc Test disableLocation api . * @tc.author wangsilu wwx1075324 @@ -405,7 +412,7 @@ describe('geolocationTest', function () { }); }) - /** @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_PROMISE_0001 + /** @tc.number geolocation_disableLocation_promise_test_001 * @tc.name testdisableLocation promise * @tc.desc Test disableLocation api . * @tc.author wangsilu wwx1075324 @@ -424,7 +431,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_PROMISE_0001 + * @tc.number geolocation_getAddressesFromLocation_promise_test_001 * @tc.name testgetAddressesFromLocation promise * @tc.desc Test getAddressesFromLocation api . * @tc.author wangsilu wwx1075324 @@ -448,7 +455,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001 + * @tc.number geolocation_GetCurrentlocation_callback_test_001 * @tc.name testGetCurrentlocation callback * @tc.desc Test GetCurrentlocation api . * @tc.author wangsilu wwx1075324 @@ -468,7 +475,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_CALLBACK_0001 + * @tc.number geolocation_isGeoServiceAvailable_callback_test_001 * @tc.name testisGeoServiceAvailable callback * @tc.desc Test isGeoServiceAvailable api . * @tc.author wangsilu wwx1075324 @@ -509,7 +516,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002 + * @tc.number geolocation_locationChange_On_test_002 * @tc.name testlocationChangeOn promise * @tc.desc Test locationChangeOn api . * @tc.author wangsilu wwx1075324 @@ -525,8 +532,18 @@ describe('geolocationTest', function () { await locationEventListener.on('locationChange',requestInfo, result => { console.info("onLocationChange callback, result: " + JSON.stringify(result)); expect(true).assertEqual(result !=null); + console.info("[lbs_js] onLocationChange latitude: " + result.latitude); + console.info("[lbs_js] onLocationChange longitude: " + result.longitude); + console.info("[lbs_js] onLocationChange altitude: " + result.altitude); + console.info("[lbs_js] onLocationChange accuracy: " + result.accuracy); + console.info("[lbs_js] onLocationChange speed: " + result.speed); + console.info("[lbs_js] onLocationChange timeStamp: " + result.timeStamp); + console.info("[lbs_js] onLocationChange direction: " + result.direction); + console.info("[lbs_js] onLocationChange additions: " + result.additions); + console.info("[lbs_js] onLocationChange additionSize: " + result.additionSize); done(); }); + console.info('LBS enableLocation callback test start ...'); geolocation.enableLocation((err, data) => { if (err) { @@ -542,7 +559,7 @@ describe('geolocationTest', function () { }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001 + * @tc.number geolocation_OnLocationServiceState_test_001 * @tc.name testOnLocationServiceState * @tc.desc Test OnLocationServiceState api . * @tc.author wangsilu wwx1075324 @@ -569,11 +586,11 @@ describe('geolocationTest', function () { } done() }); - }) + }) /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001 - * @tc.name testOnLocationServiceState + * @tc.number geolocation_offLocationServiceState_test_001 + * @tc.name testoffLocationServiceState * @tc.desc Test offLocationServiceState api . * @tc.author wangsilu wwx1075324 * @tc.size MEDIUM @@ -614,14 +631,37 @@ describe('geolocationTest', function () { console.info('LBS offLocationServiceState test start ...'); locationEventListener.off('locationServiceState', result => { - console.info("offlocationServiceState callback, result: " + JSON.stringify(result)); - expect(true).assertEqual(result !=null); - done(); + console.info("offlocationServiceState callback, result: " + JSON.stringify(result)); + expect(true).assertEqual(result !=null); + done(); }); }) + /** + * @tc.number geolocation_getLastLocation_callback__test_001 + * @tc.name testgetLastLocation callback + * @tc.desc Test getLastLocation api . + * @tc.author wangsilu wwx1075324 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('geolocation_getLastLocation_callback__test_001', 0, async function (done) { + console.info('LBS getLastLocation test start ...'); + geolocation.getLastLocation((err, data) => { + if (err) { + console.info('[lbs_js] getLastLocation callback err is : ' + err ); + }else { + console.info("[lbs_js] getLastLocation callback data: " + JSON.stringify(data)); + expect(data).assertTrue(data != null); + console.info("[lbs_js] getLastLocation callback exit ."); + } + }); + done(); + }) + /** - * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002 + * @tc.number geolocation_locationChange_Off_test_002 * @tc.name testlocationChangeOff promise * @tc.desc Test locationChangeoff api . * @tc.author wangsilu wwx1075324 @@ -671,5 +711,89 @@ describe('geolocationTest', function () { done(); }); }) + + /** + * @tc.number geolocation_getLastLocation_promise__test_001 + * @tc.name testgetLastLocation promise + * @tc.desc Test getLastLocation api . + * @tc.author wangsilu wwx1075324 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('geolocation_getLastLocation_promise__test_001', 0, async function (done) { + console.info('LBS getLastLocation test start ...'); + geolocation.getLastLocation().then((result) => { + console.info("[lbs_js] getLastLocation promise data: " + JSON.stringify(result)); + expect(data).assertTrue(data != null); + console.info("[lbs_js] getLastLocation promise exit ."); + done(); + }).catch(error => { + console.info('[lbs_js] getLastLocation promise err is : ' + err ); + expect().assertFail(); + done(); + + }); + }) + + /** + * @tc.number geolocation_isLocationPrivacyConfirmed_promise_test_001 + * @tc.name Test setLocationPrivacyConfirmStatus promise + * @tc.desc Test setLocationPrivacyConfirmStatus api . + * @tc.author wangsilu wwx1075324 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('geolocation_setLocationPrivacyConfirmStatus_promise_test_001', 0, async function (done) { + let reqType = 1; + let value = true; + let type = "STARTUP"; + + if(type == "OTHERS"){ + reqType = 0; + } + if(type == "STARTUP"){ + reqType = 1; + } + if(type == "CORE_LOCATION"){ + reqType = 2; + } + console.info('LBS setLocationPrivacyConfirmStatus promise test start ...') + geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => { + console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp)) + expect(resp).assertTrue(); + done(); + }) + }) + + /** + * @tc.number geolocation_isLocationPrivacyConfirmed_promise_test_001 + * @tc.name Test isLocationPrivacyConfirmed promise + * @tc.desc Test isLocationPrivacyConfirmed api . + * @tc.author wangsilu wwx1075324 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('geolocation_isLocationPrivacyConfirmed_promise_test_001', 0, async function (done) { + let reqType = 1; + let value = true; + console.info('LBS setLocationPrivacyConfirmStatus promise test start ...') + geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => { + console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp)) + expect(resp).assertTrue(); + }) + + console.info('LBS isLocationPrivacyConfirmed promise test start ...'); + geolocation.isLocationPrivacyConfirmed(reqType).then(resp => { + console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp)) + expect(resp).assertTrue(); + console.info("[lbs_js] isLocationPrivacyConfirmed callback exit ."); + done(); + }) + }) + + })