From 71834f960bc8d3e57b56b78b97cb79341ae8c315 Mon Sep 17 00:00:00 2001 From: quanli Date: Tue, 29 Nov 2022 04:40:52 +0800 Subject: [PATCH] quanli1@huawei.com Signed-off-by: quanli --- .../main/js/default/test/GeocoderTest.test.js | 167 +++++++++++------- .../main/js/default/test/LocationTest.test.js | 41 +++-- 2 files changed, 132 insertions(+), 76 deletions(-) diff --git a/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js b/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js index f36668a79..fa6cce0c6 100644 --- a/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js +++ b/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js @@ -231,40 +231,62 @@ describe('geolocationTest_geo1', function () { */ it('SUB_HSS_LocationSystem_Geo_0600', 0, async function (done) { let reverseGeocodeRequest1 = { "latitude": 90, "longitude": 121.62771, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { - console.info('[lbs_js] getAddressesFromLocation0601 promise: ' + JSON.stringify(data)); - expect(true).assertEqual((JSON.stringify(data)) != null); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0601 promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { + console.info('[lbs_js] getAddressesFromLocation0601 promise: ' + JSON.stringify(data)); + expect(true).assertEqual((JSON.stringify(data)) != null); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0601 promise then error." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + console.info('[lbs_js] not support now'); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } + let reverseGeocodeRequest2 = { "latitude": 90.1, "longitude": 121.62771, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => { - console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data)); - expect(data.length).assertEqual(0); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0602 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); - }); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => { + console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data)); + expect(data.length).assertEqual(0); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0602 promise then error." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } + let reverseGeocodeRequest3 = { "latitude": -90, "longitude": 121.62771, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => { - console.info('[lbs_js] getAddressesFromLocation0603 promise: ' + JSON.stringify(data)); - expect(true).assertEqual((JSON.stringify(data)) != null); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0603 promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => { + console.info('[lbs_js] getAddressesFromLocation0603 promise: ' + JSON.stringify(data)); + expect(true).assertEqual((JSON.stringify(data)) != null); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0603 promise then error." + JSON.stringify(error)); + console.info('[lbs_js] not support now'); + expect(true).assertEqual(JSON.stringify(error) != null); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } let reverseGeocodeRequest4 = { "latitude": -90.1, "longitude": 121.62771, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest4).then((data) => { - console.info('[lbs_js] getAddressesFromLocation0604 promise: ' + JSON.stringify(data)); - expect(data.length).assertEqual(0); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0604 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); - }); - done() + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest4).then((data) => { + console.info('[lbs_js] getAddressesFromLocation0604 promise: ' + JSON.stringify(data)); + expect(data.length).assertEqual(0); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0604 promise then error." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } + done(); }) /** @@ -277,40 +299,60 @@ describe('geolocationTest_geo1', function () { */ it('SUB_HSS_LocationSystem_Geo_0700', 0, async function (done) { let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 180, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { - console.info('[lbs_js] getAddressesFromLocation0701 promise: ' + JSON.stringify(data)); - expect(true).assertEqual((JSON.stringify(data)) != null); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0701 promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { + console.info('[lbs_js] getAddressesFromLocation0701 promise: ' + JSON.stringify(data)); + expect(true).assertEqual((JSON.stringify(data)) != null); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0701 promise then error." + JSON.stringify(error)); + console.info('[lbs_js] not support now'); + expect(true).assertEqual(JSON.stringify(error) != null); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } let reverseGeocodeRequest1 = { "latitude": 31.265496, "longitude": -180.1, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { - console.info('[lbs_js] getAddressesFromLocation0702 promise: ' + JSON.stringify(data)); - expect(data.length).assertEqual(0); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0702 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); - }); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { + console.info('[lbs_js] getAddressesFromLocation0702 promise: ' + JSON.stringify(data)); + expect(data.length).assertEqual(0); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0702 promise then error." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } let reverseGeocodeRequest2 = { "latitude": 31.265496, "longitude": 180, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => { - console.info('[lbs_js] getAddressesFromLocation0703 promise: ' + JSON.stringify(data)); - expect(true).assertEqual((JSON.stringify(data)) != null); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0703 promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => { + console.info('[lbs_js] getAddressesFromLocation0703 promise: ' + JSON.stringify(data)); + expect(true).assertEqual((JSON.stringify(data)) != null); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0703 promise then error." + JSON.stringify(error)); + console.info('[lbs_js] not support now'); + expect(true).assertEqual(JSON.stringify(error) != null); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } let reverseGeocodeRequest3 = { "latitude": 31.265496, "longitude": 180.1, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => { - console.info('[lbs_js] getAddressesFromLocation0704 promise: ' + JSON.stringify(data)); - expect(data.length).assertEqual(0); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation0704 promise then error." + JSON.stringify(error)); - expect(true).assertEqual((JSON.stringify(error)) != null); - }); - done() + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => { + console.info('[lbs_js] getAddressesFromLocation0704 promise: ' + JSON.stringify(data)); + expect(data.length).assertEqual(0); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation0704 promise then error." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } + done(); }) /** @@ -949,3 +991,4 @@ describe('geolocationTest_geo1', function () { }) }) + diff --git a/location/geolocation_standard/src/main/js/default/test/LocationTest.test.js b/location/geolocation_standard/src/main/js/default/test/LocationTest.test.js index 2c95b7303..068783dd6 100644 --- a/location/geolocation_standard/src/main/js/default/test/LocationTest.test.js +++ b/location/geolocation_standard/src/main/js/default/test/LocationTest.test.js @@ -508,14 +508,20 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_SendCommand_0100', 0, async function (done) { let requestInfo = { 'scenairo': 0x301, 'command': "command_1" }; - await geolocation.sendCommand(requestInfo, (err, result) => { - if (err) { - console.info('sendcommand callback err:' + JSON.stringify(err)); - expect(true).assertEqual(JSON.stringify(err) != null); - done(); - } - console.info('sendcommand callback result:' + JSON.stringify(result)); - }); + try { + await geolocation.sendCommand(requestInfo, (err, result) => { + if (err) { + console.info('sendcommand callback err:' + JSON.stringify(err)); + expect(true).assertEqual(JSON.stringify(err) != null); + 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); + } + done(); }) /** @@ -528,14 +534,20 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_SendCommand_0200', 0, async function (done) { let requestInfo = { 'scenairo': 0x301, 'command': "command_1" }; - geolocation.sendCommand(requestInfo).then((result) => { - console.info('sendCommand promise result:' + result); - done(); - }).catch(error => { + try { + geolocation.sendCommand(requestInfo).then((result) => { + console.info('sendCommand promise result:' + result); + done(); + }).catch(error => { + console.info('sendcommand promise err:' + JSON.stringify(error)); + 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); - done(); - }) + } + done(); }) /** @@ -1249,3 +1261,4 @@ describe('geolocationTest_geo3', function () { }) }) + -- GitLab