From 862d196440cd45272caa4a7d6b2dec9e35e08113 Mon Sep 17 00:00:00 2001 From: du-zhihai Date: Wed, 16 Nov 2022 16:42:58 +0800 Subject: [PATCH] =?UTF-8?q?continuationManager=E6=B5=8B=E8=AF=95=E5=A5=97?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E7=82=B9=E5=87=BB=E6=8E=88?= =?UTF-8?q?=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: du-zhihai Change-Id: If0fa02a4cee8cd0487473836e7c0cabb722591dd --- .../src/main/js/TestAbility/app.js | 14 +++++++++++++ .../js/test/ContinuationManagerJsunit.test.js | 21 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/ability/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js b/ability/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js index cdc31f3dc..05970690e 100644 --- a/ability/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js +++ b/ability/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js @@ -17,6 +17,19 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' +import featureAbility from '@ohos.ability.featureAbility'; + +async function requestPermission() { + try { + let context = featureAbility.getContext(); + await context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, (data) => { + console.info('TestApplication requestPermission data: ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('TestApplication permission' + JSON.stringify(err)); + } +} + export default { onCreate() { console.info('TestApplication onCreate') @@ -24,6 +37,7 @@ export default { var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() console.info('start run testcase!!!') Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + requestPermission() }, onDestroy() { console.info("TestApplication onDestroy"); diff --git a/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js b/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js index 2e95331ed..6d25d42ae 100644 --- a/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js +++ b/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js @@ -13,6 +13,7 @@ * limitations under the License. */ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import { UiDriver, BY } from '@ohos.uitest' import continuationManager from '@ohos.continuation.continuationManager'; const TEST_DEVICE_ID = "test_deviceId"; @@ -24,6 +25,26 @@ describe('continuationManagerTest', function() { beforeAll(async function (done) { console.info('beforeAll'); + var driver = UiDriver.create() + await driver.delayMs(2000); + + var data_sync_allow = await driver.findComponent(BY.text("允许")) + await driver.delayMs(1000) + var wait_count = 0 + while (data_sync_allow == null || data_sync_allow == undefined) { + data_sync_allow = await driver.findComponent(BY.text("允许")) + wait_count += 1 + await driver.delayMs(1000) + if (wait_count == 3) { + break + } + } + if (data_sync_allow == null) { + console.info('应用非首次开启') + } else { + await data_sync_allow.click() + console.log('点击多设备授权框的允许按钮') + } done(); }) -- GitLab