diff --git a/ability/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js b/ability/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js index cdc31f3dcf031e2f6a7665d9653e53bb649e21c5..05970690e44eb288b3800d0a10ea9dbb285b7d06 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 2e95331edafb6bc445c76d47367d99252aacbe51..6d25d42aef57a2aabde3bac928d291f6df303ab4 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(); })