diff --git a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/MainAbility/pages/index.ets index c7a8c17de33415f95d38d047c86ef9ae5d631686..9d55879f3923d5f6a95525162dc5ebb865d7aa28 100644 --- a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/MainAbility/pages/index.ets @@ -1,3 +1,18 @@ +/* +* 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 '@ohos.router'; @Entry diff --git a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index.ets index 63c7d43d6c7d4f720c00758436e53f367e2e094f..3bb1376bf16a11bb8882e58381c6f1499069e0bd 100644 --- a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index.ets +++ b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index.ets @@ -1,3 +1,18 @@ +/* +* 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 { diff --git a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index2.ets b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index2.ets index 5f72ec0e64f1d8dfe08e63599e9121f2755156fc..ae4dc02582f7c4aaf7583dee23b1f2383a481cb0 100644 --- a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index2.ets +++ b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index2.ets @@ -1,3 +1,18 @@ +/* +* 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 { diff --git a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index3.ets b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index3.ets index 5f72ec0e64f1d8dfe08e63599e9121f2755156fc..ae4dc02582f7c4aaf7583dee23b1f2383a481cb0 100644 --- a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index3.ets +++ b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/pages/index3.ets @@ -1,3 +1,18 @@ +/* +* 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 { diff --git a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/test/List.test.ets index d766fe249dfc3ada636f27e64d9b64451ce32c93..caa07c3911a97aed3eab456f7864b1d430eb4e79 100644 --- a/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsabilityusertest/entry/src/main/ets/test/List.test.ets @@ -1,3 +1,18 @@ +/* +* 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 abilityTest from './Ability.test' export default function testsuite() { diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/app.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..42f68baf7174c367b0d1193b6e12b90c73091821 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actskillprocesswithaccountclosetest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b8889764aa68711d3602a8c007044f62589a9de6 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActskillProcessWithAccountCloseTest" + } + ] +} diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/BUILD.gn b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d29b393421a43c03046ccdb7a0ef4ba21783693d --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/BUILD.gn @@ -0,0 +1,45 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_hap("ActSkillProcessWithAccountCloseTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + hap_name = "ActSkillProcessWithAccountCloseTest" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":actskillprocesswithaccountclosetest_js_assets", + ":actskillprocesswithaccountclosetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" +} + +ohos_app_scope("actskillprocesswithaccountclosetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actskillprocesswithaccountclosetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actskillprocesswithaccountclosetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actskillprocesswithaccountclosetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/Test.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..10d0b1f21a2a8376078cceb1f6d3bb4314a3b69b --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/Test.json @@ -0,0 +1,11 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.actskillprocesswithaccountclosetest", + "module-name": "entry", + "shell-timeout": "600000" + } +} + diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ae1bf3ce4d07b5d5a4e8bc485d994849d55de70 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* +* 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..f49453f99c401118f969cc1cb3329e8b04307145 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,53 @@ +/* +* 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 Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility 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.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'TestAbility/pages/index', null) + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3690508c405ca2fd7a849fbae0ae59a37c8286e --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/MainAbility/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. +*/ +import router from '@ohos.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/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..7fbba8118156be41084fa06a2715e63a1ba33210 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -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 end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d55fb10291670d788c540dc369a36dd6ae5ce94 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,31 @@ +/* +* 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 { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f05e8b48e9a7cf7832368951bbbc53a69674607 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + it('assertContain',0, function () { + console.info("it begin") + let a = 'abc' + let b = 'b' + expect(a).assertContain(b) + expect(a).assertEqual(a) + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf6f241a06f8aa77442bd600ce6e870c760e88fe --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* +* 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 abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/module.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..63433eb8d6b9487794cb12a568e2b0f733abdad3 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/module.json @@ -0,0 +1,36 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..126ece494316f3d5856578c6d568f6db06a8178f --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "app_name", + "value": "ActskillProcessWithAccountCloseTest" + }, + { + "name": "description_application", + "value": "demo for test" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActskillProcessWithAccountCloseTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/BUILD.gn b/ability/ability_runtime/actsshellcommandfunctionalitytest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a81d550fa311d03be3a2962cd80423d815e5fb0e --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni") + +group("actsshellcommandfunctionalitytest") { + testonly = true + if (is_standard_system) { + deps = [ + "ActskillProcessWithAccountCloseTest:ActSkillProcessWithAccountCloseTest", + "ExecuteShellCommand:ExecuteShellCommand", + ] + } +} diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/app.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..27541cdf126c6c063c6ca6581efb9f2106725e3a --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.executeshellcommand", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d06c4d78bb1117ae47a49007f2e3c790df75ac18 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ExecuteShellCommand" + } + ] +} diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/BUILD.gn b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..969510da4b5bb3c18d07051c61cc976be068be21 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ExecuteShellCommand") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":executeshellcommand_js_assets", + ":executeshellcommand_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ExecuteShellCommand" +} + +ohos_app_scope("executeshellcommand_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("executeshellcommand_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("executeshellcommand_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":executeshellcommand_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/Test.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..74711c618ebe006b7ff026ef1fdfeb206dd20fa6 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/Test.json @@ -0,0 +1,27 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.executeshellcommand", + "module-name": "entry", + "shell-timeout": "600000" + }, + "kits": [ + { + "type": "PushKit", + "push": [ + "ActSkillProcessWithAccountCloseTest.hap->/data/ActSkillProcessWithAccountCloseTest.hap" + ] + }, + { + "test-file-name": [ + "ActSkillProcessWithAccountCloseTest.hap", + "ExecuteShellCommand.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} + diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ae1bf3ce4d07b5d5a4e8bc485d994849d55de70 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* +* 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..b00e38977349b51175c85c51b488573515d50285 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,53 @@ +/* +* 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 Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility 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.log('MainAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('MainAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'MainAbility/pages/index', null) + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('MainAbility onWindowStageDestroy') + } + + onForeground() { + console.log('MainAbility onForeground') + } + + onBackground() { + console.log('MainAbility onBackground') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3690508c405ca2fd7a849fbae0ae59a37c8286e --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/MainAbility/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. +*/ +import router from '@ohos.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/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..ade8389c0b34836a9d9f313187d5ef318bc31413 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: MainAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a MainAbility' + ' -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 end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d55fb10291670d788c540dc369a36dd6ae5ce94 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/pages/index.ets @@ -0,0 +1,31 @@ +/* +* 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 { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a759916ee7265e47bef08ae1a668bd7465f5e3b --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,343 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' +import appManager from '@ohos.application.AppManager'; + +export default function abilityTest() { + describe('ACTS_ExecuteShellCommandTest', function () { + + /** + * @tc.number: ACTS_ExecuteShellCommand_Callback_0100 + * @tc.name: Execute a shell command without arguments (AsyncCallback). + * @tc.desc: Verify that the interface executes the Shell command successfully. + */ + it('ACTS_ExecuteShellCommand_Callback_0100', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Callback_0100 --- start") + var cmd = 'aa help' + var escresult = 'usage: aa ' + globalThis.abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.log('ACTS_ExecuteShellCommand_Callback_0100 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Callback_0100 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf(escresult); + console.log('ACTS_ExecuteShellCommand_Callback_0100 query string i = ' + i); + expect(i == -1).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Callback_0100 exitCode = ' + data.exitCode) + expect(data.exitCode).assertEqual(0); + console.log('ACTS_ExecuteShellCommand_Callback_0100 - executeShellCommand: end') + done() + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Callback_0200 + * @tc.name: Execute shell command with timeout parameter (AsyncCallback) + * @tc.desc: Verify that the interface executes the Shell command successfully. + */ + it('ACTS_ExecuteShellCommand_Callback_0200', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Callback_0200 --- start") + var cmd = 'aa start -a MainAbility -b com.example.actskillprocesswithaccountclosetest' + globalThis.abilityDelegator.executeShellCommand(cmd, 1,(err, data) => { + console.log('ACTS_ExecuteShellCommand_Callback_0200 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Callback_0200 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf('start ability successfully.'); + console.log('ACTS_ExecuteShellCommand_Callback_0200 query string i = ' + i); + expect(i == -1).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Callback_0200 exitCode = ' + data.exitCode) + expect(data.exitCode).assertEqual(0); + console.log('ACTS_ExecuteShellCommand_Callback_0200 - executeShellCommand: end') + done() + }) + setTimeout(async() => { + appManager.killProcessWithAccount('com.example.actskillProcessWithAccountclosetest', 100).then(() => { + console.log('ACTS_ExecuteShellCommand_Callback_0200 killProcess ======> start'); + }) + }, 3000 ) + }) + /** + * @tc.number: ACTS_ExecuteShellCommand_Callback_0300 + * @tc.name: Execute non-existing shell command (AsyncCallback). + * @tc.desc: Failed to execute shell command on authentication interface. + */ + it('ACTS_ExecuteShellCommand_Callback_0300', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Callback_0300 --- start") + var cmd = 'ppwd -L' + globalThis.abilityDelegator.executeShellCommand(cmd, 1,(err, data) => { + console.log('ACTS_ExecuteShellCommand_Callback_0300 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Callback_0300 stdResult = ' + data.stdResult) + var i = data.stdResult.length + console.log('ACTS_ExecuteShellCommand_Callback_0300 query string i = ' + i); + expect(i == 0).assertEqual(true); + console.log('ACTS_ExecuteShellCommand_Callback_0300 exitCode = ' + data.exitCode) + expect(data.exitCode == 0).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Callback_0300 - executeShellCommand: end') + done(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Callback_0400 + * @tc.name: Execute shell command timeout (AsyncCallback) + * @tc.desc: The authentication interface executes the shell command timed out. + */ + it('ACTS_ExecuteShellCommand_Callback_0400', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Callback_0400 --- start") + var cmd = 'aa help' + var escresult = 'usage: aa ' + globalThis.abilityDelegator.executeShellCommand(cmd,0, (err, data) => { + console.log('ACTS_ExecuteShellCommand_Callback_0400 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Callback_0400 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf(escresult); + console.log('ACTS_ExecuteShellCommand_Callback_0400 query string i = ' + i); + expect(i == -1).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Callback_0100 exitCode = ' + data.exitCode) + expect(data.exitCode).assertEqual(0); + console.log('ACTS_ExecuteShellCommand_Callback_0400 - executeShellCommand: end') + done(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Callback_0500 + * @tc.name: Invalid timeout parameter for executing shell command (AsyncCallback) + * @tc.desc: The timeout parameter for executing shell commands on the authentication interface is invalid. + */ + it('ACTS_ExecuteShellCommand_Callback_0500', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Callback_0500 --- start") + var cmd = 'aa help' + var escresult = 'usage: aa ' + globalThis.abilityDelegator.executeShellCommand(cmd,-1, (err, data) => { + console.log('ACTS_ExecuteShellCommand_Callback_0500 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Callback_0500 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf(escresult); + console.log('ACTS_ExecuteShellCommand_Callback_0500 query string i = ' + i); + expect(i == -1).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Callback_0500 exitCode = ' + data.exitCode) + expect(data.exitCode).assertEqual(0); + console.log('ACTS_ExecuteShellCommand_Callback_0500 - executeShellCommand: end') + done(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Callback_0600 + * @tc.name: The executed shell command parameter is null (AsyncCallback) + * @tc.desc: Failed to execute shell command on authentication interface. + */ + it('ACTS_ExecuteShellCommand_Callback_0600', 0, async function (done) { + let flag=true; + console.log("ACTS_ExecuteShellCommand_Callback_0600 --- start") + globalThis.abilityDelegator.executeShellCommand("",1,(err, data) => { + console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand:data'+JSON.stringify(data)) + expect(data).assertEqual(undefined); + console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand: end') + flag=false; + done(); + }) + setTimeout(()=>{ + if(flag==true){ + console.log('ACTS_ExecuteShellCommand_Callback_0600 timeout') + expect().assertFail(); + done(); + } + },5000) + }) + + + /** + * @tc.number: ACTS_ExecuteShellCommand_Callback_0700 + * @tc.name: The timeout parameter of the execution is null (AsyncCallback) + * @tc.desc: Verify that the interface executes the Shell command successfully. + */ + it('ACTS_ExecuteShellCommand_Callback_0700', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_0700 --- start") + var cmd = 'aa help' + var code = null + setTimeout(() => { + console.log('ACTS_ExecuteShellCommand_Callback_0700 code:'+JSON.stringify(code)) + if(code!=undefined){ + expect().assertFail(); + } + done(); + }, 3000) + code = globalThis.abilityDelegator.executeShellCommand(cmd,null,() => { + console.log('ACTS_ExecuteShellCommand_Callback_0700 fail:') + expect().assertFail(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Promise_0100 + * @tc.name: Execute a shell command without arguments (Promise). + * @tc.desc: Verify that the interface executes the Shell command successfully. + */ + it('ACTS_ExecuteShellCommand_Promise_0100', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Promise_0100 --- start") + var cmd = 'aa help' + var escresult = 'usage: aa ' + globalThis.abilityDelegator.executeShellCommand(cmd, 1).then((data) => { + console.log('ACTS_ExecuteShellCommand_Promise_0100 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Promise_0100 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf(escresult); + console.log('ACTS_ExecuteShellCommand_Promise_0100 query string i = ' + i); + expect(i == -1).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Promise_0100 exitCode = ' + data.exitCode) + expect(data.exitCode).assertEqual(0); + done(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Promise_0200 + * @tc.name: Execute shell command with timeout parameter (Promise) + * @tc.desc: Verify that the interface executes the Shell command successfully. + */ + it('ACTS_ExecuteShellCommand_Promise_0200', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Promise_0200 --- start") + var cmd = 'aa start -d 0 -a MainAbility -b com.example.actskillprocesswithaccountclosetest' + globalThis.abilityDelegator.executeShellCommand(cmd, 1).then((data) => { + console.log('ACTS_ExecuteShellCommand_Promise_0200 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Promise_0200 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf('start ability successfully.'); + console.log('ACTS_ExecuteShellCommand_Promise_0200 query string i = ' + i); + expect(i == -1).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Promise_0200 exitCode = ' + data.exitCode) + expect(data.exitCode).assertEqual(0); + console.log('ACTS_ExecuteShellCommand_Promise_0200 - executeShellCommand: end') + done() + }) + setTimeout(async() => { + appManager.killProcessWithAccount('com.example.actskillProcessWithAccountclosetest', 100).then(() => { + console.log('ACTS_ExecuteShellCommand_Promise_0200 killProcess ======> start'); + }) + }, 3000 ) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Promise_0300 + * @tc.name: Execute non-existing shell command (Promise). + * @tc.desc: Failed to execute shell command on authentication interface. + */ + it('ACTS_ExecuteShellCommand_Promise_0300', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Promise_0300 --- start") + var cmd = 'ppwd -L' + globalThis.abilityDelegator.executeShellCommand(cmd, 1).then((data) => { + console.log('ACTS_ExecuteShellCommand_Promise_0300 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Promise_0300 stdResult = ' + data.stdResult) + var i = data.stdResult.length + console.log('ACTS_ExecuteShellCommand_Promise_0300 query string i = ' + i); + expect(i == 0).assertEqual(true); + console.log('ACTS_ExecuteShellCommand_Promise_0300 exitCode = ' + data.exitCode) + expect(data.exitCode == 0).assertEqual(false); + console.log('ACTS_ExecuteShellCommand_Promise_0300 - executeShellCommand: end') + done(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Promise_0400 + * @tc.name: Execute shell command timeout (Promise) + * @tc.desc: The authentication interface executes the shell command timed out. + */ + it('ACTS_ExecuteShellCommand_Promise_0400', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Promise_0400 --- start") + var cmd = 'aa help' + var escresult = 'usage: aa ' + globalThis.abilityDelegator.executeShellCommand(cmd, 0).then((data) => { + console.log('ACTS_ExecuteShellCommand_Promise_0400 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Promise_0400 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf(escresult); + console.log('ACTS_ExecuteShellCommand_Promise_0400 query string i = ' + i); + expect(data.exitCode).assertEqual(0); + console.log('ACTS_ExecuteShellCommand_Promise_0400 - executeShellCommand: end') + done(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Promise_0500 + * @tc.name: Invalid timeout parameter for executing shell command (Promise) + * @tc.desc: The timeout parameter for executing shell commands on the authentication interface is invalid. + */ + it('ACTS_ExecuteShellCommand_Promise_0500', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Promise_0500 --- start") + var cmd = 'aa help' + var escresult = 'usage: aa ' + globalThis.abilityDelegator.executeShellCommand(cmd, -1).then((data) => { + console.log('ACTS_ExecuteShellCommand_Promise_0500 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Promise_0500 stdResult = ' + data.stdResult) + var i = data.stdResult.indexOf(escresult); + console.log('ACTS_ExecuteShellCommand_Promise_0500 query string i = ' + i); + expect(data.exitCode).assertEqual(0); + console.log('ACTS_ExecuteShellCommand_Promise_0500 - executeShellCommand: end') + done(); + }) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Promise_0600 + * @tc.name: The executed shell command parameter is null (Promise) + * @tc.desc: Failed to execute shell command on authentication interface. + */ + it('ACTS_ExecuteShellCommand_Promise_0600', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Promise_0600 --- start") + let flag = true; + globalThis.abilityDelegator.executeShellCommand("",1).then((data) => { + console.log('ACTS_ExecuteShellCommand_Promise_0600 - executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Promise_0600 - executeShellCommand:data'+JSON.stringify(data)) + expect(data).assertEqual(undefined); + console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand: end') + flag=false; + done(); + },(data) => { + console.log('ACTS_ExecuteShellCommand_Promise_0600 -2 executeShellCommand: start ') + console.log('ACTS_ExecuteShellCommand_Promise_0600 -2 executeShellCommand:data'+JSON.stringify(data)) + expect(data.code).assertEqual(-1); + console.log('ACTS_ExecuteShellCommand_Callback_0600 -2 executeShellCommand: end') + flag=false; + done(); + }).catch((err) => { + console.log('ACTS_ExecuteShellCommand_Promise_0600 -2 executeShellCommand:err'+JSON.stringify(err)) + }) + setTimeout(()=>{ + if(flag==true){ + console.log('ACTS_ExecuteShellCommand_Callback_0600 timeout') + expect().assertFail(); + done(); + } + },5000) + }) + + /** + * @tc.number: ACTS_ExecuteShellCommand_Promise_0700 + * @tc.name: The timeout parameter of the execution is null (Promise) + * @tc.desc: Verify that the interface executes the Shell command successfully. + */ + it('ACTS_ExecuteShellCommand_Promise_0700', 0, async function (done) { + console.log("ACTS_ExecuteShellCommand_Promise_0700 --- start") + var cmd = 'aa help' + var code = null + code = globalThis.abilityDelegator.executeShellCommand(cmd, null) + setTimeout(() => { + console.log('ACTS_ExecuteShellCommand_Callback_0700 code:'+JSON.stringify(code)) + if(code!=undefined){ + expect().assertFail(); + } + done(); + }, 3000) + }) + }) +}; diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf6f241a06f8aa77442bd600ce6e870c760e88fe --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* +* 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 abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/module.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..63433eb8d6b9487794cb12a568e2b0f733abdad3 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/module.json @@ -0,0 +1,36 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f63f4ed4cbe767fc324cfc279c0bb408d7f49450 --- /dev/null +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "app_name", + "value": "ExecuteShellCommand" + }, + { + "name": "description_application", + "value": "demo for test" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/signature/openharmony_sx.p7b b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/actsshellcommandfunctionalitytest/ExecuteShellCommand/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/MainAbility/pages/index.ets index dff51b512f4259dde2394d57849f7d21dfbce0b8..43326ac5a4887639a97e54a8db06d1d1df71bade 100644 --- a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/MainAbility/pages/index.ets @@ -1,3 +1,18 @@ +/* +* 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'; import file from '@system.file'; @Entry diff --git a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index.ets index e5efdd2d1a152ebe3cd8eae5beeb1f0c85013e74..0f2d89d2c663dceecf9df42f305a841889dfcb69 100644 --- a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index.ets +++ b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index.ets @@ -1,3 +1,18 @@ +/* +* 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 { diff --git a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index2.ets b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index2.ets index e72ad236352de9b1c888ea151d0d558c02cfda94..f17ed47f6182ee2a772b9fabc269c70390cad7a1 100644 --- a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index2.ets +++ b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index2.ets @@ -1,3 +1,4 @@ +actsstartrunnertest/entry/src/main/ets/pages/index3.ets @Entry @Component struct Index { diff --git a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index3.ets b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index3.ets index 5f72ec0e64f1d8dfe08e63599e9121f2755156fc..ae4dc02582f7c4aaf7583dee23b1f2383a481cb0 100644 --- a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index3.ets +++ b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/pages/index3.ets @@ -1,3 +1,18 @@ +/* +* 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 { diff --git a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/test/List.test.ets index d766fe249dfc3ada636f27e64d9b64451ce32c93..caa07c3911a97aed3eab456f7864b1d430eb4e79 100644 --- a/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsstartrunnertest/entry/src/main/ets/test/List.test.ets @@ -1,3 +1,18 @@ +/* +* 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 abilityTest from './Ability.test' export default function testsuite() {