From 9293e18e2af53391f10dadc2862fab94330a54d8 Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Wed, 10 Aug 2022 13:14:51 +0800 Subject: [PATCH] =?UTF-8?q?XTS=E6=B5=8B=E8=AF=95=E5=A5=97=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=96=B0=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../amsabilitymultiinstancetest/Test.json | 10 +- .../ets/TestRunner/OpenHarmonyTestRunner.ts | 78 ++ .../entry/src/main/ets/pages/index.ets | 64 -- .../entry/src/main/ets/pages/index/index.ets | 31 +- .../entry/src/main/ets/pages/second.ets | 43 -- .../entry/src/main/ets/test/Ability.test.ets | 3 +- .../entry/src/main/ets/test/List.test.ets | 4 +- .../actsabilitydelegatorcase/BUILD.gn | 6 +- .../actsabilitydelegatorcase/Test.json | 10 +- .../entry/src/main/config.json | 31 +- .../main/js/{default => MainAbility}/app.js | 0 .../{default => MainAbility}/i18n/en-US.json | 0 .../{default => MainAbility}/i18n/zh-CN.json | 0 .../pages/index/index.css | 0 .../pages/index/index.hml | 0 .../pages/index/index.js | 0 .../entry/src/main/js/TestAbility/app.js | 31 + .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 50 ++ .../main/js/TestAbility/pages/index/index.hml | 21 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 ++ .../test/ActsAbilityDelegatorCaseTest.test.js | 666 +++++++++--------- .../entry/src/main/js/test/List.test.js | 6 +- .../resources/base/element/string.json | 8 + .../{js => }/resources/base/media/icon.png | Bin .../actsamsstartabilitytest/Test.json | 10 +- .../ets/TestRunner/OpenHarmonyTestRunner.ts | 78 ++ .../entry/src/main/ets/pages/index/index.ets | 30 +- .../entry/src/main/ets/test/Ability.test.ets | 2 +- .../entry/src/main/ets/test/List.test.ets | 4 +- 32 files changed, 781 insertions(+), 506 deletions(-) create mode 100644 ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts delete mode 100644 ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.ets delete mode 100644 ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second.ets rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/{default => MainAbility}/app.js (100%) rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/{default => MainAbility}/i18n/en-US.json (100%) rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/{default => MainAbility}/i18n/zh-CN.json (100%) rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/{default => MainAbility}/pages/index/index.css (100%) rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/{default => MainAbility}/pages/index/index.hml (100%) rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/{default => MainAbility}/pages/index/index.js (100%) create mode 100644 ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/app.js create mode 100644 ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/i18n/en-US.json create mode 100644 ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.css create mode 100644 ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.hml create mode 100644 ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.js create mode 100644 ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/{js => }/resources/base/element/string.json (54%) rename ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/{js => }/resources/base/media/icon.png (100%) create mode 100644 ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/Test.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/Test.json index ab88a5292..46a251ec0 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/Test.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "500000", - "package": "com.example.abilitymultiinstance", - "shell-timeout": "300000" + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.abilitymultiinstance", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..70dcf2d62 --- /dev/null +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.abilitymultiinstance.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.ets deleted file mode 100644 index 4b3495d6f..000000000 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.ets +++ /dev/null @@ -1,64 +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 file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear() { - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters['timeout'] = 10000; - configService.setConfig(globalThis.abilityWant.parameters) - testsuite(globalThis.abilityContext) - core.execute() - } - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Test App') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets index 37b86f509..8104a9e40 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets @@ -12,34 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" +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!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - testsuite(globalThis.abilityContext) - core.execute() + let abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second.ets deleted file mode 100644 index 33d9ae452..000000000 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second.ets +++ /dev/null @@ -1,43 +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 router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets index c58111a32..8b530aded 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium" import commonEvent from '@ohos.commonEvent' let subscriberInfoMultiInstance = { @@ -100,7 +100,6 @@ export default function abilityTest(abilityContext) { console.log('ACTS_AbilityMultiInstance_Single_0100==== + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.js b/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..d94b75c08 --- /dev/null +++ b/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..b9e78ce7c --- /dev/null +++ b/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/ActsAbilityDelegatorCaseTest.test.js b/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/ActsAbilityDelegatorCaseTest.test.js index f566346d9..134609305 100644 --- a/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/ActsAbilityDelegatorCaseTest.test.js +++ b/ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/ActsAbilityDelegatorCaseTest.test.js @@ -12,135 +12,170 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import featureAbility from '@ohos.ability.featureAbility' import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import bundle from '@ohos.bundle' -describe('ActsStServiceAbilityTest', function () { - let gSetTimeout = 1000 - beforeAll(async (done) => { - console.debug('= ACTS_AbeforeAll 1812 ==== { - setTimeout(function () { - done(); - }, gSetTimeout); - }) - afterEach(async (done) => { - setTimeout(function () { - done(); - }, gSetTimeout); - }) - afterAll((done) => { - console.debug('= ACTS_AAAfterAll ==== { + console.debug('= ACTS_AbeforeAll 1812 ==== { + setTimeout(function () { done(); - } - var cmd = 'pwd' - var escresult = '/system/app' - var AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() - AbilityDelegator.executeShellCommand(cmd, (err, data) => { - clearTimeout(currentAlertTimeout); - console.log('ACTS_AExecuteShellCommand_Callback_0100 - executeShellCommand: start ') - - console.log('ACTS_AExecuteShellCommand_Callback_0100 stdResult = ' + data.stdResult) - var i = data.stdResult.indexOf('/system/app'); - console.log('ACTS_AExecuteShellCommand_Callback_0100 query string i = ' + i); - expect(i == -1).assertEqual(false); + }, gSetTimeout); + }) + afterEach(async (done) => { + setTimeout(function () { + done(); + }, gSetTimeout); + }) + afterAll((done) => { + console.debug('= ACTS_AAAfterAll ==== { + clearTimeout(currentAlertTimeout); + console.log('ACTS_AExecuteShellCommand_Callback_0100 data: ' + JSON.stringify(data)) - console.log('ACTS_AExecuteShellCommand_Callback_0100 - executeShellCommand: end') + result = data.stdResult.replace(/[\r\n]/g,""); + console.log('ACTS_AExecuteShellCommand_Callback_0100 stdResult = ' + data.stdResult) + expect(result).assertEqual('test'); - done() - }) - } catch (error) { - clearTimeout(currentAlertTimeout); - console.log("ACTS_AExecuteShellCommand_Callback_0100 : error = " + error); - console.debug('ACTS_AExecuteShellCommand_Callback_0100==== { + clearTimeout(currentAlertTimeout); + console.log('ACTS_AExecuteShellCommand_Promise_0100 - executeShellCommand: start ') + + result = data.stdResult.replace(/[\r\n]/g,""); + console.log('ACTS_AExecuteShellCommand_Promise_0100 stdResult = ' + data.stdResult) + expect(result).assertEqual('test'); + + console.log('ACTS_AExecuteShellCommand_Promise_0100 exitCode = ' + data.exitCode) + expect(data.exitCode).assertEqual(0); + done(); + }) + } catch (error) { + clearTimeout(currentAlertTimeout); + console.log("ACTS_AExecuteShellCommand_Callback_0200 : error = " + error); + console.debug('ACTS_AExecuteShellCommand_Callback_0200==== { + clearTimeout(currentAlertTimeout); + console.debug("ACTS_AGetDisplayOrientation_0100====DisplayOrientation>" + + JSON.stringify(DisplayOrientation) + " , err= " + err); + expect(DisplayOrientation == bundle.DisplayOrientation.UNSPECIFIED + || (DisplayOrientation != bundle.DisplayOrientation.LANDSCAPE + || DisplayOrientation != bundle.DisplayOrientation.PORTRAIT + || DisplayOrientation != bundle.DisplayOrientation.FOLLOW_RECENT + )).assertTrue(); + done() + } + ); + } catch (error) { + clearTimeout(currentAlertTimeout); + console.log("ACTS_AGetDisplayOrientation_0100 : error = " + error); + console.debug('ACTS_AGetDisplayOrientation_0100==== { + }) + + /** + * @tc.number: ACTS_AGetDisplayOrientation_0200 + * @tc.name: GetDisplayOrientation + * @tc.desc: Check the return type of the interface (by promise) + */ + it('ACTS_AGetDisplayOrientation_0200', 0, async function (done) { + console.log("ACTS_AGetDisplayOrientation_0200 --- start") + var currentAlertTimeout = 0; + try { + currentAlertTimeout = setTimeout(mySetTimeout, gSetTimeout); + function mySetTimeout() { + console.log('ACTS_AGetDisplayOrientation_0200==== { clearTimeout(currentAlertTimeout); - console.debug("ACTS_AGetDisplayOrientation_0100====DisplayOrientation>" + console.debug("ACTS_AGetDisplayOrientation_0200====DisplayOrientation>" + JSON.stringify(DisplayOrientation) + " , err= " + err); expect(DisplayOrientation == bundle.DisplayOrientation.UNSPECIFIED || (DisplayOrientation != bundle.DisplayOrientation.LANDSCAPE @@ -149,255 +184,220 @@ describe('ActsStServiceAbilityTest', function () { )).assertTrue(); done() } - ); - } catch (error) { - clearTimeout(currentAlertTimeout); - console.log("ACTS_AGetDisplayOrientation_0100 : error = " + error); - console.debug('ACTS_AGetDisplayOrientation_0100==== { + ); + } catch (error) { clearTimeout(currentAlertTimeout); - console.debug("ACTS_AGetDisplayOrientation_0200====DisplayOrientation>" - + JSON.stringify(DisplayOrientation) + " , err= " + err); - expect(DisplayOrientation == bundle.DisplayOrientation.UNSPECIFIED - || (DisplayOrientation != bundle.DisplayOrientation.LANDSCAPE - || DisplayOrientation != bundle.DisplayOrientation.PORTRAIT - || DisplayOrientation != bundle.DisplayOrientation.FOLLOW_RECENT - )).assertTrue(); - done() + console.log("ACTS_AGetDisplayOrientation_0200 : error = " + error); + console.debug('ACTS_AGetDisplayOrientation_0200==== { + clearTimeout(currentAlertTimeout); + console.debug("ACTS_ASetDisplayOrientation_0100====err>" + + JSON.stringify(err) + " , err= " + err); + done() + } + ); + } catch (error) { + clearTimeout(currentAlertTimeout); + console.log("ACTS_ASetDisplayOrientation_0100 : error = " + error); + console.debug('ACTS_ASetDisplayOrientation_0100==== { + }) + + /** + * @tc.number: ACTS_ASetDisplayOrientation_0200 + * @tc.name: SetDisplayOrientation + * @tc.desc: Check the return type of the interface (by promise) + */ + it('ACTS_ASetDisplayOrientation_0200', 0, async function (done) { + console.log("ACTS_ASetDisplayOrientation_0200 --- start") + var currentAlertTimeout = 0; + try { + currentAlertTimeout = setTimeout(mySetTimeout, gSetTimeout); + function mySetTimeout() { + console.log('ACTS_ASetDisplayOrientation_0200==== { clearTimeout(currentAlertTimeout); - console.debug("ACTS_ASetDisplayOrientation_0100====err>" - + JSON.stringify(err) + " , err= " + err); done() } - ); - } catch (error) { - clearTimeout(currentAlertTimeout); - console.log("ACTS_ASetDisplayOrientation_0100 : error = " + error); - console.debug('ACTS_ASetDisplayOrientation_0100==== { + ); + } catch (error) { clearTimeout(currentAlertTimeout); - done() + console.log("ACTS_ASetDisplayOrientation_0200 : error = " + error); + console.debug('ACTS_ASetDisplayOrientation_0200==== { + clearTimeout(currentAlertTimeout); + console.debug("ACTS_ASetShowOnLockScreen_0100====err>" + + JSON.stringify(err) + " , err= " + err); + done() + } + ); + } catch (error) { + clearTimeout(currentAlertTimeout); + console.log("ACTS_ASetShowOnLockScreen_0100 : error = " + error); + console.debug('ACTS_ASetShowOnLockScreen_0100==== { + }) + + /** + * @tc.number: ACTS_ASetShowOnLockScreen_0200 + * @tc.name: SetShowOnLockScreen + * @tc.desc: Check the return type of the interface (by promise) + */ + it('ACTS_ASetShowOnLockScreen_0200', 0, async function (done) { + console.log("ACTS_ASetShowOnLockScreen_0200 --- start") + var currentAlertTimeout = 0; + try { + currentAlertTimeout = setTimeout(mySetTimeout, gSetTimeout); + function mySetTimeout() { + console.log('ACTS_ASetShowOnLockScreen_0200==== { clearTimeout(currentAlertTimeout); - console.debug("ACTS_ASetShowOnLockScreen_0100====err>" - + JSON.stringify(err) + " , err= " + err); + console.debug("ACTS_ASetShowOnLockScreen_0200====then>"); done() } - ); - } catch (error) { - clearTimeout(currentAlertTimeout); - console.log("ACTS_ASetShowOnLockScreen_0100 : error = " + error); - console.debug('ACTS_ASetShowOnLockScreen_0100==== { + ); + } catch (error) { clearTimeout(currentAlertTimeout); - console.debug("ACTS_ASetShowOnLockScreen_0200====then>"); - done() + console.log("ACTS_ASetShowOnLockScreen_0200 : error = " + error); + console.debug('ACTS_ASetShowOnLockScreen_0200==== { + clearTimeout(currentAlertTimeout); + console.debug("ACTS_ASetWakeUpScreen_0100====err>" + + JSON.stringify(err) + " , err= " + err); + done() + } + ); + } catch (error) { + clearTimeout(currentAlertTimeout); + console.log("ACTS_ASetWakeUpScreen_0100 : error = " + error); + console.debug('ACTS_ASetWakeUpScreen_0100==== { + }) + + /** + * @tc.number: ACTS_ASetWakeUpScreen_0200 + * @tc.name: SetWakeUpScreen + * @tc.desc: Check the return type of the interface (by promise) + */ + it('ACTS_ASetWakeUpScreen_0200', 0, async function (done) { + console.log("ACTS_ASetWakeUpScreen_0200 --- start") + var currentAlertTimeout = 0; + try { + currentAlertTimeout = setTimeout(mySetTimeout, gSetTimeout); + function mySetTimeout() { + console.log('ACTS_ASetWakeUpScreen_0200==== { clearTimeout(currentAlertTimeout); - console.debug("ACTS_ASetWakeUpScreen_0100====err>" - + JSON.stringify(err) + " , err= " + err); + console.debug("ACTS_ASetWakeUpScreen_0200====then>"); done() } - ); - } catch (error) { - clearTimeout(currentAlertTimeout); - console.log("ACTS_ASetWakeUpScreen_0100 : error = " + error); - console.debug('ACTS_ASetWakeUpScreen_0100==== { + ); + } catch (error) { clearTimeout(currentAlertTimeout); - console.debug("ACTS_ASetWakeUpScreen_0200====then>"); - done() + console.log("ACTS_ASetWakeUpScreen_0200 : error = " + error); + console.debug('ACTS_ASetWakeUpScreen_0200====getArguments is====>" + JSON.stringify(AbilityDelegatorArgs)); - console.debug("ACTS_ATestRunner_0200====bundleName>" + JSON.stringify(AbilityDelegatorArgs.bundleName)); - expect(AbilityDelegatorArgs.bundleName).assertEqual(undefined) - console.debug("ACTS_ATestRunner_0200====parameters>" + JSON.stringify(AbilityDelegatorArgs.parameters)); - expect(AbilityDelegatorArgs.parameters).assertEqual(undefined) - console.debug("ACTS_ATestRunner_0200====testCaseNames>" - + JSON.stringify(AbilityDelegatorArgs.testCaseNames)); - expect(AbilityDelegatorArgs.testCaseNames).assertEqual(undefined) - console.debug("ACTS_ATestRunner_0200====testRunnerClassName>" - + JSON.stringify(AbilityDelegatorArgs.testRunnerClassName)); - expect(AbilityDelegatorArgs.testRunnerClassName).assertEqual(undefined) - console.debug('ACTS_ATestRunner_0200====getArguments is====>" + JSON.stringify(AbilityDelegatorArgs)); + expect(AbilityDelegatorArgs.bundleName).assertEqual('com.amsst.actsabilitydelegatorcasetest') + expect(AbilityDelegatorArgs.parameters["-b"]).assertEqual("com.amsst.actsabilitydelegatorcasetest") + expect(AbilityDelegatorArgs.parameters["-p"]).assertEqual("com.amsst.actsabilitydelegatorcasetest") + expect(AbilityDelegatorArgs.parameters["-s timeout"]).assertEqual("30000") + expect(AbilityDelegatorArgs.parameters["-s unittest"]).assertEqual("OpenHarmonyTestRunner") + expect(AbilityDelegatorArgs.parameters["-w"]).assertEqual("300000") + expect(AbilityDelegatorArgs.parameters["moduleName"]).assertEqual("") + expect(AbilityDelegatorArgs.testCaseNames).assertEqual('') + expect(AbilityDelegatorArgs.testRunnerClassName).assertEqual('OpenHarmonyTestRunner') + console.debug('ACTS_ATestRunner_0200==== { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets index 37b86f509..98754a090 100644 --- a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets +++ b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets @@ -12,10 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' @Entry @@ -23,23 +22,12 @@ import testsuite from "../../test/List.test.ets" struct Index { aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - testsuite(globalThis.abilityContext) - core.execute() + let abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets index 8e3316461..7540e051a 100644 --- a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/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 "deccjsunit/index" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import commonEvent from '@ohos.commonEvent' import missionManager from '@ohos.application.missionManager' import appManager from '@ohos.application.appManager' diff --git a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets index 882f978e7..98e9d46fa 100644 --- a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets @@ -15,8 +15,8 @@ import abilityTest from './Ability.test.ets' -export default function testsuite(context) { +export default function testsuite() { - abilityTest(context) + abilityTest(globalThis.abilityContext) } \ No newline at end of file -- GitLab