From 0804f27ef69f73b96deab97e95a57cef9e47df44 Mon Sep 17 00:00:00 2001 From: gaoxi785 Date: Wed, 16 Aug 2023 16:39:05 +0800 Subject: [PATCH] update config Signed-off-by: gaoxi785 --- .../actscontactstageapitest/AppScope/app.json | 6 +-- .../actscontactstageapitest/Test.json | 2 +- .../entry/src/main/ets/test/List.test.ets | 4 +- .../src/main/ets/test/contactstage.test.ets | 50 +++++++++++-------- .../entry/src/main/module.json | 11 ++-- .../main/resources/base/element/string.json | 48 ++++++------------ 6 files changed, 53 insertions(+), 68 deletions(-) diff --git a/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json b/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json index 16fc772c3..97725aa72 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 dac3c0891..26f815918 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 4b513f0a2..83835cc8d 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 d3645af71..cb1fa94ac 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 e594ac99e..1119bb262 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 836a3cf97..65d8fa5a7 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 -- GitLab