From 3486d9b5589457524db33e62c6456596094420ed Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Tue, 27 Sep 2022 11:55:54 +0800 Subject: [PATCH] =?UTF-8?q?XTS=E5=86=BB=E7=BB=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../src/main/ets/MainAbility/MainAbility.ts | 44 ++++++++++++--- .../entry/src/main/ets/test/Ability.test.ets | 19 +++++++ .../entry/src/main/module.json | 1 + .../src/main/ets/MainAbility/MainAbility.ts | 28 ++++++++-- .../entry/src/main/ets/test/Ability.test.ets | 19 +++++++ .../entry/src/main/module.json | 1 + .../src/main/ets/MainAbility/MainAbility.ts | 56 +++++++++++++++---- .../entry/src/main/ets/test/Ability.test.ets | 18 ++++++ .../AACommandtest/entry/src/main/module.json | 1 + .../src/main/ets/MainAbility/MainAbility.ts | 14 ++++- .../ets/MainAbility/pages/index/index.ets | 12 +--- .../entry/src/main/ets/test/Ability.test.ets | 20 ++++++- .../entry/src/main/module.json | 1 + 13 files changed, 198 insertions(+), 36 deletions(-) diff --git a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/MainAbility/MainAbility.ts index 8d70b1cf1..4e22e378b 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -18,6 +18,18 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' +async function startAbilityTest(TAG, context) { + let wantInfo = { + bundleName: "com.example.aacommandprintonetest", + abilityName: "MainAbility" + } + await context.startAbility(wantInfo).then((data) => { + console.log(TAG + "startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log(TAG + "startAbility err : " + JSON.stringify(err)); + }) +} + export default class MainAbility extends Ability { async onCreate(want, launchParam) { globalThis.abilityContext = this.context; @@ -34,96 +46,112 @@ export default class MainAbility extends Ability { cmd = 'aa test -b com.example.aacommandrelyhap -m entry_test -s class ACTS_AACommand_01_3#ACTS_AACo' + 'mmand_print_01_0100 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0100 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0100 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0100 stdResult = ' + data.stdResult) globalThis.stdResult3 = data.stdResult; console.log('ACTS_AACommand_print_01_0100 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0100', this.context); }) await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AAComm' + 'and_print_01_0200 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0200 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0200 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0200 stdResult = ' + data.stdResult) globalThis.stdResult4 = data.stdResult; console.log('ACTS_AACommand_print_01_0200 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0200', this.context); }) await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_' + 'AACommand_print_01_0300 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0300 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0300 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0300 stdResult = ' + data.stdResult) globalThis.stdResult5 = data.stdResult; console.log('ACTS_AACommand_print_01_0300 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0300', this.context); }) await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AAComma' + 'nd_print_01_0400 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0400 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0400 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0400 stdResult = ' + data.stdResult) globalThis.stdResult6 = data.stdResult; console.log('ACTS_AACommand_print_01_0400 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0400', this.context); }) await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AAComm' + 'and_print_01_0500 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0500 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0500 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0500 stdResult = ' + data.stdResult) globalThis.stdResult7 = data.stdResult; console.log('ACTS_AACommand_print_01_0500 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0500', this.context); }) await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AA' + 'Command_print_01_0600 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0600 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0600 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0600 stdResult = ' + data.stdResult) globalThis.stdResult8 = data.stdResult; console.log('ACTS_AACommand_print_01_0600 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0600', this.context); }) await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ' + 'ACTS_AACommand_01_3#ACTS_AACommand_print_01_0700 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0700 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0700 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0700 stdResult = ' + data.stdResult) globalThis.stdResult9 = data.stdResult; console.log('ACTS_AACommand_print_01_0700 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0700', this.context); }) await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + 'class ACTS_AACommand_01_3#ACTS_AACommand_print_01_0800 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0800 - executeShellCommand: start ') console.log('ACTS_AACommand_print_01_0800 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_print_01_0800 stdResult = ' + data.stdResult) globalThis.stdResult10 = data.stdResult; console.log('ACTS_AACommand_print_01_0800 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_print_01_0800', this.context); }) setTimeout(() => { diff --git a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/test/Ability.test.ets index c2fac5ed2..c19ba35c7 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/ets/test/Ability.test.ets @@ -20,6 +20,25 @@ let msgcopy: any export default function abilityTest() { describe('ActsAACommandPrinOneTest', function () { + + afterEach(async (done) => { + console.log("ActsAACommandPrinOneTest afterEach called"); + let wantInfo = { + bundleName: "com.example.aacommandprintonetest", + abilityName: "MainAbility" + } + await globalThis.abilityTestContext.startAbility(wantInfo).then((data) => { + console.log("ActsAACommandPrinOneTest startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("ActsAACommandPrinOneTest startAbility err : " + JSON.stringify(err)); + }) + + setTimeout(function () { + console.log("ActsAACommandPrinOneTest afterEach end"); + done(); + }, 1000); + }) + /** * @tc.number: ACTS_AACommand_print_0100 * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is diff --git a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json index 05d80b3ff..2fc8e8ab9 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json @@ -21,6 +21,7 @@ "icon": "$media:icon", "label": "$string:MainAbility_label", "visible": true, + "launchType": "singleton", "skills": [ { "entities": [ diff --git a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/MainAbility/MainAbility.ts index 629341379..744320137 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -18,6 +18,18 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' +async function startAbilityTest(TAG, context) { + let wantInfo = { + bundleName: "com.example.aacommandprintsynctest", + abilityName: "MainAbility" + } + await context.startAbility(wantInfo).then((data) => { + console.log(TAG + "startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log(TAG + "startAbility err : " + JSON.stringify(err)); + }) +} + export default class MainAbility extends Ability { async onCreate(want, launchParam) { globalThis.abilityContext = this.context; @@ -34,44 +46,52 @@ export default class MainAbility extends Ability { cmd = 'aa test -b com.example.aacommandprintsync -m entry_test -s class ' + 'ACTS_AACommand_01_3#ACTS_AACommand_printSync_01_0100 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_printSync_01_0100 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_printSync_01_0100 stdResult = ' + data.stdResult) globalThis.stdResult1 = data.stdResult; console.log('ACTS_AACommand_printSync_01_0100 - executeShellCommand: end ') + + await startAbilityTest('ACTS_AACommand_printSync_01_0100', this.context); }) await sleep(3000) cmd = 'aa test -m entry_test -b com.example.aacommandprintsync -s class ' + 'ACTS_AACommand_01_3#ACTS_AACommand_printSync_01_0200 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_printSync_01_0200 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_printSync_01_0200 stdResult = ' + data.stdResult) globalThis.stdResult2 = data.stdResult; console.log('ACTS_AACommand_printSync_01_0200 - executeShellCommand: end ') + + await startAbilityTest('ACTS_AACommand_printSync_01_0200', this.context); }) await sleep(3000) cmd = 'aa test -m entry_test -b com.example.aacommandprintsync -s class ' + 'ACTS_AACommand_01_3#ACTS_AACommand_printSync_01_0300 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_printSync_01_0300 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_printSync_01_0300 stdResult = ' + data.stdResult) globalThis.stdResult3 = data.stdResult; console.log('ACTS_AACommand_printSync_01_0300 - executeShellCommand: end ') + + await startAbilityTest('ACTS_AACommand_printSync_01_0300', this.context); }) await sleep(3000) cmd = 'aa test -m entry_test -b com.example.aacommandprintsync -s class ' + 'ACTS_AACommand_01_3#ACTS_AACommand_printSync_01_0400 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_printSync_01_0400 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_printSync_01_0400 stdResult = ' + data.stdResult) globalThis.stdResult4 = data.stdResult; console.log('ACTS_AACommand_printSync_01_0400 - executeShellCommand: end ') + + await startAbilityTest('ACTS_AACommand_printSync_01_0400', this.context); }) setTimeout(() => { diff --git a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/test/Ability.test.ets index 94d2b11c1..e7fa1a449 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/ets/test/Ability.test.ets @@ -18,6 +18,25 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from let msg: any export default function abilityTest() { describe('ActsAbilityTest', function () { + + afterEach(async (done) => { + console.log("ActsAACommandPrintSyncTest afterEach called"); + let wantInfo = { + bundleName: "com.example.aacommandprintsynctest", + abilityName: "MainAbility" + } + await globalThis.abilityTestContext.startAbility(wantInfo).then((data) => { + console.log("ActsAACommandPrintSyncTest startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("ActsAACommandPrintSyncTest startAbility err : " + JSON.stringify(err)); + }) + + setTimeout(function () { + console.log("ActsAACommandPrintSyncTest afterEach end"); + done(); + }, 1000); + }) + /** * @tc.number: ACTS_AACommand_printSync_0100 * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid diff --git a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json index 96db0c371..44dbabb22 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json @@ -21,6 +21,7 @@ "icon": "$media:icon", "label": "$string:MainAbility_label", "visible": true, + "launchType": "singleton", "skills": [ { "entities": [ diff --git a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/MainAbility/MainAbility.ts index 31dfb90f6..56c4ba65e 100644 --- a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -18,6 +18,18 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' +async function startAbilityTest(TAG, context) { + let wantInfo = { + bundleName: "com.example.aacommandtest", + abilityName: "MainAbility" + } + await context.startAbility(wantInfo).then((data) => { + console.log(TAG + "startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log(TAG + "startAbility err : " + JSON.stringify(err)); + }) +} + export default class MainAbility extends Ability { async onCreate(want, launchParam) { console.log('MainAbility onCreate') @@ -34,11 +46,13 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0700 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_0700 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_0700 stdResult = ' + data.stdResult) globalThis.stdResult1 = data.stdResult; console.log('ACTS_AACommand_finish_01_0700 - executeShellCommand: end ') + + await startAbilityTest('ACTS_AACommand_finish_01_0700', this.context); }) await sleep(4000) @@ -55,12 +69,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ' + 'ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0400 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_0400 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_0400 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_0400 stdResult = ' + data.stdResult) globalThis.stdResult11 = data.stdResult; console.log('ACTS_AACommand_finish_01_0400 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_0400', this.context); }) await sleep(4000) @@ -77,12 +93,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0100 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_0100 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_0100 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_0100 stdResult = ' + data.stdResult) globalThis.stdResult13 = data.stdResult; console.log('ACTS_AACommand_finish_01_0100 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_0100', this.context); }) await sleep(4000) @@ -99,12 +117,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ' + 'ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0500 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_0500 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_0500 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_0500 stdResult = ' + data.stdResult) globalThis.stdResult15 = data.stdResult; console.log('ACTS_AACommand_finish_01_0500 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_0500', this.context); }) await sleep(4000) @@ -121,12 +141,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0600 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_0600 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_0600 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_0600 stdResult = ' + data.stdResult) globalThis.stdResult17 = data.stdResult; console.log('ACTS_AACommand_finish_01_0600 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_0600', this.context); }) await sleep(4000) @@ -143,12 +165,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0900 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_0900 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_0900 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_0900 stdResult = ' + data.stdResult) globalThis.stdResult19 = data.stdResult; console.log('ACTS_AACommand_finish_01_0900 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_0900', this.context); }) await sleep(4000) @@ -165,12 +189,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap ' + '-s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_1300 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_1300 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_1300 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_1300 stdResult = ' + data.stdResult) globalThis.stdResult23 = data.stdResult; console.log('ACTS_AACommand_finish_01_1300 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_1300', this.context); }) await sleep(4000) @@ -187,12 +213,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap ' + '-s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_1400 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_1400 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_1400 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_1400 stdResult = ' + data.stdResult) globalThis.stdResult25 = data.stdResult; console.log('ACTS_AACommand_finish_01_1400 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_1400', this.context); }) await sleep(4000) @@ -209,12 +237,14 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap ' + '-s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_1500 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_1500 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_1500 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_1500 stdResult = ' + data.stdResult) globalThis.stdResult27 = data.stdResult; console.log('ACTS_AACommand_finish_01_1500 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_1500', this.context); }) await sleep(4000) @@ -231,11 +261,13 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap ' + '-s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0300 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_0300 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_0300 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_0300 stdResult = ' + data.stdResult) console.log('ACTS_AACommand_finish_01_0300 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_0300', this.context); }) await sleep(3000) @@ -252,11 +284,13 @@ export default class MainAbility extends Ability { cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap' + ' -s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_1600 -s unittest OpenHarmonyTestRunner' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_finish_01_1600 - executeShellCommand: start ') console.log('ACTS_AACommand_finish_01_1600 start err: ' + JSON.stringify(err)) console.log('ACTS_AACommand_finish_01_1600 stdResult = ' + data.stdResult) console.log('ACTS_AACommand_finish_01_1600 - executeShellCommand: end') + + await startAbilityTest('ACTS_AACommand_finish_01_1600', this.context); }) await sleep(3000) diff --git a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/test/Ability.test.ets index 03f09769d..b71df96d3 100644 --- a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/ets/test/Ability.test.ets @@ -22,6 +22,24 @@ let finishmsg1: any export default function abilityTest() { describe('ACTS_AACommand_Test', function () { + afterEach(async (done) => { + console.log("ActsAACommandTest afterEach called"); + let wantInfo = { + bundleName: "com.example.aacommandtest", + abilityName: "MainAbility" + } + await globalThis.abilityTestContext.startAbility(wantInfo).then((data) => { + console.log("ActsAACommandTest startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("ActsAACommandTest startAbility err : " + JSON.stringify(err)); + }) + + setTimeout(function () { + console.log("ActsAACommandTest afterEach end"); + done(); + }, 1000); + }) + /** * @tc.number: ACTS_AACommand_0100 * @tc.name: -b, -s unittest, -p, -s class, -s level, -s size, -s testType, -s timeout, diff --git a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json index 96db0c371..44dbabb22 100644 --- a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json @@ -21,6 +21,7 @@ "icon": "$media:icon", "label": "$string:MainAbility_label", "visible": true, + "launchType": "singleton", "skills": [ { "entities": [ diff --git a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/MainAbility.ts index 2e7d00667..f59e72750 100644 --- a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -14,6 +14,9 @@ */ import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' export default class MainAbility extends Ability { @@ -21,6 +24,15 @@ export default class MainAbility extends Ability { // Ability is creating, initialize resources for this ability console.log("MainAbility onCreate") globalThis.abilityWant = want; + + globalThis.abilityContext = this.context + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } onDestroy() { @@ -31,7 +43,7 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability console.log("MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } diff --git a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/pages/index/index.ets index b2438dfdf..bc18d0e15 100644 --- a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/pages/index/index.ets +++ b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -14,23 +14,13 @@ */ import router from '@ohos.router'; -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../../../test/List.test' @Entry @Component struct Index { - aboutToAppear(){ - console.info("start run testcase!!!!") - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + aboutToAppear(){ } build() { diff --git a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets index 128868ae0..7fa7e6243 100644 --- a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets @@ -38,6 +38,24 @@ let flagNewWant = false; export default function abilityTest() { describe('ActsNewWantTest', function () { + afterEach(async (done) => { + console.log("ACTS_NewWant afterEach called"); + let wantInfo = { + bundleName: "com.example.newwanttest", + abilityName: "com.example.newwanttest.MainAbility" + } + await globalThis.abilityTestContext.startAbility(wantInfo).then((data) => { + console.log("ACTS_NewWant startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("ACTS_NewWant startAbility err : " + JSON.stringify(err)); + }) + + setTimeout(function () { + console.log("ACTS_NewWant afterEach end"); + done(); + }, 1000); + }) + /** * @tc.number: ACTS_NewWant_Test_0100 * @tc.name: Starting standard Ability for the first time does not trigger onNewWant. @@ -608,4 +626,4 @@ export default function abilityTest() { } }) }) -} +} \ No newline at end of file diff --git a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/module.json b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/module.json index f9254d8ac..05b67da76 100644 --- a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/module.json +++ b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/module.json @@ -21,6 +21,7 @@ "label": "$string:entry_label", "visible": true, "orientation": "portrait", + "launchType": "singleton", "skills": [ { "actions": [ -- GitLab