未验证 提交 4f7b5cf9 编写于 作者: O openharmony_ci 提交者: Gitee

!7302 【OpenHarmony】【location】【monthly1018】LBS新框架适配

Merge pull request !7302 from 权力/myfeature2
...@@ -29,7 +29,9 @@ ohos_js_hap_suite("ActslocationJsTest") { ...@@ -29,7 +29,9 @@ ohos_js_hap_suite("ActslocationJsTest") {
subsystem_name = "location" subsystem_name = "location"
} }
ohos_js_assets("geolocation_js_assets") { 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") { ohos_resources("geolocation_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
......
{ {
"description": "Configuration for geolocation js api Tests", "description": "Configuration for geolocation js api Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"bundle-name": "ohos.acts.location.geolocation.function",
"package-name":"ohos.acts.location.geolocation.function",
"test-timeout": "600000", "test-timeout": "600000",
"package": "ohos.acts.location.geolocation.function", "shell-timeout": "60000",
"shell-timeout": "60000" "testcase-timeout": 70000
}, },
"kits": [ "kits": [
{ {
......
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "ohos.acts.location.geolocation.function", "package": "ohos.acts.location.geolocation.function",
"name": ".MyApplication", "name": ".entry",
"mainAbility": "ohos.acts.location.geolocation.function.MainAbility", "mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [ "deviceType": [
"tablet", "tablet",
"default", "default",
...@@ -39,12 +40,29 @@ ...@@ -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, "visible": true,
"name": "ohos.acts.location.geolocation.function.MainAbility", "launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:mainability_description", "description": "$string:TestAbility_desc",
"label": "$string:app_name", "label": "$string:TestAbility_label",
"type": "page", "type": "page",
"visible": true,
"launchType": "standard" "launchType": "standard"
} }
], ],
...@@ -69,6 +87,16 @@ ...@@ -69,6 +87,16 @@
"when": "inuse" "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", "name":"ohos.permission.LOCATION_IN_BACKGROUND",
"reason":"need use ohos.permission.LOCATION_IN_BACKGROUND", "reason":"need use ohos.permission.LOCATION_IN_BACKGROUND",
...@@ -114,7 +142,22 @@ ...@@ -114,7 +142,22 @@
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": false "autoDesignWidth": false
} }
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
} }
]
} }
} }
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
import app from '@system.app' import app from '@system.app'
import {Core, ExpectExtend} from 'deccjsunit/index'
export default { export default {
data: { data: {
...@@ -25,18 +24,6 @@ export default { ...@@ -25,18 +24,6 @@ export default {
}, },
onShow() { onShow() {
console.info('onShow finish') 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() { 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.
*/
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");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.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
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,7 +13,14 @@ ...@@ -13,7 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
require('./GeocoderTest.test.js') export default {
require('./GetCountryCode.test.js') data: {
require('./SystemLocation.test.js') title: ""
require('./LocationTest.test.js') },
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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);
})
}
};
...@@ -18,7 +18,7 @@ import {LocationEventListener} from '@ohos.geolocation'; ...@@ -18,7 +18,7 @@ import {LocationEventListener} from '@ohos.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount' 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 = { let LocationRequestScenario = {
UNSET: 0x300, UNSET: 0x300,
...@@ -85,7 +85,10 @@ async function applyPermission() { ...@@ -85,7 +85,10 @@ async function applyPermission() {
} }
} }
describe('geolocationTest_geo1', function () {
export default function geolocationTest_geo1() {
describe('geolocationTest_geo1', function () {
console.log('#start AccessTokenTests#'); console.log('#start AccessTokenTests#');
beforeAll(async function (done) { beforeAll(async function (done) {
...@@ -989,6 +992,8 @@ describe('geolocationTest_geo1', function () { ...@@ -989,6 +992,8 @@ describe('geolocationTest_geo1', function () {
} }
done(); done();
}) })
})
})
}
...@@ -14,11 +14,10 @@ ...@@ -14,11 +14,10 @@
*/ */
import geolocation from '@ohos.geolocation'; import geolocation from '@ohos.geolocation';
import geolocationm from '@ohos.geoLocationManager'; import geolocationm from '@ohos.geoLocationManager';
import geolocations from '@system.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount' 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) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
...@@ -77,7 +76,10 @@ let CountryCodeType = { ...@@ -77,7 +76,10 @@ let CountryCodeType = {
COUNTRY_CODE_FROM_NETWORK:4, COUNTRY_CODE_FROM_NETWORK:4,
} }
describe('geolocationTest_4', function () { export default function geolocationTest_4() {
describe('geolocationTest_4', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
console.info('beforeAll case'); console.info('beforeAll case');
await applyPermission(); await applyPermission();
...@@ -90,6 +92,7 @@ describe('geolocationTest_4', function () { ...@@ -90,6 +92,7 @@ describe('geolocationTest_4', function () {
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0100 * @tc.number SUB_HSS_LocationSystem_CountryCode_0100
* @tc.name Test getCountryCode * @tc.name Test getCountryCode
...@@ -102,10 +105,10 @@ describe('geolocationTest_4', function () { ...@@ -102,10 +105,10 @@ describe('geolocationTest_4', function () {
console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result));
console.info("[lbs_js] country :" + result.country); console.info("[lbs_js] country :" + result.country);
console.info("[lbs_js] type: " + result.type); console.info("[lbs_js] type: " + result.type);
expect(true).assertTrue(JSON.stringify(result)==CountryCodeType.COUNTRY_CODE_FROM_LOCALE); expect(true).assertEqual(JSON.stringify(result.type)==CountryCodeType.COUNTRY_CODE_FROM_LOCALE);
expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_SIM); expect(true).assertEqual(JSON.stringify(result.type)!=CountryCodeType.COUNTRY_CODE_FROM_SIM);
expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_LOCATION); expect(true).assertEqual(JSON.stringify(result.type)!=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_NETWORK);
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error)); console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
...@@ -164,7 +167,6 @@ describe('geolocationTest_4', function () { ...@@ -164,7 +167,6 @@ describe('geolocationTest_4', function () {
done(); done();
}) })
}) })
}
/*
* 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()
}
...@@ -18,7 +18,7 @@ import { LocationEventListener } from '@ohos.geolocation'; ...@@ -18,7 +18,7 @@ import { LocationEventListener } from '@ohos.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount' 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 , let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 ,
TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303,
DAILY_LIFE_SERVICE : 0x304 ,NO_POWER : 0x305} DAILY_LIFE_SERVICE : 0x304 ,NO_POWER : 0x305}
...@@ -97,7 +97,9 @@ async function applyPermission() { ...@@ -97,7 +97,9 @@ async function applyPermission() {
} }
} }
describe('geolocationTest_geo3', function () { export default function geolocationTest_geo3() {
describe('geolocationTest_geo3', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
console.info('beforeAll case'); console.info('beforeAll case');
await applyPermission(); await applyPermission();
...@@ -110,6 +112,7 @@ describe('geolocationTest_geo3', function () { ...@@ -110,6 +112,7 @@ describe('geolocationTest_geo3', function () {
afterEach(function () { afterEach(function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocSwitch_0300 * @tc.number SUB_HSS_LocationSystem_LocSwitch_0300
* @tc.name Test requestrequestEnableLocation api * @tc.name Test requestrequestEnableLocation api
...@@ -1259,6 +1262,9 @@ describe('geolocationTest_geo3', function () { ...@@ -1259,6 +1262,9 @@ describe('geolocationTest_geo3', function () {
},1000); },1000);
done(); done();
}) })
})
})
}
...@@ -17,7 +17,7 @@ import geolocations from '@system.geolocation'; ...@@ -17,7 +17,7 @@ import geolocations from '@system.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount' 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) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
...@@ -67,8 +67,9 @@ async function applyPermission() { ...@@ -67,8 +67,9 @@ async function applyPermission() {
console.info('[permission] case apply permission failed, createAtManager failed'); console.info('[permission] case apply permission failed, createAtManager failed');
} }
} }
export default function geolocationTest_geo2() {
describe('geolocationTest_geo2', function () { describe('geolocationTest_geo2', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
console.info('beforeAll case'); console.info('beforeAll case');
await applyPermission(); await applyPermission();
...@@ -82,6 +83,7 @@ describe('geolocationTest_geo2', function () { ...@@ -82,6 +83,7 @@ describe('geolocationTest_geo2', function () {
afterEach(function () { afterEach(function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_systemapi_0100 * @tc.number SUB_HSS_LocationSystem_systemapi_0100
* @tc.name Test getLocation * @tc.name Test getLocation
...@@ -191,7 +193,10 @@ describe('geolocationTest_geo2', function () { ...@@ -191,7 +193,10 @@ describe('geolocationTest_geo2', function () {
expect(true).assertEqual(types.length !=0); expect(true).assertEqual(types.length !=0);
}) })
})
})
}
......
...@@ -7,6 +7,22 @@ ...@@ -7,6 +7,22 @@
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability" "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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册