未验证 提交 4789f29a 编写于 作者: O openharmony_ci 提交者: Gitee

!6024 无障碍功能测试errorCode处理

Merge pull request !6024 from Mupceet/release_1022_xts_master
......@@ -19,6 +19,7 @@ group("actsaccessibletest") {
deps = [
"actsabilitylisttest:ActsAbilityListTest",
"actscaptionconfigurationtest:ActsCaptionConfigurationTest",
"actsgesturesimulationtest:ActsGestureSimulationTest",
"sceneProject/accessibilityAudibleAbility:accessibilityAudibleAbility",
"sceneProject/accessibilityGenericAbility:accessibilityGenericAbility",
"sceneProject/accessibilityHapticAbility:accessibilityHapticAbility",
......
......@@ -389,33 +389,6 @@ export default function CaptionConfigurationTest() {
}, 8000);
});
/**
* @tc.number: CaptionConfiguration_0120
* @tc.name: Call api:getcaptionsmanager() to set the caption parameter.
* @tc.desc: Call api:getcaptionsmanager() to set the caption parameter.
*/
it('CaptionConfiguration_0120', 1, async function (done) {
const caseName = "CaptionConfiguration_0120";
const logF = LOG + caseName;
registerOn = false;
setTimeout(() => {
CaptionConfigurationOn(caseName, undefined);
}, 1000);
setTimeout(() => {
excuteCase(caseName);
}, 2000);
setTimeout(() => {
var isSucceedTarget: boolean = false;
if (backList.indexOf(caseName + '_on_target_change_extra_success') != -1) {
isSucceedTarget = true;
}
expect(isSucceedTarget).assertEqual(true);
expect(registerOn).assertEqual(false);
console.info(logF + ' isSucceed : ' + (isSucceedTarget));
done();
}, 8000);
});
/**
* @tc.number: CaptionConfiguration_0130
* @tc.name: Call api:getcaptionsmanager() to set the caption parameter.
......
{
"app": {
"bundleName": "com.example.gesturesimulationtest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "GestureSimulationTest"
}
]
}
# 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("ActsGestureSimulationTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessible_js_assets",
":accessible_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsGestureSimulationTest"
subsystem_name = "barrierfree"
part_name = "accessibility"
}
ohos_app_scope("accessible_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessible_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessible_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessible_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "400000",
"bundle-name": "com.example.gesturesimulationtest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsGestureSimulationTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"param set persist.ace.testmode.enabled 1"
],
"teardown-command":[
"bm uninstall -n com.example.gesturesimulationtest"
]
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info("[GestureSimulationTest] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1
globalThis.stageContext = this.context
}
}
\ 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.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.windowStage = windowStage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* 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 file from '@system.file'
import prompt from '@system.prompt'
import commonEvent from '@ohos.commonEvent'
const LOG_PREFIX = '[CQH-GESTURE-TARGET-1]'
const EVENT_NAME_BACK = 'on_target_change_extra'
const CommonEventSubscribeInfo = {
events: ['on_assist_change']
}
@Entry
@Component
struct Index {
@State message: string = 'GestureSimulationTest'
private caseCode: string = ''
private scroller: Scroller = new Scroller()
private context2D: CanvasRenderingContext2D = new CanvasRenderingContext2D()
private swiperController: SwiperController = new SwiperController()
private arr: string[] = ["列表文本1", "列表文本2", "列表文本3", "列表文本4", "列表文本5", "列表文本6", "列表文本7",
"列表文本8", "列表文本9", "列表文本10", "列表文本11", "列表文本12", "列表文本13", "列表文本14", "列表文本15", "列表文本16",
"列表文本17", "列表文本18", "列表文本19", "列表文本20", "列表文本21", "列表文本22", "列表文本23", "列表文本24", "列表文本25",
"列表文本26", "列表文本27", "列表文本28", "列表文本29", "列表文本30"]
private Number: String[] = ['1', '2', '3']
private minNum: number = 0
private maxNum: number = 0
private addNum: number = 0
private notEnd: boolean = true
@State paintSize: number= 5
@State paintColor: Color = Color.Orange
@State pathInfoArray: PathInfo[]= new Array()
private subScriber = undefined
aboutToAppear() {
console.info('TargetApp aboutToAppear')
this.createSubscriber()
}
aboutToDisappear() {
console.info('TargetApp aboutToDisappear')
commonEvent.unsubscribe(this.subScriber)
this.subScriber = undefined
}
@Builder
Canvas() {
ForEach(this.pathInfoArray, (pathInfo) => OnePath({ pathInfo: pathInfo }))
Stack()
.width('100%')
.height('100%')
.onTouch((event: TouchEvent) => {
let x = vp2px(event.touches[0].x)
let y = vp2px(event.touches[0].y)
switch (event.type) {
case TouchType.Down:
this.pathInfoArray.push(new PathInfo(`M${x} ${y}`, this.paintSize, this.paintColor))
break
case TouchType.Move:
this.pathInfoArray[this.pathInfoArray.length-1].commands += `L${x} ${y}`
break
case TouchType.Up:
this.publishEvent()
setTimeout(()=>{
this.pathInfoArray.length = 0
}, 1500)
break
}
})
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
Stack({ alignContent: Alignment.TopEnd }) {
this.Canvas()
Row() {
Button('clear').onClick(() => this.pathInfoArray.length = 0)
}.margin(5)
}.height(545).width('100%')
Button('Test1', {stateEffect: true})
.fontSize(20)
.fontWeight(FontWeight.Bold)
.margin({ top: 10 })
.width('60%')
.height(40)
.gesture(LongPressGesture({ repeat: false })
.onActionEnd(() => {
prompt.showToast({ message: '长点击结束' })
this.publishEvent()
})
)
.onClick((e) => {
let position = 'screenX:' + vp2px(e.screenX) + ' screenY:' + vp2px(e.screenY) + ' x:' + vp2px(e.x) + ' y:' + vp2px(e.y)
console.info(LOG_PREFIX + ' button position : ' + position)
prompt.showToast({ message: position })
this.publishEvent()
})
//滑动
List({ initialIndex: 12, scroller: this.scroller }) {
ForEach(this.arr, (item) => {
ListItem() {
Text(item)
.width('100%')
.height(25)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xF9CF93)
.onClick((e) => {
let position = 'screenX:' + vp2px(e.screenX) + ' screenY:' + vp2px(e.screenY) + ' x:' + vp2px(e.x) + ' y:' + vp2px(e.y)
console.info(LOG_PREFIX + ' list1 position : ' + position)
})
}.editable(true)
}, item => item)
}
.listDirection(Axis.Vertical)
.divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 })
.edgeEffect(EdgeEffect.None)
.chainAnimation(false)
.scrollBar(BarState.On)
.onScroll((scrollOffset: number, scrollState: ScrollState) => {
this.getMaxMinNum(scrollOffset)
if (this.notEnd && scrollState == ScrollState.Idle) {
if (this.minNum < 0 && this.maxNum == 0) {
prompt.showToast({ message: '向(上)前滑动' })
this.publishEvent()
} else if (this.minNum == 0 && this.maxNum > 0) {
prompt.showToast({ message: '向(下)后滑动' })
this.publishEvent()
}
this.resetNum()
}
})
.editMode(false)
.margin({ top: 10 })
.height(140)
Text(this.message).fontSize(20).fontWeight(FontWeight.Bold).height(20)
}.height('100%').width('100%')
}
getMaxMinNum(scrollOffset: number){
this.addNum += scrollOffset
this.minNum = Math.min(this.addNum, this.minNum)
this.maxNum = Math.max(this.addNum, this.maxNum)
}
resetNum(){
this.addNum = 0
this.minNum = 0
this.maxNum = 0
}
publishEvent() {
let commonEventPublishData = {
data: this.caseCode, parameters: { res: true }
}
console.info(LOG_PREFIX + 'publishEvent data : ' + JSON.stringify(commonEventPublishData))
try {
commonEvent.publish(EVENT_NAME_BACK, commonEventPublishData, (err, data) => {
if (err && err.code != 0) {
console.info(LOG_PREFIX + 'failed to publish because ' + JSON.stringify(err))
return
}
console.info(LOG_PREFIX + 'success data : ' + JSON.stringify(data))
})
} catch (e) {
console.info(LOG_PREFIX + '[publishEvent] error' + e.message)
}
}
createSubscriber(){
commonEvent.createSubscriber(CommonEventSubscribeInfo).then((subscriber) => {
this.subScriber = subscriber
commonEvent.subscribe(subscriber, (error, commonEventData) => {
if (error.code != 0) {
console.info(LOG_PREFIX + 'subscribe failed. Cause:' + JSON.stringify(error))
return
}
console.info(LOG_PREFIX + 'subscribeTest callback : ' + JSON.stringify(commonEventData))
this.caseCode = commonEventData.data
if(commonEventData.data === 'GestureSimulation_0090'){
this.notEnd = false
}
})
}).catch((error) => {
console.info(LOG_PREFIX + 'createSubscriber failed. Cause: ' + JSON.stringify(error))
return
})
}
}
@Component
struct OnePath {
@ObjectLink pathInfo: PathInfo
build() {
Path()
.width('100%')
.height('100%')
.fillOpacity(0)
.commands(this.pathInfo.commands)
.strokeWidth(this.pathInfo.width)
.stroke(this.pathInfo.color)
}
}
@Observed
class PathInfo {
commands: string
width: number
color: Color
constructor(commands: string, width: number, color: Color) {
this.commands = commands
this.width = width
this.color = color
}
}
\ 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.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.gesturesimulationtest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
/*
* 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
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "com.example.gesturesimulationtest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts",
"name": "ServiceExtAbility",
"icon": "$media:icon",
"description": "$string:description_serviceability",
"type": "accessibility",
"visible": true,
"metadata": [
{
"name": "ohos.accessibleability",
"resource": "$profile:accessibility_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
}
],
"requestPermissions": [
{
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
}
{
"string": [
{
"name": "entry_desc",
"value": "GestureSimulationTest entry"
},
{
"name": "MainAbility_desc",
"value": "GestureSimulationTest MainAbility"
},
{
"name": "MainAbility_label",
"value": "GestureSimulationTest"
},
{
"name": "description_serviceability",
"value": "Gesture后台服务"
},
{
"name": "form_description",
"value": "Gesture辅助应用"
}
]
}
\ No newline at end of file
{
"accessibilityCapabilities": [
"retrieve",
"gesture"
],
"accessibilityCapabilityRationale": "a11y_rationale",
"settingsAbility": "com.example.myapplication.accessibilitySetting"
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册