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

!4557 添加无障碍xts api测试用例

Merge pull request !4557 from Mupceet/release_0725_xts_beta
......@@ -17,11 +17,17 @@ group("barrierfree") {
testonly = true
if (is_standard_system) {
deps = [
"accessibilityconfig:ActsAccessibilityConfigTest",
"accessibilityelement:ActsAccessibilityElementTest",
"accessibilityevent:ActsAccessibilityEventTest",
"accessibilityextension:ActsAccessibilityExtensionTest",
"accessibilityextensioncontext:ActsAccessibilityExtensionContextTest",
"accessibleabilitylist:ActsAccessibleAbilityListTest",
"accessiblecaptionconfiguration:ActsAccessibleCaptionConfigurationTest",
"accessiblecheckability:ActsAccessibleCheckAbilityTest",
"accessibleregisterstate:ActsAccessibleRegisterStateTest",
"accessiblesendevent:ActsAccessibleSendEventTest",
"targetProject/aceTest:aceTest",
]
}
}
{
"app": {
"bundleName": "com.example.accessibilityconfig",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ohosProject"
},
{
"name": "mainability_description",
"value": "ETS_Phone_Empty Stage Ability"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityConfigTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":accessibilityconfig_js_assets",
":accessibilityconfig_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilityConfigTest"
}
ohos_app_scope("accessibilityconfig_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilityconfig_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilityconfig_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilityconfig_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.accessibilityconfig",
"shell-timeout": "180000"
},
"kits": [
{
"test-file-name": [
"ActsAccessibilityConfigTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n com.example.accessibilityconfig"
]
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
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;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage)
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/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")
}
};
\ 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test"
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
aboutToAppear(){
console.info("start run testcase!!!!");
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ 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 abilityTest from './AccessibilityConfig.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.accessibilityconfig.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsAccessibilityConfigTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
},
{
"name": "Accessibility_desc",
"value": "accessibility_description"
},
{
"name": "Accessibility_label",
"value": "accessibility_label"
}
]
}
{
"src": [
"pages/index/index"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ohosProject"
},
{
"name": "mainability_description",
"value": "ETS_Phone_Empty Stage Ability"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityElementTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilityelement_js_assets",
":accessibilityelement_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilityElementTest"
}
ohos_app_scope("accessibilityelement_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilityelement_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilityelement_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilityelement_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.example.myapplication",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"aceTest.hap",
"ActsAccessibilityElementTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n com.example.myapplication",
"bm uninstall -n com.example.acetest"
]
}
]
}
\ 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 AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
import commonEvent from '@ohos.commonEvent';
import {ElementTest} from './ElementTest';
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
tester: any = undefined;
onConnect() {
console.info("[Demo] AccessibilityExtAbility onConnect");
this.tester = new ElementTest(this.context);
this.tester.init();
let commonEventPublishData = {
data: 'connect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onConnect====>onConnect publish call back result:" + JSON.stringify(err));
}
this.context.setEventTypeFilter(['click']);
}
onDisconnect() {
console.info("[Demo] AccessibilityExtAbility onDisconnect");
let commonEventPublishData = {
data: 'disconnect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onDisconnect====>onConnect publish call back result:" + JSON.stringify(err));
}
this.tester.clear();
this.tester = undefined;
}
onAccessibilityEvent(accessibilityEvent) {
console.info("[Demo] AccessibilityExtAbility onAccessibilityEvent: " + JSON.stringify(accessibilityEvent));
if (this.tester) {
this.tester.pushEvent(accessibilityEvent);
}
}
}
export default AccessibilityExtAbility;
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
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;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage)
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/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")
}
};
\ 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test"
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
aboutToAppear(){
console.info("start run testcase!!!!");
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ 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 abilityTest from './AccessibilityElement.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"extensionAbilities": [
{
"name": "AccessibilityExtAbility",
"srcEntrance": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
"label": "$string:Accessibility_label",
"description": "$string:Accessibility_desc",
"type": "accessibility",
"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"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsAccessibilityElementTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
},
{
"name": "Accessibility_desc",
"value": "accessibility_description"
},
{
"name": "Accessibility_label",
"value": "accessibility_label"
}
]
}
{
"accessibilityCapabilities": [
"retrieve"
],
"accessibilityCapabilityRationale": "a11y_rationale",
"settingsAbility": "com.accessibility.voiceaid.voiceAidSetting"
}
\ No newline at end of file
{
"src": [
"pages/index/index"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityEventTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilityevent_js_assets",
":accessibilityevent_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilityEventTest"
}
ohos_app_scope("accessibilityevent_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilityevent_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilityevent_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilityevent_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.myapplication",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"aceTest.hap",
"ActsAccessibilityEventTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n com.example.myapplication",
"bm uninstall -n com.example.acetest"
]
}
]
}
\ 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 AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
import commonEvent from '@ohos.commonEvent';
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
onConnect() {
console.info("[Demo] AccessibilityExtAbility onConnect");
let commonEventPublishData = {
data: 'connect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("[Demo] onConnect====>onConnect publish call back result:" + JSON.stringify(err));
}
this.context.setEventTypeFilter([
'accessibilityFocus', 'accessibilityFocusClear', 'click', 'longClick', 'focus', 'select', 'hoverEnter',
'hoverExit', 'textUpdate', 'textSelectionUpdate', 'scroll'
]);
}
onDisconnect() {
console.info("[Demo] AccessibilityExtAbility onDisconnect");
let commonEventPublishData = {
data: 'disconnect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("[Demo] onDisconnect====>onConnect publish call back result:" + JSON.stringify(err));
}
}
onAccessibilityEvent(accessibilityEvent) {
console.info("[Demo] AccessibilityExtAbility onAccessibilityEvent: " + accessibilityEvent.eventType);
let commonEventPublishData = {
data: 'accessibilityEvent',
parameters: {
eventType: accessibilityEvent.eventType
}
}
commonEvent.publish('accessibilityEvent', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("[Demo] onAccessibilityEvent====>accessibilityEvent publish call back result:" + JSON.stringify(err));
}
}
}
export default AccessibilityExtAbility;
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
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;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/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")
}
};
\ 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test"
@Entry
@Component
struct Index {
@State message: string = 'accessibility event';
aboutToAppear(){
console.info("start run testcase!!!!");
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import accessibility from '@ohos.accessibility'
import commonEvent from '@ohos.commonEvent'
export default function abilityTest(abilityContext) {
let targetBundleName = 'com.example.myapplication';
let subScriber = undefined;
let isConnected: boolean = false;
let eventTypes: Array<string> = [];
describe('AccessibilityEventTest', function () {
beforeAll(async function (done) {
console.info('AccessibilityEventTest beforeAll');
subScriber = await commonEvent.createSubscriber({events: ['onConnectState', 'accessibilityEvent']});
commonEvent.subscribe(subScriber, (err, data) => {
console.info('AccessibilityEventTest beforeAll data:' + JSON.stringify(data) );
if (data.data == 'connect') {
isConnected = true;
} else if (data.data == 'disconnect') {
isConnected = false;
} else if (data.data == 'accessibilityEvent') {
eventTypes.push(data.parameters.eventType);
}
});
setTimeout(async () => {
await abilityContext.startAbility({
deviceId: "",
bundleName: "com.example.acetest",
abilityName: "MainAbility",
action: "action1",
parameters: {},
});
done();
}, 5000);
})
afterAll(async function (done) {
console.info('AccessibilityEventTest: afterAll');
commonEvent.unsubscribe(subScriber);
isConnected = false;
done();
})
beforeEach(async function (done) {
console.info(`AccessibilityEventTest: beforeEach`);
eventTypes.length = 0;
setTimeout(done, 2000);
})
afterEach(async function (done) {
console.info(`AccessibilityEventTest: afterEach`);
done();
})
/*
* @tc.number AccessibilityEventTest_0100
* @tc.name AccessibilityEventTest_0100
* @tc.desc The parameter input is 'accessibilityFocus', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0100', 0, async function (done) {
console.info(`AccessibilityEventTest_0100`);
let eventType = 'accessibilityFocus';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'accessibilityFocus';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0100 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0200
* @tc.name AccessibilityEventTest_0200
* @tc.desc The parameter input is 'accessibilityFocusClear', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0200', 0, async function (done) {
console.info(`AccessibilityEventTest_0200`);
let eventType = 'accessibilityFocusClear';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'clearAccessibilityFocus';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0200 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0300
* @tc.name AccessibilityEventTest_0300
* @tc.desc The parameter input is 'click', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0300', 0, async function (done) {
console.info(`AccessibilityEventTest_0300`);
let eventType = 'click';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'click';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0300 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0400
* @tc.name AccessibilityEventTest_0400
* @tc.desc The parameter input is 'longClick', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0400', 0, async function (done) {
console.info(`AccessibilityEventTest_0400`);
let eventType = 'longClick';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'longClick';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0400 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0500
* @tc.name AccessibilityEventTest_0500
* @tc.desc The parameter input is 'focus', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0500', 0, async function (done) {
console.info(`AccessibilityEventTest_0500`);
let eventType = 'focus';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'focus';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0500 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0600
* @tc.name AccessibilityEventTest_0600
* @tc.desc The parameter input is 'select', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0600', 0, async function (done) {
console.info(`AccessibilityEventTest_0600`);
let eventType = 'select';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'select';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0600 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0700
* @tc.name AccessibilityEventTest_0700
* @tc.desc The parameter input is 'hoverEnter', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0700', 0, async function (done) {
console.info(`AccessibilityEventTest_0700`);
let eventType = 'hoverEnter';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'focus';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0700 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0800
* @tc.name AccessibilityEventTest_0800
* @tc.desc The parameter input is 'hoverExit', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0800', 0, async function (done) {
console.info(`AccessibilityEventTest_0800`);
let eventType = 'hoverExit';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'focus';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0800 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_0900
* @tc.name AccessibilityEventTest_0900
* @tc.desc The parameter input is 'textUpdate', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_0900', 0, async function (done) {
console.info(`AccessibilityEventTest_0900`);
let eventType = 'textUpdate';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'cut';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_0900 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_1000
* @tc.name AccessibilityEventTest_1000
* @tc.desc The parameter input is 'textSelectionUpdate', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_1000', 0, async function (done) {
console.info(`AccessibilityEventTest_1000`);
let eventType = 'textSelectionUpdate';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'setSelection';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_1000 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_1100
* @tc.name AccessibilityEventTest_1100
* @tc.desc The parameter input is 'scroll', test the Ability event function,
* and return void.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_1100', 0, async function (done) {
console.info(`AccessibilityEventTest_1100`);
let eventType = 'scroll';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'scrollForward';
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
findResult = true;
}
}
console.info('AccessibilityEventTest_1100 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
})
}
\ 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 abilityTest from './AccessibilityEventTest.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"extensionAbilities": [
{
"name": "AccessibilityExtAbility",
"srcEntrance": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
"label": "$string:Accessibility_label",
"description": "$string:Accessibility_desc",
"type": "accessibility",
"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"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsAccessibilityEventTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
},
{
"name": "Accessibility_desc",
"value": "accessibility_description"
},
{
"name": "Accessibility_label",
"value": "accessibility_label"
}
]
}
{
"accessibilityCapabilities": [
"retrieve"
],
"accessibilityCapabilityRationale": "a11y_rationale",
"settingsAbility": "com.accessibility.voiceaid.voiceAidSetting"
}
\ No newline at end of file
{
"src": [
"pages/index/index"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityExtensionTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilityextension_js_assets",
":accessibilityextension_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilityExtensionTest"
}
ohos_app_scope("accessibilityextension_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilityextension_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilityextension_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilityextension_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.myapplication",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"aceTest.hap",
"ActsAccessibilityExtensionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n com.example.myapplication",
"bm uninstall -n com.example.acetest"
]
}
]
}
\ 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 AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
import commonEvent from '@ohos.commonEvent';
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
onConnect() {
console.info("[Demo] AccessibilityExtAbility onConnect");
let commonEventPublishData = {
data: 'connect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onConnect====>onConnect publish call back result:" + JSON.stringify(err));
}
}
onDisconnect() {
console.info("[Demo] AccessibilityExtAbility onDisconnect");
let commonEventPublishData = {
data: 'disconnect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onDisconnect====>onConnect publish call back result:" + JSON.stringify(err));
}
}
onAccessibilityEvent(accessibilityEvent) {
console.info("[Demo] AccessibilityExtAbility onAccessibilityEvent");
}
}
export default AccessibilityExtAbility;
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
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;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/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")
}
};
\ 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test"
@Entry
@Component
struct Index {
@State message: string = 'accessibilityExtension';
aboutToAppear(){
console.info("start run testcase!!!!");
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import commonEvent from '@ohos.commonEvent'
export default function abilityTest(abilityContext) {
let isCalled: boolean = false;
let subScriber = undefined;
describe('AccessibilityExtensionTest', function () {
beforeAll(async function (done) {
console.info('AccessibilityExtensionTest: beforeAll');
subScriber = await commonEvent.createSubscriber({events: ['onConnectState']});
commonEvent.subscribe(subScriber, (err, data) => {
console.info('AccessibilityExtensionTest beforeAll subscribe data:' + JSON.stringify(data) );
isCalled = (data.data == 'connect');
});
setTimeout(done, 5000);
})
afterAll(async function (done) {
console.info('AccessibilityExtensionTest: afterAll');
commonEvent.unsubscribe(subScriber);
done();
})
beforeEach(async function (done) {
console.info(`AccessibilityExtensionTest: beforeEach`);
done();
})
afterEach(async function (done) {
console.info(`AccessibilityExtensionTest: afterEach`);
done();
})
/*
* @tc.number AccessibilityExtensionTest_Connect_0100
* @tc.name AccessibilityExtensionTest_Connect_0100
* @tc.desc The parameter input is null, test the ExtensionAbility onConnect function,
* and return undefined
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityExtensionTest_Connect_0100', 0, async function (done) {
console.info('AccessibilityExtensionTest_Connect_0100: start');
await abilityContext.startAbility({
deviceId: "",
bundleName: "com.example.acetest",
abilityName: "MainAbility",
action: "action1",
parameters: {},
});
setTimeout(() => {
console.info('AccessibilityExtensionTest_Connect_0100 isCalled : ' + isCalled);
expect(isCalled).assertEqual(true);
done();
}, 5000);
})
/*
* @tc.number AccessibilityExtensionTest_Disconnect_0200
* @tc.name AccessibilityExtensionTest_Disconnect_0200
* @tc.desc The parameter input is null, test the ExtensionAbility onDisconnect function,
* and return undefined
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityExtensionTest_Disconnect_0200', 0, async function (done) {
console.info('AccessibilityExtensionTest_Disconnect_0200 start');
let commonEventPublishData = {
data: 'disable'
}
commonEvent.publish('disableExtAbility', commonEventPublishData, (err) => {
console.info("AccessibilityExtensionTest_Disconnect_0200 publish event: " + JSON.stringify(commonEventPublishData));
});
setTimeout(() => {
console.info('AccessibilityExtensionTest_Disconnect_0200 isCalled : ' + isCalled);
expect(isCalled).assertEqual(false);
done();
}, 5000);
})
})
}
\ 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 abilityTest from './AccessibilityExtension.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"extensionAbilities": [
{
"name": "AccessibilityExtAbility",
"srcEntrance": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
"label": "$string:Accessibility_label",
"description": "$string:Accessibility_desc",
"type": "accessibility",
"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"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsAccessibilityExtensionTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
},
{
"name": "Accessibility_desc",
"value": "accessibility_description"
},
{
"name": "Accessibility_label",
"value": "accessibility_label"
}
]
}
{
"accessibilityCapabilities": [
"retrieve"
],
"accessibilityCapabilityRationale": "a11y_rationale",
"settingsAbility": "com.accessibility.voiceaid.voiceAidSetting"
}
\ No newline at end of file
{
"src": [
"pages/index/index"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityExtensionContextTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilityextensioncontext_js_assets",
":accessibilityextensioncontext_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilityExtensionContextTest"
}
ohos_app_scope("accessibilityextensioncontext_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilityextensioncontext_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilityextensioncontext_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilityextensioncontext_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "360000",
"package": "com.example.myapplication",
"shell-timeout": "360000"
},
"kits": [
{
"test-file-name": [
"aceTest.hap",
"ActsAccessibilityExtensionContextTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n com.example.myapplication",
"bm uninstall -n com.example.acetest"
]
}
]
}
/*
* 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 AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
import commonEvent from '@ohos.commonEvent';
import {ExtensionContextTest} from './ExtensionContextTest';
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
tester: ExtensionContextTest = undefined;
onConnect() {
console.info("[Demo] AccessibilityExtAbility onConnect");
this.tester = new ExtensionContextTest(this.context);
this.tester.init();
let commonEventPublishData = {
data: 'connect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onConnect====>onConnect publish call back result:" + JSON.stringify(err));
}
}
onDisconnect() {
console.info("[Demo] AccessibilityExtAbility onDisconnect");
let commonEventPublishData = {
data: 'disconnect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onDisconnect====>onConnect publish call back result:" + JSON.stringify(err));
}
this.tester.clear();
this.tester = undefined;
}
onAccessibilityEvent(accessibilityEvent) {
console.info("[Demo] AccessibilityExtAbility onAccessibilityEvent: " + accessibilityEvent.eventType);
}
}
export default AccessibilityExtAbility;
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
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;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/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 {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test"
@Entry
@Component
struct Index {
@State message: string = 'Extension Context';
aboutToAppear(){
console.info("start run testcase!!!!");
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ 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 abilityTest from './AccessibilityExtensionContext.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"extensionAbilities": [
{
"name": "AccessibilityExtAbility",
"srcEntrance": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
"label": "$string:Accessibility_label",
"description": "$string:Accessibility_desc",
"type": "accessibility",
"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"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsAccessibilityExtensionTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
},
{
"name": "Accessibility_desc",
"value": "accessibility_description"
},
{
"name": "Accessibility_label",
"value": "accessibility_label"
}
]
}
\ No newline at end of file
{
"accessibilityCapabilities": [
"retrieve",
"touchGuide",
"gesture"
],
"accessibilityCapabilityRationale": "a11y_rationale",
"settingsAbility": "com.accessibility.voiceaid.voiceAidSetting"
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityGestureEventTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilitygestureevent_js_assets",
":accessibilitygestureevent_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilityGestureEventTest"
}
ohos_app_scope("accessibilitygestureevent_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilitygestureevent_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilitygestureevent_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilitygestureevent_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.myapplication",
"shell-timeout": "180000"
},
"kits": [
{
"test-file-name": [
"aceTest.hap",
"ActsAccessibilityGestureEventTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n com.example.myapplication",
"bm uninstall -n com.example.acetest"
]
}
]
}
/*
* 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 AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
import commonEvent from '@ohos.commonEvent';
import {GestureEventTest} from './GestureEventTest';
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
tester: GestureEventTest = undefined;
onConnect() {
console.info("[Demo] AccessibilityExtAbility onConnect");
this.tester = new GestureEventTest(this.context);
this.tester.init();
let commonEventPublishData = {
data: 'connect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onConnect====>onConnect publish call back result:" + JSON.stringify(err));
}
this.context.setEventTypeFilter(['gesture']);
}
onDisconnect() {
console.info("[Demo] AccessibilityExtAbility onDisconnect");
let commonEventPublishData = {
data: 'disconnect'
}
commonEvent.publish('onConnectState', commonEventPublishData, publishCallback);
function publishCallback(err) {
console.info("onDisconnect====>onConnect publish call back result:" + JSON.stringify(err));
}
this.tester.clear();
this.tester = undefined;
}
onAccessibilityEvent(accessibilityEvent) {
let type = accessibilityEvent.eventType;
console.info("[Demo] AccessibilityExtAbility onAccessibilityEvent: " + type);
if (type === 'left' || type === 'leftThenRight' || type === 'leftThenUp' || type === 'leftThenDown'
|| type === 'right' || type === 'rightThenLeft' || type === 'rightThenUp' || type === 'rightThenDown'
|| type === 'up' || type === 'upThenLeft' || type === 'upThenRight' || type === 'upThenDown'
|| type === 'down' || type === 'downThenLeft' || type === 'downThenRight' || type === 'downThenUp') {
let commonEventPublishData = {
data: 'accessibilityEvent',
parameters: {
eventType: type
}
}
commonEvent.publish('accessibilityEvent', commonEventPublishData, publishCallback);
}
function publishCallback(err) {
console.info("[Demo] onAccessibilityEvent====>accessibilityEvent publish call back result:" + JSON.stringify(err));
}
}
}
export default AccessibilityExtAbility;
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
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;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/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 abilityTest from './AccessibilityGestureEventTest.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册