未验证 提交 8f7676c0 编写于 作者: O openharmony_ci 提交者: Gitee

!8685 arkxtest增加测试用例.被测hap包切成arkui新框架stage模型

Merge pull request !8685 from 周柯/master
......@@ -20,7 +20,7 @@ ohos_js_hap_suite("ActsUiTest") {
":uitest_ets_resources",
]
ets2abc = true
certificate_profile = "//test/xts/acts/testfwk/uitest/signature/auto_ohos_default_com.uitest.test.p7b"
certificate_profile = "../../../../../test/xts/acts/testfwk/uitest/signature/auto_ohos_default_com.uitest.test.p7b"
hap_name = "ActsUiTest"
part_name = "arkxtest"
subsystem_name = "testfwk"
......
......@@ -14,7 +14,7 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { UiComponent, UiDriver, BY, Component, Driver, UiWindow, ON, MatchPattern, DisplayRotation, ResizeDirection, UiDirection, MouseButton, WindowMode, PointerMatrix } from '@ohos.UiTest'
import { UiComponent, UiDriver, BY, Component, Driver, UiWindow, ON, MatchPattern, DisplayRotation, ResizeDirection, UiDirection, MouseButton, WindowMode, PointerMatrix, UIElementInfo, UIEventObserver } from '@ohos.UiTest'
import ability_featureAbility from '@ohos.ability.featureAbility';
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
......@@ -180,6 +180,52 @@ export default function UiTest() {
expect(btn != null).assertTrue()
await stopApplication('com.uitestScene.acts')
})
/*
* @tc.number: uiTest_10008
* @tc.name: testMonitor1
* @tc.desc: monitor toast appearance.
*/
it('testMonitor1', 0, async function () {
await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
let driver = Driver.create()
await driver.delayMs(waitUiReadyMs)
let observer = await driver.createUIEventObserver()
let callback = (UiElementInfo) => {
expect(UiElementInfo.bundleName == 'com.uitestScene.acts').assertTrue()
expect(UiElementInfo.text == 'toastShow').assertTrue()
expect(UiElementInfo.type == 'Toast').assertTrue()
}
observer.once('toastShow', callback)
let btn = await driver.findComponent(ON.text('toast'))
await btn.click()
await driver.delayMs(waitUiReadyMs)
await stopApplication('com.uitestScene.acts')
})
/*
* @tc.number: uiTest_10009
* @tc.name: testMonitor2
* @tc.desc: monitor dialog appearance.
*/
it('testMonitor2', 0, async function () {
await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
let driver = Driver.create()
await driver.delayMs(waitUiReadyMs)
let observer = await driver.createUIEventObserver()
let callback = (UiElementInfo) => {
expect(UiElementInfo.bundleName == 'com.uitestScene.acts').assertTrue()
expect(UiElementInfo.text == 'dialogShow').assertTrue()
expect(UiElementInfo.type == 'AlertDialog').assertTrue()
}
observer.once('dialogShow', callback)
let btn = await driver.findComponent(ON.text('dialog'))
await btn.click()
await driver.delayMs(waitUiReadyMs)
await stopApplication('com.uitestScene.acts')
})
})
describe('UiTest_API8', function () {
......@@ -347,9 +393,9 @@ export default function UiTest() {
await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
let driver = UiDriver.create()
await driver.delayMs(waitUiReadyMs)
let scrollBar = await driver.findComponent(BY.type('Scroll').scrollable(false))
let scrollBar = await driver.findComponent(BY.type('Scroll'))
let scrollable = await scrollBar.isScrollable()
expect(scrollable == false).assertTrue()
expect(scrollable == true).assertTrue()
await stopApplication('com.uitestScene.acts')
})
......@@ -516,7 +562,7 @@ export default function UiTest() {
await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
let driver = UiDriver.create()
await driver.delayMs(waitUiReadyMs)
await driver.swipe(300, 600, 300, 300)
await driver.swipe(300, 800, 300, 300)
let text = await driver.findComponent(BY.text('next page'))
expect(text == null).assertTrue()
await stopApplication('com.uitestScene.acts')
......@@ -812,9 +858,9 @@ export default function UiTest() {
await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
let driver = Driver.create()
await driver.delayMs(waitUiReadyMs)
let scrollBar = await driver.findComponent(ON.type('Scroll').scrollable(false))
let scrollBar = await driver.findComponent(ON.type('Scroll'))
let scrollable = await scrollBar.isScrollable()
expect(scrollable == false).assertTrue()
expect(scrollable == true).assertTrue()
await stopApplication('com.uitestScene.acts')
})
......@@ -1051,7 +1097,7 @@ export default function UiTest() {
await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
let driver = Driver.create()
await driver.delayMs(waitUiReadyMs)
await driver.swipe(300,600,300,300)
await driver.swipe(300,800,300,300)
let text = await driver.findComponent(ON.text('next page'))
expect(text == null).assertTrue()
let scrollBar = await driver.findComponent(ON.type('Scroll'))
......@@ -1641,13 +1687,13 @@ export default function UiTest() {
let button = await driver.findComponent(ON.text('jump'))
await button.longClick()
await driver.delayMs(waitUiReadyMs)
let text1 = await driver.findComponent(ON.text('orange'))
let text2 = await driver.findComponent(ON.text('one'))
let text1 = await driver.findComponent(ON.text('one'))
let text2 = await driver.findComponent(ON.text('two'))
let point1 = await text1.getBoundsCenter()
let point2 = await text2.getBoundsCenter()
await driver.drag(point1.x, point1.y, point2.x, point2.y)
await driver.delayMs(waitUiReadyMs)
let text = await driver.findComponent(ON.text('four'))
let text = await driver.findComponent(ON.text('one').isBefore(ON.text('two')))
expect(text == null).assertTrue()
await stopApplication('com.uitestScene.acts')
})
......@@ -1664,11 +1710,11 @@ export default function UiTest() {
let button = await driver.findComponent(ON.text('jump'))
await button.longClick()
await driver.delayMs(waitUiReadyMs)
let text1 = await driver.findComponent(ON.text('orange'))
let text2 = await driver.findComponent(ON.text('one'))
let text1 = await driver.findComponent(ON.text('one'))
let text2 = await driver.findComponent(ON.text('two'))
await text1.dragTo(text2)
await driver.delayMs(waitUiReadyMs)
let text = await driver.findComponent(ON.text('four'))
let text = await driver.findComponent(ON.text('one').isBefore(ON.text('two')))
expect(text == null).assertTrue()
await stopApplication('com.uitestScene.acts')
})
......
{
"app": {
"bundleName": "com.uitestScene.acts",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"uitestScene"
}
]
}
\ No newline at end of file
......@@ -14,25 +14,30 @@
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsUiTestScene") {
hap_profile = "./src/main/config.json"
hap_profile = "entry/src/main/module.json"
deps = [
":uitest_scene_ets_assets",
":uitest_scene_ets_resources",
]
ets2abc = true
js_build_mode = "debug"
testonly = true
certificate_profile = "//test/xts/acts/testfwk/uitestScene/signature/auto_ohos_default_com.uitestScene.test.p7b"
certificate_profile = "../../../../../test/xts/acts/testfwk/uitestScene/signature/auto_ohos_default_com.uitestScene.test.p7b"
hap_name = "ActsUiTestScene"
part_name = "arkxtest"
subsystem_name = "testfwk"
}
ohos_app_scope("uiTestScene_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("uitest_scene_ets_assets") {
source_dir = "./src/main/ets/MainAbility"
source_dir = "entry/src/main/ets"
}
ohos_resources("uitest_scene_ets_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
sources = [ "entry/src/main/resources" ]
deps = [ ":uiTestScene_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
import UIAbility from '@ohos.app.ability.UIAbility';
import hilog from '@ohos.hilog';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
}
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import router from '@system.router';
import prompt from '@ohos.prompt';
import promptAction from '@ohos.promptAction';
@Entry
@Component
......@@ -30,6 +30,33 @@ struct ScrollExample {
Stack({ alignContent: Alignment.TopStart }) {
Scroll(this.scroller) {
Column() {
Button('toast').fontSize(25).fontWeight(FontWeight.Bold)
.onClick(() => {
try {
promptAction.showToast({
message: 'toastShow',
duration: 60000
});
} catch (error) {
console.error(`showToast args error code is ${error.code}, message is ${error.message}`);
};
})
Button('dialog').fontSize(25).fontWeight(FontWeight.Bold)
.onClick(() => {
AlertDialog.show(
{
title: '',
message: 'dialogShow',
alignment: DialogAlignment.Bottom,
confirm: {
value: 'close',
action: () => {
console.info('close dialog')
}
}
}
)
})
Button() {
Text('next page')
.fontSize(25)
......@@ -42,10 +69,10 @@ struct ScrollExample {
router.push({ uri: 'pages/second' })
})
.gesture(
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
router.push({ uri: 'pages/fourth' })
})
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
router.push({ uri: 'pages/fourth' })
})
)
Button() {
Text('Click twice')
......@@ -55,10 +82,10 @@ struct ScrollExample {
.type(ButtonType.Capsule)
.margin({ top: 20 })
.gesture(
TapGesture({ count: 1 })
.onAction(() => {
router.push({ uri: 'pages/third' })
})
TapGesture({ count: 1 })
.onAction(() => {
router.push({ uri: 'pages/third' })
})
)
Button() {
Text(this.hoverText)
......@@ -71,7 +98,7 @@ struct ScrollExample {
if (isHover) {
this.hoverText = 'hover'
}
})
})
.onMouse((event: MouseEvent) => {
switch (event.button) {
case MouseButton.Left :
......@@ -89,10 +116,10 @@ struct ScrollExample {
router.push({ uri: 'pages/screen' })
})
.gesture(
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
router.push({ uri: 'pages/drag' })
})
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
router.push({ uri: 'pages/drag' })
})
)
Checkbox({ name: 'hi' })
.size({ width: 30, height: 30 })
......
......@@ -22,7 +22,7 @@ struct Screen {
build() {
Column() {
Image($r('app.media.computer'))
Image($r('app.media.test'))
.objectFit(ImageFit.Auto)
.height(200)
.width(200)
......
{
"module": {
"name": "uitestScene",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.uitestScene.acts.MainAbility",
"srcEntry": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "Scene_MainAbility"
"name": "module_desc",
"value": "module description"
},
{
"name": "description_mainability",
"value": "Scene_MainAbility"
},
{
"name": "TestAbility_desc",
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"name": "EntryAbility_label",
"value": "label"
}
]
......
{
"src": [
"pages/Index",
"pages/second",
"pages/third",
"pages/fourth",
"pages/screen",
"pages/drag"
]
}
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"vendor": "open",
"bundleName": "com.uitestScene.acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "com.uitestScene.acts",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "MainAbility",
"deviceType": [
"tablet",
"default",
"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": "singleton"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/second",
"pages/third",
"pages/fourth",
"pages/screen",
"pages/drag"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/**
* 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册