diff --git a/location/geolocation_standard/BUILD.gn b/location/geolocation_standard/BUILD.gn index 582e15fd942175b016885184b05ecd5c7dc53991..97b6099fc82b380f33f323f31d5d670dd3d01a97 100644 --- a/location/geolocation_standard/BUILD.gn +++ b/location/geolocation_standard/BUILD.gn @@ -29,7 +29,9 @@ ohos_js_hap_suite("ActslocationJsTest") { subsystem_name = "location" } ohos_js_assets("geolocation_js_assets") { - source_dir = "./src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("geolocation_resources") { sources = [ "./src/main/resources" ] diff --git a/location/geolocation_standard/Test.json b/location/geolocation_standard/Test.json index 8cc9be6a663900c7fe61b6ee36c260581985de00..98241964c76bb47038282df7ca1be19d7d3b18c4 100644 --- a/location/geolocation_standard/Test.json +++ b/location/geolocation_standard/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for geolocation js api Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", + "bundle-name": "ohos.acts.location.geolocation.function", + "package-name":"ohos.acts.location.geolocation.function", "test-timeout": "600000", - "package": "ohos.acts.location.geolocation.function", - "shell-timeout": "60000" + "shell-timeout": "60000", + "testcase-timeout": 70000 }, "kits": [ { @@ -14,7 +16,7 @@ "type": "AppInstallKit", "cleanup-apps": true }, - { + { "type": "ShellKit", "run-command": [ "hilog -Q pidoff" diff --git a/location/geolocation_standard/src/main/config.json b/location/geolocation_standard/src/main/config.json index 969cc6f318a10bb1d866fcae76a2cbc6a4757868..5cfc210ba2d0377f864fcf3dec9043fae39ccde6 100644 --- a/location/geolocation_standard/src/main/config.json +++ b/location/geolocation_standard/src/main/config.json @@ -15,8 +15,9 @@ "deviceConfig": {}, "module": { "package": "ohos.acts.location.geolocation.function", - "name": ".MyApplication", - "mainAbility": "ohos.acts.location.geolocation.function.MainAbility", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", "deviceType": [ "tablet", "default", @@ -28,7 +29,7 @@ "moduleType": "entry" }, "abilities": [ - { + { "skills": [ { "entities": [ @@ -39,12 +40,29 @@ ] } ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", "visible": true, - "name": "ohos.acts.location.geolocation.function.MainAbility", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", "type": "page", + "visible": true, "launchType": "standard" } ], @@ -124,8 +142,22 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } - ] + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } diff --git a/location/geolocation_standard/src/main/js/default/app.js b/location/geolocation_standard/src/main/js/MainAbility/app.js similarity index 100% rename from location/geolocation_standard/src/main/js/default/app.js rename to location/geolocation_standard/src/main/js/MainAbility/app.js diff --git a/location/geolocation_standard/src/main/js/default/i18n/en-US.json b/location/geolocation_standard/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from location/geolocation_standard/src/main/js/default/i18n/en-US.json rename to location/geolocation_standard/src/main/js/MainAbility/i18n/en-US.json diff --git a/location/geolocation_standard/src/main/js/default/i18n/zh-CN.json b/location/geolocation_standard/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from location/geolocation_standard/src/main/js/default/i18n/zh-CN.json rename to location/geolocation_standard/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/location/geolocation_standard/src/main/js/default/pages/index/index.css b/location/geolocation_standard/src/main/js/MainAbility/pages/index/index.css similarity index 100% rename from location/geolocation_standard/src/main/js/default/pages/index/index.css rename to location/geolocation_standard/src/main/js/MainAbility/pages/index/index.css diff --git a/location/geolocation_standard/src/main/js/default/pages/index/index.hml b/location/geolocation_standard/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from location/geolocation_standard/src/main/js/default/pages/index/index.hml rename to location/geolocation_standard/src/main/js/MainAbility/pages/index/index.hml diff --git a/location/geolocation_standard/src/main/js/default/test/List.test.js b/location/geolocation_standard/src/main/js/MainAbility/pages/index/index.js similarity index 71% rename from location/geolocation_standard/src/main/js/default/test/List.test.js rename to location/geolocation_standard/src/main/js/MainAbility/pages/index/index.js index 76e277e3cac5be4fb6e207f08186992c1569261b..7f41e27f73e2884ed0223a48d5ff696d6913d400 100644 --- a/location/geolocation_standard/src/main/js/default/test/List.test.js +++ b/location/geolocation_standard/src/main/js/MainAbility/pages/index/index.js @@ -13,10 +13,18 @@ * limitations under the License. */ -require('./GeocoderTest.test.js') -require('./GeocoderMTest.test.js') -require('./GetCountryCode.test.js') -require('./GetCountryCodeM.test.js') -require('./LocationTest.test.js') -require('./LocationMTest.test.js') -require('./SystemLocation.test.js') +import app from '@system.app' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} diff --git a/location/geolocation_standard/src/main/js/TestAbility/app.js b/location/geolocation_standard/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/location/geolocation_standard/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/location/geolocation_standard/src/main/js/TestAbility/i18n/en-US.json b/location/geolocation_standard/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/location/geolocation_standard/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/location/geolocation_standard/src/main/js/TestAbility/i18n/zh-CN.json b/location/geolocation_standard/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/location/geolocation_standard/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.css b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..b1bcd43387ba131cc1d30975ff7508a6f8084a4b --- /dev/null +++ b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.hml b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f629c71a9be857db6cdf94149652a191b9b272ea --- /dev/null +++ b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/location/geolocation_standard/src/main/js/default/pages/index/index.js b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.js similarity index 54% rename from location/geolocation_standard/src/main/js/default/pages/index/index.js rename to location/geolocation_standard/src/main/js/TestAbility/pages/index/index.js index 30f42fc041b3fa7bfb6fd987e38424ae0a0f8045..88b083a7f6b979019d6a2c5ad20b19c5fd43286b 100644 --- a/location/geolocation_standard/src/main/js/default/pages/index/index.js +++ b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.js @@ -1,43 +1,26 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import app from '@system.app' -import {Core, ExpectExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../test/List.test') - core.execute() - }, - onReady() { - }, -} +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/location/geolocation_standard/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/location/geolocation_standard/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/location/geolocation_standard/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/location/geolocation_standard/src/main/js/default/test/GeocoderMTest.test.js b/location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js similarity index 84% rename from location/geolocation_standard/src/main/js/default/test/GeocoderMTest.test.js rename to location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js index b1915a195046222290730e19030e7ad75fb2c0ea..02b831d297655e35a45c9c177d8b0e57983a650c 100644 --- a/location/geolocation_standard/src/main/js/default/test/GeocoderMTest.test.js +++ b/location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js @@ -13,12 +13,12 @@ * limitations under the License. */ - +import geolocation from '@ohos.geolocation'; import geolocationm from '@ohos.geoLocationManager'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' import osaccount from '@ohos.account.osAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' let LocationRequestScenario = { UNSET: 0x300, @@ -44,7 +44,7 @@ async function changedLocationMode(){ let result1 = geolocationm.isLocationEnabled(); console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); if(!result1){ - await geolocationm.requestEnableLocation().then(async(result) => { + await geolocation.requestEnableLocation().then(async(result) => { await sleep(3000); console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); }).catch((error) => { @@ -83,20 +83,23 @@ async function applyPermission() { } } -describe('geolocationTest_geo5', function () { +export default function geolocationTest_geo5() { - console.log('#start AccessTokenTests#'); - beforeAll(async function (done) { - console.info('beforeAll case'); - await applyPermission(); - done(); - }) + describe('geolocationTest_geo5', function () { + + console.log('#start AccessTokenTests#'); + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach case'); + await changedLocationMode(); + done(); + }) - beforeEach(async function (done) { - console.info('beforeEach case'); - await changedLocationMode(); - done(); - }) /** * @tc.number SUB_HSS_LocationSystem_Geo_1900 @@ -106,7 +109,7 @@ describe('geolocationTest_geo5', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_Geo_1900', 0, function () { + it('SUB_HSS_LocationSystem_Geo_1900', 0, function () { try { let geocoder1 = geolocationm.isGeocoderAvailable(); console.info('[lbs_js] isGeocoderAvailable result: ' + JSON.stringify(geocoder1)); @@ -126,19 +129,23 @@ describe('geolocationTest_geo5', function () { * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_Geo_2000', 0, async function (done) { - let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1, "locale": "zh" }; - let promise = new Promise((resolve, reject) => { + try { + let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1, "locale": "zh" }; geolocationm.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { if (err) { - console.info('[lbs_js] getAddressesFromLocation20 callback err is:' + JSON.stringify(err)); + console.info('[lbs_js] getAddressesFromLocation4 callback err is:' + JSON.stringify(err)); + return; } else { - console.info("[lbs_js] getAddressesFromLocation20 callback data is:" + JSON.stringify(data)); + console.info("[lbs_js] getAddressesFromLocation4 callback data is:" + JSON.stringify(data)); expect(true).assertEqual((JSON.stringify(data)) != null); } - resolve(); }); - }) - await promise.then(done); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation4 callback try error:"+ error); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(2000); + done(); }) /** @@ -150,27 +157,31 @@ describe('geolocationTest_geo5', function () { * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_Geo_2100', 0, async function (done) { - let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1 }; - await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { - console.info('[lbs_js] getAddressesFromLocation21 promise: ' + JSON.stringify(data)); - console.info('addressUrl: ' + JSON.stringify(data)[0].addressUrl - + JSON.stringify(data)[0].administrativeArea + JSON.stringify(data)[0].countryCode - + JSON.stringify(data)[0].countryName + JSON.stringify(data)[0].descriptions - + JSON.stringify(data)[0].descriptionsSize + data[0].latitude - + JSON.stringify(data)[0].locale + JSON.stringify(data)[0].locality - + JSON.stringify(data)[0].longitude + JSON.stringify(data)[0].phoneNumber - + JSON.stringify(data)[0].placeName - + JSON.stringify(data)[0].postalCode + JSON.stringify(data)[0].premises - + JSON.stringify(data)[0].roadName + JSON.stringify(data)[0].subAdministrativeArea - + JSON.stringify(data)[0].subLocality + JSON.stringify(data)[0].subRoadName - + JSON.stringify(data)[0].isFromMock); - done(); - }).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); - done(); - }); + try { + let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1 }; + await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { + console.info('[lbs_js] getAddressesFromLocation21 promise: ' + JSON.stringify(data)); + console.info('addressUrl: ' + JSON.stringify(data)[0].addressUrl + + JSON.stringify(data)[0].administrativeArea + JSON.stringify(data)[0].countryCode + + JSON.stringify(data)[0].countryName + JSON.stringify(data)[0].descriptions + + JSON.stringify(data)[0].descriptionsSize + data[0].latitude + + JSON.stringify(data)[0].locale + JSON.stringify(data)[0].locality + + JSON.stringify(data)[0].longitude + JSON.stringify(data)[0].phoneNumber + + JSON.stringify(data)[0].placeName + + JSON.stringify(data)[0].postalCode + JSON.stringify(data)[0].premises + + JSON.stringify(data)[0].roadName + JSON.stringify(data)[0].subAdministrativeArea + + JSON.stringify(data)[0].subLocality + JSON.stringify(data)[0].subRoadName + + JSON.stringify(data)[0].isFromMock); + }).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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation21 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } + done(); }) /** @@ -182,17 +193,21 @@ describe('geolocationTest_geo5', function () { * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_Geo_2200', 0, async function (done) { - let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 5 }; - await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { - console.info('[lbs_js] getAddressesFromLocation22 promise:' + JSON.stringify(data)); - expect(true).assertEqual((JSON.stringify(data)) != null); - done(); - }).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); - done(); - }); + try { + let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 5 }; + await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { + console.info('[lbs_js] getAddressesFromLocation22 promise:' + JSON.stringify(data)); + expect(true).assertEqual((JSON.stringify(data)) != null); + }).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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation22 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } + done(); }) /** @@ -403,13 +418,18 @@ describe('geolocationTest_geo5', function () { */ it('SUB_HSS_LocationSystem_Geo_2600', 0, async function (done) { let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 1 }; - 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); - }); + 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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocationName26 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } done(); }) @@ -422,15 +442,20 @@ describe('geolocationTest_geo5', function () { * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_Geo_2700', 0, async function (done) { - let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 5 }; - await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation10 promise data is:" + JSON.stringify(result)); - expect(true).assertEqual((JSON.stringify(result)) != null); - }).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); - }); + try { + let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 5 }; + await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocation10 promise data is:" + JSON.stringify(result)); + expect(true).assertEqual((JSON.stringify(result)) != null); + }).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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocationName27 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } done(); }) @@ -490,14 +515,19 @@ describe('geolocationTest_geo5', function () { "maxLatitude": 31.1537977881, "maxLongitude": 121.8026736943 }; - await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation29 promise data is:" + JSON.stringify(result)); - expect(true).assertEqual((JSON.stringify(result)) != null); - }).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); - }); + try { + await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocation29 promise data is:" + JSON.stringify(result)); + expect(true).assertEqual((JSON.stringify(result)) != null); + }).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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocationName29 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } done(); }) @@ -572,14 +602,19 @@ describe('geolocationTest_geo5', function () { "maxLatitude": 40.95, "maxLongitude": 116.45 }; - await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocationName31 promise data is:" + JSON.stringify(result)); - 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); - }); + try { + await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocationName31 promise data is:" + JSON.stringify(result)); + 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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocationName31 message." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } done(); }) @@ -601,14 +636,19 @@ describe('geolocationTest_geo5', function () { "maxLatitude": 39.85, "maxLongitude": 116.35 }; - await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocationName32 promise data is:" + JSON.stringify(result)); - expect(result.length >= 0).assertTrue(); - }).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); - }); + try { + await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocationName32 promise data is:" + JSON.stringify(result)); + expect(result.length >= 0).assertTrue(); + }).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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocationName32 message." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error.message)) != null); + } done(); }) @@ -961,4 +1001,8 @@ describe('geolocationTest_geo5', function () { } done(); }) -}) + + }) +} + + diff --git a/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js b/location/geolocation_standard/src/main/js/test/GeocoderTest.test.js similarity index 84% rename from location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js rename to location/geolocation_standard/src/main/js/test/GeocoderTest.test.js index 31dcbae1e9f97c2ed989cd1833cefd940ce13673..ac6f850dfd83e22e021e072c75dcffdbe8ab47e5 100644 --- a/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js +++ b/location/geolocation_standard/src/main/js/test/GeocoderTest.test.js @@ -18,7 +18,7 @@ import {LocationEventListener} from '@ohos.geolocation'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' import osaccount from '@ohos.account.osAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' let LocationRequestScenario = { UNSET: 0x300, @@ -85,20 +85,24 @@ async function applyPermission() { } } -describe('geolocationTest_geo1', function () { - console.log('#start AccessTokenTests#'); - beforeAll(async function (done) { - console.info('beforeAll case'); - await applyPermission(); - done(); - }) +export default function geolocationTest_geo1() { - beforeEach(async function (done) { - console.info('beforeEach case'); - await changedLocationMode(); - done(); - }) + describe('geolocationTest_geo1', function () { + + console.log('#start AccessTokenTests#'); + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach case'); + await changedLocationMode(); + done(); + }) + /** * @tc.number SUB_HSS_LocationSystem_Geo_0100 @@ -108,19 +112,24 @@ describe('geolocationTest_geo1', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_Geo_0100', 0, async function (done) { - geolocation.isGeoServiceAvailable(async (err, data) => { - if (err) { - console.info('[lbs_js] getGeoServiceState err is : ' + JSON.stringify(err)); - - } else { - console.info('[lbs_js] isGeoServiceAvailable callback result: ' + JSON.stringify(data)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(data) != null); - done(); - } - done(); - }) + it('SUB_HSS_LocationSystem_Geo_0100', 0, async function (done) { + try { + geolocation.isGeoServiceAvailable(async (err, data) => { + if (err) { + console.info('[lbs_js] getGeoServiceState err is : ' + JSON.stringify(err)); + } else { + console.info('[lbs_js] isGeoServiceAvailable callback result: ' + JSON.stringify(data)); + console.info('[lbs_js] not support now'); + expect(true).assertEqual(JSON.stringify(data) != null); + } + }) + } catch (error) { + console.info("[lbs_js] isGeoServiceAvailable callback err." + JSON.stringify(error)); + console.info('[lbs_js] The geocode interface is not connected to a third-party service.'); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(500); + done(); }); /** @@ -139,10 +148,12 @@ describe('geolocationTest_geo1', function () { expect(true).assertEqual(JSON.stringify(result) != null); }).catch((error) => { console.info("[lbs_js] promise then error." + JSON.stringify(error)); - expect().assertFail(); + expect(true).assertEqual(JSON.stringify(error) != null); }); } catch (error) { console.info("[lbs_js] isGeoServiceAvailable error." + JSON.stringify(error)); + console.info('[lbs_js] The geocode interface is not connected to a third-party service.'); + expect(true).assertEqual(JSON.stringify(error) != null); } done(); }) @@ -157,7 +168,7 @@ describe('geolocationTest_geo1', function () { */ it('SUB_HSS_LocationSystem_Geo_0300', 0, async function (done) { let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1, "locale": "zh" }; - let promise = new Promise((resolve, reject) => { + try { geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { if (err) { console.info('[lbs_js] getAddressesFromLocation callback err is : ' + JSON.stringify(err)); @@ -165,10 +176,13 @@ describe('geolocationTest_geo1', function () { console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(data)); expect(true).assertEqual((JSON.stringify(data)) != null); } - resolve(); }); - }) - await promise.then(done) + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation callback try err:" + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); + done(); }) /** @@ -181,26 +195,30 @@ describe('geolocationTest_geo1', function () { */ it('SUB_HSS_LocationSystem_Geo_0400', 0, async function (done) { let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { - console.info('[lbs_js] getAddressesFromLocation04 promise: ' + JSON.stringify(data)); - console.info('addressUrl: ' + JSON.stringify(data)[0].addressUrl - + JSON.stringify(data)[0].administrativeArea + JSON.stringify(data)[0].countryCode - + JSON.stringify(data)[0].countryName + JSON.stringify(data)[0].descriptions - + JSON.stringify(data)[0].descriptionsSize + data[0].latitude - + JSON.stringify(data)[0].locale + JSON.stringify(data)[0].locality - + JSON.stringify(data)[0].longitude + JSON.stringify(data)[0].phoneNumber - + JSON.stringify(data)[0].placeName - + JSON.stringify(data)[0].postalCode + JSON.stringify(data)[0].premises - + JSON.stringify(data)[0].roadName + JSON.stringify(data)[0].subAdministrativeArea - + JSON.stringify(data)[0].subLocality + JSON.stringify(data)[0].subRoadName - + JSON.stringify(data)[0].isFromMock); - done(); - }).catch(error => { - console.info("[lbs_js] getAddressesFromLocation promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { + console.info('[lbs_js] getAddressesFromLocation04 promise: ' + JSON.stringify(data)); + console.info('addressUrl: ' + JSON.stringify(data)[0].addressUrl + + JSON.stringify(data)[0].administrativeArea + JSON.stringify(data)[0].countryCode + + JSON.stringify(data)[0].countryName + JSON.stringify(data)[0].descriptions + + JSON.stringify(data)[0].descriptionsSize + data[0].latitude + + JSON.stringify(data)[0].locale + JSON.stringify(data)[0].locality + + JSON.stringify(data)[0].longitude + JSON.stringify(data)[0].phoneNumber + + JSON.stringify(data)[0].placeName + + JSON.stringify(data)[0].postalCode + JSON.stringify(data)[0].premises + + JSON.stringify(data)[0].roadName + JSON.stringify(data)[0].subAdministrativeArea + + JSON.stringify(data)[0].subLocality + JSON.stringify(data)[0].subRoadName + + JSON.stringify(data)[0].isFromMock); + }).catch(error => { + console.info("[lbs_js] getAddressesFromLocation 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] getAddressesFromLocation04 promise try err:" + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }); + } + done(); }) /** @@ -213,16 +231,20 @@ describe('geolocationTest_geo1', function () { */ it('SUB_HSS_LocationSystem_Geo_0500', 0, async function (done) { let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 5 }; - await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { - console.info('[lbs_js] getAddressesFromLocation05 promise: ' + JSON.stringify(data)); - expect(true).assertEqual((JSON.stringify(data)) != null); - done(); - }).catch((error) => { - console.info("[lbs_js] getAddressesFromLocation promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); + try { + await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { + console.info('[lbs_js] getAddressesFromLocation05 promise: ' + JSON.stringify(data)); + expect(true).assertEqual((JSON.stringify(data)) != null); + }).catch((error) => { + console.info("[lbs_js] getAddressesFromLocation 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] getAddressesFromLocation05 promise try err:" + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }); + } + done(); }) /** @@ -435,13 +457,18 @@ describe('geolocationTest_geo1', function () { */ it('SUB_HSS_LocationSystem_Geo_0900', 0, async function (done) { let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 1 }; - await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation 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)); + try { + await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocation09 promise data: " + 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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation09 try err." + JSON.stringify(error)); expect(true).assertEqual((JSON.stringify(error)) != null); - }); + } done(); }) @@ -455,14 +482,19 @@ describe('geolocationTest_geo1', function () { */ it('SUB_HSS_LocationSystem_Geo_1000', 0, async function (done) { let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 5 }; - await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation m callback data is: " + JSON.stringify(result)); - expect(true).assertEqual((JSON.stringify(result)) != null); - }).catch((error) => { - console.info("[lbs_js] getAddressesFromLocationName m promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocation10 promise data: " + JSON.stringify(result)); + expect(true).assertEqual((JSON.stringify(result)) != null); + }).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); + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation10 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + } done(); }) @@ -478,10 +510,10 @@ describe('geolocationTest_geo1', function () { try { let geocodeRequest = { "description": "", "maxItems": 1 }; await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation promise data is: " + JSON.stringify(result)); + console.info("[lbs_js] getAddressesFromLocation111 promise data: " + JSON.stringify(result)); expect(true).assertEqual((JSON.stringify(result)) != null); }).catch((error) => { - console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(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); }); @@ -492,15 +524,15 @@ describe('geolocationTest_geo1', function () { let geocodeRequest1 = { "description": null, "maxItems": 1 }; try { await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => { - console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); + console.info("[lbs_js] getAddressesFromLocation112 promise data: " + JSON.stringify(result)); expect(result.length == 0).assertTrue(); }).catch((error) => { - console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); + console.info("[lbs_js] getAddressesFromLocationName112 promise then error." + JSON.stringify(error)); expect(true).assertEqual((JSON.stringify(error)) != null); }); }catch(error){ - console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message)); - expect(true).assertEqual((JSON.stringify(error.message)) != null); + console.info("[lbs_js] getAddressesFromLocation11 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); } done(); }) @@ -522,14 +554,19 @@ describe('geolocationTest_geo1', function () { "maxLatitude": 31.1537977881, "maxLongitude": 121.8026736943 }; - await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); - expect(true).assertEqual((JSON.stringify(result)) != null); - }).catch((error) => { - console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); + expect(true).assertEqual((JSON.stringify(result)) != null); + }).catch((error) => { + console.info("[lbs_js] getAddressesFromLocationName 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] getAddressesFromLocation12 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + } done(); }) @@ -604,14 +641,19 @@ describe('geolocationTest_geo1', function () { "maxLatitude": 40.95, "maxLongitude": 116.45 }; - await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); - expect(result.length >= 0).assertTrue(); - }).catch((error) => { - console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocation14 promise data: " + JSON.stringify(result)); + expect(result.length >= 0).assertTrue(); + }).catch((error) => { + console.info("[lbs_js] getAddressesFromLocationName14 promise then err." + JSON.stringify(error)); + console.info('[lbs_js] not support now'); + expect(true).assertEqual(JSON.stringify(error) != null); + }); + }catch(error){ + console.info("[lbs_js] getAddressesFromLocation14 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + } done(); }) @@ -633,14 +675,19 @@ describe('geolocationTest_geo1', function () { "maxLatitude": 39.85, "maxLongitude": 116.35 }; - await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); - expect(result.length >= 0).assertTrue(); - }).catch((error) => { - console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); - console.info('[lbs_js] not support now'); - expect(true).assertEqual(JSON.stringify(error) != null); - }); + try { + await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { + console.info("[lbs_js] getAddressesFromLocation15 promise data is: " + JSON.stringify(result)); + expect(result.length >= 0).assertTrue(); + }).catch((error) => { + console.info("[lbs_js] getAddressesFromLocationName15 promise then err." + JSON.stringify(error)); + console.info('[lbs_js] not support now'); + expect(true).assertEqual(JSON.stringify(error) != null); + }); + }catch(error){ + console.info("[lbs_js] getAddressesFromLocation15 try err." + JSON.stringify(error)); + expect(true).assertEqual((JSON.stringify(error)) != null); + } done(); }) @@ -993,7 +1040,8 @@ describe('geolocationTest_geo1', function () { } done(); }) -}) + }) +} diff --git a/location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js b/location/geolocation_standard/src/main/js/test/GetCountryCode.test.js similarity index 56% rename from location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js rename to location/geolocation_standard/src/main/js/test/GetCountryCode.test.js index a7fc660b853cbbd694c8d170bb726b9abc145b94..2f999ecbdbf233cf7c03423799508f4963de7dd4 100644 --- a/location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js +++ b/location/geolocation_standard/src/main/js/test/GetCountryCode.test.js @@ -17,7 +17,7 @@ import geolocationm from '@ohos.geoLocationManager'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' import osaccount from '@ohos.account.osAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); @@ -76,18 +76,21 @@ let CountryCodeType = { COUNTRY_CODE_FROM_NETWORK:4, } -describe('geolocationTest_4', function () { - beforeAll(async function (done) { - console.info('beforeAll case'); - await applyPermission(); - done(); - }) +export default function geolocationTest_4() { - beforeEach(async function (done) { - console.info('beforeEach case'); - await changedLocationMode(); - done(); - }) + + describe('geolocationTest_4', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach case'); + await changedLocationMode(); + done(); + }) /** * @tc.number SUB_HSS_LocationSystem_CountryCode_0100 @@ -96,19 +99,24 @@ describe('geolocationTest_4', function () { * @tc.type Function * @tc.level since 9 */ - it('SUB_HSS_LocationSystem_CountryCode_0100', 0, async function (done) { - await geolocationm.getCountryCode().then((result) => { - console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); - console.info("[lbs_js] country :" + result.country); - console.info("[lbs_js] type: " + result.type); - expect(true).assertTrue(JSON.stringify(result)==CountryCodeType.COUNTRY_CODE_FROM_LOCALE); - expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_SIM); - expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_LOCATION); - expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_NETWORK); - }).catch((error) => { - console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + it('SUB_HSS_LocationSystem_CountryCode_0100', 0, async function (done) { + try { + await geolocationm.getCountryCode().then((result) => { + console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); + console.info("[lbs_js] country :" + result.country); + console.info("[lbs_js] type: " + result.type); + expect(true).assertEqual(JSON.stringify(result.type)==CountryCodeType.COUNTRY_CODE_FROM_LOCALE); + expect(true).assertEqual(JSON.stringify(result.type)!=CountryCodeType.COUNTRY_CODE_FROM_SIM); + expect(true).assertEqual(JSON.stringify(result.type)!=CountryCodeType.COUNTRY_CODE_FROM_LOCATION); + expect(true).assertEqual(JSON.stringify(result.type)!=CountryCodeType.COUNTRY_CODE_FROM_NETWORK); + }).catch((error) => { + console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } catch (error) { + console.info("[lbs_js] getCountryCode promise try err." + JSON.stringify(error)); expect().assertFail(); - }); + } done(); }) @@ -120,20 +128,20 @@ describe('geolocationTest_4', function () { * @tc.level since 9 */ it('SUB_HSS_LocationSystem_CountryCode_0200', 0, async function (done) { - function getCountryCodeCallback() { - return new Promise((resolve, reject) => { - geolocationm.getCountryCode((err,data) => { - if (err) { - return console.info("getCountryCode callback err: " + JSON.stringify(err)); - } else { - console.info("getCountryCode callback success"+ JSON.stringify(data)); - expect(true).assertEqual(data != null); - } - resolve(); - }) - }) + try { + geolocationm.getCountryCode((err,data) => { + if (err) { + return console.info("getCountryCode callback err: " + JSON.stringify(err)); + } else { + console.info("getCountryCode callback success"+ JSON.stringify(data)); + expect(true).assertEqual(data != null); + } + }); + } catch (error) { + console.info("[lbs_js] getCountryCode callback try err." + JSON.stringify(error)); + expect().assertFail(); } - await getCountryCodeCallback(); + await sleep(1000); done(); }) @@ -146,21 +154,37 @@ describe('geolocationTest_4', function () { */ it('SUB_HSS_LocationSystem_CountryCode_0300', 0, async function (done) { console.info("[lbs_js] countryCodeChange"); - geolocationm.on('countryCodeChange', function (data) { - console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) ); - }); - await geolocationm.getCountryCode().then((result) => { - console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); - expect(true).assertTrue(JSON.stringify(result)!=null); - }).catch((error) => { - console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + try { + geolocationm.on('countryCodeChange', function (data) { + console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) ); + }); + } catch (error) { + console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error)!=null); + } + try { + await geolocationm.getCountryCode().then((result) => { + console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); + expect(true).assertEqual(JSON.stringify(result)!=null); + }).catch((error) => { + console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } catch (error) { + console.info("[lbs_js] getCountryCode callback try err." + JSON.stringify(error)); expect().assertFail(); - }); - geolocationm.off('countryCodeChange', function (data) { - console.info('[lbs_js] countryCodeChange' + JSON.stringify(data)); - done(); - }) + } + try { + geolocationm.off('countryCodeChange', function (data) { + console.info('[lbs_js] countryCodeChange' + JSON.stringify(data)); + }) + } catch (error) { + console.info("[lbs_js] countryCodeChangeOff try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error)!=null); + } done(); }) + + }) +} -}) diff --git a/location/geolocation_standard/src/main/js/default/test/GetCountryCodeM.test.js b/location/geolocation_standard/src/main/js/test/GetCountryCodeM.test.js similarity index 55% rename from location/geolocation_standard/src/main/js/default/test/GetCountryCodeM.test.js rename to location/geolocation_standard/src/main/js/test/GetCountryCodeM.test.js index 437c0fd6ac417b437aa1b3dbd838cde0efd55d20..243f5fb9bd158e793d7c4de750cbb547c3494281 100644 --- a/location/geolocation_standard/src/main/js/default/test/GetCountryCodeM.test.js +++ b/location/geolocation_standard/src/main/js/test/GetCountryCodeM.test.js @@ -13,11 +13,12 @@ * limitations under the License. */ +import geolocation from '@ohos.geolocation'; import geolocationm from '@ohos.geoLocationManager'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' import osaccount from '@ohos.account.osAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); @@ -28,7 +29,7 @@ async function changedLocationMode(){ let result1 = geolocationm.isLocationEnabled(); console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); if(!result1){ - await geolocationm.requestEnableLocation().then(async(result) => { + await geolocation.requestEnableLocation().then(async(result) => { await sleep(3000); console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); }).catch((error) => { @@ -74,18 +75,21 @@ let CountryCodeType = { COUNTRY_CODE_FROM_NETWORK:4, } -describe('geolocationTest_6', function () { - beforeAll(async function (done) { - console.info('beforeAll case'); - await applyPermission(); - done(); - }) +export default function geolocationTest_6() { - beforeEach(async function (done) { - console.info('beforeEach case'); - await changedLocationMode(); - done(); - }) + + describe('geolocationTest_6', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach case'); + await changedLocationMode(); + done(); + }) /** * @tc.number SUB_HSS_LocationSystem_CountryCode_0400 @@ -94,19 +98,24 @@ describe('geolocationTest_6', function () { * @tc.type Function * @tc.level since 9 */ - it('SUB_HSS_LocationSystem_CountryCode_0400', 0, async function (done) { - await geolocationm.getCountryCode().then((result) => { - console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); - console.info("[lbs_js] country :" + result.country); - console.info("[lbs_js] type: " + result.type); - expect(true).assertTrue(JSON.stringify(result)==CountryCodeType.COUNTRY_CODE_FROM_LOCALE); - expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_SIM); - expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_LOCATION); - expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_NETWORK); - }).catch((error) => { - console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + it('SUB_HSS_LocationSystem_CountryCode_0400', 0, async function (done) { + try { + await geolocationm.getCountryCode().then((result) => { + console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); + console.info("[lbs_js] country :" + result.country); + console.info("[lbs_js] type: " + result.type); + expect(true).assertEqual(JSON.stringify(result.type)==CountryCodeType.COUNTRY_CODE_FROM_LOCALE); + expect(true).assertEqual(JSON.stringify(result.type)!=CountryCodeType.COUNTRY_CODE_FROM_SIM); + expect(true).assertEqual(JSON.stringify(result.type)!=CountryCodeType.COUNTRY_CODE_FROM_LOCATION); + expect(true).assertEqual(JSON.stringify(result.type)!=CountryCodeType.COUNTRY_CODE_FROM_NETWORK); + }).catch((error) => { + console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } catch (error) { + console.info("[lbs_js] getCountryCode promise try err." + JSON.stringify(error)); expect().assertFail(); - }); + } done(); }) @@ -118,20 +127,20 @@ describe('geolocationTest_6', function () { * @tc.level since 9 */ it('SUB_HSS_LocationSystem_CountryCode_0500', 0, async function (done) { - function getCountryCodeCallback() { - return new Promise((resolve, reject) => { - geolocationm.getCountryCode((err,data) => { - if (err) { - return console.info("[lbs_js] getCountryCode callback err: " + JSON.stringify(err)); - } else { - console.info("[lbs_js] getCountryCode callback success"+ JSON.stringify(data)); - expect(true).assertEqual(data != null); - } - resolve(); - }) + try { + geolocationm.getCountryCode((err,data) => { + if (err) { + return console.info("[lbs_js] getCountryCode callback err: " + JSON.stringify(err)); + } else { + console.info("[lbs_js] getCountryCode callback success"+ JSON.stringify(data)); + expect(true).assertEqual(data != null); + } }) + } catch (error) { + console.info("[lbs_js] getCountryCode callback try err." + JSON.stringify(error)); + expect().assertFail(); } - await getCountryCodeCallback(); + await sleep(1500); done(); }) @@ -144,21 +153,37 @@ describe('geolocationTest_6', function () { */ it('SUB_HSS_LocationSystem_CountryCode_0600', 0, async function (done) { console.info("[lbs_js] countryCodeChange"); - geolocationm.on('countryCodeChange', function (data) { - console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) ); - }); - await geolocationm.getCountryCode().then((result) => { - console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); - expect(true).assertTrue(JSON.stringify(result)!=null); - }).catch((error) => { - console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + try { + geolocationm.on('countryCodeChange', function (data) { + console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) ); + }); + } catch (error) { + console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error)); + expect(true).assertEqual(error != null); + } + try { + await geolocationm.getCountryCode().then((result) => { + console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); + expect(true).assertEqual(JSON.stringify(result)!=null); + }).catch((error) => { + console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } catch (error) { + console.info("[lbs_js] getCountryCode promise try err." + JSON.stringify(error)); expect().assertFail(); - }); - geolocationm.off('countryCodeChange', function (data) { - console.info('[lbs_js] countryCodeChange' + JSON.stringify(data)); - done(); - }) + } + try { + geolocationm.off('countryCodeChange', function (data) { + console.info('[lbs_js] countryCodeChange' + JSON.stringify(data)); + }) + } catch (error) { + console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error)); + expect(true).assertEqual(error != null); + } done(); }) -}) + }) +} + diff --git a/location/geolocation_standard/src/main/js/test/List.test.js b/location/geolocation_standard/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..1657b327ec9ed83abd5b363baa460c7c2dae1447 --- /dev/null +++ b/location/geolocation_standard/src/main/js/test/List.test.js @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import geolocationTest_geo5 from './GeocoderMTest.test.js' +import geolocationTest_geo1 from './GeocoderTest.test.js' +import geolocationTest_4 from './GetCountryCode.test.js' +import geolocationTest_6 from './GetCountryCodeM.test.js' +import geolocationTest_geo3 from './LocationTest.test.js' +import geolocationTest_geo7 from './LocationMTest.test.js' +import geolocationTest_geo2 from './SystemLocation.test.js' +export default function testsuite() { + geolocationTest_geo5() + geolocationTest_geo1() + geolocationTest_4() + geolocationTest_6() + geolocationTest_geo3() + geolocationTest_geo7() + geolocationTest_geo2() +} diff --git a/location/geolocation_standard/src/main/js/default/test/LocationMTest.test.js b/location/geolocation_standard/src/main/js/test/LocationMTest.test.js similarity index 54% rename from location/geolocation_standard/src/main/js/default/test/LocationMTest.test.js rename to location/geolocation_standard/src/main/js/test/LocationMTest.test.js index 8528a309ceb5d8b303d532079ea986561059c6ad..e52806a2e08e398d0da3aa27b88716b1bfe0fbf9 100644 --- a/location/geolocation_standard/src/main/js/default/test/LocationMTest.test.js +++ b/location/geolocation_standard/src/main/js/test/LocationMTest.test.js @@ -13,12 +13,12 @@ * limitations under the License. */ - +import geolocation from '@ohos.geolocation'; import geolocationm from '@ohos.geoLocationManager'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' import osaccount from '@ohos.account.osAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 , TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, @@ -38,7 +38,7 @@ async function changedLocationMode(){ let result1 = geolocationm.isLocationEnabled(); console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); if(!result1){ - await geolocationm.requestEnableLocation().then(async(result) => { + await geolocation.requestEnableLocation().then(async(result) => { await sleep(3000); console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); }).catch((error) => { @@ -53,7 +53,7 @@ async function changedLocationMode(){ async function enableLocationSwitch(){ function enableLocationSwitchCallback(){ return new Promise((resolve, reject)=>{ - geolocationm.requestEnableLocation((err, data) => { + geolocation.requestEnableLocation((err, data) => { if (err) { console.info('[lbs_js] requestEnableLocation callback err is : ' + err ); }else { @@ -65,7 +65,6 @@ async function enableLocationSwitch(){ } await enableLocationSwitchCallback(); done(); - } @@ -96,18 +95,23 @@ async function applyPermission() { } } -describe('geolocationTest_geo7', function () { - beforeAll(async function (done) { - console.info('beforeAll case'); - await applyPermission(); - done(); - }) - beforeEach(function () { - console.info('beforeEach case'); - }) - afterEach(function () { - }) +export default function geolocationTest_geo7() { + + + describe('geolocationTest_geo7', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + done(); + }) + + beforeEach(function () { + console.info('beforeEach case'); + }) + afterEach(function () { + }) + /** * @tc.number SUB_HSS_LocationSystem_LocSwitch_0600 @@ -117,10 +121,15 @@ describe('geolocationTest_geo7', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_LocSwitch_0600', 0, function () { - let state = geolocationm.isLocationEnabled(); - console.info('[lbs_js] getLocationSwitchState06 result: ' + JSON.stringify(state)); - expect(state).assertTrue(); + 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); + } catch (error) { + console.info("[lbs_js] getLocationSwitchState06 try err." + JSON.stringify(error)); + expect().assertFail(); + } }); /** @@ -136,60 +145,72 @@ describe('geolocationTest_geo7', function () { var locationServiceState = (state) => { console.log('[lbs_js] locationServiceState: state: ' + JSON.stringify(state)); } - geolocationm.on('locationEnabledChange', locationServiceState); - geolocationm.off('locationEnabledChange', locationServiceState); - expect(true).assertTrue(); + try { + geolocationm.on('locationEnabledChange', locationServiceState); + } catch (error) { + console.info("[lbs_js] locationServiceStateOn07 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationEnabledChange', locationServiceState); + } catch (error) { + console.info("[lbs_js] locationServiceStateOff07 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) /** * @tc.number SUB_HSS_LocationSystem_SingleLoc_1500 * @tc.name Test getCurrentLocation - * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.. + * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_SingleLoc_1500', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 }; - function getCurrentLocationCallback() { - return new Promise((resolve, reject) => { - geolocationm.getCurrentLocation(currentLocationRequest, (err, result) => { - if (err) { - console.info("[lbs_js] getCurrentLocation15 callback err: " + JSON.stringify(err)); - expect(true).assertEqual(err != null); - console.info('[lbs_js] getCurrentLocationCallback reject after'); - done(); - } else { - console.info("[lbs_js] getCurrentLocation15 callback result:" + JSON.stringify(result)); - expect(true).assertEqual(result != null); - resolve(); - } - }); - }) + try { + geolocationm.getCurrentLocation(currentLocationRequest, (err, result) => { + if (err) { + console.info("[lbs_js] getCurrentLocation15 callback err: " + JSON.stringify(err)); + expect(true).assertEqual(err != null); + console.info('[lbs_js] getCurrentLocationCallback reject after'); + done(); + } else { + console.info("[lbs_js] getCurrentLocation15 callback result:" + JSON.stringify(result)); + expect(true).assertEqual(result != null); + } + }); + } catch (error) { + console.info("[lbs_js] getCurrentLocation15 callback try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); } - console.info('[lbs_js] getCurrentLocationCallback start'); - await getCurrentLocationCallback(); + await sleep(1500); done(); }) /** * @tc.number SUB_HSS_LocationSystem_SingleLoc_1600 * @tc.name Test getCurrentLocation - * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.. + * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_SingleLoc_1600', 0, async function (done) { let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation16 promise result ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation16 promise err:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation16 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -203,13 +224,18 @@ describe('geolocationTest_geo7', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_1700', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info("[lbs_js] getCurrentLocation callback17, result: " + JSON.stringify(result)); - expect(true).assertEqual(result != null); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation callback17:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + console.info("[lbs_js] getCurrentLocation callback17, result:" + JSON.stringify(result)); + expect(true).assertEqual(result != null); + }).catch(error => { + console.info('[lbs_js] getCurrentLocation callback17:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation callback17 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) + } done(); }) @@ -223,13 +249,17 @@ describe('geolocationTest_geo7', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_1800', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation18 promise result ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation18 promise err:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation18 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -243,13 +273,17 @@ describe('geolocationTest_geo7', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_1900', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 1000, "maxAccuracy": 0 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation19 promise result:' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation19 promise err:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation18 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -265,19 +299,28 @@ describe('geolocationTest_geo7', function () { it('SUB_HSS_LocationSystem_SingleLoc_2000', 0, async function (done) { let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest2 = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result201 ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation promise err201:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation1901 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - await geolocationm.getCurrentLocation(currentLocationRequest2).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result202 ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation_0002 promise err202:' + JSON.stringify(error)); + } + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation1902 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -291,13 +334,17 @@ describe('geolocationTest_geo7', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_2100', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation21 promise result ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation21 promise err:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation21 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -311,13 +358,17 @@ describe('geolocationTest_geo7', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_2200', 0, async function (done) { let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation22 promise result:' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation22 promise err:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation22 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -331,13 +382,17 @@ describe('geolocationTest_geo7', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_2300', 0, async function (done) { let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result23:' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation promise err23:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation23 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -352,18 +407,28 @@ describe('geolocationTest_geo7', function () { it('SUB_HSS_LocationSystem_SingleLoc_2400', 0, async function (done) { let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 5 }; let currentLocationRequest1 = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 2 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result241 ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation promise err241:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation241 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - 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)); + } + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation242 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) + } done(); }) @@ -379,19 +444,28 @@ describe('geolocationTest_geo7', function () { it('SUB_HSS_LocationSystem_SingleLoc_2500', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": -1 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result251 ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation promise err0251:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation251 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - 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)); + } + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation252 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -406,19 +480,28 @@ describe('geolocationTest_geo7', function () { it('SUB_HSS_LocationSystem_SingleLoc_2600', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result261 ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation promise err261:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation261 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - 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)); + } + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation262 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -433,19 +516,28 @@ describe('geolocationTest_geo7', function () { it('SUB_HSS_LocationSystem_SingleLoc_2700', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": 0, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": -1000, "maxAccuracy": 0 }; - await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result271 ' + JSON.stringify(result)); - }).catch(error => { - console.info('[lbs_js] getCurrentLocation promise err271:' + JSON.stringify(error)); + try { + await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => { + 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); + }); + } catch (error) { + console.info("[lbs_js] getCurrentLocation271 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }); - 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)); + } + 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); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation272 promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -517,8 +609,18 @@ describe('geolocationTest_geo7', function () { console.info('[lbs_js] locationChanger16 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn16 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff16 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -538,8 +640,18 @@ describe('geolocationTest_geo7', function () { console.info('[lbs_js] locationChanger17 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn17 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff17 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -559,8 +671,18 @@ describe('geolocationTest_geo7', function () { console.info('[lbs_js] locationChanger18 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn18 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff18 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -580,8 +702,18 @@ describe('geolocationTest_geo7', function () { console.info('[lbs_js] locationChanger19 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn19 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff19 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -606,10 +738,30 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger202 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange2 !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange1); - geolocationm.on('locationChange', requestInfo, locationChange2); - geolocationm.off('locationChange', locationChange1); - geolocationm.off('locationChange', locationChange2); + try { + geolocationm.on('locationChange', requestInfo, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOn201 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + 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); + } + try { + geolocationm.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOff201 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangerOff202 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -630,8 +782,18 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger21 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn21 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff21 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -652,8 +814,18 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger22 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn22 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff22 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -674,8 +846,18 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger23 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn23 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff23 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -695,8 +877,18 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger24 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn24 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff24 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -716,8 +908,18 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger25 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn25 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff25 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -737,8 +939,18 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger26 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn26 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff26 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -761,13 +973,33 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(locationChange1 !=null); }; var locationChange2 = (location) => { - console.log('[lbs_js] locationChanger282 data:' + JSON.stringify(location)); + console.log('[lbs_js] locationChanger272 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange2 !=null); }; - geolocationm.on('locationChange', requestInfo1, locationChange1); - geolocationm.off('locationChange', locationChange1); - geolocationm.on('locationChange', requestInfo2, locationChange2); - geolocationm.off('locationChange', locationChange2); + try { + geolocationm.on('locationChange', requestInfo1, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOn271 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOff271 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + 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); + } + try { + geolocationm.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangerOff272 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -793,10 +1025,30 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger282 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange2 !=null); }; - geolocationm.on('locationChange', requestInfo1, locationChange1); - geolocationm.off('locationChange', locationChange1); - geolocationm.on('locationChange', requestInfo2, locationChange2); - geolocationm.off('locationChange', locationChange2); + try { + geolocationm.on('locationChange', requestInfo1, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOn281 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOff281 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + 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); + } + try { + geolocationm.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangerOff282 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -822,10 +1074,30 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] locationChanger292 data:' + JSON.stringify(location)); expect(true).assertEqual(locationChange2 !=null); }; - geolocationm.on('locationChange', requestInfo1, locationChange1); - geolocationm.off('locationChange', locationChange1); - geolocationm.on('locationChange', requestInfo2, locationChange2); - geolocationm.off('locationChange', locationChange2); + try { + geolocationm.on('locationChange', requestInfo1, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOn291 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangerOff291 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + 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); + } + try { + geolocationm.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangerOff292 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -845,8 +1117,18 @@ describe('geolocationTest_geo7', function () { console.info('[lbs_js] LastlocationChanger1: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } try { let last =geolocationm.getLastLocation(); console.info('[lbs_js] getLastLocation latitude: ' + result.latitude + @@ -880,7 +1162,12 @@ describe('geolocationTest_geo7', function () { +'altitudes' + data[0].altitudes+' azimuths: ' + data[0].azimuths + 'carrierFrequencies: ' + data[0].carrierFrequencies); } - geolocationm.on('satelliteStatusChange', gnssStatusCb); + try { + geolocationm.on('satelliteStatusChange', gnssStatusCb); + } catch (error) { + console.info("[lbs_js] satelliteStatusOn03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } enableLocationSwitch(); let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, "distanceInterval": 0, "maxAccuracy": 0}; @@ -888,9 +1175,24 @@ describe('geolocationTest_geo7', function () { console.log('[lbs_js] gnsslocationChanger3: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocationm.on('locationChange', requestInfo, locationChange); - geolocationm.off('satelliteStatusChange', gnssStatusCb); - geolocationm.off('locationChange', locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('satelliteStatusChange', gnssStatusCb); + } catch (error) { + console.info("[lbs_js] satelliteStatusOff03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -920,14 +1222,24 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(error !=null); done(); } - geolocationm.on('locationChange', requestInfo, locationChange); + try { + geolocationm.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOn04 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } try { geolocationm.off('nmeaMessage', nmeaCb); } catch (error) { console.info("nmea off err:" + JSON.stringify(error)); expect(true).assertEqual(error !=null); } - geolocationm.off('locationChange', locationChange); + try { + geolocationm.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -945,15 +1257,35 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest1 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false}; - geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest1, cachedLocationsCb1); - geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1); + try { + geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest1, cachedLocationsCb1); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOn071 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOff071 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } var cachedLocationsCb2 = (locations) => { console.log('[lbs_js] cachedGnssLocationsReporting7:locations:' + JSON.stringify(locations)); expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest2 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false}; - geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest2, cachedLocationsCb2); - geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1); + try { + geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest2, cachedLocationsCb2); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOn072 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOff072 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -971,8 +1303,18 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; - geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); + try { + geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOn08 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOff08 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -990,25 +1332,33 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; - let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, - "distanceInterval": 0, "maxAccuracy": 0}; - geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); - function getCachedGnssLocationsSizeCallback(){ - return new Promise((resolve, reject)=>{ - geolocationm.getCachedGnssLocationsSize((err, data) => { - if (err) { - console.info('[lbs_js] getCachedGnssLocationsSize callback err is : ' + JSON.stringify(err)); - expect(true).assertTrue(err != null); - }else { - console.info("[lbs_js] getCachedGnssLocationsSize callback data is: " + JSON.stringify(data)); - expect(true).assertTrue(data != null); - } - resolve(); - }); - }) + try { + geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOn09 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); } - await getCachedGnssLocationsSizeCallback(); + try { + geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOff09 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.getCachedGnssLocationsSize((err, data) => { + if (err) { + console.info('[lbs_js] getCachedGnssLocationsSize09 callback err:' + JSON.stringify(err)); + expect(true).assertEqual(err != null); + }else { + console.info("[lbs_js] getCachedGnssLocationsSize09 callback data:" + JSON.stringify(data)); + expect(true).assertEqual(data != null); + } + }); + } catch (error) { + console.info("[lbs_js] getCachedGnssLocationsSize09 callback try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }) @@ -1026,19 +1376,31 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; - let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, - "distanceInterval": 0, "maxAccuracy": 0}; - geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); - await geolocationm.getCachedGnssLocationsSize().then( (result) => { - console.info('[lbs_js] getCachedGnssLocationsSiz promise '+ JSON.stringify(result)); - expect(true).assertTrue(result != null); - done(); - }).catch((error) => { - console.info("[lbs_js] promise then error." + JSON.stringify(error)); - expect(true).assertTrue(error != null); - done(); - }); + try { + geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOn10 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOff10 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + 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); + }); + } catch (error) { + console.info("[lbs_js] getCachedGnssLocationsSize promise try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + done(); }) /** @@ -1055,25 +1417,33 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; - let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, - "distanceInterval": 0, "maxAccuracy": 0}; - geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); - function flushCachedGnssLocationsCallback(){ - return new Promise((resolve, reject)=>{ - geolocationm.flushCachedGnssLocations((err, data) => { - if (err) { - console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + JSON.stringify(err)); - expect(true).assertTrue(err != null); - }else { - console.info("[lbs_js] flushCachedGnssLocations callback data is: " + JSON.stringify(data)); - expect(true).assertTrue(data); - } - resolve(); - }); - }) + try { + geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); } - await flushCachedGnssLocationsCallback(); + try { + geolocationm.flushCachedGnssLocations((err, data) => { + if (err) { + console.info('[lbs_js] flushCachedGnssLocations11 callback err is : ' + JSON.stringify(err)); + expect(true).assertEqual(err != null); + }else { + console.info("[lbs_js] flushCachedGnssLocations11 callback data is: " + JSON.stringify(data)); + expect(true).assertEqual(data != null); + } + }); + } catch (error) { + console.info("[lbs_js] flushCachedGnssLocations11 callback try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }) @@ -1091,19 +1461,29 @@ describe('geolocationTest_geo7', function () { expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; - let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, - "distanceInterval": 0, "maxAccuracy": 0}; - geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); - await geolocationm.flushCachedGnssLocations().then( (result) => { - console.info('[lbs_js] flushCachedGnssLocations promise '+ JSON.stringify(result)); - expect(true).assertTrue(result); - done(); - }).catch((error) => { - console.info("[lbs_js] promise then error." + JSON.stringify(error)); - expect(true).assertTrue(error != null); - done(); - }); + try { + geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + 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)); + }); + } catch (error) { + console.info("[lbs_js] flushCachedGnssLocations11 promise try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -1119,10 +1499,7 @@ describe('geolocationTest_geo7', function () { await changedLocationMode(); let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence}; - setTimeout(async ()=>{ - let want = (wantAgent) => { - console.log('[lbs_js] wantAgent: ' + JSON.stringify(wantAgent)); - }; + try { geolocationm.on('gnssFenceStatusChange', geofenceRequest, (want) => { if(err){ @@ -1130,8 +1507,12 @@ describe('geolocationTest_geo7', function () { } console.info("[lbs_js] fenceStatusChange2 callback result:" + JSON.stringify(want)); expect(true).assertEqual(want !=null); - done(); }); + } catch (error) { + console.info("[lbs_js] FenceStatusOn2 try error:"+ JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { geolocationm.off('gnssFenceStatusChange',geofenceRequest, (want) => { if(err){ @@ -1140,7 +1521,11 @@ describe('geolocationTest_geo7', function () { console.info("[lbs_js] off fenceStatusChange2 callback result:" + JSON.stringify(want)); expect(true).assertEqual(want !=null); }); - },1000); + } catch (error) { + console.info("[lbs_js] FenceStatusOff2 try error:"+ JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }) @@ -1156,10 +1541,7 @@ describe('geolocationTest_geo7', function () { await changedLocationMode(); let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; let geofenceRequest = {"priority":0x203, "scenario":0x301, "geofence": geofence}; - setTimeout(async ()=>{ - let want = (wantAgent) => { - console.log('[lbs_js] wantAgent: ' + JSON.stringify(wantAgent)); - }; + try { geolocationm.on('gnssFenceStatusChange', geofenceRequest, (want) => { if(err){ @@ -1167,8 +1549,12 @@ describe('geolocationTest_geo7', function () { } console.info("[lbs_js] fenceStatusChange3 callback result: " + JSON.stringify(want)); expect(true).assertEqual(want !=null); - done(); }); + } catch (error) { + console.info("[lbs_js] FenceStatusOn3 try error:"+ JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { geolocationm.off('gnssFenceStatusChange',geofenceRequest, (want) => { if(err){ @@ -1177,7 +1563,14 @@ describe('geolocationTest_geo7', function () { console.info("[lbs_js] off fenceStatusChange3 callback result:" + JSON.stringify(want)); expect(true).assertEqual(want !=null); }); - },1000); + } catch (error) { + console.info("[lbs_js] FenceStatusOff3 try error:"+ JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }) -}) + + }) +} + diff --git a/location/geolocation_standard/src/main/js/default/test/LocationTest.test.js b/location/geolocation_standard/src/main/js/test/LocationTest.test.js similarity index 52% rename from location/geolocation_standard/src/main/js/default/test/LocationTest.test.js rename to location/geolocation_standard/src/main/js/test/LocationTest.test.js index d9e45af0e218c8bc646051b70a6df889d679767c..d869a66ec6a58ae6bef11b425924facb23ffeb0e 100644 --- a/location/geolocation_standard/src/main/js/default/test/LocationTest.test.js +++ b/location/geolocation_standard/src/main/js/test/LocationTest.test.js @@ -18,7 +18,7 @@ import { LocationEventListener } from '@ohos.geolocation'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' import osaccount from '@ohos.account.osAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 , TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, DAILY_LIFE_SERVICE : 0x304 ,NO_POWER : 0x305} @@ -97,18 +97,21 @@ async function applyPermission() { } } -describe('geolocationTest_geo3', function () { - beforeAll(async function (done) { - console.info('beforeAll case'); - await applyPermission(); - done(); - }) +export default function geolocationTest_geo3() { + + describe('geolocationTest_geo3', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + done(); + }) + + beforeEach(function () { + console.info('beforeEach case'); + }) + afterEach(function () { + }) - beforeEach(function () { - console.info('beforeEach case'); - }) - afterEach(function () { - }) /** * @tc.number SUB_HSS_LocationSystem_LocSwitch_0300 @@ -118,16 +121,22 @@ describe('geolocationTest_geo3', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_LocSwitch_0300', 0, async function (done) { - geolocation.isLocationEnabled(async (err, data) => { - if (err) { - console.info('[lbs_js] getLocationSwitchState callback err is : ' + JSON.stringify(err)); - - } else { - console.info("[lbs_js] getLocationSwitchState callback data: " + JSON.stringify(data)); - expect(data).assertTrue(); - } - }) + it('SUB_HSS_LocationSystem_LocSwitch_0300', 0, async function (done) { + try { + geolocation.isLocationEnabled(async (err, data) => { + if (err) { + console.info('[lbs_js] getLocationSwitchState callback err is : ' + JSON.stringify(err)); + + } else { + console.info("[lbs_js] getLocationSwitchState callback data: " + JSON.stringify(data)); + expect(data).assertTrue(); + } + }) + } catch (error) { + console.info("[lbs_js] getLocationSwitchState callback try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }); @@ -140,12 +149,18 @@ describe('geolocationTest_geo3', function () { * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_LocSwitch_0400', 0, async function (done) { - await geolocation.isLocationEnabled().then((result1) => { - console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + JSON.stringify(result1)); - expect(result1).assertTrue(); - }).catch((error) => { + try { + await geolocation.isLocationEnabled().then((result1) => { + console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + JSON.stringify(result1)); + expect(result1).assertTrue(); + }).catch((error) => { + console.info("[lbs_js] getLocationSwitchStateLocSwitch_0004 err." + JSON.stringify(error)); + expect().assertFail(); + }); + } catch (error) { + console.info("[lbs_js] getLocationSwitchState callback try err." + JSON.stringify(error)); expect().assertFail(); - }); + } done(); }); @@ -158,13 +173,22 @@ describe('geolocationTest_geo3', function () { * @tc.level Level 2 */ it('SUB_HSS_LocationSystem_LocSwitch_0500', 0, async function (done) { - console.log('just for overwriting,locationServiceState test need system api '); + console.log('just for overwriting,locationServiceState test need system api'); var locationServiceState = (state) => { console.log('locationServiceState: state: ' + JSON.stringify(state)); } - geolocation.on('locationServiceState', locationServiceState); - geolocation.off('locationServiceState', locationServiceState); - expect(true).assertTrue(); + try { + geolocation.on('locationServiceState', locationServiceState); + } catch (error) { + console.info("[lbs_js] locationServiceStateOn05 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationServiceState', locationServiceState); + } catch (error) { + console.info("[lbs_js] locationServiceStateOff05 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -178,29 +202,22 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0100', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 }; - function getCurrentLocationCallback() { - return new Promise((resolve, reject) => { - geolocation.getCurrentLocation(currentLocationRequest, (err, result) => { - if (err) { - console.info("getCurrentLocation callback err: " + JSON.stringify(err)); - expect(true).assertEqual(err != null); - console.info('getCurrentLocationCallback reject after') - } else { - console.info("getCurrentLocation callback, result: " + JSON.stringify(result)); - expect(true).assertEqual(result != null); - resolve(); - } - }); - }) - } - console.info('getCurrentLocationCallback start'); - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info("getCurrentLocation callback_0003, result: " + JSON.stringify(result)); - expect(true).assertEqual(result != null); - }).catch(error => { - console.info('getCurrentLocation callback_0003:' + JSON.stringify(error)); + try { + geolocation.getCurrentLocation(currentLocationRequest, (err, result) => { + if (err) { + console.info("[lbs_js] getCurrentLocation callback err: " + JSON.stringify(err)); + expect(true).assertEqual(err != null); + console.info('[lbs_js] getCurrentLocationCallback reject after') + } else { + console.info("[lbs_js] getCurrentLocation callback, result: " + JSON.stringify(result)); + expect(true).assertEqual(result != null); + } + }); + } catch (error) { + console.info("[lbs_js] getCurrentLocation callback try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) + } + await sleep(1000); done(); }) @@ -214,13 +231,17 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0200', 0, async function (done) { let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation_0002 promise err:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result ' + JSON.stringify(result)); + }).catch(error => { + console.info('[lbs_js] getCurrentLocation_0002 promise err:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -234,29 +255,18 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0300', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 1000, "maxAccuracy": 10 }; - function getCurrentLocationCallback() { - return new Promise((resolve, reject) => { - geolocation.getCurrentLocation(currentLocationRequest, (err, result) => { - if (err) { - console.info("getCurrentLocation callback_0003 err: " + JSON.stringify(err)); - expect(true).assertEqual(err != null); - console.info('getCurrentLocationCallback reject after') - } else { - console.info("getCurrentLocation callback_0003, result: " + JSON.stringify(result)); - expect(true).assertEqual(result != null); - resolve(); - } - }); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info("[lbs_js] getCurrentLocation callback_0003, result: " + JSON.stringify(result)); + expect(true).assertEqual(result != null); + }).catch(error => { + console.info('[lbs_js] getCurrentLocation callback_0003:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); }) - } - console.info('getCurrentLocationCallback start'); - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info("getCurrentLocation callback_0003, result: " + JSON.stringify(result)); - expect(true).assertEqual(result != null); - }).catch(error => { - console.info('getCurrentLocation callback_0003:' + JSON.stringify(error)); + } catch (error) { + console.info("[lbs_js] getCurrentLocation callback03 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) + } done(); }) @@ -270,13 +280,17 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0400', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result004 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err004:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result004 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err004:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise04 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -290,13 +304,17 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0500', 0, async function (done) { let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 1000, "maxAccuracy": 0 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result005 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err005:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result005 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err005:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise05 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -312,19 +330,28 @@ describe('geolocationTest_geo3', function () { it('SUB_HSS_LocationSystem_SingleLoc_0600', 0, async function (done) { let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest2 = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result0061 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err0061:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result061 ' + JSON.stringify(result)); + }).catch(error => { + console.info('[lbs_js]getCurrentLocation promise err061:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise061 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - await geolocation.getCurrentLocation(currentLocationRequest2).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result0062 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation_0002 promise err0062:' + JSON.stringify(error)); + } + try { + await geolocation.getCurrentLocation(currentLocationRequest2).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result062 ' + JSON.stringify(result)); + }).catch(error => { + console.info('[lbs_js]getCurrentLocation promise err062:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise062 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -338,13 +365,17 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0700', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result007 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err007:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result007 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err007:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise07 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -358,13 +389,17 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0800', 0, async function (done) { let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result010 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err010:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result010 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err010:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise08 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -378,13 +413,17 @@ describe('geolocationTest_geo3', function () { */ it('SUB_HSS_LocationSystem_SingleLoc_0900', 0, async function (done) { let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result009 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err009:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result009 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err009:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise09 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -399,18 +438,28 @@ describe('geolocationTest_geo3', function () { it('SUB_HSS_LocationSystem_SingleLoc_1000', 0, async function (done) { let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 5 }; let currentLocationRequest1 = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 2 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result010 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err010:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result010 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err010:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise101 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result0102 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err0102:' + JSON.stringify(error)); + } + try { + await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result0102 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err0102:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise102 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) + } done(); }) @@ -426,19 +475,28 @@ describe('geolocationTest_geo3', function () { it('SUB_HSS_LocationSystem_SingleLoc_1100', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": -1 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result011 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err011:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result011 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err011:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise111 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result0112 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err0112:' + JSON.stringify(error)); + } + try { + await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result0112 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err0112:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise112 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -453,19 +511,28 @@ describe('geolocationTest_geo3', function () { it('SUB_HSS_LocationSystem_SingleLoc_1200', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result012 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err012:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result012 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err012:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise121 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }) - await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result0122 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err0122:' + JSON.stringify(error)); + } + try { + await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result0122 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err0122:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise122 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -480,19 +547,28 @@ describe('geolocationTest_geo3', function () { it('SUB_HSS_LocationSystem_SingleLoc_1300', 0, async function (done) { let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": 0, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": -1000, "maxAccuracy": 0 }; - await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result0131 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err0122:' + JSON.stringify(error)); + try { + await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result131 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err131:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }); + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise131 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - }); - await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { - console.info('[lbs_js] getCurrentLocation promise result0132 ' + JSON.stringify(result)); - }).catch(error => { - console.info('getCurrentLocation promise err0122:' + JSON.stringify(error)); + } + try { + await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { + console.info('[lbs_js] getCurrentLocation promise result132 ' + JSON.stringify(result)); + }).catch(error => { + console.info('getCurrentLocation promise err132:' + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + }) + } catch (error) { + console.info("[lbs_js] getCurrentLocation promise132 try err." + JSON.stringify(error)); expect(true).assertEqual(JSON.stringify(error) != null); - done(); - }) + } done(); }) @@ -565,8 +641,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn01 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff01 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -586,8 +672,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn02 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff02 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -607,8 +703,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff03 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -628,8 +734,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn04 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff04 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -648,16 +764,36 @@ describe('geolocationTest_geo3', function () { "distanceInterval": 5, "maxAccuracy": 10}; var locationChange1 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange1 !=null); }; var locationChange2 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange2 !=null); }; - geolocation.on('locationChange', requestInfo, locationChange1); - geolocation.on('locationChange', requestInfo, locationChange2); - geolocation.off('locationChange', locationChange1); - geolocation.off('locationChange', locationChange2); + try { + geolocation.on('locationChange', requestInfo, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOn051 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.on('locationChange', requestInfo, locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOn052 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOff051 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOff052 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -678,8 +814,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn07 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff07 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -700,8 +846,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn08 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff08 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -722,8 +878,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn09 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff09 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -743,8 +909,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn10 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff10 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -764,8 +940,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -785,8 +971,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn12 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff12 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -806,16 +1002,36 @@ describe('geolocationTest_geo3', function () { "distanceInterval": 0, "maxAccuracy": 0}; var locationChange1 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange1 !=null); }; var locationChange2 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange2 !=null); }; - geolocation.on('locationChange', requestInfo1, locationChange1); - geolocation.off('locationChange', locationChange1); - geolocation.on('locationChange', requestInfo2, locationChange2); - geolocation.off('locationChange', locationChange2); + try { + geolocation.on('locationChange', requestInfo1, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOn131 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOff131 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.on('locationChange', requestInfo2, locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOn132 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOff132 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -835,16 +1051,36 @@ describe('geolocationTest_geo3', function () { "distanceInterval": 0, "maxAccuracy": 2}; var locationChange1 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange1 !=null); }; var locationChange2 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange2 !=null); }; - geolocation.on('locationChange', requestInfo1, locationChange1); - geolocation.off('locationChange', locationChange1); - geolocation.on('locationChange', requestInfo2, locationChange2); - geolocation.off('locationChange', locationChange2); + try { + geolocation.on('locationChange', requestInfo1, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOn141 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOff141 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.on('locationChange', requestInfo2, locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOn142 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOff142 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -864,16 +1100,36 @@ describe('geolocationTest_geo3', function () { "distanceInterval": 0, "maxAccuracy": -1}; var locationChange1 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange1 !=null); }; var locationChange2 = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); - expect(true).assertEqual(locationChange !=null); + expect(true).assertEqual(locationChange2 !=null); }; - geolocation.on('locationChange', requestInfo1, locationChange1); - geolocation.off('locationChange', locationChange1); - geolocation.on('locationChange', requestInfo2, locationChange2); - geolocation.off('locationChange', locationChange2); + try { + geolocation.on('locationChange', requestInfo1, locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOn151 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange1); + } catch (error) { + console.info("[lbs_js] locationChangeOff151 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.on('locationChange', requestInfo2, locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOn152 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange2); + } catch (error) { + console.info("[lbs_js] locationChangeOff152 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -893,8 +1149,18 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } await geolocation.getLastLocation().then((result) => { console.info('[lbs_js] getLastLocation promise result: ' + JSON.stringify(result)); expect(true).assertEqual(JSON.stringify(result) != null); @@ -928,24 +1194,33 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('locationChange', locationChange); - - function getLastLocationCallback(){ - return new Promise((resolve, reject)=>{ - geolocation.getLastLocation((err, data) => { - if (err) { - console.info('[LastLoc_0002] getLastLocation callback err is : ' + JSON.stringify(err)); - expect(true).assertEqual(err !=null); - } else { - console.info('[LastLoc_0002] getLastLocation callback result: ' + JSON.stringify(data)); - expect(true).assertEqual(data !=null); - } - resolve(); - }); - }) + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); } - await getLastLocationCallback(); + try { + geolocation.getLastLocation((err, data) => { + if (err) { + console.info('[lbs_js] getLastLocation2 callback err:' + JSON.stringify(err)); + expect(true).assertEqual(err !=null); + } else { + console.info('[lbs_js] getLastLocation2 callback result:' + JSON.stringify(data)); + expect(true).assertEqual(data !=null); + } + }); + } catch (error) { + console.info("[lbs_js] getLastLocation2 callback try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }) @@ -967,7 +1242,12 @@ describe('geolocationTest_geo3', function () { +'altitudes' + data[0].altitudes+' azimuths: ' + data[0].azimuths + 'carrierFrequencies: ' + data[0].carrierFrequencies); } - geolocation.on('gnssStatusChange', gnssStatusCb); + try { + geolocation.on('gnssStatusChange', gnssStatusCb); + } catch (error) { + console.info("[lbs_js] gnssStatusChangeOn1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } enableLocationSwitch(); let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, "distanceInterval": 0, "maxAccuracy": 0}; @@ -975,9 +1255,24 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('gnssStatusChange', gnssStatusCb); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('gnssStatusChange', gnssStatusCb); + } catch (error) { + console.info("[lbs_js] gnssStatusChangeOff1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -1000,10 +1295,30 @@ describe('geolocationTest_geo3', function () { console.log('locationChanger: data: ' + JSON.stringify(location)); expect(true).assertEqual(locationChange !=null); }; - geolocation.on('nmeaMessageChange', nmeaCb); - geolocation.on('locationChange', requestInfo, locationChange); - geolocation.off('nmeaMessageChange', nmeaCb); - geolocation.off('locationChange', locationChange); + try { + geolocation.on('nmeaMessageChange', nmeaCb); + } catch (error) { + console.info("[lbs_js] nmeaChangeOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.on('locationChange', requestInfo, locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('nmeaMessageChange', nmeaCb); + } catch (error) { + console.info("[lbs_js] nmeaChangeOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('locationChange', locationChange); + } catch (error) { + console.info("[lbs_js] locationChangeOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -1021,15 +1336,35 @@ describe('geolocationTest_geo3', function () { expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest1 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false}; - geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest1, cachedLocationsCb1); - geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb1); + try { + geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest1, cachedLocationsCb1); + } catch (error) { + console.info("[lbs_js] cachedGnssOn11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb1); + } catch (error) { + console.info("[lbs_js] cachedGnssOff11 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } var cachedLocationsCb2 = (locations) => { console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); expect(true).assertEqual(locations !=null); } var CachedGnssLoactionsRequest2 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false}; - geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest2, cachedLocationsCb2); - geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb1); + try { + geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest2, cachedLocationsCb2); + } catch (error) { + console.info("[lbs_js] cachedGnssOn12 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb1); + } catch (error) { + console.info("[lbs_js] cachedGnssOff12 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -1049,8 +1384,18 @@ describe('geolocationTest_geo3', function () { var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, "distanceInterval": 0, "maxAccuracy": 0}; - geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); + try { + geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -1070,23 +1415,33 @@ describe('geolocationTest_geo3', function () { var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, "distanceInterval": 0, "maxAccuracy": 0}; - geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); - function getCachedGnssLocationsSizeCallback(){ - return new Promise((resolve, reject)=>{ - geolocation.getCachedGnssLocationsSize((err, data) => { - if (err) { - console.info('[lbs_js] getCachedGnssLocationsSize callback err is : ' + JSON.stringify(err)); - expect(true).assertTrue(err != null); - }else { - console.info("[lbs_js] getCachedGnssLocationsSize callback data is: " + JSON.stringify(data)); - expect(true).assertTrue(data != null); - } - resolve(); - }); - }) + try { + geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); } - await getCachedGnssLocationsSizeCallback(); + try { + geolocation.getCachedGnssLocationsSize((err, data) => { + if (err) { + console.info('[lbs_js] getCachedGnssLocationsSize callback err:' + JSON.stringify(err)); + expect(true).assertEqual(err != null); + }else { + console.info("[lbs_js] getCachedGnssLocationsSize callback data is:" + JSON.stringify(data)); + expect(true).assertEqual(data != null); + } + }); + } catch (error) { + console.info("[lbs_js] getCachedGnssLocationsS callback try err:" + JSON.stringify(data)); + expect(true).assertEqual(data != null); + } + await sleep(1000); done(); }) @@ -1106,17 +1461,31 @@ describe('geolocationTest_geo3', function () { var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, "distanceInterval": 0, "maxAccuracy": 0}; - geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); - await geolocation.getCachedGnssLocationsSize().then( (result) => { - console.info('[lbs_js] getCachedGnssLocationsSiz promise '+ JSON.stringify(result)); - expect(true).assertTrue(result != null); - done(); - }).catch((error) => { - console.info("[lbs_js] promise then error." + JSON.stringify(error)); - expect(true).assertTrue(error != null); - done(); - }); + try { + geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + await geolocation.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); + }); + } catch (error) { + console.info("[lbs_js] getCachedGnssLocationsS promise try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + done(); }) /** @@ -1135,23 +1504,33 @@ describe('geolocationTest_geo3', function () { var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, "distanceInterval": 0, "maxAccuracy": 0}; - geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); - function flushCachedGnssLocationsCallback(){ - return new Promise((resolve, reject)=>{ - geolocation.flushCachedGnssLocations((err, data) => { - if (err) { - console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + JSON.stringify(err)); - expect(true).assertTrue(err != null); - }else { - console.info("[lbs_js] flushCachedGnssLocations callback data is: " + JSON.stringify(data)); - expect(true).assertTrue(data); - } - resolve(); - }); - }) + try { + geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); } - await flushCachedGnssLocationsCallback(); + try { + geolocation.flushCachedGnssLocations((err, data) => { + if (err) { + console.info('[lbs_js] flushCachedGnssLocations callback err:' + JSON.stringify(err)); + expect(true).assertEqual(err != null); + }else { + console.info("[lbs_js] flushCachedGnssLocations callback data:" + JSON.stringify(data)); + expect(true).assertEqual(data != null); + } + }); + } catch (error) { + console.info("[lbs_js] flushCachedGnssLoc callback try err: " + JSON.stringify(data)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }) @@ -1171,17 +1550,30 @@ describe('geolocationTest_geo3', function () { var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, "distanceInterval": 0, "maxAccuracy": 0}; - geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); - geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); - await geolocation.flushCachedGnssLocations().then( (result) => { - console.info('[lbs_js] flushCachedGnssLocations promise '+ JSON.stringify(result)); - expect(true).assertTrue(result); - done(); - }).catch((error) => { - console.info("[lbs_js] promise then error." + JSON.stringify(error)); - expect(true).assertTrue(error != null); - done(); - }); + try { + geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); + } catch (error) { + console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { + await geolocation.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)); + expect(true).assertEqual(error != null); + }); + } catch (error) { + console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) @@ -1197,28 +1589,37 @@ describe('geolocationTest_geo3', function () { await changedLocationMode(); let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence}; - setTimeout(async ()=>{ - let want = (wantAgent) => { - console.log('wantAgent: ' + JSON.stringify(wantAgent)); - }; + let want = (wantAgent) => { + console.log('wantAgent: ' + JSON.stringify(wantAgent)); + }; + try { geolocation.on('fenceStatusChange', geofenceRequest, (want) => { if(err){ - return console.info("fenceStatusChange on callback err: " + err); + return console.info("[lbs_js] fenceStatusChangeOn callback err:" + err); } - console.info("fenceStatusChange callback, result: " + JSON.stringify(want)); + console.info("[lbs_js] fenceStatusChange callback result: " + JSON.stringify(want)); expect(true).assertEqual(want !=null); done(); }); + } catch (error) { + console.info("[lbs_js] fenceStatusChangeOn1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { geolocation.off('fenceStatusChange',geofenceRequest, (want) => { if(err){ - return console.info("fenceStatusChange callback err: " + err); + return console.info("[lbs_js] fenceStatusChange callback err:" + err); } - console.info("off fenceStatusChange callback, result: " + JSON.stringify(want)); + console.info("[lbs_js] off fenceStatusChange callback result:" + JSON.stringify(want)); expect(true).assertEqual(want !=null); }); - },1000); + } catch (error) { + console.info("[lbs_js] fenceStatusChangeOff1 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + await sleep(1000); done(); }) @@ -1234,31 +1635,38 @@ describe('geolocationTest_geo3', function () { await changedLocationMode(); let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; let geofenceRequest = {"priority":0x203, "scenario":0x301, "geofence": geofence}; - setTimeout(async ()=>{ - let want = (wantAgent) => { - console.log('wantAgent: ' + JSON.stringify(wantAgent)); - }; + try { geolocation.on('fenceStatusChange', geofenceRequest, (want) => { if(err){ - return console.info("fenceStatusChange on callback err: " + err); + return console.info("[lbs_js] fenceStatusChangeOn callback err:" + err); } - console.info("fenceStatusChange callback, result: " + JSON.stringify(want)); + console.info("[lbs_js] fenceStatusChange callback, result: " + JSON.stringify(want)); expect(true).assertEqual(want !=null); done(); }); + } catch (error) { + console.info("[lbs_js] fenceStatusChangeOn5 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } + try { geolocation.off('fenceStatusChange',geofenceRequest, (want) => { if(err){ - return console.info("fenceStatusChange callback err: " + err); + return console.info("[lbs_js] fenceStatusChange callback err:" + err); } - console.info("off fenceStatusChange callback, result: " + JSON.stringify(want)); + console.info("[lbs_js] fenceStatusChangeOff callback result:" + JSON.stringify(want)); expect(true).assertEqual(want !=null); }); - },1000); + } catch (error) { + console.info("[lbs_js] fenceStatusChangeOff5 try err." + JSON.stringify(error)); + expect(true).assertEqual(JSON.stringify(error) != null); + } done(); }) -}) + + }) +} diff --git a/location/geolocation_standard/src/main/js/default/test/SystemLocation.test.js b/location/geolocation_standard/src/main/js/test/SystemLocation.test.js similarity index 93% rename from location/geolocation_standard/src/main/js/default/test/SystemLocation.test.js rename to location/geolocation_standard/src/main/js/test/SystemLocation.test.js index 0dc9ae32960b9d0c32086b273fd78f3e2de19615..539150484ab6f7fe5ec253d519435ea131a2d705 100644 --- a/location/geolocation_standard/src/main/js/default/test/SystemLocation.test.js +++ b/location/geolocation_standard/src/main/js/test/SystemLocation.test.js @@ -17,7 +17,7 @@ import geolocations from '@system.geolocation'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' import osaccount from '@ohos.account.osAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); @@ -67,20 +67,22 @@ async function applyPermission() { console.info('[permission] case apply permission failed, createAtManager failed'); } } +export default function geolocationTest_geo2() { + + describe('geolocationTest_geo2', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + done(); + }) + beforeEach(async function (done) { + console.info('beforeEach case'); + await changedLocationMode(); + done() + }) + afterEach(function () { + }) -describe('geolocationTest_geo2', function () { - beforeAll(async function (done) { - console.info('beforeAll case'); - await applyPermission(); - done(); - }) - beforeEach(async function (done) { - console.info('beforeEach case'); - await changedLocationMode(); - done() - }) - afterEach(function () { - }) /** * @tc.number SUB_HSS_LocationSystem_systemapi_0100 @@ -90,7 +92,7 @@ describe('geolocationTest_geo2', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_systemapi_0100', 0, async function (done) { + it('SUB_HSS_LocationSystem_systemapi_0100', 0, async function (done) { geolocations.getLocation({ timeout:30000, coordType:'wgs84', @@ -191,7 +193,9 @@ describe('geolocationTest_geo2', function () { expect(true).assertEqual(types.length !=0); }) -}) + + }) +} diff --git a/location/geolocation_standard/src/main/resources/base/element/string.json b/location/geolocation_standard/src/main/resources/base/element/string.json index 14f9c3a9210f78b12caf3b945dc2b2c0f63f7d3d..bd9f96fc039b0fe969e0f19c42baedf7a63edf8e 100644 --- a/location/geolocation_standard/src/main/resources/base/element/string.json +++ b/location/geolocation_standard/src/main/resources/base/element/string.json @@ -7,6 +7,22 @@ { "name": "mainability_description", "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file