From 2897430878a6251679f8b0214cb4cac0d7a77d05 Mon Sep 17 00:00:00 2001 From: m00512953 Date: Tue, 20 Dec 2022 15:16:13 +0800 Subject: [PATCH] mingxihua@huawei.com.cn Signed-off-by: m00512953 --- .../actsonandoffscreentest/Test.json | 17 ++++++++++ .../main/ets/test/OnAndOffScreenTest.test.ets | 10 +++++- .../actsfeatureabilitytest/Test.json | 17 ++++++++++ .../main/js/test/FeatureAbilityJsunit.test.js | 33 +++++++++++-------- .../main/js/test/StartAbilityJsunit.test.js | 25 ++++++++++++++ 5 files changed, 87 insertions(+), 15 deletions(-) diff --git a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/Test.json b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/Test.json index 4553d0904..8250ec410 100644 --- a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/Test.json +++ b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/Test.json @@ -17,6 +17,23 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "param set persist.ace.testmode.enabled 1", + "param set persist.sys.suspend_manager_enabled 0", + "reboot", + "power-shell wakeup", + "hilog -Q pidoff", + "hilog -b DEBUG", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ], + "teardown-command": [ + "param set persist.sys.suspend_manager_enabled 1", + "reboot" + ] } ] } diff --git a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets index 90a15a796..807396215 100644 --- a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets +++ b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets @@ -17,6 +17,9 @@ import commonEvent from '@ohos.commonEvent'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import power from '@ohos.power'; import backgroundTaskManager from '@ohos.backgroundTaskManager'; +import { BY, UiDriver, UiComponent, MatchPattern } from '@ohos.uitest'; + +var driver; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); @@ -39,15 +42,20 @@ export default function OnAndOffScreenTest() { }) id = delayInfo.requestId; console.log(TAG1 + "requestId is : " + id); + driver = await UiDriver.create(); setTimeout(function () { console.log(TAG1 + "beforeAll end"); done(); }, sleepTimeOne); - }) + }) afterAll(async (done) => { console.log(TAG1 + "afterAll called"); backgroundTaskManager.cancelSuspendDelay(id); + let button = await driver.findComponent(BY.text('知道了').enabled(true)); + await sleep(4000); + await button.click(); + await sleep(2000); setTimeout(function () { console.log(TAG1 + "afterAll end"); done(); diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/Test.json b/ability/ability_runtime/featureability/actsfeatureabilitytest/Test.json index f2af25373..2df96f985 100644 --- a/ability/ability_runtime/featureability/actsfeatureabilitytest/Test.json +++ b/ability/ability_runtime/featureability/actsfeatureabilitytest/Test.json @@ -22,6 +22,23 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "param set persist.ace.testmode.enabled 1", + "param set persist.sys.suspend_manager_enabled 0", + "reboot", + "power-shell wakeup", + "hilog -Q pidoff", + "hilog -b DEBUG", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ], + "teardown-command": [ + "param set persist.sys.suspend_manager_enabled 1", + "reboot" + ] } ] } diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js index 573a43c7f..57b6b9573 100644 --- a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js +++ b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js @@ -19,6 +19,9 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from import commonEvent from '@ohos.commonEvent' import particleAbility from '@ohos.ability.particleAbility' import backgroundTaskManager from '@ohos.backgroundTaskManager' +import { BY, UiDriver, UiComponent, MatchPattern } from '@ohos.uitest'; + +var driver; const START_ABILITY_TIMEOUT = 4000; let subscriberInfoActsStartAbility0100 = { @@ -61,20 +64,22 @@ function sleep(time) { export default function actsFeatureAbilityTest() { describe('ActsFeatureAbilityTest', function () { - beforeAll(function() { - - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll called') - }) - - afterAll(function() { - - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll called') + beforeAll(async (done) => { + console.info('beforeAll called') + driver = await UiDriver.create(); + await sleep(2000); + done(); + }) + + afterAll(async (done) => { + let button = await driver.findComponent(BY.text('知道了').enabled(true)); + await sleep(4000); + await button.click(); + await sleep(4000); + setTimeout(function () { + console.info('afterAll called') + done(); + }, 6000); }) beforeEach(function() { diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js index e420df97c..c453f5df3 100644 --- a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js +++ b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js @@ -14,14 +14,39 @@ */ import featureAbility from '@ohos.ability.featureAbility' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import { BY, UiDriver, UiComponent, MatchPattern } from '@ohos.uitest'; + +var driver; let resultCode = 123; let bundleName = 'ohso.act.aafwk'; let mainAbilityName = 'ohos.acts.aafwk.jsap'; const errCode = 1; const errCode1 = 202; + +function sleep(time) { + return new Promise((resolve)=>setTimeout(resolve,time)); +} + export default function startAbilityTest() { describe('StartAbilityTest', function () { + + beforeAll(async (done) => { + driver = await UiDriver.create(); + await sleep(2000); + done(); + }) + + afterAll(async (done) => { + let button = await driver.findComponent(BY.text('知道了').enabled(true)); + await sleep(4000); + await button.click(); + await sleep(2000); + setTimeout(function () { + console.log("afterAll end"); + done(); + }, 6000); + }) afterEach(async function(done) { let wantInfo = { -- GitLab