diff --git a/arkXtest/BUILD.gn b/arkXtest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8eca0b47815ea39a8b0501c9f79867be2c246812 --- /dev/null +++ b/arkXtest/BUILD.gn @@ -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("//build/ohos_var.gni") + +group("arkXtest") { + testonly = true + if (is_standard_system) { + deps = [ "uitest:uitestActs" ] + } +} diff --git a/arkXtest/uitest/BUILD.gn b/arkXtest/uitest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a7b9c7f12a9d473ca96f7055270ec55957f653b7 --- /dev/null +++ b/arkXtest/uitest/BUILD.gn @@ -0,0 +1,36 @@ +# 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("uitestActs") { + hap_profile = "./src/main/config.json" + deps = [ + ":uitest_ets_assets", + ":uitest_ets_resources", + ":uitest_ets_test_assets", + ] + ets2abc = true + certificate_profile = "//test/xts/acts/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b" + hap_name = "uitestActs" +} +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 0000000000000000000000000000000000000000..ed1d23104fc4f4483b5e6bcf61938003953b3f02 --- /dev/null +++ b/arkXtest/uitest/Test.json @@ -0,0 +1,38 @@ +{ + "description": "Configuration for uitest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "1800000", + "bundle-name": "com.uitest.acts", + "package-name": "com.uitest.acts", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "$module.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "PushKit", + "push": [ + "resource/arkXtest/arkXtest_windowsTest.hap -> /data/local/tmp/arkXtest_windowsTest.hap", + "resource/arkXtest/window_manager_config.xml -> /system/etc/window/resources/window_manager_config.xml" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602", + "bm install -p /data/local/tmp/arkXtest_windowsTest.hap" + ], + "teardown-command": [ + "bm uninstall -n com.example.windows" + ] + } + ] +} \ 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 Binary files /dev/null and b/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b differ diff --git a/arkXtest/uitest/src/main/config.json b/arkXtest/uitest/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..36a89d10257c850ce42ab3dcb566a0240c720466 --- /dev/null +++ b/arkXtest/uitest/src/main/config.json @@ -0,0 +1,102 @@ +{ + "app": { + "vendor": "open", + "bundleName": "com.uitest.acts", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.uitest.acts", + "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" + ], + "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 0000000000000000000000000000000000000000..f7619f93f7c8ed901bfab4b51edf4df9166b03fb --- /dev/null +++ b/arkXtest/uitest/src/main/ets/MainAbility/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['-s 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/MainAbility/pages/fourth.ets b/arkXtest/uitest/src/main/ets/MainAbility/pages/fourth.ets new file mode 100644 index 0000000000000000000000000000000000000000..fda1bd719035a16905da7851875bdacdda5a2c90 --- /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 0000000000000000000000000000000000000000..ce47034bf74466667efabd4792218b955cb4d328 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,107 @@ +/** + * 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() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('MainPage') + .fontSize(50) + .fontWeight(FontWeight.Bold) + 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' }) + }) + ) + + Button() { + Text('Click twice') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ top: 20 }) + .gesture( + TapGesture({ count: 1 }) + .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 0000000000000000000000000000000000000000..9dcd951896be78626c21d48cf64296d4194f8a81 --- /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 0000000000000000000000000000000000000000..78eea6035c85dbea81733e8414ef77fe66a8508b --- /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('doubleClick') + .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 0000000000000000000000000000000000000000..bce6196d05fb2266ff0a96005f29233e033515c9 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/TestAbility/app.ets @@ -0,0 +1,24 @@ +/** + * 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/TestAbility/pages/index.ets b/arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce47034bf74466667efabd4792218b955cb4d328 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,107 @@ +/** + * 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() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('MainPage') + .fontSize(50) + .fontWeight(FontWeight.Bold) + 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' }) + }) + ) + + Button() { + Text('Click twice') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ top: 20 }) + .gesture( + TapGesture({ count: 1 }) + .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/TestRunner/OpenHarmonyTestRunner.ts b/arkXtest/uitest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b35659daba8771ef16abe4ec26cd82e242b3de4 --- /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'] + '.MainAbility' + 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/List.test.ets b/arkXtest/uitest/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ebbed8f8ccf03b2ba8d9fc8180f9b064f515df05 --- /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 './uitest.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/arkXtest/uitest/src/main/ets/test/uitest.test.ets b/arkXtest/uitest/src/main/ets/test/uitest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d69fd2c97d20f418c299f1c67a5b5abcf2e91572 --- /dev/null +++ b/arkXtest/uitest/src/main/ets/test/uitest.test.ets @@ -0,0 +1,737 @@ +/** + * 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, WindowMode } 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 uiTest() { + describe('UiTestCase', function () { + + /* + * @tc.number: uiTest_0100 + * @tc.name: testInputText + * @tc.desc: inject text to the target UiComponent + */ + it('testInputText', 0, async function () { + let driver = UiDriver.create() + 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() + }) + + /* + * @tc.number: uiTest_0200 + * @tc.name: testClearText + * @tc.desc: clear text of the target UiComponent + */ + it('testClearText', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let input1 = await driver.findComponent(BY.type('TextInput')) + await input1.inputText('abc') + let input2 = await driver.findComponent(BY.type('TextInput')) + await input2.clearText() + await driver.delayMs(waitUiReadyMs) + let input_new = await driver.findComponent(BY.type('TextInput')) + let text = await input_new.getText() + expect(text).assertEqual('') + }) + + /* + * @tc.number: uiTest_0300 + * @tc.name: testCheckable + * @tc.desc: find UiComponent by checkable attribute and get it's checkable attribute. + */ + it('testCheckable', 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(checkable == true).assertTrue() + }) + + /* + * @tc.number: uiTest_0400 + * @tc.name: testChecked + * @tc.desc: find UiComponent by checked attribute and get it's checked attribute. + */ + it('testChecked', 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(checked == false).assertTrue() + }) + + /* + * @tc.number: uiTest_0500 + * @tc.name: testMatchPattern + * @tc.desc: specifies the string value match pattern. + */ + it('testMatchPattern', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let Button1 = await driver.findComponent(BY.text('next page',MatchPattern.EQUALS)) + expect(await Button1.getText() == 'next page').assertTrue() + let Button2 = await driver.findComponent(BY.text('next',MatchPattern.STARTS_WITH)) + expect(await Button2.getText() == 'next page').assertTrue() + let Button3 = await driver.findComponent(BY.text('page',MatchPattern.ENDS_WITH)) + expect(await Button3.getText() == 'next page').assertTrue() + let Button4 = await driver.findComponent(BY.text('ext',MatchPattern.CONTAINS)) + expect(await Button4.getText() == 'next page').assertTrue() + }) + + /* + * @tc.number: uiTest_0600 + * @tc.name: testClick + * @tc.desc: click in the specified location on the screen. + */ + it('testClick', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let Button = await driver.findComponent(BY.text('next page')) + let center = await Button.getBoundsCenter() + await driver.click(center.X, center.Y) + 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() + }) + + /* + * @tc.number: uiTest_0700 + * @tc.name: testDoubleClick + * @tc.desc: doubleClick in the specified location on the screen. + */ + it('testDoubleClick', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let Button = await driver.findComponent(BY.text('Click twice')) + let center = await Button.getBoundsCenter() + await driver.doubleClick(center.X, center.Y) + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('doubleClick')) + let text = await button.getText() + expect(text == 'doubleClick').assertTrue() + await button.click() + }) + + /* + * @tc.number: uiTest_0800 + * @tc.name: testLongClick + * @tc.desc: longClick in the specified location on the screen. + */ + it('testLongClick', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let Button = await driver.findComponent(BY.text('next page')) + let center = await Button.getBoundsCenter() + await driver.longClick(center.X, center.Y) + await driver.delayMs(waitUiReadyMs) + let newButton = await driver.findComponent(BY.text('longClick')) + let text = await newButton.getText() + expect(text == 'longClick').assertTrue() + await newButton.click() + }) + + /* + * @tc.number: uiTest_0900 + * @tc.name: testUiComponentClick + * @tc.desc: click this UiComponentClick. + */ + it('testUiComponentClick', 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) + let newButton = await driver.findComponent(BY.text('back to index')) + let text = await newButton.getText() + expect(text == 'back to index').assertTrue() + await newButton.click() + }) + + /* + * @tc.number: uiTest_1000 + * @tc.name: testUiComponentDoubleClick + * @tc.desc: doubleClick this UiComponentClick. + */ + it('testUiComponentDoubleClick', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('Click twice')) + await button.doubleClick() + await driver.delayMs(waitUiReadyMs) + let newButton = await driver.findComponent(BY.text('doubleClick')) + let text = await newButton.getText() + expect(text == 'doubleClick').assertTrue() + await newButton.click() + }) + + /* + * @tc.number: uiTest_1100 + * @tc.name: testUiComponentLongClick + * @tc.desc: longClick this UiComponentClick. + */ + it('testUiComponentLongClick', 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() + }) + + /* + * @tc.number: uiTest_1200 + * @tc.name: testKey + * @tc.desc: find UiComponent by key attribute and get it's key attribute. + */ + it('testKey', 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() + }) + + /* + * @tc.number: uiTest_1300 + * @tc.name: testId + * @tc.desc: find UiComponent by id attribute and get it's id attribute. + */ + it('testId', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('next page')) + let id = await button.getId() + let button2 = await driver.findComponent(BY.id(id)) + expect(await button2.getText() == 'next page').assertTrue() + }) + + /* + * @tc.number: uiTest_1400 + * @tc.name: testType + * @tc.desc: find UiComponent by type attribute and get it's type attribute. + */ + it('testType', 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() + }) + + /* + * @tc.number: uiTest_1500 + * @tc.name: testClickable + * @tc.desc: find UiComponent by clickable attribute and get it's clickable attribute. + */ + it('testClickable', 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(clickable == false).assertTrue() + }) + + /* + * @tc.number: uiTest_1600 + * @tc.name: testLongClickable + * @tc.desc: find UiComponent by longClickable attribute and get it's longClickable attribute. + */ + it('testLongClickable', 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(longClickable== false).assertTrue() + }) + + /* + * @tc.number: uiTest_1700 + * @tc.name: testScrollable + * @tc.desc: find UiComponent by scrollable attribute and get it's scrollable attribute. + */ + it('testScrollable', 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(scrollable == false).assertTrue() + }) + + /* + * @tc.number: uiTest_1800 + * @tc.name: testEnabled + * @tc.desc: find UiComponent by enabled attribute and get it's enabled attribute. + */ + it('testEnabled', 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 == true).assertTrue() + }) + + /* + * @tc.number: uiTest_1900 + * @tc.name: testFocused + * @tc.desc: find UiComponent by focused attribute and get it's focused attribute. + */ + it('testFocused', 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(focused == false).assertTrue() + }) + + /* + * @tc.number: uiTest_2000 + * @tc.name: testSelected + * @tc.desc: find UiComponent by selected attribute and get it's selected attribute. + */ + it('testSelected', 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(selected == false).assertTrue() + }) + + /* + * @tc.number: uiTest_2100 + * @tc.name: testPressBack + * @tc.desc: Press the BACK key. + */ + it('testPressBack', 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() + }) + + /* + * @tc.number: uiTest_2200 + * @tc.name: testFindComponents + * @tc.desc: find all the matched UiComponents on current UI + */ + it('testFindComponents', 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() + }) + + /* + * @tc.number: uiTest_2300 + * @tc.name: testTriggerKey + * @tc.desc: press the specified key. + */ + it('testTriggerKey', 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) + let keyBack = 2 + await driver.triggerKey(keyBack) + await driver.delayMs(waitUiReadyMs) + let button_ori = await driver.findComponent(BY.text('next page')) + expect(await button_ori.getText() == 'next page').assertTrue() + }) + + /* + * @tc.number: uiTest_2400 + * @tc.name: testGetUiComponentBounds + * @tc.desc: get the bounds of this UiComponent. + */ + it('testGetUiComponentBounds', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let text = await driver.findComponent(BY.text('next page')) + expect(text !== null).assertTrue() + let bounds = await text.getBounds(); + expect(bounds !== null).assertTrue() + expect(bounds.rightX).assertLarger(bounds.leftX) + expect(bounds.bottomY).assertLarger(bounds.topY) + }) + + /* + * @tc.number: uiTest_2500 + * @tc.name: testGetUiComponentBoundsCenter + * @tc.desc: get the boundsCenter of this @link UiComponent. + */ + it('testGetUiComponentBoundsCenter', 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() + let bounds = await button.getBounds() + expect(point!== null).assertTrue() + expect(point.Y == (bounds.bottomY + bounds.topY)/2).assertTrue() + expect(point.X == (bounds.rightX + bounds.leftX)/2).assertTrue() + }) + + /* + * @tc.number: uiTest_2600 + * @tc.name: testWaitForComponent + * @tc.desc: Find the first matched UiComponent on current UI during the time given. + */ + it('testWaitForComponent', 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() + }) + + /* + * @tc.number: uiTest_2700 + * @tc.name: testScreenCap + * @tc.desc: capture current screen. + */ + it('testScreenCap', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let savePath = '/data/local/tmp/1.png' + let success = await driver.screenCap(savePath) + expect(success == true).assertTrue() + }) + + /* + * @tc.number: uiTest_2800 + * @tc.name: testAssertComponentExist + * @tc.desc: Assert whether the matched UiComponent exists on current UI;. + */ + it('testAssertComponentExist', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + await driver.assertComponentExist(BY.text('next page')) + }) + + /* + * @tc.number: uiTest_2900 + * @tc.name: testIsBefore + * @tc.desc: find uiComponent which is before another UiComponent that specified by given. + */ + it('testIsBefore', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.isBefore(BY.text('Click twice')).type('Button')) + expect(await button.getType() == 'Button').assertTrue() + }) + + /* + * @tc.number: uiTest_3000 + * @tc.name: testIsAfter + * @tc.desc: find uiComponent which is after another UiComponent that specified by given. + */ + it('testIsAfter', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.isAfter(BY.text('next page')).type('Text')) + expect(await button.getText() == 'Click twice').assertTrue() + }) + + /* + * @tc.number: uiTest_3100 + * @tc.name: testSwipe + * @tc.desc: swipe on the screen between the specified points. + */ + it('testSwipe', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + await driver.swipe(300,600,300,300) + let text = await driver.findComponent(BY.text('next page')) + expect(text == null).assertTrue() + await driver.swipe(300,300,300,600) + }) + + /* + * @tc.number: uiTest_3200 + * @tc.name: testScrollSearch + * @tc.desc: scroll on this UiComponent to find matched UiComponent. + */ + it('testScrollSearch', 0, async function () { + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let scrollBar = await driver.findComponent(BY.type('Scroll')) + let button = await scrollBar.scrollSearch(BY.text('next page')) + expect(await button.getText() == 'next page').assertTrue() + }) + + /* + * @tc.number: uiTest_3300 + * @tc.name: testScrollToBottom + * @tc.desc: scroll on this UiComponent to the bottom. + */ + it('testScrollToBottom', 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() + }) + + /* + * @tc.number: uiTest_3400 + * @tc.name: testScrollToTop + * @tc.desc: scroll on this UiComponent to the top. + */ + it('testScrollToTop', 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() + await scrollBar.scrollToTop() + let button = await driver.findComponent(BY.text('next page')) + expect(await button.getText() == 'next page').assertTrue() + }) + + /* + * @tc.number: uiTest_3500 + * @tc.name: testGetWindowMode + * @tc.desc: get the window mode of this UiWindow. + */ + it('testGetWindowMode', 0, async function () { + await startAbility('com.example.windows', 'MainAbility') + let driver = UiDriver.create() + await driver.delayMs(waitUiReadyMs) + let window1 = await driver.findWindow({bundleName:'com.example.windows'}) + let mode1 = await window1.getWindowMode() + expect(mode1 == WindowMode.FULLSCREEN).assertTrue() + let window2 = await driver.findWindow({bundleName:'com.example.windows'}) + await window2.resume() + let mode2 = await window2.getWindowMode() + expect(mode2 == WindowMode.FLOATING).assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_3600 + * @tc.name: testGetBundleName + * @tc.desc: get the bundleName of this UiWindow. + */ + it('testGetBundleName', 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'}) + let name = await window.getBundleName() + expect(name == 'com.example.windows').assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_3700 + * @tc.name: testGetTitle + * @tc.desc: get the title of this UiWindow. + */ + it('testGetTitle', 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'}) + let title = await window.getTitle() + expect(title == '').assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_3800 + * @tc.name: testWindowMoveTo + * @tc.desc: move this UiWindow to the specified points. + */ + it('testWindowMoveTo', 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'}) + let bounds1 = await window1.getBounds() + await window1.moveTo(100,100) + await driver.delayMs(waitUiReadyMs) + let window2 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds2 = await window2.getBounds() + expect(bounds1 != bounds2).assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_3900 + * @tc.name: testWindowResize + * @tc.desc: resize this UiWindow to the specified size for the specified direction. + */ + it('testWindowResize', 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'}) + let bounds1 = await window1.getBounds() + await window1.resize(400,400,ResizeDirection.RIGHT_DOWN) + await driver.delayMs(waitUiReadyMs) + let window2 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds2 = await window2.getBounds() + expect(bounds2 != bounds1).assertTrue() + await window2.resize(500,500,ResizeDirection.RIGHT_UP) + let window3 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds3= await window2.getBounds() + expect(bounds3 != bounds2).assertTrue() + await window3.resize(400,400,ResizeDirection.LEFT_DOWN) + let window4 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds4= await window2.getBounds() + expect(bounds4 != bounds3).assertTrue() + await window4.resize(500,500,ResizeDirection.LEFT_DOWN) + let window5 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds5= await window2.getBounds() + expect(bounds5 != bounds4).assertTrue() + await window5.resize(500,400,ResizeDirection.DOWN) + let window6 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds6= await window2.getBounds() + expect(bounds6 != bounds5).assertTrue() + await window6.resize(500,500,ResizeDirection.UP) + let window7 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds7 = await window2.getBounds() + expect(bounds7 != bounds5).assertTrue() + await window7.resize(500,500,ResizeDirection.UP) + let window8 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds8 = await window2.getBounds() + expect(bounds8 != bounds7).assertTrue() + await window8.resize(400,500,ResizeDirection.LEFT) + let window9 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds9 = await window2.getBounds() + expect(bounds9 != bounds8).assertTrue() + await window9.resize(400,500,ResizeDirection.RIGHT) + let window10 = await driver.findWindow({bundleName:'com.example.windows'}) + let bounds10 = await window2.getBounds() + expect(bounds10 != bounds9).assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_4000 + * @tc.name: testWindowFocus + * @tc.desc: set the focused status of this UiWindow. + */ + it('testWindowFocus', 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.focus() + let IsActive = await window.focus() + expect(IsActive == true).assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_4100 + * @tc.name: testWindowMaximize + * @tc.desc: maximize this UiWindow. + */ + it('testWindowMaximize', 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() + let window2 = await driver.findWindow({bundleName:'com.example.windows'}) + await window2.maximize() + await driver.delayMs(waitUiReadyMs) + let window3 = await driver.findWindow({bundleName:'com.example.windows'}) + let mode = await window3.getWindowMode() + expect(mode == WindowMode.FULLSCREEN).assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_4200 + * @tc.name: testWindowMinimize + * @tc.desc: minimize this UiWindow. + */ + it('testWindowMinimize', 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() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('Clock')) + expect(button != null).assertTrue() + await stopApplication('com.example.windows') + }) + + /* + * @tc.number: uiTest_4300 + * @tc.name: testWindowClose + * @tc.desc: close this UiWindow. + */ + it('testWindowClose', 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() + await driver.delayMs(waitUiReadyMs) + let button = await driver.findComponent(BY.text('Clock')) + expect(button != null).assertTrue() + }) + + }) + +} \ 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 0000000000000000000000000000000000000000..498677efbde065c36668727190d3613cbf278bfc --- /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 Binary files /dev/null and b/arkXtest/uitest/src/main/resources/base/media/icon.png differ diff --git a/test_packages.gni b/test_packages.gni index fbfdbed7f08541c746d1b6f60f756432e8a6f43b..9611590a7d3d55b8c9cda69a36fd4b440466c4c9 100644 --- a/test_packages.gni +++ b/test_packages.gni @@ -14,6 +14,7 @@ import("//test/xts/tools/build/suite.gni") _all_test_packages = [ + "${ACTS_ROOT}/arkXtest:arkXtest", "${ACTS_ROOT}/global:global", "${ACTS_ROOT}/security:security", "${ACTS_ROOT}/useriam:useriam",