diff --git a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js index 8cf2f46fc100c8da5a7fbc9dbdf1002c21ad918b..4f65cfcf5a873635fc3cfaf4ae202d4f1147bf62 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js @@ -14,13 +14,10 @@ */ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' - import wifiMg from '@ohos.wifiManager' import osaccount from '@ohos.account.osAccount' import bundle from '@ohos.bundle' import abilityAccessCtrl from '@ohos.abilityAccessCtrl' - - function sleep(delay) { return new Promise(resovle => setTimeout(resovle, delay)) } @@ -182,12 +179,20 @@ export default function actsWifiManagerEventTest() { groupName : "DIRECT-AAAZZZ123", goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO, }; - await wifiMg.getCurrentGroup() - .then(data => { - let resultLength = Object.keys(data).length; - console.info("[wifi_test] getCurrentGroup promise result -> " + JSON.stringify(data)); - expect(true).assertEqual(resultLength!=0); - }); + try { + await wifiMg.getCurrentP2pGroup() + .then(data => { + let resultLength = Object.keys(data).length; + console.info("[wifi_test] getCurrentP2pGroup promise result -> " + JSON.stringify(data)); + expect(true).assertEqual(resultLength!=0); + }).catch((error) => { + console.error('[wifi_test] getCurrentP2pGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentP2pGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } wifiMg.off(p2pGroupState, p2pPersistentGroupChangeCallback); done(); }) @@ -214,5 +219,3 @@ export default function actsWifiManagerEventTest() { console.log("*************[wifi_test] start wifi js unit test end*************"); }) } - - diff --git a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js index e4640885197f5e19b1383fb723f542fb1bdd4cfd..313bcd0247d073f9f5418844add6e75efd41837d 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js @@ -84,11 +84,19 @@ export default function actsWifiManagerFunctionTest() { expect(wifiMg.isWifiActive()).assertTrue(); let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test]getCurrentGroup promise result -> " + JSON.stringify(data)); - expect(true).assertEqual(data.groupName == wifiP2PConfig.groupName); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } function getCurrentGroupResult(){ return new Promise((resolve, reject) => { wifiMg.getCurrentGroup( @@ -116,11 +124,19 @@ export default function actsWifiManagerFunctionTest() { await getCurrentGroupResult(); let removeGroupResult = wifiMg.removeGroup(); await sleep(2000); - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error1: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -148,11 +164,19 @@ export default function actsWifiManagerFunctionTest() { console.info("[wifi_test]createGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); - expect(true).assertEqual(data.networkId == -999); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); + expect(true).assertEqual(data.networkId == -999); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } try { let removeGroupResult = wifiMg.removeGroup(); await sleep(2000); @@ -160,11 +184,19 @@ export default function actsWifiManagerFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error1: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -194,11 +226,19 @@ export default function actsWifiManagerFunctionTest() { }); let removeGroupResult = wifiMg.removeGroup(); await sleep(2000); - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -228,11 +268,19 @@ export default function actsWifiManagerFunctionTest() { }); let removeGroupResult = wifiMg.removeGroup(); await sleep(2000); - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -260,11 +308,19 @@ export default function actsWifiManagerFunctionTest() { console.info("[wifi_test]createGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test]getCurrentGroup promise result :" + JSON.stringify(data)); - expect(true).assertEqual(data.passphrase != wifiP2PConfig.passphrase); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); + expect(true).assertEqual(data.networkId == -999); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } try { let removeGroupResult = wifiMg.removeGroup(); await sleep(2000); @@ -272,11 +328,19 @@ export default function actsWifiManagerFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -306,11 +370,19 @@ export default function actsWifiManagerFunctionTest() { }); let removeGroupResult = wifiMg.removeGroup(); await sleep(2000); - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -337,7 +409,10 @@ export default function actsWifiManagerFunctionTest() { await wifiMg.getCurrentGroup() .then(data => { console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); - expect(true).assertEqual(5160 < data.frequency < 5865); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); let removeGroupResult = await wifiMg.removeGroup(); await sleep(2000); @@ -345,6 +420,9 @@ export default function actsWifiManagerFunctionTest() { .then(data => { console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); }catch(error){ console.info("[wifi_test]createGroup 5G goBand result : " + JSON.stringify(error.message)); @@ -384,6 +462,9 @@ export default function actsWifiManagerFunctionTest() { .then(data => { console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); }catch(error){ console.info("[wifi_test]createGroup auto goBand result : " + JSON.stringify(error.message)); @@ -418,10 +499,13 @@ export default function actsWifiManagerFunctionTest() { }); let removeGroupResult = wifi.removeGroup(); await sleep(2000); - await wifi.getCurrentGroup() + await wifiMg.getCurrentGroup() .then(data => { console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); }catch(error){ console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); @@ -456,10 +540,13 @@ export default function actsWifiManagerFunctionTest() { }); let removeGroupResult = wifi.removeGroup(); await sleep(2000); - await wifi.getCurrentGroup() + await wifiMg.getCurrentGroup() .then(data => { console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); }catch(error){ console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); @@ -494,10 +581,13 @@ export default function actsWifiManagerFunctionTest() { }); let removeGroupResult = wifi.removeGroup(); await sleep(2000); - await wifi.getCurrentGroup() + await wifiMg.getCurrentGroup() .then(data => { console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); }catch(error){ console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); @@ -533,11 +623,19 @@ export default function actsWifiManagerFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -556,11 +654,19 @@ export default function actsWifiManagerFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifiMg.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifiMg.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -720,5 +826,3 @@ export default function actsWifiManagerFunctionTest() { console.log("*************[wifi_test] start wifi js unit test end*************"); }) } - - diff --git a/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js b/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js index 1e3f66dac7b273c7de4c9b219a438ba7a06863e8..0635274a10be663362b672b7eca8f74db2e7b817 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js @@ -180,12 +180,20 @@ export default function actsWifiEventTest() { groupName : "DIRECT-AAAZZZ123", goBand : wifi.GroupOwnerBand.GO_BAND_AUTO, }; - 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); - }); + try { + 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); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } wifi.off(p2pGroupState, p2pPersistentGroupChangeCallback); done(); }) @@ -214,5 +222,3 @@ export default function actsWifiEventTest() { console.log("*************[wifi_test] start wifi js unit test end*************"); }) } - - diff --git a/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js b/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js index 0c53d0fddc11e286210ffc7a941ffd5a2561ba24..d72cb6471aacd76c575f6bbe25606eb39ccf1ffd 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js @@ -86,11 +86,19 @@ export default function actsWifiFunctionTest() { console.log("[wifi_test]createGroup result: " + JSON.stringify(createGroupResult)); await sleep(2000); expect(createGroupResult).assertTrue(); - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test]getCurrentGroup promise result -> " + JSON.stringify(data)); - expect(true).assertEqual(data.groupName == wifiP2PConfig.groupName); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); + expect(true).assertEqual(data.groupName == wifiP2PConfig.groupName); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error != null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } function getCurrentGroupResult(){ return new Promise((resolve, reject) => { wifi.getCurrentGroup( @@ -119,11 +127,19 @@ export default function actsWifiFunctionTest() { let removeGroupResult = wifi.removeGroup(); await sleep(2000); expect(removeGroupResult).assertTrue(); - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error != null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error1: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -156,6 +172,9 @@ export default function actsWifiFunctionTest() { .then(data => { console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); expect(true).assertEqual(data.networkId == -999); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); try { let removeGroupResult = wifi.removeGroup(); @@ -165,11 +184,19 @@ export default function actsWifiFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -202,11 +229,19 @@ export default function actsWifiFunctionTest() { let removeGroupResult = wifi.removeGroup(); await sleep(2000); expect(removeGroupResult).assertTrue(); - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -239,11 +274,19 @@ export default function actsWifiFunctionTest() { let removeGroupResult = wifi.removeGroup(); await sleep(2000); expect(removeGroupResult).assertTrue(); - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -276,6 +319,9 @@ export default function actsWifiFunctionTest() { .then(data => { console.info("[wifi_test]getCurrentGroup promise result :" + JSON.stringify(data)); expect(true).assertEqual(data.passphrase != wifiP2PConfig.passphrase); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); try { let removeGroupResult = wifi.removeGroup(); @@ -285,11 +331,19 @@ export default function actsWifiFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -322,11 +376,19 @@ export default function actsWifiFunctionTest() { let removeGroupResult = wifi.removeGroup(); await sleep(2000); expect(removeGroupResult).assertTrue(); - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -355,7 +417,10 @@ export default function actsWifiFunctionTest() { await wifi.getCurrentGroup() .then(data => { console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); - expect(true).assertEqual(5160 < data.frequency < 5865); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error != null); }); let removeGroupResult = await wifi.removeGroup(); await sleep(2000); @@ -364,6 +429,9 @@ export default function actsWifiFunctionTest() { .then(data => { console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error)); + expect(true).assertEqual(error != null); }); }catch(error){ console.info("[wifi_test]createGroup 5G goBand result : " + JSON.stringify(error.message)); @@ -406,6 +474,9 @@ export default function actsWifiFunctionTest() { .then(data => { console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); }); }catch(error){ console.info("[wifi_test]createGroup auto goBand result : " + JSON.stringify(error.message)); @@ -442,11 +513,19 @@ export default function actsWifiFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -465,11 +544,19 @@ export default function actsWifiFunctionTest() { console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } - await wifi.getCurrentGroup() - .then(data => { - console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName == null); - }); + try { + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }).catch((error) => { + console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); + expect(true).assertEqual(error !=null); + }); + }catch(error){ + console.info("[wifi_test]getCurrentGroup promise error message : " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } done(); }) @@ -600,5 +687,3 @@ export default function actsWifiFunctionTest() { console.log("*************[wifi_test] start wifi js unit test end*************"); }) } - - diff --git a/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js b/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js index 0c3d9633aa195404c17602575d6cc2cd2e9c5a19..9bde9e06c50c1816f8f59b86e1c91a4e7062e8a2 100644 --- a/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js @@ -53,14 +53,6 @@ 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, -} - export default function actsWifiCandidateNetWorkTest() { describe('actsWifiCandidateNetWorkTest', function () { beforeAll(async function (done) { @@ -88,7 +80,7 @@ export default function actsWifiCandidateNetWorkTest() { "bssid": "22:9b:e6:48:1f:5c", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, + "securityType": wifi.WifiSecurityType.WIFI_SEC_TYPE_PSK, }; await wifi.addUntrustedConfig(wifiDeviceConfig) .then(ret => { @@ -104,6 +96,19 @@ export default function actsWifiCandidateNetWorkTest() { }).catch((error) => { console.error('[wifi_test]removeUntrustedConfig promise failed -> ' + JSON.stringify(error)); }); + + let WIFI_SEC_TYPE_INVALID = wifi.WifiSecurityType.WIFI_SEC_TYPE_INVALID; + console.info("[wifi_test]WIFI_SEC_TYPE_INVALID : " + JSON.stringify(WIFI_SEC_TYPE_INVALID)); + expect(true).assertEqual( WIFI_SEC_TYPE_INVALID == 0); + let WIFI_SEC_TYPE_OPEN = wifi.WifiSecurityType.WIFI_SEC_TYPE_OPEN; + console.info("[wifi_test]WIFI_SEC_TYPE_OPEN : " + JSON.stringify(WIFI_SEC_TYPE_OPEN)); + expect(true).assertEqual( WIFI_SEC_TYPE_OPEN == 1); + let WIFI_SEC_TYPE_WEP = wifi.WifiSecurityType.WIFI_SEC_TYPE_WEP; + console.info("[wifi_test]WIFI_SEC_TYPE_WEP : " + JSON.stringify(WIFI_SEC_TYPE_WEP)); + expect(true).assertEqual( WIFI_SEC_TYPE_WEP == 2); + let WIFI_SEC_TYPE_SAE = wifi.WifiSecurityType.WIFI_SEC_TYPE_SAE; + console.info("[wifi_test]WIFI_SEC_TYPE_SAE : " + JSON.stringify(WIFI_SEC_TYPE_SAE)); + expect(true).assertEqual( WIFI_SEC_TYPE_SAE == 4); done(); }) @@ -120,7 +125,7 @@ export default function actsWifiCandidateNetWorkTest() { "bssid": "22:9b:e6:48:1f:5c", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, + "securityType": wifi.WifiSecurityType.WIFI_SEC_TYPE_PSK, } function addCandidate() { return new Promise((resolve, reject) => { diff --git a/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js b/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js index 604a60b93c015819879db7f370c79d4a5e9e8fab..95d6d30c09ae2a92e2726d17106316b4fc40904e 100644 --- a/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js @@ -20,6 +20,18 @@ import osaccount from '@ohos.account.osAccount' import bundle from '@ohos.bundle' import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +function sleep(delay) { + return new Promise(resovle => setTimeout(resovle, delay)) +} + +function checkWifiPowerOn(){ + console.info("[wifi_test]wifi status:" + wifiMg.isWifiActive()); +} + +function resolveIP(ip) { + return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF); +} + async function applyPermission() { let osAccountManager = osaccount.getAccountManager(); console.info("=== getAccountManager finish"); @@ -41,27 +53,6 @@ async function applyPermission() { } } -function sleep(delay) { - return new Promise(resovle => setTimeout(resovle, delay)) -} - -function checkWifiPowerOn(){ - console.info("[wifi_test]wifi status:" + wifiMg.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_EAP: 5, - WIFI_SEC_TYPE_EAP_SUITE_B: 6, - WIFI_SEC_TYPE_OWE:7 , - WIFI_SEC_TYPE_WAPI_CERT:8 , - WIFI_SEC_TYPE_WAPI_PSK:9 , -} - export default function actsWifiManagerCandidateNetWorkTest() { describe('actsWifiManagerCandidateNetWorkTest', function () { beforeAll(async function (done) { @@ -118,6 +109,25 @@ export default function actsWifiManagerCandidateNetWorkTest() { expect(true).assertEqual( (JSON.stringify(error)) !=null); }); console.info("[wifi_test]wifi get WEP CandidateConfigs result : " + JSON.stringify(getconfig)); + + let WIFI_SEC_TYPE_INVALID = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_INVALID; + console.info("[wifi_test]WIFI_SEC_TYPE_INVALID : " + JSON.stringify(WIFI_SEC_TYPE_INVALID)); + expect(true).assertEqual( WIFI_SEC_TYPE_INVALID == 0); + let WIFI_SEC_TYPE_EAP = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_EAP; + console.info("[wifi_test]WIFI_SEC_TYPE_EAP : " + JSON.stringify(WIFI_SEC_TYPE_EAP)); + expect(true).assertEqual( WIFI_SEC_TYPE_EAP == 5); + let WIFI_SEC_TYPE_EAP_SUITE_B = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_EAP_SUITE_B; + console.info("[wifi_test]WIFI_SEC_TYPE_EAP_SUITE_B : " + JSON.stringify(WIFI_SEC_TYPE_EAP_SUITE_B)); + expect(true).assertEqual( WIFI_SEC_TYPE_EAP_SUITE_B == 6); + let WIFI_SEC_TYPE_OWE = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_OWE; + console.info("[wifi_test]WIFI_SEC_TYPE_OWE : " + JSON.stringify(WIFI_SEC_TYPE_OWE)); + expect(true).assertEqual( WIFI_SEC_TYPE_OWE == 7); + let WIFI_SEC_TYPE_WAPI_CERT = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_WAPI_CERT; + console.info("[wifi_test]WIFI_SEC_TYPE_WAPI_CERT : " + JSON.stringify(WIFI_SEC_TYPE_WAPI_CERT)); + expect(true).assertEqual( WIFI_SEC_TYPE_WAPI_CERT == 8); + let WIFI_SEC_TYPE_WAPI_PSK = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_WAPI_PSK; + console.info("[wifi_test]WIFI_SEC_TYPE_WAPI_CERT : " + JSON.stringify(WIFI_SEC_TYPE_WAPI_PSK)); + expect(true).assertEqual( WIFI_SEC_TYPE_WAPI_PSK == 9); done(); }) diff --git a/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js b/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js index 6d21aadd00a6cc89cf940e1b0f35ee11c30e1e5d..28e9be18326036c8b0a3dd0c91c38425c767fafe 100644 --- a/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js @@ -14,12 +14,23 @@ */ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - import wifiMg from '@ohos.wifiManager' +import wifiManagerExt from '@ohos.wifiManagerExt' import osaccount from '@ohos.account.osAccount' import bundle from '@ohos.bundle' import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +function sleep(delay) { + return new Promise(resovle => setTimeout(resovle, delay)) +} + +function checkWifiPowerOn(){ + console.info("[wifi_test]wifi status:" + wifiMg.isWifiActive()); +} +function resolveIP(ip) { + return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF); +} + async function applyPermission() { let osAccountManager = osaccount.getAccountManager(); console.info("=== getAccountManager finish"); @@ -41,19 +52,6 @@ async function applyPermission() { } } -import wifiManagerExt from '@ohos.wifiManagerExt' - -function sleep(delay) { - return new Promise(resovle => setTimeout(resovle, delay)) -} - -function checkWifiPowerOn(){ - console.info("[wifi_test]wifi status:" + wifiMg.isWifiActive()); -} -function resolveIP(ip) { - return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF); -} - export default function actsWifiManagerEventTest() { describe('actsWifiManagerEventTest', function() { beforeAll(async function (done) { diff --git a/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js b/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js index c0a783ce5d1515ab2eced81f1df3b2a3c4cf450d..ba800f66f63aed77121e6f42a880b9effa678551 100644 --- a/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js @@ -53,15 +53,6 @@ async function applyPermission() { } } -let wifiChannelWidth = { - WIDTH_20MHZ : 0, - WIDTH_40MHZ : 1, - WIDTH_80MHZ : 2, - WIDTH_160MHZ : 3, - WIDTH_80MHZ_PLUS : 4, - WIDTH_INVALID:null, -} - export default function actsWifiManagerFunctionsTest() { describe('actsWifiManagerFunctionsTest', function() { beforeAll(async function (done) { @@ -185,6 +176,25 @@ export default function actsWifiManagerFunctionsTest() { let countrylenth = getCountryCodeResult.length; console.info("[wifi_test]getCountryCode.length :" + JSON.stringify(countrylenth)); expect(true).assertEqual(countrylenth == 2); + + let WIDTH_20MHZ = wifiMg.WifiChannelWidth .WIDTH_20MHZ; + console.info("[wifi_test]WIDTH_20MHZ : " + JSON.stringify(WIDTH_20MHZ)); + expect(true).assertEqual( WIDTH_20MHZ == 0); + let WIDTH_40MHZ = wifiMg.WifiChannelWidth .WIDTH_40MHZ; + console.info("[wifi_test]WIDTH_40MHZ : " + JSON.stringify(WIDTH_40MHZ)); + expect(true).assertEqual( WIDTH_40MHZ == 1); + let WIDTH_80MHZ = wifiMg.WifiChannelWidth .WIDTH_80MHZ; + console.info("[wifi_test]WIDTH_80MHZ : " + JSON.stringify(WIDTH_80MHZ)); + expect(true).assertEqual( WIDTH_80MHZ == 2); + let WIDTH_160MHZ = wifiMg.WifiChannelWidth .WIDTH_160MHZ; + console.info("[wifi_test]WIDTH_160MHZ : " + JSON.stringify(WIDTH_160MHZ)); + expect(true).assertEqual( WIDTH_160MHZ == 3); + let WIDTH_80MHZ_PLUS = wifiMg.WifiChannelWidth .WIDTH_80MHZ_PLUS; + console.info("[wifi_test]WIDTH_80MHZ_PLUS : " + JSON.stringify(WIDTH_80MHZ_PLUS)); + expect(true).assertEqual( WIDTH_80MHZ_PLUS == 4); + let WIDTH_INVALID = wifiMg.WifiChannelWidth .WIDTH_INVALID; + console.info("[wifi_test]WIDTH_INVALID : " + JSON.stringify(WIDTH_INVALID)); + expect(true).assertEqual( WIDTH_INVALID == 5); }) /** diff --git a/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js b/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js index 1e37c950679e3d2300f1d290a8d0992bc8514f2a..8f2cfcdbe6bbc52f18ca632f7870c886517eb0a0 100644 --- a/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js @@ -16,6 +16,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import wifi from '@ohos.wifi' + import wifiext from '@ohos.wifiext' import osaccount from '@ohos.account.osAccount' import bundle from '@ohos.bundle' @@ -42,6 +43,7 @@ async function applyPermission() { } } + function sleep(delay) { return new Promise(resovle => setTimeout(resovle, delay)) } @@ -53,12 +55,6 @@ function resolveIP(ip) { return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF); } -let powerModel = { - SLEEPING : 0, - GENERAL : 1, - THROUGH_WALL : 2, -} - export default function actsWifiEventTest() { describe('actsWifiEventTest', function() { beforeAll(async function (done) { @@ -361,6 +357,15 @@ export default function actsWifiEventTest() { console.info("SUB_Communication_WiFi_SysCaps_Test_0007 canIUse isAccessToken error: " + e); } console.info('SUB_Communication_WiFi_SysCaps_Test_0007 end'); + let SLEEPING = wifiext.PowerModel.SLEEPING; + console.info("[wifi_test]SLEEPING : " + JSON.stringify(SLEEPING)); + expect(true).assertEqual( SLEEPING == 0); + let GENERAL = wifiext.PowerModel.GENERAL; + console.info("[wifi_test]GENERAL : " + JSON.stringify(GENERAL)); + expect(true).assertEqual( GENERAL == 1); + let THROUGH = wifiext.PowerModel.THROUGH_WALL; + console.info("[wifi_test]THROUGH : " + JSON.stringify(THROUGH)); + expect(true).assertEqual( THROUGH == 2); done(); }) console.log("*************[wifi_test] start wifi js unit test end*************"); diff --git a/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js b/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js index 7e4db773441f5c3ffe18c470d8a3f0d2420e9241..901c0dc9940a4769e7c8159b192ad885ccbccb01 100644 --- a/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js @@ -20,6 +20,17 @@ import osaccount from '@ohos.account.osAccount' import bundle from '@ohos.bundle' import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +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); +} + async function applyPermission() { let osAccountManager = osaccount.getAccountManager(); console.info("=== getAccountManager finish"); @@ -41,17 +52,6 @@ async function applyPermission() { } } -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); -} - export default function actsWifiFunctionsTest() { describe('actsWifiFunctionsTest', function() { beforeAll(async function (done) { @@ -74,8 +74,6 @@ export default function actsWifiFunctionsTest() { * @tc.level Level 0 */ it('Communication_WiFi_XTS_Sta_0002', 0, async function (done) { - let scan = wifi.scan(); - await sleep(3000); await wifi.getScanInfos() .then(result => { let clen = Object.keys(result).length; diff --git a/location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js b/location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js index 74a972957a011ff67de76404b0963e5106b63182..659b4ab245e54d4700b6a02aa486b280dd884f75 100644 --- a/location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js +++ b/location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Huawei Device Co., Ltd. + * 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 @@ -45,7 +45,7 @@ async function changedLocationMode(){ console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); if(!result1){ await geolocation.requestEnableLocation().then(async(result) => { - await sleep(3000); + await sleep(1000); console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); }).catch((error) => { console.info("[lbs_js] promise then error." + JSON.stringify(error)); @@ -116,11 +116,12 @@ export default function geolocationTest_geo5() { expect(true).assertEqual(JSON.stringify(geocoder1) != null); } catch (error) { console.info('[lbs_js] isGeocoderAvailable err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } }); - /** + /** * @tc.number SUB_HSS_LocationSystem_Geo_2000 * @tc.name TestgetAddressesFromLocation * @tc.desc Address Resolution Test. @@ -130,11 +131,12 @@ export default function geolocationTest_geo5() { */ it('SUB_HSS_LocationSystem_Geo_2000', 0, async function (done) { try { - let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1, "locale": "zh" }; + let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1 }; geolocationm.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { if (err) { console.info('[lbs_js] getAddressesFromLocation4 callback err is:' + JSON.stringify(err)); - return; + console.info('[lbs_js] not support now'); + expect(err.code).assertEqual(801); } else { console.info("[lbs_js] getAddressesFromLocation4 callback data is:" + JSON.stringify(data)); expect(true).assertEqual((JSON.stringify(data)) != null); @@ -142,12 +144,13 @@ export default function geolocationTest_geo5() { }); } catch (error) { console.info("[lbs_js] getAddressesFromLocation4 callback try error:"+ error); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } await sleep(2000); done(); }) + /** * @tc.number SUB_HSS_LocationSystem_Geo_2100 * @tc.name TestgetAddressesFromLocation @@ -158,7 +161,7 @@ export default function geolocationTest_geo5() { */ it('SUB_HSS_LocationSystem_Geo_2100', 0, async function (done) { try { - let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1 }; + let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 5}; await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { console.info('[lbs_js] getAddressesFromLocation21 promise: ' + JSON.stringify(data)); console.info('addressUrl: ' + JSON.stringify(data)[0].addressUrl @@ -175,12 +178,13 @@ export default function geolocationTest_geo5() { }).catch(error => { console.info("[lbs_js] getAddressesFromLocation21 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getAddressesFromLocation21 try err." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -201,12 +205,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocation22 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getAddressesFromLocation22 try err." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -226,12 +231,12 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(data)) != null); }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2301 promise then error." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); + expect(true).assertFalse(); } let reverseGeocodeRequest2 = { "latitude": 90.1, "longitude": 121.62771, "maxItems": 1 }; try { @@ -240,11 +245,11 @@ export default function geolocationTest_geo5() { expect(data.length).assertEqual(0); }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2302 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); + expect(error.code).assertEqual("401"); } let reverseGeocodeRequest3 = { "latitude": -90, "longitude": 121.62771, "maxItems": 1 }; try { @@ -254,25 +259,26 @@ export default function geolocationTest_geo5() { }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2303 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); + expect(true).assertFalse(); } let reverseGeocodeRequest4 = { "latitude": -90.1, "longitude": 121.62771, "maxItems": 1 }; try { await geolocationm.getAddressesFromLocation(reverseGeocodeRequest4).then((data) => { console.info('[lbs_js] getAddressesFromLocation2304 promise: ' + JSON.stringify(data)); - expect(data.length).assertEqual(0); + expect(true).assertEqual((JSON.stringify(data)) != null); }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2304 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); + expect(error.code).assertEqual("401"); } + await sleep(1000); done(); }) @@ -293,12 +299,13 @@ export default function geolocationTest_geo5() { }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2401 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); + expect(true).assertFalse(); } + await sleep(1000); let reverseGeocodeRequest1 = { "latitude": 31.265496, "longitude": -180.1, "maxItems": 1 }; try { await geolocationm.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { @@ -306,12 +313,13 @@ export default function geolocationTest_geo5() { expect(data.length).assertEqual(0); }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2402 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } + await sleep(1000); let reverseGeocodeRequest2 = { "latitude": 31.265496, "longitude": 180, "maxItems": 1 }; try { await geolocationm.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => { @@ -320,12 +328,13 @@ export default function geolocationTest_geo5() { }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2403 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); + expect(true).assertFalse(); } + await sleep(1000); let reverseGeocodeRequest3 = { "latitude": 31.265496, "longitude": 180.1, "maxItems": 1 }; try { await geolocationm.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => { @@ -333,12 +342,13 @@ export default function geolocationTest_geo5() { expect(data.length).assertEqual(0); }).catch(error => { console.info("[lbs_js] getAddressesFromLocation2404 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); } catch (error) { - console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); expect(true).assertEqual((JSON.stringify(error.message)) != null); } + await sleep(1000); done(); }) @@ -356,10 +366,6 @@ export default function geolocationTest_geo5() { "description": "上海市浦东新区金穗路1800号", "maxItems": 1, "locale": "zh", - "minLatitude": "", - "minLongitude": "", - "maxLatitude": "", - "maxLongitude": "" }; try { geolocationm.getAddressesFromLocationName(geocodeRequest, (err, data) => { @@ -397,14 +403,14 @@ export default function geolocationTest_geo5() { } } else { console.info("[lbs_js] getAddressesFromLocationName08 callback data is: " + JSON.stringify(data)); - expect(true).assertEqual((JSON.stringify(data)) != null); } done(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName08 message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -417,19 +423,21 @@ export default function geolocationTest_geo5() { * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_Geo_2600', 0, async function (done) { - let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 1 }; + let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 3 }; try { await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { console.info("[lbs_js] getAddressesFromLocation09 callback data is:" + JSON.stringify(result)); expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName09 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getAddressesFromLocationName26 try err." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -450,12 +458,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName10 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getAddressesFromLocationName27 try err." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -466,6 +475,7 @@ export default function geolocationTest_geo5() { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 + 需要实测!!!! */ it('SUB_HSS_LocationSystem_Geo_2800', 0, async function (done) { try { @@ -475,13 +485,13 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName111 promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName111 message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); let geocodeRequest1 = { "description": null, "maxItems": 1 }; try { await geolocationm.getAddressesFromLocationName(geocodeRequest1).then((result) => { @@ -489,12 +499,13 @@ export default function geolocationTest_geo5() { expect(result.length == 0).assertTrue(); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName112 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName112 message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); done(); }) @@ -522,12 +533,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName29 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getAddressesFromLocationName29 try err." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -555,12 +567,13 @@ export default function geolocationTest_geo5() { expect(result.length == 0).assertTrue(); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName301 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName301 message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); let geocodeRequest1 = { "description": null, "maxItems": 1, @@ -575,12 +588,14 @@ export default function geolocationTest_geo5() { expect(result.length == 0).assertTrue(); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName302 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); + }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName302 message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); done(); }) @@ -608,13 +623,13 @@ export default function geolocationTest_geo5() { expect(result.length >= 0).assertTrue(); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName31 promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getAddressesFromLocationName31 message." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); done(); }) @@ -643,12 +658,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName32 promise then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getAddressesFromLocationName32 message." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); done(); }) @@ -676,12 +692,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise1 then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message1." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); let geocodeRequest2 = { "description": "上海金穗路1800号", "maxItems": 1, @@ -697,12 +714,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise2 then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message2." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); let geocodeRequest3 = { "description": "上海金穗路1800号", "maxItems": 1, @@ -717,12 +735,13 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) == null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise3 then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message3." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); let geocodeRequest4 = { "description": "上海金穗路1800号", "maxItems": 1, @@ -738,12 +757,13 @@ export default function geolocationTest_geo5() { expect(true).assertEqual(JSON.stringify(error) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise4 then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message4." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); let geocodeRequest5 = { "description": "上海金穗路1800号", "maxItems": 1, @@ -759,12 +779,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise5 then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message5." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); let geocodeRequest6 = { "description": "上海金穗路1800号", "maxItems": 1, @@ -780,12 +801,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise6 then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message6." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); let geocodeRequest7 = { "description": "上海金穗路1800号", "maxItems": 1, @@ -800,12 +822,13 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) == null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise7 then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message7." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); let geocodeRequest8 = { "description": "上海金穗路1800号", "maxItems": 1, @@ -820,12 +843,13 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) == null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName33 promise8 then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName33 message8." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); done(); }) @@ -853,12 +877,13 @@ export default function geolocationTest_geo5() { }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise1 then error." + JSON.stringify(error)); console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message1." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); let geocodeRequest2 = { "description": "北京天安门", "maxItems": 1, @@ -873,12 +898,14 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise2 then error." + JSON.stringify(error)); - expect(error.length != 0).assertTrue(); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message2." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); let geocodeRequest3 = { "description": "北京天安门", "maxItems": 1, @@ -893,12 +920,13 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise3 then error." + JSON.stringify(error)); - expect(error.length != 0).assertTrue(); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message3." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); let geocodeRequest4 = { "description": "北京天安门", "maxItems": 1, @@ -913,12 +941,13 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise4 then error." + JSON.stringify(error)); - expect(error.length != 0).assertTrue(); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message4." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); let geocodeRequest5 = { "description": "北京天安门", "maxItems": 1, @@ -933,11 +962,12 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise5 then error." + JSON.stringify(error)); - expect(error.length != 0).assertTrue(); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message5." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } let geocodeRequest6 = { "description": "北京天安门", @@ -953,12 +983,14 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise6 then error." + JSON.stringify(error)); - expect(error.length != 0).assertTrue(); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message6." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(true).assertFalse(); } + await sleep(1000); let geocodeRequest7 = { "description": "北京天安门", "maxItems": 1, @@ -973,11 +1005,11 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise7 then error." + JSON.stringify(error)); - expect(error.length != 0).assertTrue(); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message7." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } let geocodeRequest8 = { "description": "北京天安门", @@ -993,15 +1025,18 @@ export default function geolocationTest_geo5() { expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { console.info("[lbs_js] getAddressesFromLocationName34 promise8 then error." + JSON.stringify(error)); - expect(error.length != 0).assertTrue(); + expect(true).assertFalse(); }); }catch(error){ console.info("[lbs_js] getAddressesFromLocationName34 message8." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + expect(error.code).assertEqual("401"); } + await sleep(1000); done(); }) + + }) } diff --git a/location/geolocation_standard/src/main/js/test/GetCountryCodeM.test.js b/location/geolocation_standard/src/main/js/test/GetCountryCodeM.test.js index 64c3ae223790f154b204433618a1c435b4ade401..e2b9ea3e5d71cbe3022a69a1bd335004923e9cc6 100644 --- a/location/geolocation_standard/src/main/js/test/GetCountryCodeM.test.js +++ b/location/geolocation_standard/src/main/js/test/GetCountryCodeM.test.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Huawei Device Co., Ltd. + * 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 @@ -30,7 +30,7 @@ async function changedLocationMode(){ console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); if(!result1){ await geolocation.requestEnableLocation().then(async(result) => { - await sleep(3000); + await sleep(1000); console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); }).catch((error) => { console.info("[lbs_js] promise then error." + JSON.stringify(error)); @@ -130,6 +130,7 @@ export default function geolocationTest_6() { geolocationm.getCountryCode((err,data) => { if (err) { return console.info("[lbs_js] getCountryCode callback err: " + JSON.stringify(err)); + expect().assertFail(); } else { console.info("[lbs_js] getCountryCode callback success"+ JSON.stringify(data)); expect(true).assertEqual(data != null); @@ -158,7 +159,7 @@ export default function geolocationTest_6() { }); } catch (error) { console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error)); - expect(true).assertEqual(error != null); + expect().assertFail(); } try { await geolocationm.getCountryCode().then((result) => { @@ -178,7 +179,7 @@ export default function geolocationTest_6() { }) } catch (error) { console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error)); - expect(true).assertEqual(error != null); + expect().assertFail(); } done(); }) diff --git a/location/geolocation_standard/src/main/js/test/LocationMTest.test.js b/location/geolocation_standard/src/main/js/test/LocationMTest.test.js index 2f5fc12115fb63b3c3cd69c5b25f9ca729450b07..0e16a6a423ca48b16aca25d889a6ce9175f962b2 100644 --- a/location/geolocation_standard/src/main/js/test/LocationMTest.test.js +++ b/location/geolocation_standard/src/main/js/test/LocationMTest.test.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Huawei Device Co., Ltd. + * 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 @@ -39,7 +39,7 @@ async function changedLocationMode(){ console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); if(!result1){ await geolocation.requestEnableLocation().then(async(result) => { - await sleep(3000); + ; console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); }).catch((error) => { console.info("[lbs_js] promise then error." + JSON.stringify(error)); @@ -80,6 +80,7 @@ async function applyPermission() { console.info('[permission] case accessTokenID is ' + tokenID); let permissionName1 = 'ohos.permission.LOCATION'; let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND'; + let permissionName3 = 'ohos.permission.APPROXIMATELY_LOCATION'; await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); }).catch((err) => { @@ -90,6 +91,11 @@ async function applyPermission() { }).catch((err) => { console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); + }); } else { console.info('[permission] case apply permission failed, createAtManager failed'); } @@ -113,6 +119,7 @@ export default function geolocationTest_geo7() { }) + /** * @tc.number SUB_HSS_LocationSystem_LocSwitch_0600 * @tc.name Test requestrequestEnableLocation api @@ -124,8 +131,8 @@ export default function geolocationTest_geo7() { it('SUB_HSS_LocationSystem_LocSwitch_0600', 0, function () { try { let state = geolocationm.isLocationEnabled(); - console.info('[lbs_js] getLocationSwitchState06 result: ' + JSON.stringify(state)); - expect(true).assertEqual(JSON.stringify(state) != null); + console.info('[lbs_js] getLocationSwitchState06 result: ' + JSON.stringify(state)); + expect(true).assertEqual(state); } catch (error) { console.info("[lbs_js] getLocationSwitchState06 try err." + JSON.stringify(error)); expect().assertFail(); @@ -147,15 +154,16 @@ export default function geolocationTest_geo7() { } try { geolocationm.on('locationEnabledChange', locationServiceState); + } catch (error) { console.info("[lbs_js] locationServiceStateOn07 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect().assertFail(); } try { geolocationm.off('locationEnabledChange', locationServiceState); } catch (error) { console.info("[lbs_js] locationServiceStateOff07 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect().assertFail(); } done(); }) @@ -174,7 +182,7 @@ export default function geolocationTest_geo7() { geolocationm.getCurrentLocation(currentLocationRequest, (err, result) => { if (err) { console.info("[lbs_js] getCurrentLocation15 callback err: " + JSON.stringify(err)); - expect(true).assertEqual(err != null); + expect(err.code).assertEqual(3301200); console.info('[lbs_js] getCurrentLocationCallback reject after'); done(); } else { @@ -184,9 +192,9 @@ export default function geolocationTest_geo7() { }); } catch (error) { console.info("[lbs_js] getCurrentLocation15 callback try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } - await sleep(1500); + await sleep(1000); done(); }) @@ -205,12 +213,13 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation16 promise result ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation16 promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation16 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -230,12 +239,13 @@ export default function geolocationTest_geo7() { expect(true).assertEqual(result != null); }).catch(error => { console.info('[lbs_js] getCurrentLocation callback17:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation callback17 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -254,12 +264,13 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation18 promise result ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation18 promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation18 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -278,12 +289,13 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation19 promise result:' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation19 promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation18 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -300,27 +312,29 @@ export default function geolocationTest_geo7() { let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest2 = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 }; try { - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => { console.info('[lbs_js] getCurrentLocation1901 promise result:' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation1901 promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation1901 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); try { await geolocationm.getCurrentLocation(currentLocationRequest2).then((result) => { console.info('[lbs_js] getCurrentLocation1902 promise result:' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation1902 promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation1902 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -339,12 +353,13 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation21 promise result ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation21 promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation21 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -363,12 +378,13 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation22 promise result:' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation22 promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation22 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -387,12 +403,13 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation promise result23:' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err23:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation23 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -412,23 +429,25 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation promise result241 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err241:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation241 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); try { await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => { console.info('[lbs_js] getCurrentLocation promise result242 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err242:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation242 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -449,23 +468,25 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation promise result251 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err251:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation251 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); try { await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => { console.info('[lbs_js] getCurrentLocation promise result252 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err252:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation252 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -485,23 +506,25 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation promise result261 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err261:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation261 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); try { await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => { console.info('[lbs_js] getCurrentLocation promise result262 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err262:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation262 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -521,23 +544,25 @@ export default function geolocationTest_geo7() { console.info('[lbs_js] getCurrentLocation promise result271 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err271:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }); } catch (error) { console.info("[lbs_js] getCurrentLocation271 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); try { await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => { console.info('[lbs_js] getCurrentLocation promise result272 ' + JSON.stringify(result)); }).catch(error => { console.info('[lbs_js] getCurrentLocation promise err272:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual(3301200); }) } catch (error) { console.info("[lbs_js] getCurrentLocation272 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -550,20 +575,22 @@ export default function geolocationTest_geo7() { * @tc.level Level 2 */ it('SUB_HSS_SendCommand_0300', 0, async function (done) { - let requestInfo = { 'scenairo': 0x301, 'command': "command_1" }; + let requestInfo = { 'scenario': 0x301, 'command': "command_1" }; try { await geolocationm.sendCommand(requestInfo, (err, result) => { if (err) { console.info('sendcommand callback err:' + JSON.stringify(err)); - expect(true).assertEqual(JSON.stringify(err) != null); + console.info('sendcommand not support'); + expect(err.code).assertEqual(801); done(); } console.info('sendcommand callback result:' + JSON.stringify(result)); }); } catch (error) { console.info('sendcommand callback err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -576,20 +603,23 @@ export default function geolocationTest_geo7() { * @tc.level Level 2 */ it('SUB_HSS_SendCommand_0400', 0, async function (done) { - let requestInfo = { 'scenairo': 0x301, 'command': "command_1" }; + let requestInfo = { 'scenario': 0x301, 'command': "command_1" }; try { geolocationm.sendCommand(requestInfo).then((result) => { - console.info('sendCommand promise result:' + result); + console.info('[lbs_js] sendCommand promise result:' + result); done(); }).catch(error => { - console.info('sendcommand promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] sendcommand promise err:' + JSON.stringify(error)); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); + //expect(true).assertEqual(JSON.stringify(error) != null); done(); }) } catch (error) { - console.info('sendcommand promise err:' + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] sendcommand promise err:' + JSON.stringify(error)); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -613,14 +643,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn16 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff16 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -644,14 +675,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn17 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff17 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -675,14 +707,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn18 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff18 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -706,14 +739,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn19 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff19 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -742,26 +776,27 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOn201 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.on('locationChange', requestInfo, locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOn202 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOff201 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOff202 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -786,14 +821,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn21 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff21 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -818,14 +854,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn22 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff22 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -850,14 +887,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn23 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff23 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -881,14 +919,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn24 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff24 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -912,14 +951,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn25 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff25 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -943,14 +983,15 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn26 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff26 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -980,26 +1021,28 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo1, locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOn271 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOff271 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); try { geolocationm.on('locationChange', requestInfo2, locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOn272 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOff272 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -1029,26 +1072,28 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo1, locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOn281 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOff281 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); try { geolocationm.on('locationChange', requestInfo2, locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOn282 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOff282 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -1078,26 +1123,28 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo1, locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOn291 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange1); } catch (error) { console.info("[lbs_js] locationChangerOff291 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); try { geolocationm.on('locationChange', requestInfo2, locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOn292 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange2); } catch (error) { console.info("[lbs_js] locationChangerOff292 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -1121,26 +1168,30 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); try { - let last =geolocationm.getLastLocation(); - console.info('[lbs_js] getLastLocation latitude: ' + result.latitude + + let last =geolocationm.getLastLocation(); + console.info('[lbs_js] getLastLocation latitude: ' + last.latitude + ' longitude: ' + result.longitude +' altitude: ' + result.altitude +' accuracy: ' + result.accuracy+' speed: ' + result.speed + 'timeStamp: ' + result.timeStamp+'direction:' + result.direction+' timeSinceBoot: ' + result.timeSinceBoot +'additions: ' + result.additions+' additionSize' + result.additionSize + 'isFromMock' +result.isFromMock); + expect(true).assertEqual(JSON.stringify(last) != null); } catch (error) { console.info("[lbs_js] getLastLocation error:"+ error) + expect(error.code).assertEqual("3301200"); } + await sleep(1500); done(); }) @@ -1166,7 +1217,7 @@ export default function geolocationTest_geo7() { geolocationm.on('satelliteStatusChange', gnssStatusCb); } catch (error) { console.info("[lbs_js] satelliteStatusOn03 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } enableLocationSwitch(); let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, @@ -1179,20 +1230,21 @@ export default function geolocationTest_geo7() { geolocationm.on('locationChange', requestInfo, locationChange); } catch (error) { console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('satelliteStatusChange', gnssStatusCb); } catch (error) { console.info("[lbs_js] satelliteStatusOff03 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -1219,8 +1271,7 @@ export default function geolocationTest_geo7() { geolocationm.on('nmeaMessage', nmeaCb); } catch (error) { console.info("nmea on err:" + JSON.stringify(error)); - expect(true).assertEqual(error !=null); - done(); + expect(true).assertFalse(); } try { geolocationm.on('locationChange', requestInfo, locationChange); @@ -1232,14 +1283,15 @@ export default function geolocationTest_geo7() { geolocationm.off('nmeaMessage', nmeaCb); } catch (error) { console.info("nmea off err:" + JSON.stringify(error)); - expect(true).assertEqual(error !=null); + expect(true).assertFalse(); } try { geolocationm.off('locationChange', locationChange); } catch (error) { console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -1261,14 +1313,16 @@ export default function geolocationTest_geo7() { geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest1, cachedLocationsCb1); } catch (error) { console.info("[lbs_js] cachedGnssLocOn071 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(error.code).assertEqual("801"); } try { geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1); } catch (error) { console.info("[lbs_js] cachedGnssLocOff071 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } + await sleep(1500); var cachedLocationsCb2 = (locations) => { console.log('[lbs_js] cachedGnssLocationsReporting7:locations:' + JSON.stringify(locations)); expect(true).assertEqual(locations !=null); @@ -1278,14 +1332,17 @@ export default function geolocationTest_geo7() { geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest2, cachedLocationsCb2); } catch (error) { console.info("[lbs_js] cachedGnssLocOn072 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1); } catch (error) { console.info("[lbs_js] cachedGnssLocOff072 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } + await sleep(1500); done(); }) @@ -1307,14 +1364,17 @@ export default function geolocationTest_geo7() { geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOn08 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOff08 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } + await sleep(1500); done(); }) @@ -1336,19 +1396,23 @@ export default function geolocationTest_geo7() { geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOn09 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOff09 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } + await sleep(1500); try { geolocationm.getCachedGnssLocationsSize((err, data) => { if (err) { console.info('[lbs_js] getCachedGnssLocationsSize09 callback err:' + JSON.stringify(err)); - expect(true).assertEqual(err != null); + console.info('[lbs_js] not support now'); + expect(err.code).assertEqual(801); }else { console.info("[lbs_js] getCachedGnssLocationsSize09 callback data:" + JSON.stringify(data)); expect(true).assertEqual(data != null); @@ -1356,7 +1420,8 @@ export default function geolocationTest_geo7() { }); } catch (error) { console.info("[lbs_js] getCachedGnssLocationsSize09 callback try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); + } await sleep(1000); done(); @@ -1380,26 +1445,31 @@ export default function geolocationTest_geo7() { geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOn10 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOff10 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } + await sleep(1000); try { await geolocationm.getCachedGnssLocationsSize().then( (result) => { console.info('[lbs_js] getCachedGnssLocationsSiz promise '+ JSON.stringify(result)); expect(true).assertEqual(result != null); }).catch((error) => { console.info("[lbs_js] promise then error." + JSON.stringify(error)); - expect(true).assertEqual(error != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] getCachedGnssLocationsSize promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1500); done(); }) @@ -1421,19 +1491,23 @@ export default function geolocationTest_geo7() { geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } + await sleep(1000); try { geolocationm.flushCachedGnssLocations((err, data) => { if (err) { console.info('[lbs_js] flushCachedGnssLocations11 callback err is : ' + JSON.stringify(err)); - expect(true).assertEqual(err != null); + console.info('[lbs_js] not support now'); + expect(err.code).assertEqual(801); }else { console.info("[lbs_js] flushCachedGnssLocations11 callback data is: " + JSON.stringify(data)); expect(true).assertEqual(data != null); @@ -1441,7 +1515,7 @@ export default function geolocationTest_geo7() { }); } catch (error) { console.info("[lbs_js] flushCachedGnssLocations11 callback try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } await sleep(1000); done(); @@ -1465,25 +1539,31 @@ export default function geolocationTest_geo7() { geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); } catch (error) { console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } + await sleep(1000); try { await geolocationm.flushCachedGnssLocations().then( (result) => { console.info('[lbs_js] flushCachedGnssLocations promise '+ JSON.stringify(result)); expect(true).assertEqual(result != null); }).catch((error) => { console.info("[lbs_js] promise then error." + JSON.stringify(error)); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual(801); }); } catch (error) { console.info("[lbs_js] flushCachedGnssLocations11 promise try err." + JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + expect(true).assertFalse(); } + await sleep(1000); done(); }) @@ -1510,7 +1590,8 @@ export default function geolocationTest_geo7() { }); } catch (error) { console.info("[lbs_js] FenceStatusOn2 try error:"+ JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('gnssFenceStatusChange',geofenceRequest, @@ -1523,7 +1604,8 @@ export default function geolocationTest_geo7() { }); } catch (error) { console.info("[lbs_js] FenceStatusOff2 try error:"+ JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } await sleep(1000); done(); @@ -1546,13 +1628,16 @@ export default function geolocationTest_geo7() { (want) => { if(err){ return console.info("[lbs_js] fenceStatusChange3 on callback err: " + err); + console.info("[lbs_js] fenceStatusChange not support "); + expect(err.code).assertEqual(801); } console.info("[lbs_js] fenceStatusChange3 callback result: " + JSON.stringify(want)); expect(true).assertEqual(want !=null); }); } catch (error) { console.info("[lbs_js] FenceStatusOn3 try error:"+ JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } try { geolocationm.off('gnssFenceStatusChange',geofenceRequest, @@ -1565,7 +1650,8 @@ export default function geolocationTest_geo7() { }); } catch (error) { console.info("[lbs_js] FenceStatusOff3 try error:"+ JSON.stringify(error)); - expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + expect(error.code).assertEqual("801"); } await sleep(1000); done();