diff --git a/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json b/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json index 16fc772c301a706d68fdce167a2815d8b532f1a6..97725aa72d91460a6d7df07626058fdff6cb4be1 100644 --- a/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json +++ b/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json @@ -1,15 +1,11 @@ { "app": { "bundleName": "com.example.actscontactstageapitest", - "vendor": "huawei", + "vendor": "example", "versionCode": 1000000, "versionName": "1.0.0", - "debug": true, "icon": "$media:icon", "label": "$string:app_name", - "description": "$string:description_application", - "keepAlive": true, - "singleUser": true, "minAPIVersion": 10, "targetAPIVersion": 10, "car": { diff --git a/telephony/telephonyjstest/actscontactstageapitest/Test.json b/telephony/telephonyjstest/actscontactstageapitest/Test.json index dac3c0891951eb4d2021e696317795ff13e127fa..26f8159182548434ede4726426c136ef5139d06c 100644 --- a/telephony/telephonyjstest/actscontactstageapitest/Test.json +++ b/telephony/telephonyjstest/actscontactstageapitest/Test.json @@ -4,7 +4,7 @@ "type": "OHJSUnitTest", "test-timeout": "600000", "bundle-name": "com.example.actscontactstageapitest", - "module-name": "entry", + "module-name": "entry_test", "shell-timeout": "600000", "testcase-timeout": 70000 }, diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/List.test.ets b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/List.test.ets index 4b513f0a276534ea55b901ba67d7ddbc6e0562dd..83835cc8dc527e41ebc2020de263283951886764 100644 --- a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/List.test.ets +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/List.test.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import contactstage from './contactstage.test' +import contactStage from './contactstage.test'; export default function testsuite() { - contactstage(); + contactStage(); } \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/contactstage.test.ets b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/contactstage.test.ets index d3645af71192ab19adb495f418b183f6aa762a85..cb1fa94ac764659d77275ef2ad0348e3d8383e4b 100644 --- a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/contactstage.test.ets +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/contactstage.test.ets @@ -15,7 +15,8 @@ import contact from '@ohos.contact'; import { afterAll, beforeAll, describe, expect, it } from '@ohos/hypium'; -import { Driver, ON } from '@ohos.UiTest'; +import uitest from '@ohos.UiTest'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' export default function ContactInterfaceStageTest() { @@ -30,27 +31,36 @@ export default function ContactInterfaceStageTest() { } } - async function driveFn() { - console.info("come in driveFn"); - let driver = Driver.create(); - console.info("driver is " + JSON.stringify(driver)); - sleep(2000); - let button = await driver.findComponent(ON.text('允许')); - console.info("button is " + JSON.stringify(button)); - await button.click(); - sleep(5000); - } + beforeAll( async function () { + console.info("beforeAll case"); + try { + let permissions = ["ohos.permission.WRITE_CONTACTS", "ohos.permission.READ_CONTACTS"]; + let atManager = abilityAccessCtrl.createAtManager(); + atManager.requestPermissionsFromUser(globalThis.context, permissions, (err, result) => { + if (err) { + console.info('getPermission failed: ' + JSON.stringify(err)); + } else { + console.info('getPermission suc: ' + JSON.stringify(result)); + } + }); - beforeAll(async function () { - var permissions = ["ohos.permission.WRITE_CONTACTS", "ohos.permission.READ_CONTACTS"]; - //通过stage方式弹窗 - featureAbility.getContext().requestPermissionsFromUser(permissions, 0, () => { - console.info("start requestPermissionsFromUser"); - }); - for (let i = 0; i < 2; i++) { - await driveFn(); - console.log("get user_grant permission"); + let driver = await uitest.Driver.create(); + sleep(500); + + for (let i = 0; i < 5; i++) { + await sleep(500); + console.info("driver is " + JSON.stringify(driver)); + let button = await driver.findComponent(uitest.ON.text('允许')); + if (button != undefined) { + console.info("button is " + JSON.stringify(button)); + await button.click(); + } + } + console.info("getPermission end"); + } catch (error) { + console.info(`getPermission failed, error: ${error}`); } + sleep(3000); }); afterAll(async function () { diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/module.json b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/module.json index e594ac99e8d29b3e4f2f168afd53272d9516eb2d..1119bb26278669f36918098794ad030ecd36a7af 100644 --- a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/module.json +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/module.json @@ -2,7 +2,7 @@ "module": { "name": "entry_test", "type": "feature", - "description": "$string:MainAbility_label", + "description": "$string:module_test_desc", "mainElement": "TestAbility", "deviceTypes": [ "tablet", @@ -17,13 +17,12 @@ { "name": "TestAbility", "srcEntrance": "./ets/TestAbility/TestAbility.ets", - "description": "$string:MainAbility_label", + "description": "$string:TestAbility_desc", "icon": "$media:icon", - "label": "$string:entry_label", + "label": "$string:TestAbility_label", + "exported": true, "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:white", - "visible": true, - "orientation": "portrait", + "startWindowBackground": "$color:start_window_background", "skills": [ { "entities": [ diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/string.json index 836a3cf9761c3d14e20d008c64729aa3d1277b96..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c 100644 --- a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/string.json +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/string.json @@ -1,36 +1,16 @@ { - "string": [ - { - "name": "phone_entry_dsc", - "value": "i am an entry for phone" - }, - { - "name": "phone_entry_main", - "value": "the phone entry ability" - }, - { - "name": "entry_label", - "value": "ActsContactStageAPITest" - }, - { - "name": "form_description", - "value": "my form" - }, - { - "name": "description_application", - "value": "demo for test" - }, - { - "name": "entry_desc", - "value": "description" - }, - { - "name": "MainAbility_desc", - "value": "description" - }, - { - "name": "MainAbility_label", - "value": "label" - } + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } ] -} +} \ No newline at end of file