From 404d5e9af57bcd7d11338c0bc8e9064799914057 Mon Sep 17 00:00:00 2001 From: zhouke Date: Fri, 15 Jul 2022 15:22:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0uitest=20xts=E7=94=A8?= =?UTF-8?q?=E4=BE=8B.Signed-off-by:=20.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouke --- arkXtest/BUILD.gn | 23 + arkXtest/uitest/BUILD.gn | 36 ++ arkXtest/uitest/Test.json | 19 + .../auto_ohos_default_com.uitest.test.p7b | Bin 0 -> 3418 bytes arkXtest/uitest/src/main/config.json | 105 +++++ .../uitest/src/main/ets/MainAbility/app.ets | 22 + .../src/main/ets/MainAbility/pages/fourth.ets | 45 ++ .../src/main/ets/MainAbility/pages/index.ets | 88 ++++ .../src/main/ets/MainAbility/pages/second.ets | 43 ++ .../src/main/ets/MainAbility/pages/third.ets | 43 ++ .../uitest/src/main/ets/TestAbility/app.ets | 34 ++ .../src/main/ets/TestAbility/pages/fourth.ets | 45 ++ .../src/main/ets/TestAbility/pages/index.ets | 88 ++++ .../src/main/ets/TestAbility/pages/second.ets | 43 ++ .../src/main/ets/TestAbility/pages/third.ets | 43 ++ .../ets/TestRunner/OpenHarmonyTestRunner.ts | 77 +++ .../uitest/src/main/ets/test/Ability.test.ets | 439 ++++++++++++++++++ .../uitest/src/main/ets/test/List.test.ets | 19 + .../main/resources/base/element/string.json | 20 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes test_packages.gni | 1 + 21 files changed, 1233 insertions(+) create mode 100644 arkXtest/BUILD.gn create mode 100644 arkXtest/uitest/BUILD.gn create mode 100644 arkXtest/uitest/Test.json create mode 100644 arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b create mode 100644 arkXtest/uitest/src/main/config.json create mode 100644 arkXtest/uitest/src/main/ets/MainAbility/app.ets create mode 100644 arkXtest/uitest/src/main/ets/MainAbility/pages/fourth.ets create mode 100644 arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets create mode 100644 arkXtest/uitest/src/main/ets/MainAbility/pages/second.ets create mode 100644 arkXtest/uitest/src/main/ets/MainAbility/pages/third.ets create mode 100644 arkXtest/uitest/src/main/ets/TestAbility/app.ets create mode 100644 arkXtest/uitest/src/main/ets/TestAbility/pages/fourth.ets create mode 100644 arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets create mode 100644 arkXtest/uitest/src/main/ets/TestAbility/pages/second.ets create mode 100644 arkXtest/uitest/src/main/ets/TestAbility/pages/third.ets create mode 100644 arkXtest/uitest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 arkXtest/uitest/src/main/ets/test/Ability.test.ets create mode 100644 arkXtest/uitest/src/main/ets/test/List.test.ets create mode 100644 arkXtest/uitest/src/main/resources/base/element/string.json create mode 100644 arkXtest/uitest/src/main/resources/base/media/icon.png diff --git a/arkXtest/BUILD.gn b/arkXtest/BUILD.gn new file mode 100644 index 000000000..2fffa655b --- /dev/null +++ b/arkXtest/BUILD.gn @@ -0,0 +1,23 @@ +# 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("//build/ohos_var.gni") + +group("arkXtest") { + testonly = true + if (is_standard_system) { + deps = [ + "uitest:uitest_xts", + ] + } +} diff --git a/arkXtest/uitest/BUILD.gn b/arkXtest/uitest/BUILD.gn new file mode 100644 index 000000000..ca9ff6b85 --- /dev/null +++ b/arkXtest/uitest/BUILD.gn @@ -0,0 +1,36 @@ +# 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") + +ohos_js_hap_suite("uitest_xts") { + hap_profile = "./src/main/config.json" + deps = [ + ":uitest_ets_assets", + ":uitest_ets_test_assets", + ":uitest_ets_resources", + ] + ets2abc = true + certificate_profile = "//test/xts/acts/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b" + hap_name = "uitest_xts" +} +ohos_js_assets("uitest_ets_assets") { + source_dir = "./src/main/ets/MainAbility" +} +ohos_js_assets("uitest_ets_test_assets") { + source_dir = "./src/main/ets/TestAbility" +} +ohos_resources("uitest_ets_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/arkXtest/uitest/Test.json b/arkXtest/uitest/Test.json new file mode 100644 index 000000000..b4ab56805 --- /dev/null +++ b/arkXtest/uitest/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for uitest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "1800000", + "bundle-name": "com.uitest.test", + "package-name": "com.uitest.test", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "$module.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b b/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b new file mode 100644 index 0000000000000000000000000000000000000000..725043f4a0ab0ecbc4159390ac8e11c14d1a3297 GIT binary patch literal 3418 zcmcgvYj6|S8MPj^V~ntg4K^-dEFPwS?7OmLSx%F%tG8@PmMqJbFfl7>^{}LsEbVF~ zQwR}_!y|^0Ou^+9gTa^vNCybUoq?oj1BC<_63VnG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Z$5Iy$4Qwj@AeHdh5N?Wurw}2-NH(I_d U**Yn7{K%oqF777Q>?Y2C0nOb>q5uE@ literal 0 HcmV?d00001 diff --git a/arkXtest/uitest/src/main/config.json b/arkXtest/uitest/src/main/config.json new file mode 100644 index 000000000..3aff4ae13 --- /dev/null +++ b/arkXtest/uitest/src/main/config.json @@ -0,0 +1,105 @@ +{ + "app": { + "vendor": "open", + "bundleName": "com.uitest.test", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.uitest.test", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "visible": true, + "srcPath": "TestAbility", + "name": ".TestAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second", + "pages/third", + "pages/fourth" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second", + "pages/third", + "pages/fourth" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/MainAbility/app.ets b/arkXtest/uitest/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..d22357676 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/MainAbility/app.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/MainAbility/pages/fourth.ets b/arkXtest/uitest/src/main/ets/MainAbility/pages/fourth.ets new file mode 100644 index 000000000..fda1bd719 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/MainAbility/pages/fourth.ets @@ -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 router from '@system.router'; + +@Entry +@Component +struct Fourth + +{ + private content: string = "Fourth Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('longClick') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets b/arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..91d0261dd --- /dev/null +++ b/arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,88 @@ +/** + * 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 prompt from '@ohos.prompt'; + +@Entry +@Component +struct ScrollExample { + scroller: Scroller = new Scroller() + private arr: number[] = [1,2,3,4] + + build() { + Stack({ alignContent: Alignment.TopStart }) { + Scroll(this.scroller) { + Column() { + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.key('my-key') + .type(ButtonType.Capsule) + .margin({ top: 20 }) + .onClick(() => { + router.push({ uri: 'pages/second' }) + }) + .gesture( + LongPressGesture({repeat:false}) + .onAction((event: GestureEvent)=>{ + router.push({ uri: 'pages/fourth' }) + }) + ) + Text('Click twice') + .margin({top:20}) + .gesture( + TapGesture({ count: 2 }) + .onAction(() => { + router.push({ uri: 'pages/third' }) + }) + ) + Checkbox({name:'hi'}) + .size({width:30,height:30}) + TextInput({ placeholder: 'welcome', text: 'Hello World'}) + .type(InputType.Normal) + .width(300) + .height(50) + .fontSize(40) + .enabled(true) + .margin({ top: 20 }) + ForEach(this.arr, (item) => { + Text(item.toString()) + .width('100%').height('30%').backgroundColor(0xFFFFFF) + .borderRadius(75).fontSize(80).textAlign(TextAlign.Center) + .margin({ top: 10 }) + }, item => item) + Button() { + Text('bottom') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20, left: 150 + }) + .onClick(() => { + router.push({ uri: 'pages/second' }) + }) + }.width('100%') + } + .scrollable(ScrollDirection.Vertical).scrollBar(BarState.On) + .scrollBarColor(Color.Gray).scrollBarWidth(30) + .onScroll((xOffset: number, yOffset: number) => { + console.info(xOffset + ' ' + yOffset) + }) + }.width('100%').height('100%').backgroundColor(0xDCDCDC) + } +} + diff --git a/arkXtest/uitest/src/main/ets/MainAbility/pages/second.ets b/arkXtest/uitest/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 000000000..9dcd95189 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/MainAbility/pages/third.ets b/arkXtest/uitest/src/main/ets/MainAbility/pages/third.ets new file mode 100644 index 000000000..6ffa52789 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/MainAbility/pages/third.ets @@ -0,0 +1,43 @@ +/** + * 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 Third{ + private content: string = "Third Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('page_3') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/TestAbility/app.ets b/arkXtest/uitest/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..0ecadbc2c --- /dev/null +++ b/arkXtest/uitest/src/main/ets/TestAbility/app.ets @@ -0,0 +1,34 @@ +/** + * 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!!!') + abilityDelegatorArguments.parameters['timeout'] = 3000000 + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, + +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/TestAbility/pages/fourth.ets b/arkXtest/uitest/src/main/ets/TestAbility/pages/fourth.ets new file mode 100644 index 000000000..fda1bd719 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/TestAbility/pages/fourth.ets @@ -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 router from '@system.router'; + +@Entry +@Component +struct Fourth + +{ + private content: string = "Fourth Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('longClick') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets b/arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..91d0261dd --- /dev/null +++ b/arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,88 @@ +/** + * 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 prompt from '@ohos.prompt'; + +@Entry +@Component +struct ScrollExample { + scroller: Scroller = new Scroller() + private arr: number[] = [1,2,3,4] + + build() { + Stack({ alignContent: Alignment.TopStart }) { + Scroll(this.scroller) { + Column() { + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.key('my-key') + .type(ButtonType.Capsule) + .margin({ top: 20 }) + .onClick(() => { + router.push({ uri: 'pages/second' }) + }) + .gesture( + LongPressGesture({repeat:false}) + .onAction((event: GestureEvent)=>{ + router.push({ uri: 'pages/fourth' }) + }) + ) + Text('Click twice') + .margin({top:20}) + .gesture( + TapGesture({ count: 2 }) + .onAction(() => { + router.push({ uri: 'pages/third' }) + }) + ) + Checkbox({name:'hi'}) + .size({width:30,height:30}) + TextInput({ placeholder: 'welcome', text: 'Hello World'}) + .type(InputType.Normal) + .width(300) + .height(50) + .fontSize(40) + .enabled(true) + .margin({ top: 20 }) + ForEach(this.arr, (item) => { + Text(item.toString()) + .width('100%').height('30%').backgroundColor(0xFFFFFF) + .borderRadius(75).fontSize(80).textAlign(TextAlign.Center) + .margin({ top: 10 }) + }, item => item) + Button() { + Text('bottom') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20, left: 150 + }) + .onClick(() => { + router.push({ uri: 'pages/second' }) + }) + }.width('100%') + } + .scrollable(ScrollDirection.Vertical).scrollBar(BarState.On) + .scrollBarColor(Color.Gray).scrollBarWidth(30) + .onScroll((xOffset: number, yOffset: number) => { + console.info(xOffset + ' ' + yOffset) + }) + }.width('100%').height('100%').backgroundColor(0xDCDCDC) + } +} + diff --git a/arkXtest/uitest/src/main/ets/TestAbility/pages/second.ets b/arkXtest/uitest/src/main/ets/TestAbility/pages/second.ets new file mode 100644 index 000000000..9dcd95189 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/TestAbility/pages/second.ets @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/TestAbility/pages/third.ets b/arkXtest/uitest/src/main/ets/TestAbility/pages/third.ets new file mode 100644 index 000000000..6ffa52789 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/TestAbility/pages/third.ets @@ -0,0 +1,43 @@ +/** + * 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 Third{ + private content: string = "Third Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('page_3') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/arkXtest/uitest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..91a202502 --- /dev/null +++ b/arkXtest/uitest/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/arkXtest/uitest/src/main/ets/test/Ability.test.ets b/arkXtest/uitest/src/main/ets/test/Ability.test.ets new file mode 100644 index 000000000..40a36a436 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/test/Ability.test.ets @@ -0,0 +1,439 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { UiDriver, BY, ResizeDirection, MatchPattern } from '@ohos.uitest' +import ability_featureAbility from '@ohos.ability.featureAbility'; + +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +const waitUiReadyMs = 1000; + +async function startAbility(bundleName: string, abilityName: string) { + await delegator.executeShellCommand(`aa start -b ${bundleName} -a ${abilityName}`).then(result => { + console.info(`UiTestCase, start abilityFinished: ${result}`) + }).catch(err => { + console.error(`UiTestCase, start abilityFailed: ${err}`) + }) +} + +async function stopApplication(bundleName: string) { + await delegator.executeShellCommand(`aa force-stop ${bundleName} `).then(result => { + console.info(`UiTestCase, stop application finished: ${result}`) + }).catch(err => { + console.error(`UiTestCase,stop application failed: ${err}`) + }) +} + +export default function abilityTest() { + describe('UiTestCase', function () { + it('UiComponent.InputText', 0, async function () { + let driver = UiDriver.create() + //await startAbility('com.example.myapplication', 'com.example.entry.MainAbility') + await driver.delayMs(waitUiReadyMs) + let input = await driver.findComponent(BY.type('TextInput')) + await input.inputText('123') + await driver.delayMs(waitUiReadyMs) + let input_new = await driver.findComponent(BY.type('TextInput')) + let text = await input_new.getText() + expect(text == '123').assertTrue() + }) + + it('UiComponent.ClearText', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let input = await driver.findComponent(BY.type('TextInput')) + await input.clearText() + await driver.delayMs(waitUiReadyMs) + let input_new = await driver.findComponent(BY.type('TextInput')) + let text = await input_new.getText() + expect(text).assertEqual('') + }) + + it('checkable', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.checkable(true).type('Checkbox')) + let checkable = await button.isCheckable() + expect(typeof (checkable) == 'boolean').assertTrue() + }) + + it('checked', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.checked(false).type('Checkbox')) + let checked = await button.isChecked() + expect(typeof (checked) == 'boolean').assertTrue() + }) + + it('UiDriver.click', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + await driver.click(350, 90) + await driver.delayMs(waitUiReadyMs) + let newButton = await driver.findComponent(BY.text('back to index')) + let text = await newButton.getText() + expect(text == 'back to index').assertTrue() + await newButton.click() + }) + + it('UiDriver.LongClick', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + await driver.longClick(350, 90) + await driver.delayMs(waitUiReadyMs) + let newButton = await driver.findComponent(BY.text('longClick')) + let text = await newButton.getText() + expect(text == 'longClick').assertTrue() + await newButton.click() + }) + + it('key', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.key('my-key')) + expect(await button.getKey() == 'my-key').assertTrue() + }) + + it('UiComponent.Click', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page', MatchPattern.EQUALS)) + await button.click() + await driver.delayMs(waitUiReadyMs) + let newButton = await driver.findComponent(BY.text('back to index')) + let text = await newButton.getText() + expect(text == 'back to index').assertTrue() + await newButton.click() + }) + + it('UiComponent.LongClick', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page')) + await button.longClick() + await driver.delayMs(waitUiReadyMs) + let newButton = await driver.findComponent(BY.text('longClick')) + let text = await newButton.getText() + expect(text == 'longClick').assertTrue() + await newButton.click() + }) + + it('UiComponent.getType', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let text = await driver.findComponent(BY.type('Text')) + let type = await text.getType() + expect(type == 'Text').assertTrue() + }) + + it('UiComponent.getText', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page')) + let text = await button.getText() + expect(text == 'next page').assertTrue() + }) + + it('UiComponent.isClickable', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page').clickable(false)) + let clickable = await button.isClickable() + expect(typeof (clickable) == 'boolean').assertTrue() + }) + + it('UiComponent.isLongClickable', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page').longClickable(false)) + let longClickable = await button.isLongClickable() + expect(typeof (longClickable) == 'boolean').assertTrue() + }) + + it('UiComponent.isScrollable', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let scrollBar = await driver.findComponent(BY.type('Scroll').scrollable(false)) + let scrollable = await scrollBar.isScrollable() + expect(typeof (scrollable) == 'boolean').assertTrue() + }) + + it('UiComponent.isEnabled', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page').enabled(true)) + let enable = await button.isEnabled() + expect(enable).assertEqual(true) + }) + + it('UiComponent.isFocused', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page').focused(false)) + let focused = await button.isFocused() + expect(typeof (focused) == 'boolean').assertTrue() + }) + + it('UiComponent.isSelected', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page').selected(false)) + let selected = await button.isSelected() + expect(typeof (selected) == 'boolean').assertTrue() + }) + + it('UiComponent.scrollToBottom', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let scrollBar = await driver.findComponent(BY.type('Scroll')) + expect(scrollBar != null).assertTrue() + await scrollBar.scrollToBottom() + let button = await driver.findComponent(BY.text('bottom')) + expect(await button.getText() == 'bottom').assertTrue() + await scrollBar.scrollToTop() + }) + + it('UiComponent.scrollToTop', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + await driver.swipe(100, 200, 100, 100) + await driver.delayMs(waitUiReadyMs) + let scrollBar = await driver.findComponent(BY.type('Scroll')) + expect(scrollBar !== null).assertTrue() + await scrollBar.scrollToTop() + let button = await driver.findComponent(BY.text('next page')) + expect(await button.getText() == 'next page').assertTrue() + }) + + it('UiDriver.assertComponentExist', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + await driver.assertComponentExist(BY.text('next page')) + }) + + it('UiDriver.pressBack', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page')) + await button.click() + await driver.delayMs(waitUiReadyMs) + await driver.pressBack() + await driver.delayMs(waitUiReadyMs) + let button_ori = await driver.findComponent(BY.text('next page')) + expect(await button_ori.getText() == 'next page').assertTrue() + }) + + it('UiDriver.findComponents', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let buttons = await driver.findComponents(BY.type('Button')) + expect(await buttons[0].getText() != null).assertTrue() + }) + + it('UiDriver.triggerKey', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page')) + await button.click() + await driver.delayMs(waitUiReadyMs) + await driver.triggerKey(2) + await driver.delayMs(waitUiReadyMs) + let button_ori = await driver.findComponent(BY.text('next page')) + expect(await button_ori.getText() == 'next page').assertTrue() + }) + + it('UiDriver.swipe', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + await driver.swipe(100, 500, 100, 100) + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('bottom')) + let text = await button.getText() + expect(text == 'bottom').assertTrue() + await driver.swipe(100, 100, 100, 600) + + }) + + it('UiDriver.screenCap', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let path = '/data/local/tmp/1.png' + let success = await driver.screenCap(path) + expect(typeof (success) == 'boolean').assertTrue() + }) + + it('getUiComponentBounds', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let text = await driver.findComponent(BY.text('Hello World')) + expect(text !== null).assertTrue() + let bounds = await text.getBounds(); + console.info(`UiTestCase, bounds=${bounds}, type=${typeof (bounds)}`) + console.info(bounds.rightX.toString()) + console.info(bounds.leftX.toString()) + console.info(bounds.topY.toString()) + console.info(bounds.bottomY.toString()) + expect(bounds !== null).assertTrue() + expect(bounds.rightX).assertLarger(bounds.leftX) + expect(bounds.bottomY).assertLarger(bounds.topY) + }) + + it('getUiComponentBoundsCenter', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page')) + let point = await button.getBoundsCenter() + expect(point!== null).assertTrue() + }) + + it('UiDriver.waitForComponent', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.waitForComponent(BY.text('next page'), waitUiReadyMs) + expect(button !== null).assertTrue() + }) + + it('By.isBefore', 0, async function () { + await startAbility('com.ohos.settings', 'com.ohos.settings.MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.isBefore(BY.text('显示与亮度')).text('移动数据')) + expect(await button.getText() == '移动数据').assertTrue() + }) + + it('By.isAfter', 0, async function () { + await startAbility('com.ohos.settings', 'com.ohos.settings.MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.isAfter(BY.text('显示与亮度')).text('声音')) + expect(await button.getText() == '声音').assertTrue() + }) + + it('window.test', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(200) + let window = await driver.findWindow({bundleName:'com.example.windows'}) + await window.resume() + await driver.delayMs(200) + let window2 = await driver.findWindow({bundleName:'com.example.windows'}) + await window2.moveTo(300, 300) + await driver.delayMs(200) + let button2 = await driver.findComponent(BY.text('Clock')) + await button2.click() + }) + + it('window.test_2', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('自由窗口创建')) + await button.click() + await driver.delayMs(waitUiReadyMs) + let window_2 = await driver.findWindow({bundleName:'com.example.windows'}) + await window_2.resize(400, 400, 7) + let window = await driver.findWindow({bundleName:'com.example.windows'}) + await window.resize(600, 600, 7) + await stopApplication('com.example.windows') + }) + + it('window.resize', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let window = await driver.findWindow({bundleName:'com.example.windows'}) + await window.resume() + await driver.delayMs(waitUiReadyMs) + let window1 = await driver.findWindow({bundleName:'com.example.windows'}) + await window1.moveTo(100,100) + await driver.delayMs(waitUiReadyMs) + let window2 = await driver.findWindow({bundleName:'com.example.windows'}) + await window2.resize(600, 600,7) + await driver.delayMs(waitUiReadyMs) + }) + + it('window.maximize', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let window = await driver.findWindow({bundleName:'com.example.windows'}) + await window.maximize() + }) + + it('window.minimize', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let window = await driver.findWindow({bundleName:'com.example.windows'}) + await window.minimize() + }) + + it('window.close', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let window = await driver.findWindow({bundleName:'com.example.windows'}) + await window.close() + }) + + it('window.split', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let window = await driver.findWindow({bundleName:'com.example.windows'}) + await window.split() + }) + + }) + + + + afterAll(function () { + console.info(`uitestApiStatistic::Start runnig afterAll`) + try { + let mod = globalThis.requireInternal('uitest') + // collect all functions + let objects = { + 'By': mod.By, 'UiDriver': mod.UiDriver, 'UiComponent': mod.UiComponent + } + let allApis = [] + for (let name in objects) { + let object = objects[name] + Object.getOwnPropertyNames(object).forEach(pn => { + if (pn != 'constructor' && typeof (object[pn]) == 'function') { + allApis.push(name + '.' + pn) + } + }) + + Object.getOwnPropertyNames(object.prototype).forEach(pn => { + if (pn != 'constructor' && typeof (object.prototype[pn]) == 'function') { + allApis.push(name + '.' + pn) + } + }) + } + + let calledApis: Array = mod.getCalledJsApis() + calledApis.forEach(name => console.info(`uitestApiStatistic::CoveredApi: ${name}`)) + let missedApis = allApis.filter(value =>!calledApis.includes(value)) + console.info(`uitestApiStatistic::Total ${allApis.length}, coverd ${calledApis.length}, missed ${missedApis.length}`) + missedApis.forEach(name => console.warn(`uitestApiStatistic::NotCoveredApi: ${name}`)) + } catch (e) { + console.error(`uitestApiStatistic::Runnig afterAll failed: ${e}`) + } finally { + console.info(`uitestApiStatistic::End runnig afterAll`) + } + }) + } diff --git a/arkXtest/uitest/src/main/ets/test/List.test.ets b/arkXtest/uitest/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..a73bd12b1 --- /dev/null +++ b/arkXtest/uitest/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/arkXtest/uitest/src/main/resources/base/element/string.json b/arkXtest/uitest/src/main/resources/base/element/string.json new file mode 100644 index 000000000..498677efb --- /dev/null +++ b/arkXtest/uitest/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "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/arkXtest/uitest/src/main/resources/base/media/icon.png b/arkXtest/uitest/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD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