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 4e22e378bfe8b973538c9094adfd09727be7dcca..f984de4cd352193528ee63eefff89588c94877c9 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 @@ -44,7 +44,7 @@ export default class MainAbility extends Ability { abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - cmd = 'aa test -b com.example.aacommandrelyhap -m entry_test -s class ACTS_AACommand_01_3#ACTS_AACo' + + cmd = 'aa test -b com.example.aacommandrelyhap -m entry_test -s class AACommandPrintOneTest#ACTS_AACo' + 'mmand_print_01_0100 -s unittest OpenHarmonyTestRunner' abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0100 - executeShellCommand: start ') @@ -52,13 +52,12 @@ export default class MainAbility extends Ability { 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) + await sleep(3000) - cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AAComm' + + cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class AACommandPrintOneTest#ACTS_AAComm' + 'and_print_01_0200 -s unittest OpenHarmonyTestRunner' abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0200 - executeShellCommand: start ') @@ -66,13 +65,12 @@ export default class MainAbility extends Ability { 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) + await sleep(3000) - cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_' + + cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class AACommandPrintOneTest#ACTS_' + 'AACommand_print_01_0300 -s unittest OpenHarmonyTestRunner' abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0300 - executeShellCommand: start ') @@ -80,13 +78,12 @@ export default class MainAbility extends Ability { 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) + await sleep(3000) - cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AAComma' + + cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class AACommandPrintOneTest#ACTS_AAComma' + 'nd_print_01_0400 -s unittest OpenHarmonyTestRunner' abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0400 - executeShellCommand: start ') @@ -94,13 +91,12 @@ export default class MainAbility extends Ability { 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) + await sleep(3000) - cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AAComm' + + cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class AACommandPrintOneTest#ACTS_AAComm' + 'and_print_01_0500 -s unittest OpenHarmonyTestRunner' abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0500 - executeShellCommand: start ') @@ -108,13 +104,12 @@ export default class MainAbility extends Ability { 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) + await sleep(3000) - cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ACTS_AACommand_01_3#ACTS_AA' + + cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class AACommandPrintOneTest#ACTS_AA' + 'Command_print_01_0600 -s unittest OpenHarmonyTestRunner' abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.log('ACTS_AACommand_print_01_0600 - executeShellCommand: start ') @@ -122,42 +117,38 @@ export default class MainAbility extends Ability { 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) + await sleep(3000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ' + - 'ACTS_AACommand_01_3#ACTS_AACommand_print_01_0700 -s unittest OpenHarmonyTestRunner' + 'AACommandPrintOneTest#ACTS_AACommand_print_01_0700 -s unittest OpenHarmonyTestRunner' 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) + await sleep(3000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + - 'class ACTS_AACommand_01_3#ACTS_AACommand_print_01_0800 -s unittest OpenHarmonyTestRunner' + 'class AACommandPrintOneTest#ACTS_AACommand_print_01_0800 -s unittest OpenHarmonyTestRunner' 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(() => { Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - - }, 5000) + }, 6000) } onDestroy() { 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 7ac0abaddf4e2cfa0be1396c8b80a5c4f022174b..73d4d156e3461a015e404be55d0383214d193922 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json @@ -33,6 +33,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/AACommandPrint.test.ets similarity index 94% rename from ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/Ability.test.ets rename to ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/AACommandPrint.test.ets index ade57a953a47d5392303409d33e88c8454a77c86..0993cfdf25cebcdeefc02d4f31b3e1a12f704df2 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/AACommandPrint.test.ets @@ -13,13 +13,10 @@ * limitations under the License. */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import { describe, it } from '@ohos/hypium' -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} export default function abilityTest() { - describe('ACTS_AACommand_01_3', function () { + describe('AACommandPrintTest', function () { /** * @tc.number: ACTS_AACommand_printSync_01_0100 * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, @@ -27,7 +24,8 @@ export default function abilityTest() { * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through * the test command. */ - it('ACTS_AACommand_printSync_01_0100', 0, async function (done) { + it('ACTS_AACommand_printSync_01_0100', 0, async function (done) { + done() console.log("ACTS_AACommand_printSync_01_0100 start ====> " ) var msg = '测试日志!@#$%^&*()_+QWE{}|?> callback " ) console.log("ACTS_AACommand_printSync_01_0100 finishTest test end " + "========> callback data: "+JSON.stringify(data)) - done() }) }) @@ -49,6 +46,7 @@ export default function abilityTest() { * the test command. */ it('ACTS_AACommand_printSync_01_0200', 0, async function (done) { + done() var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaa' + '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + @@ -65,7 +63,6 @@ export default function abilityTest() { var finishmsg = 'ACTS_AACommand_printSync_01_0200 end' globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ console.log("ACTS_AACommand_printSync_01_0200 print test end ========> callback " ) - done() }) }) @@ -77,6 +74,7 @@ export default function abilityTest() { * the test command. */ it('ACTS_AACommand_printSync_01_0300', 0, async function (done) { + done() var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaa' + '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + @@ -94,7 +92,6 @@ export default function abilityTest() { var finishmsg = 'ACTS_AACommand_printSync_01_0300 end' globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ console.log("ACTS_AACommand_printSync_01_0300 print test end ========> callback " ) - done() }) }) @@ -106,12 +103,12 @@ export default function abilityTest() { * the test command. */ it('ACTS_AACommand_printSync_01_0400', 0, async function (done) { + done() globalThis.abilityDelegator.printSync(null); console.log("ACTS_AACommand_printSync_01_0300 printSync end ====> " ) var finishmsg = 'ACTS_AACommand_printSync_01_0400 end' globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ console.log("ACTS_AACommand_printSync_01_0400 print test end ========> callback " ) - done() }) }) }) diff --git a/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/List.test.ets index caa07c3911a97aed3eab456f7864b1d430eb4e79..618be73e041efb3f61b7a2ff7fef206b54885303 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/ets/test/List.test.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import abilityTest from './Ability.test' +import abilityTest from './AACommandPrint.test' export default function testsuite() { abilityTest() 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 744320137558c962a8671023d0db94d5fce41791..7ee38c331cb6e4d9b9a1c8fc4b95d49369760da2 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 @@ -45,59 +45,54 @@ export default class MainAbility extends Ability { abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() cmd = 'aa test -b com.example.aacommandprintsync -m entry_test -s class ' + - 'ACTS_AACommand_01_3#ACTS_AACommand_printSync_01_0100 -s unittest OpenHarmonyTestRunner' + 'AACommandPrintTest#ACTS_AACommand_printSync_01_0100 -s unittest OpenHarmonyTestRunner' 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' + 'AACommandPrintTest#ACTS_AACommand_printSync_01_0200 -s unittest OpenHarmonyTestRunner' 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' + 'AACommandPrintTest#ACTS_AACommand_printSync_01_0300 -s unittest OpenHarmonyTestRunner' 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' + 'AACommandPrintTest#ACTS_AACommand_printSync_01_0400 -s unittest OpenHarmonyTestRunner' 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(() => { Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - - }, 5000) + }, 6000) } onDestroy() { 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 34441664894c5461c8ca036386e21a240b10711b..ccf3be6d02ac81841c037f716f2b94934ad6dbb7 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json @@ -33,6 +33,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/AACommand.test.ets b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/AACommand.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0af78671d7d852375ff6ec25ca9bc316538a96c9 --- /dev/null +++ b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/AACommand.test.ets @@ -0,0 +1,280 @@ + +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' + +export default function abilityTest() { + describe('AACommandTest', function () { + /** + * @tc.number: ACTS_AACommand_finishTest_01_0100 + * @tc.name: Each parameter of the test command is valid, and the finishTest interface is called + * in AsyncCallback mode. + * The msg parameter is valid (including Chinese and special characters) and the code parameter + * is valid (1). + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0100', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_0100 finishTest test end ========> callback " ) + + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0200 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback + * mode. The msg parameter is invalid (null) and the code parameter is valid (1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0200', 0, async function (done) { + done(); + var code = globalThis.abilityDelegator.finishTest(null, 1,()=>{ + console.log(" ACTS_AACommand_finish_01_0200 finishTest test end ========> callback " ) + expect().assertFail(); + }) + setTimeout(() => { + console.log('ACTS_AACommand_finish_01_0200 code:'+JSON.stringify(code)) + if(code!=undefined){ + console.log('ACTS_AACommand_finish_01_0200 start failed') + expect().assertFail(); + } + }, 3000) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0300 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback + * mode. The msg parameter is invalid (Undefined) and the code parameter is valid (1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0300', 0, async function (done) { + var code = globalThis.abilityDelegator.finishTest(undefined, 1,()=>{ + console.log(" ACTS_AACommand_finish_01_0300 finishTest test end ========> callback " ) + expect().assertFail(); + }) + setTimeout(() => { + console.log('ACTS_AACommand_finish_01_0300 code:'+JSON.stringify(code)) + if(code!=undefined){ + console.log('ACTS_AACommand_finish_01_0300 start failed') + expect().assertFail(); + } + done(); + }, 3000) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0400 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback + * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter + * is valid (Number.MAX_VALUE) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0400', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_0400 finishTest test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0500 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback + * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter + * is valid (Number.MIN_VALUE) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0500', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_0500 finishTest test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0600 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback + * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter + * is valid (Number.MAX_VALUE+1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0600', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_0600 finishTest test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0700 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback + * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter + * is valid (Number.MIN_VALUE-1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0700', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_0700 finishTest test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0800 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback + * mode. The msg parameter is invalid(including Chinese and special characters) and the + * code parameter is valid (“ABCD”) + * @tc.desc: Verify that the process of the test framework is not stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0800', 0, async function (done) { + done(); + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log(" ACTS_AACommand_finish_01_0800 finishTest test end ========> callback " ) + expect().assertFail(); + }) + + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_0900 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter + * is valid (1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_0900', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?> { + console.log("ACTS_AACommand_finish_01_0900 finishTest test end ========> callback " ) + + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_1000 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is invalid(null) and the code parameter is valid (1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_1000', 0, async function (done) { + done() + globalThis.abilityDelegator.finishTest(null, 1) + + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_1100 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is invalid(undefined) and the code parameter is valid (1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_1100', 0, async function (done) { + done() + globalThis.abilityDelegator.finishTest(undefined, 1) + + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_1200 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter + * is valid (Number.MAX_VALUE) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_1200', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_1200 finishTest test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_1300 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter + * is valid (Number.MIN_VALUE) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_1300', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_1300 finishTest test end ========> callback " ) + done() + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_1400 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter + * is valid (Number.MAX_VALUE+1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_1400', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_1400 finishTest test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_1500 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter + * is valid (Number.MIN_VALUE-1) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_1500', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_finish_01_1500 finishTest test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_finishTest_01_1600 + * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise + * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter + * is valid (ABCD) + * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. + */ + it('ACTS_AACommand_finish_01_1600', 0, async function (done) { + var code = null + var msg = '测试日志!@#$%^&*()_+QWE{}|?> { + console.log('ACTS_AACommand_finish_01_1600 code:'+JSON.stringify(code)) + if(code!=undefined){ + console.log('ACTS_AACommand_finish_01_1600 start failed') + expect().assertFail(); + } + done(); + }, 3000) + }) + }) +}; + diff --git a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/AACommandPrintOne.test.ets b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/AACommandPrintOne.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..295d3c6e9574323c7150a5c779e949e9c88b977c --- /dev/null +++ b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/AACommandPrintOne.test.ets @@ -0,0 +1,215 @@ + +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from '@ohos/hypium' + +export default function abilityTest() { + describe('AACommandPrintOneTest', function () { + /** + * @tc.number: ACTS_AACommand_print_01_0100 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in AsyncCallback mode. The print information includes Chinese, special characters, etc. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through + * the test command. + */ + it('ACTS_AACommand_print_01_0100', 0, async function (done) { + console.log("ACTS_AACommand_print_01_0100 start ====> " ) + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_print_01_0100 print test end ========> callback " ) + console.log("ACTS_AACommand_print_01_0100 print test end ========> callback err: "+JSON.stringify(err) ) + console.log("ACTS_AACommand_print_01_0100 print test end ========> callback data: "+JSON.stringify(data)) + }) + var finishmsg = 'ACTS_AACommand_print_01_0100 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then((data)=>{ + console.log("ACTS_AACommand_print_01_0100 finishTest test end ========> callback " ) + console.log("ACTS_AACommand_print_01_0100 finishTest test end ========> callback data: "+JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_AACommand_print_01_0200 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in AsyncCallback mode. The length of the print message is 1000 characters. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through + * the test command. + */ + it('ACTS_AACommand_print_01_0200', 0, async function (done) { + done() + var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaa' + + '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' + globalThis.abilityDelegator.print(msg,()=>{ + console.log("print test end ========> callback " ) + }) + var finishmsg = 'ACTS_AACommand_print_01_0200 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ + console.log("ACTS_AACommand_print_01_0200 print test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_print_01_0300 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in AsyncCallback mode. The length of the print message is greater than 1000 characters. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through + * the test command. + */ + it('ACTS_AACommand_print_01_0300', 0, async function (done) { + done() + var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' + + 'fffffffffff' + globalThis.abilityDelegator.print(msg,()=>{ + console.log("print test end ========> callback " ) + }) + var finishmsg = 'ACTS_AACommand_print_01_0300 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ + console.log("ACTS_AACommand_print_01_0300 print test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_print_01_0400 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in AsyncCallback mode. print information is null. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through + * the test command. + */ + it('ACTS_AACommand_print_01_0400', 0, async function (done) { + done() + globalThis.abilityDelegator.print(null,()=>{ + console.log("print test end ========> callback " ) + }) + var finishmsg = 'ACTS_AACommand_print_01_0400 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ + console.log("ACTS_AACommand_print_01_0400 print test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_print_01_0500 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in Promise mode. The print information includes Chinese, special characters, etc. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through + * the test command. + */ + it('ACTS_AACommand_print_01_0500', 0, async function (done) { + done() + var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ + console.log("ACTS_AACommand_print_01_0500 print test end ========> callback " ) + }) + var finishmsg = 'ACTS_AACommand_print_01_0500 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ + console.log("ACTS_AACommand_print_01_0500 print test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_print_01_0600 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in Promise mode. The length of the print message is 1000 characters. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally + * through the test command. + */ + it('ACTS_AACommand_print_01_0600', 0, async function (done) { + done() + var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' + globalThis.abilityDelegator.print(msg).then(()=>{ + console.log("ACTS_AACommand_print_01_0600 print test end ========> callback " ) + }) + var finishmsg = 'ACTS_AACommand_print_01_0600 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ + console.log("ACTS_AACommand_print_01_0600 2 print test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_print_01_0700 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in Promise mode. The length of the print message is greater than 1000 characters. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through + * the test command. + */ + it('ACTS_AACommand_print_01_0700', 0, async function (done) { + done() + var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' + + 'fffffffffff' + globalThis.abilityDelegator.print(msg).then(()=>{ + console.log("ACTS_AACommand_print_01_0700 print test end ========> callback " ) + }) + var finishmsg = 'ACTS_AACommand_print_01_0700 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ + console.log("ACTS_AACommand_print_01_0700 2 print test end ========> callback " ) + }) + }) + + /** + * @tc.number: ACTS_AACommand_print_01_0800 + * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is + * called in Promise mode. print information is null. + * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally + * through the test command. + */ + it('ACTS_AACommand_print_01_0800', 0, async function (done) { + done() + globalThis.abilityDelegator.print("").then(()=>{ + console.log("ACTS_AACommand_print_01_0800 print test end ========> callback " ) + }) + var finishmsg = 'ACTS_AACommand_print_01_0800 end' + globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ + console.log("ACTS_AACommand_print_01_0800 2 print test end ========> callback " ) + }) + }) + }) +}; + diff --git a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/Ability.test.ets deleted file mode 100644 index 46b9bfff16ad7538d7f2775ddfaad5c44857896d..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/Ability.test.ets +++ /dev/null @@ -1,488 +0,0 @@ - -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} -export default function abilityTest() { - describe('ACTS_AACommand_01_3', function () { - /** - * @tc.number: ACTS_AACommand_print_01_0100 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in AsyncCallback mode. The print information includes Chinese, special characters, etc. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through - * the test command. - */ - it('ACTS_AACommand_print_01_0100', 0, async function (done) { - console.log("ACTS_AACommand_print_01_0100 start ====> " ) - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_print_01_0100 print test end ========> callback " ) - console.log("ACTS_AACommand_print_01_0100 print test end ========> callback err: "+JSON.stringify(err) ) - console.log("ACTS_AACommand_print_01_0100 print test end ========> callback data: "+JSON.stringify(data)) - }) - await sleep(1000); - var finishmsg = 'ACTS_AACommand_print_01_0100 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then((data)=>{ - console.log("ACTS_AACommand_print_01_0100 finishTest test end ========> callback " ) - console.log("ACTS_AACommand_print_01_0100 finishTest test end ========> callback data: "+JSON.stringify(data)) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_print_01_0200 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in AsyncCallback mode. The length of the print message is 1000 characters. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through - * the test command. - */ - it('ACTS_AACommand_print_01_0200', 0, async function (done) { - var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaa' + - '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' - globalThis.abilityDelegator.print(msg,()=>{ - console.log("print test end ========> callback " ) - }) - await sleep(1000); - var finishmsg = 'ACTS_AACommand_print_01_0200 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ - console.log("ACTS_AACommand_print_01_0200 print test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_print_01_0300 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in AsyncCallback mode. The length of the print message is greater than 1000 characters. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through - * the test command. - */ - it('ACTS_AACommand_print_01_0300', 0, async function (done) { - var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' + - 'fffffffffff' - globalThis.abilityDelegator.print(msg,()=>{ - console.log("print test end ========> callback " ) - }) - await sleep(1000); - var finishmsg = 'ACTS_AACommand_print_01_0300 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ - console.log("ACTS_AACommand_print_01_0300 print test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_print_01_0400 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in AsyncCallback mode. print information is null. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through - * the test command. - */ - it('ACTS_AACommand_print_01_0400', 0, async function (done) { - globalThis.abilityDelegator.print(null,()=>{ - console.log("print test end ========> callback " ) - }) - await sleep(1000); - var finishmsg = 'ACTS_AACommand_print_01_0400 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ - console.log("ACTS_AACommand_print_01_0400 print test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_print_01_0500 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in Promise mode. The print information includes Chinese, special characters, etc. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through - * the test command. - */ - it('ACTS_AACommand_print_01_0500', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_print_01_0500 print test end ========> callback " ) - }) - await sleep(1000); - var finishmsg = 'ACTS_AACommand_print_01_0500 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ - console.log("ACTS_AACommand_print_01_0500 print test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_print_01_0600 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in Promise mode. The length of the print message is 1000 characters. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally - * through the test command. - */ - it('ACTS_AACommand_print_01_0600', 0, async function (done) { - var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' - globalThis.abilityDelegator.print(msg).then(()=>{ - console.log("ACTS_AACommand_print_01_0600 print test end ========> callback " ) - }) - await sleep(1000); - var finishmsg = 'ACTS_AACommand_print_01_0600 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ - console.log("ACTS_AACommand_print_01_0600 2 print test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_print_01_0700 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in Promise mode. The length of the print message is greater than 1000 characters. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally through - * the test command. - */ - it('ACTS_AACommand_print_01_0700', 0, async function (done) { - var msg = '0callbackaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - '9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae' + - 'fffffffffff' - globalThis.abilityDelegator.print(msg).then(()=>{ - console.log("ACTS_AACommand_print_01_0700 print test end ========> callback " ) - }) - await sleep(1000); - var finishmsg = 'ACTS_AACommand_print_01_0700 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ - console.log("ACTS_AACommand_print_01_0700 2 print test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_print_01_0800 - * @tc.name: The -b, -p, -s, -w and other parameters of the test command are valid, and the print interface is - * called in Promise mode. print information is null. - * @tc.desc: Verify that the test framework can be started normally and the logs can be output normally - * through the test command. - */ - it('ACTS_AACommand_print_01_0800', 0, async function (done) { - globalThis.abilityDelegator.print("").then(()=>{ - console.log("ACTS_AACommand_print_01_0800 print test end ========> callback " ) - }) - var finishmsg = 'ACTS_AACommand_print_01_0800 end' - globalThis.abilityDelegator.finishTest(finishmsg, 1).then(()=>{ - console.log("ACTS_AACommand_print_01_0800 2 print test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0100 - * @tc.name: Each parameter of the test command is valid, and the finishTest interface is called - * in AsyncCallback mode. - * The msg parameter is valid (including Chinese and special characters) and the code parameter - * is valid (1). - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0100', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_0100 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0200 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback - * mode. The msg parameter is invalid (null) and the code parameter is valid (1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0200', 0, async function (done) { - setTimeout(() => { - console.log('ACTS_AACommand_finish_01_0200 code:'+JSON.stringify(code)) - if(code!=undefined){ - expect().assertFail(); - } - done(); - }, 3000) - var code = globalThis.abilityDelegator.finishTest(null, 1,()=>{ - console.log(" ACTS_AACommand_finish_01_0200 finishTest test end ========> callback " ) - expect().assertFail(); - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0300 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback - * mode. The msg parameter is invalid (Undefined) and the code parameter is valid (1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0300', 0, async function (done) { - setTimeout(() => { - console.log('ACTS_AACommand_finish_01_0300 code:'+JSON.stringify(code)) - if(code!=undefined){ - expect().assertFail(); - } - done(); - }, 3000) - var code = globalThis.abilityDelegator.finishTest(undefined, 1,()=>{ - console.log(" ACTS_AACommand_finish_01_0300 finishTest test end ========> callback " ) - expect().assertFail(); - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0400 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback - * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter - * is valid (Number.MAX_VALUE) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0400', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_0400 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0500 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback - * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter - * is valid (Number.MIN_VALUE) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0500', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_0500 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0600 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback - * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter - * is valid (Number.MAX_VALUE+1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0600', 0, async function (done) { - - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_0600 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0700 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback - * mode. The msg parameter is invalid(including Chinese and special characters) and the code parameter - * is valid (Number.MIN_VALUE-1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0700', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_0700 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0800 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in AsyncCallback - * mode. The msg parameter is invalid(including Chinese and special characters) and the - * code parameter is valid (“ABCD”) - * @tc.desc: Verify that the process of the test framework is not stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0800', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log(" ACTS_AACommand_finish_01_0800 finishTest test end ========> callback " ) - expect().assertFail(); - }) - await sleep(2000); - done(); - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_0900 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter - * is valid (1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_0900', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?> { - console.log("ACTS_AACommand_finish_01_0900 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_1000 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is invalid(null) and the code parameter is valid (1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_1000', 0, async function (done) { - globalThis.abilityDelegator.finishTest(null, 1) - await sleep(2000); - done() - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_1100 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is invalid(undefined) and the code parameter is valid (1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_1100', 0, async function (done) { - globalThis.abilityDelegator.finishTest(undefined, 1) - await sleep(2000); - done() - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_1200 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter - * is valid (Number.MAX_VALUE) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_1200', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_1200 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_1300 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter - * is valid (Number.MIN_VALUE) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_1300', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_1300 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_1400 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter - * is valid (Number.MAX_VALUE+1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_1400', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_1400 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_1500 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter - * is valid (Number.MIN_VALUE-1) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_1500', 0, async function (done) { - var msg = '测试日志!@#$%^&*()_+QWE{}|?>{ - console.log("ACTS_AACommand_finish_01_1500 finishTest test end ========> callback " ) - done() - }) - }) - - /** - * @tc.number: ACTS_AACommand_finishTest_01_1600 - * @tc.name: The parameters of the test command are valid, and the finishTest interface is called in Promise - * mode. The msg parameter is valid(including Chinese and special characters) and the code parameter - * is valid (ABCD) - * @tc.desc: Verify that the process of the test framework can be stopped by calling this interface. - */ - it('ACTS_AACommand_finish_01_1600', 0, async function (done) { - var code = null - var msg = '测试日志!@#$%^&*()_+QWE{}|?> { - console.log('ACTS_AACommand_finish_01_1600 code:'+JSON.stringify(code)) - if(code!=undefined){ - expect().assertFail(); - } - done(); - }, 3000) - code = globalThis.abilityDelegator.finishTest(msg, 'ABCD') - }) - }) -}; - diff --git a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/List.test.ets index caa07c3911a97aed3eab456f7864b1d430eb4e79..0f3d68850bebe6bd5b81b053316f88d06d23cbfc 100644 --- a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/ets/test/List.test.ets @@ -13,8 +13,10 @@ * limitations under the License. */ -import abilityTest from './Ability.test' +import aaCommandTest from './AACommand.test' +import aaCommandPrintOneTest from './AACommandPrintOne.test' export default function testsuite() { - abilityTest() + aaCommandTest() + aaCommandPrintOneTest() } \ No newline at end of file diff --git a/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/ets/test/Ability.test.ets index 132551b2e4af630cd7b1bae517403a80146373d7..5c48654a0eb771ed5a07afe41a14d11378fa683f 100644 --- a/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/ets/test/Ability.test.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import { describe, it, expect } from '@ohos/hypium' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' export default function abilityTest() { describe('ACTS_AACommand_01_3', function () { 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 7d4790bc0f072477943ae5911ab2ad22bf46f6b5..013e66287e4486bd815cac40b838728abad1a6ee 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 @@ -46,20 +46,19 @@ export default class MainAbility extends Ability { abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + - 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0700 -s unittest OpenHarmonyTestRunner' + 'class AACommandTest#ACTS_AACommand_finish_01_0700 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_0700 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_0700 : data : ' + JSON.stringify(data)); globalThis.stdResult2 = data["stdResult"]; @@ -69,21 +68,20 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ' + - 'ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0400 -s unittest OpenHarmonyTestRunner' + 'AACommandTest#ACTS_AACommand_finish_01_0400 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_0700 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_0700 : data : ' + JSON.stringify(data)); globalThis.stdResult12 = data["stdResult"]; @@ -93,21 +91,20 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + - 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0100 -s unittest OpenHarmonyTestRunner' + 'class AACommandTest#ACTS_AACommand_finish_01_0100 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_0700 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_0700 : data : ' + JSON.stringify(data)); globalThis.stdResult14 = data["stdResult"]; @@ -117,21 +114,20 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s class ' + - 'ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0500 -s unittest OpenHarmonyTestRunner' + 'AACommandTest#ACTS_AACommand_finish_01_0500 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_0500 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_0500 : data : ' + JSON.stringify(data)); globalThis.stdResult16 = data["stdResult"]; @@ -141,21 +137,20 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + - 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0600 -s unittest OpenHarmonyTestRunner' + 'class AACommandTest#ACTS_AACommand_finish_01_0600 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_0600 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_0600 : data : ' + JSON.stringify(data)); globalThis.stdResult18 = data["stdResult"]; @@ -165,21 +160,20 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap -s ' + - 'class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0900 -s unittest OpenHarmonyTestRunner' + 'class AACommandTest#ACTS_AACommand_finish_01_0900 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_0900 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_0900 : data : ' + JSON.stringify(data)); globalThis.stdResult20 = data["stdResult"]; @@ -189,21 +183,20 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap ' + - '-s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_1300 -s unittest OpenHarmonyTestRunner' + '-s class AACommandTest#ACTS_AACommand_finish_01_1300 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_1300 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_1300 : data : ' + JSON.stringify(data)); globalThis.stdResult24 = data["stdResult"]; @@ -213,21 +206,20 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap ' + - '-s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_1400 -s unittest OpenHarmonyTestRunner' + '-s class AACommandTest#ACTS_AACommand_finish_01_1400 -s unittest OpenHarmonyTestRunner' 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_1400 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_1400 : data : ' + JSON.stringify(data)); globalThis.stdResult26 = data["stdResult"]; @@ -237,21 +229,20 @@ export default class MainAbility extends Ability { await sleep(2000) 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, async (err, data) => { + '-s class AACommandTest#ACTS_AACommand_finish_01_1500 -s unittest OpenHarmonyTestRunner' + 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) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_1500 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_1500 : data : ' + JSON.stringify(data)); globalThis.stdResult28 = data["stdResult"]; @@ -261,43 +252,41 @@ export default class MainAbility extends Ability { await sleep(2000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap ' + - '-s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_0300 -s unittest OpenHarmonyTestRunner' + '-s class AACommandTest#ACTS_AACommand_finish_01_0300 -s unittest OpenHarmonyTestRunner' 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) + await sleep(2000) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_0300 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_0300 : data : ' + JSON.stringify(data)); globalThis.stdResult30 = data["stdResult"]; console.info('ACTS_AACommand_finish_01_0300 end'); }) - await sleep(2000) + await sleep(4000) cmd = 'aa test -m entry_test -b com.example.aacommandrelyhap' + - ' -s class ACTS_AACommand_01_3#ACTS_AACommand_finish_01_1600 -s unittest OpenHarmonyTestRunner' + ' -s class AACommandTest#ACTS_AACommand_finish_01_1600 -s unittest OpenHarmonyTestRunner' 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) + await sleep(2000) cmd = 'aa dump -a' - abilityDelegator.executeShellCommand(cmd, (err, data) => { + abilityDelegator.executeShellCommand(cmd, async (err, data) => { console.info('ACTS_AACommand_finish_01_1600 : err : ' + JSON.stringify(err)); console.info('ACTS_AACommand_finish_01_1600 : data : ' + JSON.stringify(data)); globalThis.stdResult34 = data["stdResult"]; @@ -306,7 +295,7 @@ export default class MainAbility extends Ability { setTimeout(() => { Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - }, 5000) + }, 6000) } onDestroy() { 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 34441664894c5461c8ca036386e21a240b10711b..ccf3be6d02ac81841c037f716f2b94934ad6dbb7 100644 --- a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json @@ -33,6 +33,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file