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 8d70b1cf1cd684ad5b315a5c920feafebcb118d4..4e22e378bfe8b973538c9094adfd09727be7dcca 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 c2fac5ed2fe30c841f1a6e75a145d217b399b31e..c19ba35c77d451510ef5ea554aa26d6967b3df48 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 05d80b3ffb7a5dc4712aeb00c20f51800315942f..2fc8e8ab925214858fd19c090ec73c032d3eb31d 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 62934137965cf3c86ca1e7060cd19d1ba6b745b3..744320137558c962a8671023d0db94d5fce41791 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 94d2b11c1bc35f7490503e08a69ac3e83c8787ed..e7fa1a4492b001dc0aae7bcc5baf11fdb3bbf29f 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 96db0c371f6341dbf2ed7025e2dcedd77b341fac..44dbabb227fdd0c43fe8630d0cfd1229fa2d1078 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 31dfb90f624a077dc289f59fe3915dcc19cd8e50..56c4ba65eb101eb99263606b9b2a377cd538db39 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 03f09769d3c6d166dfefb7a864a0fb7c560a3bb4..b71df96d39d3c6ceff0abeca673347c560be2902 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 96db0c371f6341dbf2ed7025e2dcedd77b341fac..44dbabb227fdd0c43fe8630d0cfd1229fa2d1078 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 2e7d00667eda224bc5e25c2eab34ad1987b1aa56..f59e7275010954155d0cf84c42d690d9cb308f88 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 b2438dfdf6b68001495268bff1bc2cdb5ab6c01d..bc18d0e15e33ca45d70f69187330e712eba1d974 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 128868ae0b91e34b653b1a1317feb78967c5287c..7fa7e6243d2d3270b1fc7807f546b64bfcdcba40 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 f9254d8acc7aa5c585ea9ee873777d53cb263bb9..05b67da76ef34ed88d676817d024a8254f06dcc4 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": [