From 1cbf518fd4e1c2a6bff31a6ef3e39069c9b2137e Mon Sep 17 00:00:00 2001 From: quanli Date: Tue, 29 Nov 2022 22:32:48 +0800 Subject: [PATCH] quanli1@huawei.com Signed-off-by: quanli --- location/geolocation_standard/BUILD.gn | 4 +- location/geolocation_standard/Test.json | 10 +- .../geolocation_standard/src/main/config.json | 279 ++++++++++-------- .../main/js/{default => MainAbility}/app.js | 0 .../{default => MainAbility}/i18n/en-US.json | 0 .../{default => MainAbility}/i18n/zh-CN.json | 0 .../pages/index/index.css | 0 .../pages/index/index.hml | 0 .../pages/index/index.js | 13 - .../src/main/js/TestAbility/app.js | 31 ++ .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 ++ .../main/js/TestAbility/pages/index/index.hml | 5 + .../pages/index/index.js} | 45 +-- .../js/TestRunner/OpenHarmonyTestRunner.js | 59 ++++ .../{default => }/test/GeocoderTest.test.js | 37 ++- .../{default => }/test/GetCountryCode.test.js | 46 +-- .../src/main/js/test/List.test.js | 26 ++ .../{default => }/test/LocationTest.test.js | 34 ++- .../{default => }/test/SystemLocation.test.js | 37 ++- .../main/resources/base/element/string.json | 16 + 22 files changed, 465 insertions(+), 223 deletions(-) rename location/geolocation_standard/src/main/js/{default => MainAbility}/app.js (100%) rename location/geolocation_standard/src/main/js/{default => MainAbility}/i18n/en-US.json (100%) rename location/geolocation_standard/src/main/js/{default => MainAbility}/i18n/zh-CN.json (100%) rename location/geolocation_standard/src/main/js/{default => MainAbility}/pages/index/index.css (100%) rename location/geolocation_standard/src/main/js/{default => MainAbility}/pages/index/index.hml (100%) rename location/geolocation_standard/src/main/js/{default => MainAbility}/pages/index/index.js (67%) create mode 100644 location/geolocation_standard/src/main/js/TestAbility/app.js create mode 100644 location/geolocation_standard/src/main/js/TestAbility/i18n/en-US.json create mode 100644 location/geolocation_standard/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 location/geolocation_standard/src/main/js/TestAbility/pages/index/index.css create mode 100644 location/geolocation_standard/src/main/js/TestAbility/pages/index/index.hml rename location/geolocation_standard/src/main/js/{default/test/List.test.js => TestAbility/pages/index/index.js} (73%) create mode 100644 location/geolocation_standard/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename location/geolocation_standard/src/main/js/{default => }/test/GeocoderTest.test.js (98%) rename location/geolocation_standard/src/main/js/{default => }/test/GetCountryCode.test.js (86%) create mode 100644 location/geolocation_standard/src/main/js/test/List.test.js rename location/geolocation_standard/src/main/js/{default => }/test/LocationTest.test.js (99%) rename location/geolocation_standard/src/main/js/{default => }/test/SystemLocation.test.js (93%) diff --git a/location/geolocation_standard/BUILD.gn b/location/geolocation_standard/BUILD.gn index 582e15fd9..97b6099fc 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 8cc9be6a6..98241964c 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 41bf2df27..5cfc210ba 100644 --- a/location/geolocation_standard/src/main/config.json +++ b/location/geolocation_standard/src/main/config.json @@ -1,120 +1,163 @@ -{ - "app": { - "bundleName": "ohos.acts.location.geolocation.function", - "vendor": "acts", - "version": { - "code": 1000000, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.location.geolocation.function", - "name": ".MyApplication", - "mainAbility": "ohos.acts.location.geolocation.function.MainAbility", - "deviceType": [ +{ + "app": { + "bundleName": "ohos.acts.location.geolocation.function", + "vendor": "acts", + "version": { + "code": 1000000, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.location.geolocation.function", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", + "deviceType": [ "tablet", "default", - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "visible": true, - "name": "ohos.acts.location.geolocation.function.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.LOCATION", - "reason": "need use ohos.permission.LOCATION", - "usedScene": { - "ability": [ - "ohos.acts.location.geolocation.function.MainAbility" - ], - "when": "inuse" - } - }, - { - "name":"ohos.permission.ACCESS_LOCATION", - "reason":"need use ohos.permission.ACCESS_LOCATION", - "usedScene": { - "ability": [ - "ohos.acts.location.geolocation.function.MainAbility" - ], - "when": "inuse" - } - }, - { - "name":"ohos.permission.LOCATION_IN_BACKGROUND", - "reason":"need use ohos.permission.LOCATION_IN_BACKGROUND", - "usedScene": { - "ability": [ - "ohos.acts.location.geolocation.function.MainAbility" - ], - "when": "inuse" - } - }, - { - "name":"ohos.permission.MANAGE_SECURE_SETTINGS", - "reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS", - "usedScene": { - "ability": [ - "ohos.acts.location.geolocation.function.MainAbility" - ], - "when": "inuse" - } - }, - { - "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "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, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.LOCATION", + "reason": "need use ohos.permission.LOCATION", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.ACCESS_LOCATION", + "reason":"need use ohos.permission.ACCESS_LOCATION", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.APPROXIMATELY_LOCATION", + "reason":"need use ohos.permission.APPROXIMATELY_LOCATION", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.LOCATION_IN_BACKGROUND", + "reason":"need use ohos.permission.LOCATION_IN_BACKGROUND", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.MANAGE_SECURE_SETTINGS", + "reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "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/pages/index/index.js b/location/geolocation_standard/src/main/js/MainAbility/pages/index/index.js similarity index 67% rename from location/geolocation_standard/src/main/js/default/pages/index/index.js rename to location/geolocation_standard/src/main/js/MainAbility/pages/index/index.js index 30f42fc04..7f41e27f7 100644 --- a/location/geolocation_standard/src/main/js/default/pages/index/index.js +++ b/location/geolocation_standard/src/main/js/MainAbility/pages/index/index.js @@ -14,7 +14,6 @@ */ import app from '@system.app' -import {Core, ExpectExtend} from 'deccjsunit/index' export default { data: { @@ -25,18 +24,6 @@ export default { }, 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() { }, 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 000000000..cdc31f3dc --- /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 000000000..3cb24b374 --- /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 000000000..c804e32c0 --- /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 000000000..b1bcd4338 --- /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 000000000..f629c71a9 --- /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/test/List.test.js b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.js similarity index 73% rename from location/geolocation_standard/src/main/js/default/test/List.test.js rename to location/geolocation_standard/src/main/js/TestAbility/pages/index/index.js index 413e3e2ee..88b083a7f 100644 --- a/location/geolocation_standard/src/main/js/default/test/List.test.js +++ b/location/geolocation_standard/src/main/js/TestAbility/pages/index/index.js @@ -1,19 +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. - */ - -require('./GeocoderTest.test.js') -require('./GetCountryCode.test.js') -require('./SystemLocation.test.js') -require('./LocationTest.test.js') +/* + * 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 000000000..c5fa8620c --- /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/GeocoderTest.test.js b/location/geolocation_standard/src/main/js/test/GeocoderTest.test.js similarity index 98% 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 fa6cce0c6..946fa3ed8 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,21 +85,24 @@ async function applyPermission() { } } -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(); - }) +export default function geolocationTest_geo1() { + 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 * @tc.name testIsGeoServiceAvailable @@ -108,7 +111,7 @@ describe('geolocationTest_geo1', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_Geo_0100', 0, async function (done) { + 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)); @@ -989,6 +992,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 86% 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 ee78ae619..1f08e2de5 100644 --- a/location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js +++ b/location/geolocation_standard/src/main/js/test/GetCountryCode.test.js @@ -14,11 +14,10 @@ */ import geolocation from '@ohos.geolocation'; import geolocationm from '@ohos.geoLocationManager'; -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)); @@ -77,18 +76,22 @@ 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 @@ -97,15 +100,15 @@ describe('geolocationTest_4', function () { * @tc.type Function * @tc.level since 9 */ - it('SUB_HSS_LocationSystem_CountryCode_0100', 0, async function (done) { + 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); + 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(); @@ -163,8 +166,7 @@ describe('geolocationTest_4', function () { }) 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 000000000..636c11176 --- /dev/null +++ b/location/geolocation_standard/src/main/js/test/List.test.js @@ -0,0 +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 geolocationTest_geo1 from './GeocoderTest.test.js' +import geolocationTest_4 from './GetCountryCode.test.js' +import geolocationTest_geo3 from './LocationTest.test.js' +import geolocationTest_geo2 from './SystemLocation.test.js' +export default function testsuite() { + geolocationTest_geo1() + geolocationTest_4() + geolocationTest_geo3() + geolocationTest_geo2() +} 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 99% 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 068783dd6..dd4a4105c 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,7 +121,7 @@ describe('geolocationTest_geo3', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_LocSwitch_0300', 0, async function (done) { + 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)); @@ -1259,6 +1262,9 @@ describe('geolocationTest_geo3', function () { },1000); 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 cb4abac83..8da80b6ae 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,10 @@ 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 14f9c3a92..bd9f96fc0 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 -- GitLab