diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/BUILD.gn index 8ef13928a7811cd09491f33906a5196354f80eee..0565341a09bc685b25176dee187657d6b9dd5a35 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormAcquireTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormAcquireTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/Test.json index e20b59e8618753f2c1b204e45b096ec378a56786..65874b0a3a291934f0ec8b543de041e486661a9d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formacquiretest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formacquiretest", + "package-name": "com.ohos.st.formacquiretest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json index 0ed03d198f22c595f73261f143dacdab72ff1ea6..c1e01e845cd806c5fb6d427c6268b5f5b8fe809d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json @@ -16,7 +16,7 @@ "module": { "package": "com.ohos.st.formacquiretest", "name": ".FormAcquireSTApp", - "mainAbility": ".MainAbility", + "mainAbility": "com.ohos.st.formacquiretest.MainAbility", "deviceType": [ "phone" ], @@ -39,13 +39,27 @@ } ], "visible": true, - "name": ".MainAbility", + "name": "com.ohos.st.formacquiretest.MainAbility", + "srcPath": "MainAbility", "srcLanguage": "ets", "icon": "$media:icon", "description": "$string:description_mainability", "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -135,6 +149,24 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/pages/index.ets index 934996e9344963249339774c054dbcafc043ddab..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 40000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e29d14473a765b7c542a99f6f1fce908974b300 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,33 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + console.log('Application onCreate2222') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ebe2a118a93e1b8744707100e2e7c26cdfb99610 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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. + */ + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..f46586409480ebe887804b398e0b71294c3b78ca --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 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() +} + +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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/FmsAcquireForm.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/FmsAcquireForm.test.ets index cce3bb1e31fc6e131fd5609d727a01618f639ab1..cb718c637486144af0d2aefc788dec26c7440b57 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/FmsAcquireForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onErrorForm_Event = { events: ["FMS_FormOnError_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/resources/base/element/string.json index f018e8c97b8fe45599ad59c5432fe8453a37f252..0677ecf33d6aae716d1836b0ef982b855484f333 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/BUILD.gn index c71a0b1237a6858c85d778c1e7a4f5fa3b1b8613..2bef34d7119d61e3915216eb5c323b3cca8efbe0 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormAcquire2Test") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormAcquire2Test") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/Test.json index fe5a5e3bba0cd2efe51dbbc7a897140dcf4e9663..0d89776b9759332c5dcbc92d62d7eeb672be3676 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formacquiretest2", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formacquiretest2", + "package-name": "com.ohos.st.formacquiretest2", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json index 8c015323574d24e6e06bc99ef13fa41a79ec2428..f5fd8a283edf4229155e935fa38613a8cf812164 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -135,6 +148,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/pages/index.ets index 934996e9344963249339774c054dbcafc043ddab..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 40000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/FmsAcquireForm2.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/FmsAcquireForm2.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/FmsAcquireForm2.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/FmsAcquireForm2.test.ets index f0ea932ef4b4f45da952de58effc6439ded7d8f7..0eb17e84a984fd4246ae47a760f8f45b8176c4f8 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/FmsAcquireForm2.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/FmsAcquireForm2.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onErrorForm_Event = { events: ["FMS_FormOnError_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/resources/base/element/string.json index 3fd7831c6173babb5cb572e4041b0ecc7b6d7d7b..cc2ed53c087f54ae4dc1aa263625c8743d17a4e3 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/BUILD.gn index 9e47d17cbe6e9f8fa3201aed7f261b2dccaaa22a..9c29332b0c196e9be600ea3bea085d200942431c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormDeleteTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormDeleteTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json index b412802a8235344f13bdc6084cb49585a7437794..c41f81071f64306d7fd9a7c17c9bcd691af76a44 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formdeletetest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formdeletetest", + "package-name": "com.ohos.st.formdeletetest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json index eb92dae2bb21722b7be898ace5f4101b6a9147ec..6f8538908a163152a2a766919f633bf853d20282 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -157,6 +170,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/pages/index.ets index cd248861eeb1a25cdbd1bab32b9e266f03cf2d8a..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 20000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/FmsDeleteForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/FmsDeleteForm.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/FmsDeleteForm.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/FmsDeleteForm.test.ets index f47eb716d1d86a365f2681e5d6ea1233cea71b1a..151d24e4dc983d02670595f24a2bc6128f5f9ffa 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/FmsDeleteForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/FmsDeleteForm.test.ets @@ -16,7 +16,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import commonEvent from '@ohos.commonEvent'; import systemTime from '@ohos.systemTime'; -import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' const onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/BUILD.gn index 7667b3cc946907895c473a365cbe1382ee40bae2..b7c1722e122907ecd47fa7462a6862cb4ed3185b 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormDynamicRefreshTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormDynamicRefreshTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/Test.json index 6e016602f77566e7becf42c94a99558fcc54da78..cf33678c88a7c8e7e29a00143c662f5642486e94 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formdynamicrefreshtest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formdynamicrefreshtest", + "package-name": "com.ohos.st.formdynamicrefreshtest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json index 083bd3e3ece7e3702e3a0f96c595042d24190fb8..32026dbd99926b0556ea4fddb503813e63270b52 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -134,6 +147,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/pages/index.ets index bd535b4d476a15433fc062a0416c86f3e389c7c3..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,43 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/FmsDynamicRefreshForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/FmsDynamicRefreshForm.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/FmsDynamicRefreshForm.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/FmsDynamicRefreshForm.test.ets index cfcc92ec5e9fddcfd215e6e021dcba41c66e132f..09ee65d6bbb73ad412e0a563beeb7a806e643dd7 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/FmsDynamicRefreshForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/FmsDynamicRefreshForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' const onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/resources/base/element/string.json index ae9989858446df06e4ac2983b7eb48bb196887b3..b05b0cf27935f542894cb455cac82c7777d2e00e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/BUILD.gn index cd7895dd4feff4de2ff1d14180c5b691e25b9cfe..b0f64134b02ac6a066decdd1c1889a0baaa6e261 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormFuzzTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormFuzzTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/Test.json index 3284745911b025ce31a8866b4c3b186fdb0be6be..9c1257b26dd5f9a5d95ae685960f743a80e3262f 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "600000", - "package": "com.ohos.st.formfuzztest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formfuzztest", + "package-name": "com.ohos.st.formfuzztest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json index 936424cf10310da044ca0df21a366403f3731c72..8543a6e915322cd9f88c97724000226440c2eeab 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -138,6 +151,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/pages/index.ets index a531fcd34e8b57698b7d8e5474af36e0aff1b378..4a7074d28d671f4be2d8257127eadc632fe53410 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,41 +13,11 @@ * limitations under the License. */ -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { private componentName: string = `FormSystemFuzzTest`; - aboutToAppear() { - console.info(`${this.componentName} start run testcase!!!!`); - - featureAbility.getWant() - .then((want: any) => { - console.info(`${this.componentName} Operation successful. Data: ${JSON.stringify(want)}`); - 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'); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error(`${this.componentName} Operation failed. Cause: ${JSON.stringify(error)}`); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/CastTempFormFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/CastTempFormFuzz.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/CastTempFormFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/CastTempFormFuzz.test.ets index b997fc8dd77e56f28320ea5b4c73b8a2c2038c3f..ca55778a9a3c0b62792feb9d3be4f3d757bc090a 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/CastTempFormFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/CastTempFormFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const castTempFormFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/DeleteFormFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/DeleteFormFuzz.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/DeleteFormFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/DeleteFormFuzz.test.ets index 7fba18a42b90384a61c8241ff6b82e9bfecaa89a..b2b6eb81585dcbb103e23a87a0ce6c07aca6f01c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/DeleteFormFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/DeleteFormFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const deleteFormFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/DisableFormsUpdateFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/DisableFormsUpdateFuzz.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/DisableFormsUpdateFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/DisableFormsUpdateFuzz.test.ets index ad04207a513f6a9c7d9ed7f1f231d88b418d0833..48a3f026f65b421616168263848c6eb309c86be8 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/DisableFormsUpdateFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/DisableFormsUpdateFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const disableFormsUpdateFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/EnableFormsUpdateFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/EnableFormsUpdateFuzz.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/EnableFormsUpdateFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/EnableFormsUpdateFuzz.test.ets index d70f2d1cf437147fa788cef5a6b20d68d91011b8..9976453d0b9aeae9ab186002018444457bc9931c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/EnableFormsUpdateFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/EnableFormsUpdateFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const enableFormsUpdateFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/GetFormsInfoFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/GetFormsInfoFuzz.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/GetFormsInfoFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/GetFormsInfoFuzz.test.ets index e77d96703dbdc04cd3349ca6fbea9527649acfb6..7870950c2f224e462b107a950d784b0a4ebaac6d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/GetFormsInfoFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/GetFormsInfoFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const getFormsInfoFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/NotifyInvisibleFormsFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/NotifyInvisibleFormsFuzz.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/NotifyInvisibleFormsFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/NotifyInvisibleFormsFuzz.test.ets index 226974fb49f12ed1f5fb82389e104d60e6e9a0ec..f2b602e4ddb9bfcc959df5a4bf7023b6b3edb6a9 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/NotifyInvisibleFormsFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/NotifyInvisibleFormsFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const notifyInvisibleFormsFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/NotifyVisibleFormsFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/NotifyVisibleFormsFuzz.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/NotifyVisibleFormsFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/NotifyVisibleFormsFuzz.test.ets index d16eb88f47f95c723b184b2e8058d63d09b84e75..15a29872ffac99f733a75a2057b0764189c4ddec 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/NotifyVisibleFormsFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/NotifyVisibleFormsFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const notifyVisibleFormsFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/ReleaseFormFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/ReleaseFormFuzz.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/ReleaseFormFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/ReleaseFormFuzz.test.ets index 1b2fc1b2004963dc3d4fab41d094ef06a6a994e5..0dc146dba93b773d41c0babe10c55ead09a73f4d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/ReleaseFormFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/ReleaseFormFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const releaseFormFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/RequestFormFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/RequestFormFuzz.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/RequestFormFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/RequestFormFuzz.test.ets index de9d3457ed98b3c652c690ae7c77691414a53c34..687d090a6d50af89d8ba0799af61b8eeab3119f7 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/RequestFormFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/RequestFormFuzz.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const requestFormFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/SetFormNextRefreshTimeFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/SetFormNextRefreshTimeFuzz.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/SetFormNextRefreshTimeFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/SetFormNextRefreshTimeFuzz.test.ets index 548ec7b574abce8bd982884f61f2b9f6d1cec53e..4d030380aa50610615aaf7b07dcaa68999bfaa2c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/SetFormNextRefreshTimeFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/SetFormNextRefreshTimeFuzz.test.ets @@ -14,7 +14,7 @@ */ import formProvider from '@ohos.application.formProvider'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const setFormNextRefreshTimeFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/UpdateFormFuzz.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/UpdateFormFuzz.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/UpdateFormFuzz.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/UpdateFormFuzz.test.ets index 33faff56300bbb15ec5fcde31f2d82e8da49f5fc..5aeb3e8faef3b3726fa400ec23d4e08fe52ad741 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/UpdateFormFuzz.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/UpdateFormFuzz.test.ets @@ -14,7 +14,7 @@ */ import formProvider from '@ohos.application.formProvider'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets'; export const updateFormFuzzTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/getParam.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/getParam.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/MainAbility/test/getParam.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/ets/test/getParam.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/BUILD.gn index d33dd2b17a876365591b3f2569402a25595814da..dd5b42ace396dc6079b097df1d7a751f158dd3c6 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormsOneAndOneTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormsOneAndOneTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/Test.json index d3a25ebfc5776593d89c3ea1b2f2b9c0cbf3b863..a409935a813073793be6ae2dd922b992f82154bd 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formsoneandonetest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formsoneandonetest", + "package-name": "com.ohos.st.formsoneandonetest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/config.json index ffdbd0ae1a7de07bcdcd1141bcd95cb64a2b6e98..a15daad37c5acd5a06b3f4d7be668393c3bf6c82 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -108,6 +121,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/pages/index.ets index a39d5ea046c98a45fe715f66a7ba53c816e634d4..506bb81ed5b084e679ede9fc1f7c62c8c4860174 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,41 +13,11 @@ * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'; -import testsuite from '../test/List.test.ets'; - @Entry @Component struct Index { private componentName: string = `FormsOneAndOneTest`; - aboutToAppear() { - console.info(`${this.componentName} start run testcase!!!!`); - - featureAbility.getWant() - .then((want: any) => { - console.info(`${this.componentName} Operation successful. Data: ${JSON.stringify(want)}`); - 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'); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error(`${this.componentName} Operation failed. Cause: ${JSON.stringify(error)}`); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/GetAllFormsInfo.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/GetAllFormsInfo.test.ets index 7cc7f1fdd4075540df93fd8e03e09bdb2b1db27e..58a8d0ae908af324d343bc47ea6dc31ab5981455 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/GetAllFormsInfo.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import FormInfo from '@ohos.application.formInfo'; function sleep(time) { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/GetFormsInfo.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/GetFormsInfo.test.ets index d5bd25b2ecf5b7d57761d356a6af31a4d105a380..8e3403f80e26e061735f4b5366602e6d90c0d4a8 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/GetFormsInfo.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import FormInfo from '@ohos.application.formInfo'; export const getFormsInfoTest = (describeName, filterParameter) => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/BUILD.gn index 2bf6b395d8457c17fb12e15b81741b2be8e185a7..75e502758e15043bde3eaf297d24b80e6f09e06f 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormsOneAndTwoTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormsOneAndTwoTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/Test.json index ca9ca39beb59c1f49508e211de8d64491860a498..7e7374557719d49e10eaa08262a29a4ca672035c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formsoneandtwotest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formsoneandtwotest", + "package-name": "com.ohos.st.formsoneandtwotest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/config.json index c554bf7f0b374d89d4b1e180cd8b909f6c5737c2..0183f81e01ab174e87ed93c2d81974532e691642 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -108,6 +121,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/pages/index.ets index fcbc42d152ff2db108588036a875287feb8f8d12..f1af21fd851c2d3409120402564326f01f03f97a 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,41 +13,11 @@ * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'; -import testsuite from '../test/List.test.ets'; - @Entry @Component struct Index { private componentName: string = `FormsOneAndTwoTest`; - aboutToAppear() { - console.info(`${this.componentName} start run testcase!!!!`); - - featureAbility.getWant() - .then((want: any) => { - console.info(`${this.componentName} Operation successful. Data: ${JSON.stringify(want)}`); - 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'); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error(`${this.componentName} Operation failed. Cause: ${JSON.stringify(error)}`); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets index 670da2dc8e1a1ee9c94c6b13795653c744fb00b7..fd1fe68cfb7fcd8e7b361d695a55d64cc5f10ac6 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import FormInfo from '@ohos.application.formInfo'; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/BUILD.gn index 669989594dac25b4d740f7962dc2b6c3376a6a62..f27e6e6e5160367439db38e773a2f2031bb6524e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormsOneAndZeroTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormsOneAndZeroTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/Test.json index 79d26f01ee745d7997b6040fef388d7acfeb53d8..ccf68bf17454b756429cb1810c0fc0bd8868ae61 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formsoneandzerotest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formsoneandzerotest", + "package-name": "com.ohos.st.formsoneandzerotest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/config.json index e7891fe8147c649b0117d2fd306f27d22b0a9cc1..739668a77e2b5c7081568b1a35c3ceba3c6ee7ba 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -108,6 +121,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/pages/index.ets index 7a89132a4e62eabe2bfb7bb9868800240227282e..835aab2fd59d40f06165c6105ece506c8320a9d1 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,41 +13,11 @@ * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'; -import testsuite from '../test/List.test.ets'; - @Entry @Component struct Index { private componentName: string = `FormsOneAndZeroTest`; - aboutToAppear() { - console.info(`${this.componentName} start run testcase!!!!`); - - featureAbility.getWant() - .then((want: any) => { - console.info(`${this.componentName} Operation successful. Data: ${JSON.stringify(want)}`); - 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'); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error(`${this.componentName} Operation failed. Cause: ${JSON.stringify(error)}`); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets index e3b8503e66822eeaece2fe0d17e078195e49d1cd..169f3825aa1e4accf97b6d436a2e883c43b5b01f 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' import FormInfo from '@ohos.application.formInfo'; function sleep(time) { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/BUILD.gn index 6f7352b1936c20a1b5702a3907f53ed9a384d39a..8c54f64bc627710263770df8dc46abf554d9d8f3 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormsWithoutPermTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormsWithoutPermTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/Test.json index 608989c1e379a524a9fbf33b519e354700eaa3ff..6672730aad7b29d55892a89e2fc54bac9f6d623e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formswithoutpermtest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formswithoutpermtest", + "package-name": "com.ohos.st.formswithoutpermtest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/config.json index 0783c577fa31b903c0430c50b27cfa418c363980..9a7fb1603e47fd6194d237dbddaddabb390edfad 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -104,6 +117,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/pages/index.ets index dcdf0676df5c11b2bc1854fe2c0ff1569847cc27..a64ebaf5591cbf26ec9a1706f9334eb3429a8a81 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,41 +13,11 @@ * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'; -import testsuite from '../test/List.test.ets'; - @Entry @Component struct Index { private componentName: string = `FormsWithoutPermTest`; - aboutToAppear() { - console.info(`${this.componentName} start run testcase!!!!`); - - featureAbility.getWant() - .then((want: any) => { - console.info(`${this.componentName} Operation successful. Data: ${JSON.stringify(want)}`); - 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'); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error(`${this.componentName} Operation failed. Cause: ${JSON.stringify(error)}`); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/GetAllFormsInfo.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/GetAllFormsInfo.test.ets index 86ab2a9d690e138e69a5ae9a7ca82effde87be08..5d91f12ae3a21c20f9f334d562f7c7adde4ecc20 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/GetAllFormsInfo.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' export const getAllFormsInfoTest = (describeName, filterParameter) => { const ERR_OK_CODE = 0; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/GetFormsInfo.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/GetFormsInfo.test.ets index b21a6691837bf38add3998e16062c326b2be792b..0a19707aafd0a209d627239a808d406c72babb73 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/GetFormsInfo.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' export const getFormsInfoTest = (describeName, filterParameter) => { const ERR_PERMISSION_DENY_CODE = 2; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formswithoutpermtest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/BUILD.gn index 0abc21cd6dbcc7f9b1fd4ebf81a6387e4bb76537..3caf4978be643fe4118293627293435e7dbbc42c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormsZeroTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormsZeroTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/Test.json index 1e84c156fb08f6fa11585e900bc6f50fa65c7336..870023e5c9e39c5bb42859de4b5408fad520a8f7 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formszerotest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formszerotest", + "package-name": "com.ohos.st.formszerotest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/config.json index 041bbb3370fff840ad9017f2f974de3333136915..e55f5685b64ebab1c69132342aeb368fd31e0a96 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -108,6 +121,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/pages/index.ets index ca551d272f732e4b999d1517c078d3717be565a4..ba7d6a293834380d802df5ff7179684b0e7e350e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,41 +13,11 @@ * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'; -import testsuite from '../test/List.test.ets'; - @Entry @Component struct Index { private componentName: string = `FormsZeroTest`; - aboutToAppear() { - console.info(`${this.componentName} start run testcase!!!!`); - - featureAbility.getWant() - .then((want: any) => { - console.info(`${this.componentName} Operation successful. Data: ${JSON.stringify(want)}`); - 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'); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error(`${this.componentName} Operation failed. Cause: ${JSON.stringify(error)}`); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets similarity index 98% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets index bb3abde74d93513be04c148c44245d324186cab5..78bcac9763e65b37720bd1223d6a52eca6fbcb37 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/test/GetAllFormsInfo.test.ets @@ -14,7 +14,7 @@ */ import formHost from '@ohos.application.formHost'; -import { describe, expect, it } from 'deccjsunit/index'; +import { describe, expect, it } from '@ohos/hypium' export const getAllFormsInfoTest = (describeName, filterParameter) => { const ERR_OK_CODE = 0; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formszerotest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/BUILD.gn index a03ce7fae6dc5795fb8e53ce4be15e133c0687af..3713df1596f363ae1b697ade0d38f20231bcdaec 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormHostDeathRecipientTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormHostDeathRecipientTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/Test.json index c9fc4338625f49f9c77daa0c8d709ec9c4bb4986..4e22ab70c5374e65ba0f9962c8f660cccfef11dc 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "120000", - "package": "com.ohos.st.formhostdeathrecipienttest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formhostdeathrecipienttest", + "package-name": "com.ohos.st.formhostdeathrecipienttest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/config.json index c756590f5f38714be368493813f03b6a2f4adafa..f38d28074d0921c1a28be01a42432fc666ebc03f 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -127,6 +140,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/pages/index.ets index d90a8cc5694df48b5b3bd5550a38494acecfef76..300f37a76c431c951cb1862e8ebfed3d86ca344e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 60000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/test/FmsHostDeathRecipient.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/test/FmsHostDeathRecipient.test.ets index f174204c7e6e8025bfbe0d99a54d2b6de38931a9..f30ad8726c14213522268d8c6649d32a316eb6b1 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/test/FmsHostDeathRecipient.test.ets @@ -15,7 +15,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' const onAcquiredEvent = { events: [`FMS_FormOnAcquired_commonEvent`], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/BUILD.gn index 3cb29b2eaed9c7ef14ccf496367cf38228c96791..d41ee332586123fe2a4b1aef28f6bf5fbdfe15e4 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormPerformanceTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormPerformanceTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json index ac9ae4d70dca5b4c984a7c9ecb889ca79e7d6655..79951d919992ac4b167a7453ce4c2544130f4fc6 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formperformancetest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formperformancetest", + "package-name": "com.ohos.st.formperformancetest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/config.json index b24ab04371f25c77bc9e00b1620218635f371270..4125e2667315915d341ff54b6a645abcffe3d106 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -120,6 +133,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/pages/index.ets index f235c8023f5fad5ea7e4e4d3f2a3f9a0b20aec65..ec5d2d8efb8fecba0166babda748d6ac4f1fa21d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 20000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/FmsPerformanceTest.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/test/FmsPerformanceTest.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/FmsPerformanceTest.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/test/FmsPerformanceTest.test.ets index c201dbc2691d1ada18ffe859c2d2ab5f0b182f84..08248f9bb31b7810d5a14e5f4b25452c3832b2b8 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/FmsPerformanceTest.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/test/FmsPerformanceTest.test.ets @@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import formHost from '@ohos.application.formHost'; import commonEvent from '@ohos.commonEvent'; import systemTime from '@ohos.systemTime'; -import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' const onAcquiredEvent = { events: [`FMS_FormOnAcquired_commonEvent`], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/BUILD.gn index ca387290273119127b2bcf827d1c5bfbfa2efafa..a0375a95acaa3c28279610f674b659af27328535 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormReleaseTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormReleaseTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/Test.json index 4991ea4d2f5ee0eb0900e0b5305dc8d48e88e300..426b0d9978d22d156f2b5e49ca4ec77ff063eaec 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formreleasetest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formreleasetest", + "package-name": "com.ohos.st.formreleasetest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json index fd2252d466c6d42c3e426a39898d17f5d80dbee9..867cbe0e16c6ad70a992d4238cd7a466ee11a704 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -142,6 +155,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/pages/index.ets index cd248861eeb1a25cdbd1bab32b9e266f03cf2d8a..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 20000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/FmsReleaseForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/FmsReleaseForm.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/FmsReleaseForm.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/FmsReleaseForm.test.ets index 2a4b59f8a2776dea27a433bf5e42faf4e42be5be..bef74bca0e9e49878bf3fb8c1c0e6c4ed39b4941 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/FmsReleaseForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/FmsReleaseForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/BUILD.gn index c69de805104f6027fa91d5a4423ecb39446b2bb5..71866396388bc0c9e2f53772811b8b9c62e1ff08 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormStateDisableTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormStateDisableTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/Test.json index f692d0dffbb74376ebad44fa6703a3d99c42c296..44e0dc5fdf5dedba35447ee66f6e846ff6417d20 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formstatedisabletest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formstatedisabletest", + "package-name": "com.ohos.st.formstatedisabletest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json index e94c22a605c0083ce7239782b619267ae9cc0723..f12ebbf7cab84a87b66419ccc9e95bbea78adedd 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -144,6 +157,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/pages/index.ets index 2178a7f807dc1796f20ce22def4fd33614536b2b..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 30000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/FmsFormStateDisable.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/FmsFormStateDisable.test.ets index ce857acd33bfbc6ede705215eb65c1dca0d959fa..793cff053aacea7e6fe55865d12eafa7d918000c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/FmsFormStateDisable.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/element/string.json index 39fe2a50ceccda9ee33a9a5498f376f592fdd74f..c2d62c4680e48a3a33d51a0cdad70ba38ad3c083 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/BUILD.gn index 23fe654556dbf49ab1faf16f45f561d213a70bb2..ddac1b5f8f39fb191360e43c875993e3326c4710 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormStateEnableTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormStateEnableTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json index d0068688e3849ed62e3927354377d88da1d255c6..77f317d68f3248c2baf5c7458786e08cf4c50ee5 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formstateenabletest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formstateenabletest", + "package-name": "com.ohos.st.formstateenabletest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json index 5f7229632a2ddbdac75b86e5fa4296bba0cfbf7a..cbb125b936eca69883eb4292f58ad6827b4bbb2d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -144,6 +157,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/pages/index.ets index 2178a7f807dc1796f20ce22def4fd33614536b2b..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 30000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/FmsFormStateEnable.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/FmsFormStateEnable.test.ets index 96c355bb6390721e0ec067fe5c3c5fa06cfaf0db..e412b411248bd8f72052713898d8728bab9a8d4e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/FmsFormStateEnable.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/element/string.json index f89b18b0ba85f13d834eacfda58eafc0e7e8a190..3c4c22f47b1c9127226c3c60b1bb9b47c64d2ab5 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/BUILD.gn index b89130654451f2ed119247197fc5f94fc659db24..24078ea4acea23e3df01932e2a418dbe4fea01b7 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormStateNotifyInvisibleTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormStateNotifyInvisibleTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/Test.json index 5f8892ba8fc3f3d08887af022084092abed28d1c..a8a55d0b9ce98f53dc39c1e802f2fd19e4e197bc 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formstatenotifyinvisibletest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formstatenotifyinvisibletest", + "package-name": "com.ohos.st.formstatenotifyinvisibletest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json index 5c76a92a593b3599aa950bd05f08d2ffd0ff5bb2..8d6fef062e42d8489b70503fe37c02f8f6d89153 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -144,6 +157,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/pages/index.ets index 9ec7ce2d67c2b0adc3a0d326487f4d4ca61477d6..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 10000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/FmsFormStateNotifyInvisible.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/FmsFormStateNotifyInvisible.test.ets index 1f851a364c76e882460b982d9c83d20bc8caf43e..3fc87b2f5f905356ba6a29ff22910c06958ee026 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/FmsFormStateNotifyInvisible.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { describe, afterEach, beforeEach, expect, it } from "deccjsunit/index"; +import { describe, afterEach, beforeEach, expect, it } from '@ohos/hypium' var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/element/string.json index 88745269a1a6e8a7046797f5ad4941c07bb3d1df..3e640f1d71a536de6f43c67cf7496e0629f4036d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/BUILD.gn index 384ea328e786459c8f42d11c276a65738893d07b..2c93dc97f43c24e063e12d77975162cb17d29610 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormStateNotifyInvisible2Test") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormStateNotifyInvisible2Test") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/Test.json index c5dcc8507dc85b88693929e20da4bbfa905f59dc..b290187107af3ae80b64331cf7c08d6c70bf2181 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formstatenotifyinvisibletest2", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formstatenotifyinvisibletest2", + "package-name": "com.ohos.st.formstatenotifyinvisibletest2", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json index a9d89444883243131e69d2b47c089f2c68cbd394..9bcb03ea97ebb7f111f17dbb6de7a674ba06acad 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -144,6 +157,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/pages/index.ets index 9ec7ce2d67c2b0adc3a0d326487f4d4ca61477d6..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 10000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/FmsFormStateNotifyInvisible2.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/FmsFormStateNotifyInvisible2.test.ets index c886fd3df6150137fa79787ddaba4b9af7745841..84d1c284602236796f1efe13be40f322e81da042 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/FmsFormStateNotifyInvisible2.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/element/string.json index 88745269a1a6e8a7046797f5ad4941c07bb3d1df..3e640f1d71a536de6f43c67cf7496e0629f4036d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/BUILD.gn index fa7596556050b3228f9de68e3df53aec9b96f226..e3bc3975ddb059173495988f719e1fc0e44e83a3 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormStateNotifyVisibleTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormStateNotifyVisibleTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/Test.json index 29fa626d8be8b7a545bf439c66d21a39f35c8ef8..0cc7bf2d9d4ca6ae357a8ee3e2ddbf4ea6519e6a 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formstatenotifyvisibletest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formstatenotifyvisibletest", + "package-name": "com.ohos.st.formstatenotifyvisibletest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json index 15e46578e801e592ec2410e2473e1d477c66052e..cdf7831de6083f70651f501bd33bd104e3dbbb38 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -144,6 +157,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/pages/index.ets index 9ec7ce2d67c2b0adc3a0d326487f4d4ca61477d6..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 10000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/FmsFormStateNotifyVisible.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/FmsFormStateNotifyVisible.test.ets index 804612722d2d5f58d8f8946a83449317370112fc..9458578b86097e315be87c59333d4632f88dd423 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/FmsFormStateNotifyVisible.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/element/string.json index 63cba75d54d0fc140df672f33a824d6dd3b746f7..538ea87894ab9f57248098d4419943fe78775d2e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/BUILD.gn index 1e9a3a85814b9a655d603a4560ed0a3188e0762f..96b4855eb02104127daf9817475541114a0dd010 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormStressTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormStressTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/Test.json index 229c7ae975abd8c373c77a4de3dc1d67668f012f..8c4f07e9509f369a4961696fe0e8d9ec02098e0f 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "360000", - "package": "com.ohos.st.formstresstest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formstresstest", + "package-name": "com.ohos.st.formstresstest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json index 7f1a408596d20cd773dfebf460e0da76443e7deb..5637e0cc11ceecc54d14d329e91be306afe28ad7 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -163,6 +176,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/pages/index.ets index a5548b2108cd36d9ebb5068ad14d793c3ca76ae0..fef3b19fba9b5995eda2fefe9a15f95eacd73c73 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,44 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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'); - want.parameters['timeout'] = 10000; - console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/FmsStress.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/FmsStress.test.ets similarity index 87% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/FmsStress.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/FmsStress.test.ets index f47cbacfb9d74b42914ebd6facffdf1c99e5d2ac..e23601167a51d1998aa7155c8f3962308f502e07 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/FmsStress.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/FmsStress.test.ets @@ -16,7 +16,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import formHost from '@ohos.application.formHost'; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' const onDeletedEvent = { events: [`FMS_FormOnDeleted_commonEvent`] @@ -111,6 +111,7 @@ export default function test() { }, () => publishOnDeleteCallback(tcNumber)); }, 500); console.info(`${tcNumber} onAcquiredCallback end`); + done() }); try { @@ -133,6 +134,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); + done() } }); @@ -174,6 +176,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); + done() } } else { commonEvent.unsubscribe(onAcquiredEventSubscriber, () => unsubscribeOnAcquiredCallback(tcNumber)); @@ -185,6 +188,7 @@ export default function test() { }, () => publishOnDeleteCallback(tcNumber)); }, 500); console.info(`${tcNumber} onAcquiredCallback end`); + done() } }); @@ -210,6 +214,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); + done() } }); @@ -250,6 +255,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); + done() } commonEvent.unsubscribe(onAcquiredEventSubscriber, () => unsubscribeOnAcquiredCallback(tcNumber)); setTimeout(() => { @@ -260,6 +266,7 @@ export default function test() { }, () => publishOnDeleteCallback(tcNumber)); }, 500); console.info(`${tcNumber} onAcquiredCallback end`); + done() } }); @@ -285,76 +292,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); - } - }); - - /** - * @tc.number: FMS_stressTest_0500 - * @tc.name: Provider set form next refresh time test. - * @tc.desc: setFormNextRefreshTime method working well. - */ - it(`FMS_stressTest_0500`, 0, async (done) => { - const tcNumber = `FMS_stressTest_0500`; - - subscribeDeletedEvent(tcNumber, 1, done); - - commonEvent.subscribe(onSupplyEventSubscriber, async (err, data) => { - console.info(`${tcNumber} onSupplyCallback data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`); - const kind = data.parameters.kind; - const supplyFormId = `onCreate` == kind - ? JSON.parse(data.parameters.parameters).parameters[`ohos.extra.param.key.form_identity`] - : `onVisibilityChange` == kind - ? Object.keys(JSON.parse(data.parameters.parameters))[0] - : data.parameters.parameters; - console.info(`${tcNumber} onSupplyCallback formId: ${supplyFormId} kind: ${kind}`); - - if (`onSetFormNextRefreshTime` == kind) { - commonEvent.unsubscribe(onSupplyEventSubscriber, () => unsubscribeOnSupplyCallback(tcNumber)); - setTimeout(() => { - commonEvent.publish(formOnDeleteEvent, { - parameters: { - formIds: [].concat(supplyFormId) - } - }, () => publishOnDeleteCallback(tcNumber)); - }, 500); - console.info(`${tcNumber} onSupplyCallback end`); - } - }); - - commonEvent.subscribe(onAcquiredEventSubscriber, async (err, data) => { - const kind = data.parameters.kind; - const formId = data.parameters.formId; - console.info(`${tcNumber} onAcquiredCallback data: ${JSON.stringify(data)}, error: ${JSON.stringify(err)}`); - console.info(`${tcNumber} onAcquiredCallback formId: ${formId}`); - - if (`notifyVisibleForms` == kind) { - expect(err.code).assertEqual(0); - commonEvent.unsubscribe(onAcquiredEventSubscriber, () => unsubscribeOnAcquiredCallback(tcNumber)); - console.info(`${tcNumber} onAcquiredCallback end`); - } - }); - - try { - const res = await featureAbility.startAbility({ - want: { - bundleName: `com.ohos.st.formsystemhostk`, - abilityName: `com.ohos.st.formsystemhostk.MainAbility`, - parameters: { - formId: `0`, - name: `Form_Js001`, - bundle: `com.form.formsystemtestserviceg.hmservice`, - ability: `com.form.formsystemtestserviceg.hmservice.FormAbility`, - moduleName: `entry`, - notifyVisibleForms: true, - isCreate: true - } - } - }); - console.info(`${tcNumber} featureAbility.startAbility res: ${JSON.stringify(res)}`); - } catch (error) { - console.info(`${tcNumber} error: ${JSON.stringify(error)}`); - console.info(`${tcNumber} should not reach here`); - expect().assertFail(); + done() } }); @@ -385,6 +323,7 @@ export default function test() { }, () => publishOnDeleteCallback(tcNumber)); }, 500); console.info(`${tcNumber} onAcquiredCallback end`); + done() } }); @@ -409,6 +348,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); + done() } }); @@ -442,6 +382,7 @@ export default function test() { }, () => publishOnDeleteCallback(tcNumber)); }, 500); console.info(`${tcNumber} onSupplyCallback end`); + done() } }); @@ -479,6 +420,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); + done() } }); @@ -515,6 +457,7 @@ export default function test() { }, () => publishOnDeleteCallback(tcNumber)); }, 500); console.info(`${tcNumber} onSupplyCallback end`); + done() } } }); @@ -561,6 +504,7 @@ export default function test() { console.info(`${tcNumber} error: ${JSON.stringify(error)}`); console.info(`${tcNumber} should not reach here`); expect().assertFail(); + done() } }); diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/BUILD.gn b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/BUILD.gn index ec41ac74ade9d1ec3228b18007212b2ae58fa6d6..f3fe996ba9f13d19eaf84211c62b1a36a1c2e07c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/BUILD.gn +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/BUILD.gn @@ -17,6 +17,7 @@ ohos_js_hap_suite("ActsFormUpdateRefreshTest") { hap_profile = "./entry/src/main/config.json" deps = [ ":hjs_demo_js_assets", + ":hjs_demo_js_test_assets", ":hjs_demo_resources", ] ets2abc = true @@ -28,6 +29,9 @@ ohos_js_hap_suite("ActsFormUpdateRefreshTest") { ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("hjs_demo_js_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/Test.json index c74674296ea7dbd1eb7089fd6220afee83fd17a1..cc42aa86a71c5d5f9b388c9f8355a5ed6177a92e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.ohos.st.formupdaterefreshtest", - "shell-timeout": "60000" + "bundle-name": "com.ohos.st.formupdaterefreshtest", + "package-name": "com.ohos.st.formupdaterefreshtest", + "shell-timeout": "600000", + "testcase-timeout":"30000" }, "kits": [ { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json index 8c500327e09e4cfd3bb7cf66bffc0bb22a0498f2..72b3d879e6c3f39ef41b943f45783d1be018daec 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json @@ -46,6 +46,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "singleton" } ], "defPermissions": [ @@ -153,6 +166,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/pages/index.ets index bd535b4d476a15433fc062a0416c86f3e389c7c3..baafb821f59e51d2d23ab337d7b5912c3944c014 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,43 +13,10 @@ * limitations under the License. */ -// @ts-nocheck -import featureAbility from "@ohos.ability.featureAbility"; -import file from '@system.file'; -import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index"; -import testsuite from "../test/List.test.ets"; - @Entry @Component struct Index { - aboutToAppear() { - - console.info("[FormComponent] start run testcase!!!!"); - - featureAbility.getWant() - .then((want: any) => { - console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); - 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('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); - configService.setConfig(want.parameters); - testsuite(); - core.execute(); - }) - .catch((error: any) => { - console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); - }) - } - build() { Flex({ direction: FlexDirection.Column, diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestAbility/app.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..870e5798acfde4ef19d493a53a5ce12506d880bb --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + 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') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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 call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/FmsUpdateRefreshForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/test/FmsUpdateRefreshForm.test.ets similarity index 99% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/FmsUpdateRefreshForm.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/test/FmsUpdateRefreshForm.test.ets index 958ac7cef44f0d72e8c26693fc733c99e3e56359..270b019595b664cd8d8b7abfced7f272a757bef1 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/FmsUpdateRefreshForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/test/FmsUpdateRefreshForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/List.test.ets rename to ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/test/List.test.ets diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/resources/base/element/string.json index be88fb57ccf5fe22f6052ba0214cb897047fed1d..6e6480757ae1feec92a93442e6c3194cd6718a7d 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file