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

!5956 重新提交适配无障碍添加ErrorCode

Merge pull request !5956 from Mupceet/master
...@@ -19,12 +19,13 @@ group("barrierfree") { ...@@ -19,12 +19,13 @@ group("barrierfree") {
deps = [ deps = [
"accessibilityconfig:ActsAccessibilityConfigTest", "accessibilityconfig:ActsAccessibilityConfigTest",
"accessibilityconfigreqreadpermission:ActsAccessibilityConfigReqReadPermissionTest", "accessibilityconfigreqreadpermission:ActsAccessibilityConfigReqReadPermissionTest",
"accessibilityconfigreqwritepermission:ActsAccessibilityConfigReqWritePermissionTest",
"accessibilityelement:ActsAccessibilityElementTest", "accessibilityelement:ActsAccessibilityElementTest",
"accessibilityerrcode:ActsAccessibilityErrCodeTest",
"accessibilityevent:ActsAccessibilityEventTest", "accessibilityevent:ActsAccessibilityEventTest",
"accessibilityextension:ActsAccessibilityExtensionTest", "accessibilityextension:ActsAccessibilityExtensionTest",
"accessibilityextensioncontext:ActsAccessibilityExtensionContextTest", "accessibilityextensioncontext:ActsAccessibilityExtensionContextTest",
"accessibilitygestureevent:ActsAccessibilityGestureEventTest", "accessibilitygestureevent:ActsAccessibilityGestureEventTest",
"accessibilitysendaccessibilityevent:ActsAccessibilitySendAccessibilityEventTest",
"accessibleabilitylist:ActsAccessibleAbilityListTest", "accessibleabilitylist:ActsAccessibleAbilityListTest",
"accessiblecaptionconfiguration:ActsAccessibleCaptionConfigurationTest", "accessiblecaptionconfiguration:ActsAccessibleCaptionConfigurationTest",
"accessiblecheckability:ActsAccessibleCheckAbilityTest", "accessiblecheckability:ActsAccessibleCheckAbilityTest",
......
/*
* 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';
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
onConnect() {
console.info("[Demo] AccessibilityExtAbility onConnect");
}
onDisconnect() {
console.info("[Demo] AccessibilityExtAbility onDisconnect");
}
onAccessibilityEvent(accessibilityEvent) {
console.info("[Demo] AccessibilityExtAbility onAccessibilityEvent: " + JSON.stringify(accessibilityEvent));
}
}
export default AccessibilityExtAbility;
\ No newline at end of file
...@@ -13,12 +13,21 @@ ...@@ -13,12 +13,21 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' 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 MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want,launchParam){ onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability // Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate") console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want; 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() { onDestroy() {
...@@ -28,7 +37,7 @@ export default class MainAbility extends Ability { ...@@ -28,7 +37,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
//globalThis.windowStage = windowStage //globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage //globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context globalThis.abilityContext = this.context
......
...@@ -13,19 +13,10 @@ ...@@ -13,19 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' 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 { export default class TestAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log('TestAbility onCreate') 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() { onDestroy() {
...@@ -34,7 +25,13 @@ export default class TestAbility extends Ability { ...@@ -34,7 +25,13 @@ export default class TestAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate') console.log('TestAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'TestAbility/pages/index', null) 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; globalThis.abilityContext = this.context;
} }
......
...@@ -21,7 +21,8 @@ var abilityDelegatorArguments = undefined ...@@ -21,7 +21,8 @@ var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) { function translateParamsToString(parameters) {
const keySet = new Set([ const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it', '-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout' '-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]) ])
let targetParams = ''; let targetParams = '';
for (const key in parameters) { for (const key in parameters) {
...@@ -52,14 +53,19 @@ export default class OpenHarmonyTestRunner implements TestRunner { ...@@ -52,14 +53,19 @@ export default class OpenHarmonyTestRunner implements TestRunner {
console.log('OpenHarmonyTestRunner onRun run') console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = { let lMonitor = {
abilityName: testAbilityName, abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback, onAbilityCreate: onAbilityCreateCallback,
}; };
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName var cmd = 'aa start -d 0 -a com.example.accessibilityxts.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd) console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => { (err: any, d: any) => {
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
"uiSyntax": "ets", "uiSyntax": "ets",
"pages": "$profile:main_pages", "pages": "$profile:main_pages",
"abilities": [{ "abilities": [{
"name": "TestAbility", "name": "com.example.accessibilityxts.MainAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ts", "srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main", "description": "$string:phone_entry_main",
"icon": "$media:icon", "icon": "$media:icon",
"label": "$string:entry_label", "label": "$string:entry_label",
...@@ -30,7 +30,21 @@ ...@@ -30,7 +30,21 @@
] ]
}] }]
}], }],
"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": [{ "requestPermissions": [{
"name": "ohos.permission.READ_ACCESSIBILITY_CONFIG", "name": "ohos.permission.READ_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.READ_ACCESSIBILITY_CONFIG" "reason": "need use ohos.permission.READ_ACCESSIBILITY_CONFIG"
......
{
"accessibilityCapabilities": [
"retrieve"
],
"accessibilityCapabilityRationale": "a11y_rationale",
"settingsAbility": "com.accessibility.voiceaid.voiceAidSetting"
}
\ No newline at end of file
{ {
"src": [ "src": [
"TestAbility/pages/index" "MainAbility/pages/index/index"
] ]
} }
\ 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';
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
onConnect() {
console.info("[Demo] AccessibilityExtAbility onConnect");
}
onDisconnect() {
console.info("[Demo] AccessibilityExtAbility onDisconnect");
}
onAccessibilityEvent(accessibilityEvent) {
console.info("[Demo] AccessibilityExtAbility onAccessibilityEvent: " + JSON.stringify(accessibilityEvent));
}
}
export default AccessibilityExtAbility;
\ No newline at end of file
...@@ -13,12 +13,21 @@ ...@@ -13,12 +13,21 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' 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 MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want,launchParam){ onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability // Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate") console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want; 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() { onDestroy() {
......
...@@ -13,19 +13,10 @@ ...@@ -13,19 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' 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 { export default class TestAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log('TestAbility onCreate') 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() { onDestroy() {
...@@ -34,7 +25,13 @@ export default class TestAbility extends Ability { ...@@ -34,7 +25,13 @@ export default class TestAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate') console.log('TestAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'TestAbility/pages/index', null) 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; globalThis.abilityContext = this.context;
} }
......
...@@ -21,7 +21,8 @@ var abilityDelegatorArguments = undefined ...@@ -21,7 +21,8 @@ var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) { function translateParamsToString(parameters) {
const keySet = new Set([ const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it', '-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout' '-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]) ])
let targetParams = ''; let targetParams = '';
for (const key in parameters) { for (const key in parameters) {
...@@ -52,14 +53,19 @@ export default class OpenHarmonyTestRunner implements TestRunner { ...@@ -52,14 +53,19 @@ export default class OpenHarmonyTestRunner implements TestRunner {
console.log('OpenHarmonyTestRunner onRun run') console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = { let lMonitor = {
abilityName: testAbilityName, abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback, onAbilityCreate: onAbilityCreateCallback,
}; };
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName var cmd = 'aa start -d 0 -a com.example.accessibilityxts.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd) console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => { (err: any, d: any) => {
......
...@@ -38,8 +38,9 @@ export default function abilityTest() { ...@@ -38,8 +38,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100');
config.highContrastText.set(true, (err, result) => { config.highContrastText.set(true, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -62,6 +63,8 @@ export default function abilityTest() { ...@@ -62,6 +63,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_0200 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -76,8 +79,9 @@ export default function abilityTest() { ...@@ -76,8 +79,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700');
config.invertColor.set(true, (err, result) => { config.invertColor.set(true, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -100,6 +104,8 @@ export default function abilityTest() { ...@@ -100,6 +104,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_0800 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -114,8 +120,9 @@ export default function abilityTest() { ...@@ -114,8 +120,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300');
config.contentTimeout.set(0, (err, result) => { config.contentTimeout.set(0, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -138,6 +145,8 @@ export default function abilityTest() { ...@@ -138,6 +145,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_1400 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -152,8 +161,9 @@ export default function abilityTest() { ...@@ -152,8 +161,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900');
config.animationOff.set(true, (err, result) => { config.animationOff.set(true, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -176,6 +186,8 @@ export default function abilityTest() { ...@@ -176,6 +186,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_2000 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -190,8 +202,9 @@ export default function abilityTest() { ...@@ -190,8 +202,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500');
config.brightnessDiscount.set(0.1, (err, result) => { config.brightnessDiscount.set(0.1, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -214,6 +227,8 @@ export default function abilityTest() { ...@@ -214,6 +227,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_2600 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -228,8 +243,9 @@ export default function abilityTest() { ...@@ -228,8 +243,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900');
config.mouseKey.set(true, (err, result) => { config.mouseKey.set(true, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -252,6 +268,8 @@ export default function abilityTest() { ...@@ -252,6 +268,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_5000 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -265,9 +283,10 @@ export default function abilityTest() { ...@@ -265,9 +283,10 @@ export default function abilityTest() {
*/ */
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500');
config.mouseAutoClick.set(-1, (err, result) => { config.mouseAutoClick.set(1, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -290,6 +309,8 @@ export default function abilityTest() { ...@@ -290,6 +309,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_5600 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -304,8 +325,9 @@ export default function abilityTest() { ...@@ -304,8 +325,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100');
config.shortkey.set(true, (err, result) => { config.shortkey.set(true, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -328,6 +350,8 @@ export default function abilityTest() { ...@@ -328,6 +350,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_6200 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -343,8 +367,9 @@ export default function abilityTest() { ...@@ -343,8 +367,9 @@ export default function abilityTest() {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700');
let value = 'teststr' let value = 'teststr'
config.shortkeyTarget.set(value, (err, result) => { config.shortkeyTarget.set(value, (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -368,6 +393,8 @@ export default function abilityTest() { ...@@ -368,6 +393,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_6800 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -382,8 +409,9 @@ export default function abilityTest() { ...@@ -382,8 +409,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900');
config.daltonizationColorFilter.set('Normal', (err, result) => { config.daltonizationColorFilter.set('Normal', (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -402,8 +430,9 @@ export default function abilityTest() { ...@@ -402,8 +430,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000', 0, async function(done) { it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000'); console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000');
config.daltonizationColorFilter.set('Deuteranomaly', (err, result) => { config.daltonizationColorFilter.set('Deuteranomaly', (err, result) => {
if (err.code != 0) { if (err && err.code != 0) {
expect(true).assertTrue(); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else { } else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000 has no write permission`); console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000 has no write permission`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -426,6 +455,8 @@ export default function abilityTest() { ...@@ -426,6 +455,8 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_8100 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done(); done();
}); });
}) })
...@@ -444,6 +475,50 @@ export default function abilityTest() { ...@@ -444,6 +475,50 @@ export default function abilityTest() {
expect(null).assertFail(); expect(null).assertFail();
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_8200 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
/*
* @tc.number AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8300
* @tc.name AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8300
* @tc.desc Test enableAbility() function in callback mode.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8300', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8300');
let name = 'com.example.accessibilityconfigreqreadpermission/AccessibilityExtAbility';
config.enableAbility(name, ['retrieve', 'touchGuide', 'keyEventObserver'], (err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8300 error: ${JSON.stringify(err)}`);
if (err && err.code != 0) {
expect(201).assertEqual(err.code);
} else {
expect(null).assertFail();
}
done();
});
})
/*
* @tc.number AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8400
* @tc.name AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8400
* @tc.desc Test disableAbility() function in callback mode.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8400', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8400');
let name = 'com.example.accessibilityconfigreqreadpermission/AccessibilityExtAbility';
config.disableAbility(name, (err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8400 err: ${JSON.stringify(err)}`);
if (err && err.code != 0) {
expect(201).assertEqual(err.code);
} else {
expect(null).assertFail();
}
done(); done();
}); });
}) })
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"uiSyntax": "ets", "uiSyntax": "ets",
"pages": "$profile:main_pages", "pages": "$profile:main_pages",
"abilities": [{ "abilities": [{
"name": "TestAbility", "name": "com.example.accessibilityxts.MainAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ts", "srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main", "description": "$string:phone_entry_main",
"icon": "$media:icon", "icon": "$media:icon",
"label": "$string:entry_label", "label": "$string:entry_label",
...@@ -29,7 +29,21 @@ ...@@ -29,7 +29,21 @@
] ]
}] }]
}], }],
"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": [{ "requestPermissions": [{
"name": "ohos.permission.READ_ACCESSIBILITY_CONFIG", "name": "ohos.permission.READ_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.READ_ACCESSIBILITY_CONFIG" "reason": "need use ohos.permission.READ_ACCESSIBILITY_CONFIG"
......
{
"accessibilityCapabilities": [
"retrieve"
],
"accessibilityCapabilityRationale": "a11y_rationale",
"settingsAbility": "com.accessibility.voiceaid.voiceAidSetting"
}
\ No newline at end of file
{ {
"src": [ "src": [
"TestAbility/pages/index" "MainAbility/pages/index/index"
] ]
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ import commonEvent from '@ohos.commonEvent'; ...@@ -16,6 +16,7 @@ import commonEvent from '@ohos.commonEvent';
import accessibility from '@ohos.accessibility'; import accessibility from '@ohos.accessibility';
const invalidString = 'xxx'; const invalidString = 'xxx';
const invalidValue = 1;
export class ElementTest { export class ElementTest {
private context = undefined; private context = undefined;
...@@ -604,7 +605,7 @@ export class ElementTest { ...@@ -604,7 +605,7 @@ export class ElementTest {
} }
} catch (e) { } catch (e) {
console.info('ElementTest executeAttributeValuePromise ' + caseName + ' catch(e): ' + JSON.stringify(e)); console.info('ElementTest executeAttributeValuePromise ' + caseName + ' catch(e): ' + JSON.stringify(e));
if (input == invalidString) { if (input == invalidString && e && e.code != 0) {
result = true; result = true;
} }
} }
...@@ -737,12 +738,15 @@ export class ElementTest { ...@@ -737,12 +738,15 @@ export class ElementTest {
console.info('ElementTest executePerformActionPromise ' + caseName + ' action: ' + action + ', args: ' + JSON.stringify(args)); console.info('ElementTest executePerformActionPromise ' + caseName + ' action: ' + action + ', args: ' + JSON.stringify(args));
let ret = await element.performAction(action, args); let ret = await element.performAction(action, args);
console.info('ElementTest executePerformActionPromise ' + caseName + ' ret: ' + JSON.stringify(ret)); console.info('ElementTest executePerformActionPromise ' + caseName + ' ret: ' + JSON.stringify(ret));
if (typeof(ret) == 'boolean') { if (typeof(ret) == 'undefined') {
result = true; result = true;
} }
} catch (e) { } catch (e) {
console.info('ElementTest executePerformActionPromise ' + caseName + ' catch(e): ' + JSON.stringify(e)); console.info('ElementTest executePerformActionPromise ' + caseName + ' catch(e): ' + JSON.stringify(e));
if (action == invalidString) { if (e && e.code != 0) {
if (e.code == 9300005 || e.code == 9300000) {
result = true;
}
result = true; result = true;
} }
} }
...@@ -795,7 +799,7 @@ export class ElementTest { ...@@ -795,7 +799,7 @@ export class ElementTest {
} }
} catch (e) { } catch (e) {
console.info('ElementTest executeFindElementPromiseByFocusType ' + caseName + ' catch(e): ' + JSON.stringify(e)); console.info('ElementTest executeFindElementPromiseByFocusType ' + caseName + ' catch(e): ' + JSON.stringify(e));
if (condition == invalidString) { if (condition == invalidString && e && e.code != 0) {
result = true; result = true;
} }
} }
...@@ -850,7 +854,9 @@ export class ElementTest { ...@@ -850,7 +854,9 @@ export class ElementTest {
element.attributeNames((err, names) => { element.attributeNames((err, names) => {
console.info('ElementTest executeAttributeNamesCallback ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeAttributeNamesCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeAttributeNamesCallback ' + caseName + ' names: ' + JSON.stringify(names)); console.info('ElementTest executeAttributeNamesCallback ' + caseName + ' names: ' + JSON.stringify(names));
if (err.code == 0 && Array.isArray(names)) { if (err && err.code != 0) {
result = false;
} else if (Array.isArray(names)) {
result = true; result = true;
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
...@@ -873,9 +879,9 @@ export class ElementTest { ...@@ -873,9 +879,9 @@ export class ElementTest {
element.attributeValue(input, (err, value) => { element.attributeValue(input, (err, value) => {
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' value: ' + JSON.stringify(value)); console.info('ElementTest executeAttributeValueCallback ' + caseName + ' value: ' + JSON.stringify(value));
if (input == invalidString && err.code != 0) { if (err && err.code != 0) {
result = true; result = true;
} else if (err.code == 0 && typeof(value) == outputType) { } else if (typeof(value) == outputType) {
result = true; result = true;
} else { } else {
console.warn('ElementTest executeAttributeValueCallback ' + caseName + ' valueType: ' + typeof(value)); console.warn('ElementTest executeAttributeValueCallback ' + caseName + ' valueType: ' + typeof(value));
...@@ -899,10 +905,10 @@ export class ElementTest { ...@@ -899,10 +905,10 @@ export class ElementTest {
element.attributeValue(input, (err, value) => { element.attributeValue(input, (err, value) => {
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' value: ' + JSON.stringify(value)); console.info('ElementTest executeAttributeValueCallback ' + caseName + ' value: ' + JSON.stringify(value));
if (err.code == 0 && typeof(value) == 'object' && typeof(value.left) == 'number' if (typeof(value) == 'object' && typeof(value.left) == 'number'
&& typeof(value.top) == 'number' && typeof(value.width) == 'number' && typeof(value.height) == 'number') { && typeof(value.top) == 'number' && typeof(value.width) == 'number' && typeof(value.height) == 'number') {
result = true; result = true;
} else { } else if (err) {
console.warn('ElementTest executeAttributeValueCallbackRect ' + caseName + ' valueType: ' + typeof(value)); console.warn('ElementTest executeAttributeValueCallbackRect ' + caseName + ' valueType: ' + typeof(value));
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
...@@ -928,7 +934,9 @@ export class ElementTest { ...@@ -928,7 +934,9 @@ export class ElementTest {
target.attributeValue('triggerAction', (err, value) => { target.attributeValue('triggerAction', (err, value) => {
console.info('ElementTest executeAttributeValueCallbackTriggerAction ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeAttributeValueCallbackTriggerAction ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeAttributeValueCallbackTriggerAction ' + caseName + ' valueType: ' + typeof(value)); console.info('ElementTest executeAttributeValueCallbackTriggerAction ' + caseName + ' valueType: ' + typeof(value));
if (err.code == 0 && eventType == 'click' && typeof(value) == 'string') { if (err) {
this.publishCaseResult(caseName, false);
} else if (eventType == 'click' && typeof(value) == 'string') {
this.publishCaseResult(caseName, true); this.publishCaseResult(caseName, true);
} }
}); });
...@@ -960,7 +968,9 @@ export class ElementTest { ...@@ -960,7 +968,9 @@ export class ElementTest {
element.attributeValue('rootElement', (err, value) => { element.attributeValue('rootElement', (err, value) => {
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' value: ' + JSON.stringify(value)); console.info('ElementTest executeAttributeValueCallback ' + caseName + ' value: ' + JSON.stringify(value));
if (err.code == 0 && typeof(value) == 'object') { if (err) {
let result = false;
} else if (typeof(value) == 'object') {
result = true; result = true;
} else { } else {
console.warn('ElementTest executeAttributeValueCallback ' + caseName + ' valueType: ' + typeof(value)); console.warn('ElementTest executeAttributeValueCallback ' + caseName + ' valueType: ' + typeof(value));
...@@ -978,7 +988,9 @@ export class ElementTest { ...@@ -978,7 +988,9 @@ export class ElementTest {
element.attributeValue(input, (err, value) => { element.attributeValue(input, (err, value) => {
console.info('ElementTest executeAttributeValueCallbackArray ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeAttributeValueCallbackArray ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeAttributeValueCallbackArray ' + caseName + ' value: ' + JSON.stringify(value)); console.info('ElementTest executeAttributeValueCallbackArray ' + caseName + ' value: ' + JSON.stringify(value));
if (err.code == 0 && Array.isArray(value)) { if (err) {
let result = false;
} else if (Array.isArray(value)) {
if ((value.length == 0)|| if ((value.length == 0)||
(value.length > 0 && typeof(value[0]) == outputType)) { (value.length > 0 && typeof(value[0]) == outputType)) {
result = true; result = true;
...@@ -996,7 +1008,7 @@ export class ElementTest { ...@@ -996,7 +1008,7 @@ export class ElementTest {
element.actionNames((err, actions) => { element.actionNames((err, actions) => {
console.info('ElementTest executeActionNamesCallback ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeActionNamesCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeActionNamesCallback ' + caseName + ' actions: ' + JSON.stringify(actions)); console.info('ElementTest executeActionNamesCallback ' + caseName + ' actions: ' + JSON.stringify(actions));
if (err.code == 0 && Array.isArray(actions)) { if (Array.isArray(actions)) {
if ((actions.length == 0) || if ((actions.length == 0) ||
(actions.length > 0 && typeof(actions[0]) == 'string')) { (actions.length > 0 && typeof(actions[0]) == 'string')) {
result = true; result = true;
...@@ -1016,9 +1028,12 @@ export class ElementTest { ...@@ -1016,9 +1028,12 @@ export class ElementTest {
element.performAction(action, args, (err, ret) => { element.performAction(action, args, (err, ret) => {
console.info('ElementTest executePerformActionCallback ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executePerformActionCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executePerformActionCallback ' + caseName + ' ret: ' + JSON.stringify(ret)); console.info('ElementTest executePerformActionCallback ' + caseName + ' ret: ' + JSON.stringify(ret));
if (action == invalidString && err.code != 0) { if (err && err.code != 0) {
if (err.code == 9300005 || err.code == 9300000) {
result = true;
}
result = true; result = true;
} else if (err.code == 0 && typeof(ret) == 'boolean') { } else if (typeof(ret) == 'undefined') {
result = true; result = true;
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
...@@ -1034,9 +1049,9 @@ export class ElementTest { ...@@ -1034,9 +1049,9 @@ export class ElementTest {
element.findElement('content', condition, (err, found) => { element.findElement('content', condition, (err, found) => {
console.info('ElementTest executeFindElementCallbackByContent ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeFindElementCallbackByContent ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeFindElementCallbackByContent ' + caseName + ' element: ' + JSON.stringify(found)); console.info('ElementTest executeFindElementCallbackByContent ' + caseName + ' element: ' + JSON.stringify(found));
if (condition == invalidString && err.code != 0) { if (condition == invalidString && err && err.code != 0) {
result = true; result = true;
} else if (err.code == 0 && Array.isArray(found)) { } else if (Array.isArray(found)) {
if (found.length == 0 || typeof(found[0]) == 'object') { if (found.length == 0 || typeof(found[0]) == 'object') {
result = true; result = true;
} }
...@@ -1058,9 +1073,9 @@ export class ElementTest { ...@@ -1058,9 +1073,9 @@ export class ElementTest {
element.findElement('focusType', condition, (err, found) => { element.findElement('focusType', condition, (err, found) => {
console.info('ElementTest executeFindElementCallbackByFocusType ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeFindElementCallbackByFocusType ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeFindElementCallbackByFocusType ' + caseName + ' element: ' + JSON.stringify(found)); console.info('ElementTest executeFindElementCallbackByFocusType ' + caseName + ' element: ' + JSON.stringify(found));
if (condition == invalidString && err.code != 0) { if (condition == invalidString && err && err.code != 0) {
result = true; result = true;
} else if (err.code == 0 && typeof(found) == 'object') { } else if (typeof(found) == 'object') {
result = true; result = true;
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
...@@ -1085,7 +1100,7 @@ export class ElementTest { ...@@ -1085,7 +1100,7 @@ export class ElementTest {
console.info('ElementTest executeFindElementCallbackByFocusDirection ' + caseName + ' element: ' + JSON.stringify(found)); console.info('ElementTest executeFindElementCallbackByFocusDirection ' + caseName + ' element: ' + JSON.stringify(found));
if (condition == invalidString && err.code != 0) { if (condition == invalidString && err.code != 0) {
result = true; result = true;
} else if (err.code == 0 && typeof(found) == 'object') { } else if (typeof(found) == 'object') {
result = true; result = true;
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
...@@ -1106,7 +1121,9 @@ export class ElementTest { ...@@ -1106,7 +1121,9 @@ export class ElementTest {
element.findElement('focusDirection', 'down', (err, found) => { element.findElement('focusDirection', 'down', (err, found) => {
console.info('ElementTest executeFindElementCallback5900 ' + caseName + ' err: ' + JSON.stringify(err)); console.info('ElementTest executeFindElementCallback5900 ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeFindElementCallback5900 ' + caseName + ' element: ' + JSON.stringify(found)); console.info('ElementTest executeFindElementCallback5900 ' + caseName + ' element: ' + JSON.stringify(found));
if (err.code == 0 && typeof(found) == 'object') { if (err && err.code != 0) {
}if (typeof(found) == 'object') {
result = true; result = true;
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
......
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
{ {
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
} }
] ]
} }
......
{
"app": {
"bundleName": "com.example.accessibilityerrcode",
"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("ActsAccessibilityErrCodeTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":accessibilityerrcode_js_assets",
":accessibilityerrcode_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilityErrCodeTest"
part_name = "accessibility"
subsystem_name = "barrierfree"
}
ohos_app_scope("accessibilityerrcode_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilityerrcode_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilityerrcode_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilityerrcode_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "240000",
"bundle-name": "com.example.accessibilityerrcode",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsAccessibilityErrCodeTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell setmode 602"
],
"teardown-command":[
"bm uninstall -n com.example.accessibilityerrcode"
]
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
/*
* 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'
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, "MainAbility/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 router from '@ohos.router';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
aboutToAppear(){
console.info("start run testcase!!!!");
}
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 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.setUIContent(this.context, 'TestAbility/pages/index', null)
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility 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 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%')
}
}
\ 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 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'
])
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 + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ 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 './AccessibilityErrCode.test.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.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"
]
}]
}],
"requestPermissions": [{
"name": "ohos.permission.READ_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.READ_ACCESSIBILITY_CONFIG"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
}
\ 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": "ActsAccessibilityErrCodeTest"
},
{
"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": [
"TestAbility/pages/index"
]
}
\ No newline at end of file
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
{ {
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
} }
] ]
} }
......
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
{ {
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
} }
] ]
} }
......
...@@ -60,7 +60,7 @@ export class ExtensionContextTest { ...@@ -60,7 +60,7 @@ export class ExtensionContextTest {
switch (caseName) { switch (caseName) {
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1500': case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1500':
bundleName = ['com.example.accessibleformextension']; bundleName = ['com.example.accessibilityxts'];
this.setTargetBundleNameCallback(caseName, bundleName); this.setTargetBundleNameCallback(caseName, bundleName);
break; break;
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1600': case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1600':
...@@ -71,7 +71,7 @@ export class ExtensionContextTest { ...@@ -71,7 +71,7 @@ export class ExtensionContextTest {
this.setTargetBundleNameCallback(caseName, bundleName); this.setTargetBundleNameCallback(caseName, bundleName);
break; break;
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1800': case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1800':
bundleName = ['com.example.accessibleformextension']; bundleName = ['com.example.accessibilityxts'];
this.setTargetBundleNamePromise(caseName, bundleName); this.setTargetBundleNamePromise(caseName, bundleName);
break; break;
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1900': case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1900':
...@@ -240,7 +240,7 @@ export class ExtensionContextTest { ...@@ -240,7 +240,7 @@ export class ExtensionContextTest {
private async getDisPlayId() { private async getDisPlayId() {
let displayId = -1; let displayId = -1;
display.getDefaultDisplay((err, data) => { display.getDefaultDisplay((err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error("getDisPlayId getDefaultDisplay error"); console.error("getDisPlayId getDefaultDisplay error");
} else { } else {
console.info("getDisPlayId getDefaultDisplay data.id: " + JSON.stringify(data.id)); console.info("getDisPlayId getDefaultDisplay data.id: " + JSON.stringify(data.id));
...@@ -268,8 +268,7 @@ export class ExtensionContextTest { ...@@ -268,8 +268,7 @@ export class ExtensionContextTest {
let tartgetNode = await rootNode.findElement('content', 'button1'); let tartgetNode = await rootNode.findElement('content', 'button1');
console.info("setAccessibilityFocus tartgetNode: " + JSON.stringify(tartgetNode)); console.info("setAccessibilityFocus tartgetNode: " + JSON.stringify(tartgetNode));
if (tartgetNode) { if (tartgetNode) {
isFocus = await tartgetNode[0].performAction("accessibilityFocus"); await tartgetNode[0].performAction("accessibilityFocus");
console.info("setAccessibilityFocus isFocus: " + JSON.stringify(isFocus));
} }
} }
} }
...@@ -284,8 +283,7 @@ export class ExtensionContextTest { ...@@ -284,8 +283,7 @@ export class ExtensionContextTest {
let tartgetNode = await rootNode.findElement('content', 'button1'); let tartgetNode = await rootNode.findElement('content', 'button1');
console.info("setAccessibilityFocus tartgetNode: " + JSON.stringify(tartgetNode)); console.info("setAccessibilityFocus tartgetNode: " + JSON.stringify(tartgetNode));
if (tartgetNode) { if (tartgetNode) {
isFocus = await tartgetNode[0].performAction("clearAccessibilityFocus"); await tartgetNode[0].performAction("clearAccessibilityFocus");
console.info("setAccessibilityFocus isFocus: " + JSON.stringify(isFocus));
} }
} }
} }
...@@ -295,9 +293,13 @@ export class ExtensionContextTest { ...@@ -295,9 +293,13 @@ export class ExtensionContextTest {
let result = true; let result = true;
this.context.setTargetBundleName(bundleName, (err, res) => { this.context.setTargetBundleName(bundleName, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
result = false; if ((bundleName.length == 0 || bundleName[0] == 'aaa') && err && err.code != 0) {
result = true;
} else {
result = false;
}
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}); });
...@@ -310,7 +312,11 @@ export class ExtensionContextTest { ...@@ -310,7 +312,11 @@ export class ExtensionContextTest {
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}).catch((error) => { }).catch((error) => {
console.error(caseName + " error: " + JSON.stringify(error)); console.error(caseName + " error: " + JSON.stringify(error));
result = false; if ((bundleName.length == 0 || bundleName[0] == 'aaa') && error && error.code != 0) {
result = true;
} else {
result = false;
}
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}); });
} }
...@@ -319,7 +325,7 @@ export class ExtensionContextTest { ...@@ -319,7 +325,7 @@ export class ExtensionContextTest {
let result = false; let result = false;
this.context.getWindowRootElement(async (err, res) => { this.context.getWindowRootElement(async (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
} }
if (res == undefined) { if (res == undefined) {
...@@ -339,21 +345,16 @@ export class ExtensionContextTest { ...@@ -339,21 +345,16 @@ export class ExtensionContextTest {
let result = false; let result = false;
if ((windowId == -1) || (windowId == 1000)){ if ((windowId == -1) || (windowId == 1000)){
this.context.getWindowRootElement(-1, async (err, res) => { this.context.getWindowRootElement(-1, async (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); if (err && err.code != 0) {
if (err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
result = true result = true;
}
if (res == undefined) {
console.error(caseName + " res is undefined");
result = true
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}); });
} else { } else {
this.context.getWindowRootElement(windowId, async (err, res) => { this.context.getWindowRootElement(windowId, async (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
} }
if (res == undefined) { if (res == undefined) {
...@@ -374,12 +375,6 @@ export class ExtensionContextTest { ...@@ -374,12 +375,6 @@ export class ExtensionContextTest {
let result = false; let result = false;
if ((windowId == -1) || (windowId == 1000)){ if ((windowId == -1) || (windowId == 1000)){
this.context.getWindowRootElement(-1).then(async (res) => { this.context.getWindowRootElement(-1).then(async (res) => {
console.info(caseName + " res: " + JSON.stringify(res));
if (res == undefined) {
console.error(caseName + " res is undefined");
result = true;
}
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}).catch((error) => { }).catch((error) => {
console.error(caseName + " error: " + JSON.stringify(error)); console.error(caseName + " error: " + JSON.stringify(error));
...@@ -411,7 +406,7 @@ export class ExtensionContextTest { ...@@ -411,7 +406,7 @@ export class ExtensionContextTest {
let result = false; let result = false;
this.context.getWindows((err, res) => { this.context.getWindows((err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
} }
if (res == undefined) { if (res == undefined) {
...@@ -429,11 +424,11 @@ export class ExtensionContextTest { ...@@ -429,11 +424,11 @@ export class ExtensionContextTest {
private async getWindowsByIdCallback(caseName: string, displayId: number) { private async getWindowsByIdCallback(caseName: string, displayId: number) {
let result = false; let result = false;
console.info(caseName + " displayId: " + JSON.stringify(displayId)); console.info(caseName + " displayId: " + JSON.stringify(displayId));
if (displayId == -1) { if (displayId == -1 || displayId == 100) {
this.context.getWindows(displayId, (err, res) => { this.context.getWindows(-1, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) { if (err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
result = true; result = true;
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
...@@ -441,7 +436,7 @@ export class ExtensionContextTest { ...@@ -441,7 +436,7 @@ export class ExtensionContextTest {
} else { } else {
this.context.getWindows(displayId, (err, res) => { this.context.getWindows(displayId, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
} }
if (res) { if (res) {
...@@ -458,18 +453,21 @@ export class ExtensionContextTest { ...@@ -458,18 +453,21 @@ export class ExtensionContextTest {
let result = false; let result = false;
console.info(caseName + " displayId: " + JSON.stringify(displayId)); console.info(caseName + " displayId: " + JSON.stringify(displayId));
if (displayId == -1) { if (displayId == -1) {
this.context.getWindows(-1, (err, res) => { this.context.getWindows(displayId).then(async (res) => {
console.info(caseName + " res: " + JSON.stringify(res)); result = false;
if (err.code != 0) { this.publishCaseResult(caseName, result);
console.error(caseName + " err: " + JSON.stringify(err.code)); }).catch((err) => {
console.error(caseName + 'err:' + JSON.stringify(err));
if (err && err.code != 0) {
result = true; result = true;
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}); });
} else { } else {
this.context.getWindows(displayId, (err, res) => { this.context.getWindows(displayId, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
} }
if (res) { if (res) {
...@@ -486,7 +484,7 @@ export class ExtensionContextTest { ...@@ -486,7 +484,7 @@ export class ExtensionContextTest {
let result = false; let result = false;
this.context.getFocusElement((err, res) => { this.context.getFocusElement((err, res) => {
console.info(caseName + "res: " + JSON.stringify(res)); console.info(caseName + "res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + "err: " + JSON.stringify(err.code)); console.error(caseName + "err: " + JSON.stringify(err.code));
result = true; result = true;
} }
...@@ -510,7 +508,7 @@ export class ExtensionContextTest { ...@@ -510,7 +508,7 @@ export class ExtensionContextTest {
} }
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
} else { } else {
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + "err: " + JSON.stringify(err.code)); console.error(caseName + "err: " + JSON.stringify(err.code));
result = true; result = true;
} }
...@@ -523,7 +521,7 @@ export class ExtensionContextTest { ...@@ -523,7 +521,7 @@ export class ExtensionContextTest {
} else { } else {
this.context.getFocusElement(false, (err, res) => { this.context.getFocusElement(false, (err, res) => {
console.info(caseName + "res: " + JSON.stringify(res)); console.info(caseName + "res: " + JSON.stringify(res));
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + "err: " + JSON.stringify(err.code)); console.error(caseName + "err: " + JSON.stringify(err.code));
result = true; result = true;
} }
...@@ -579,21 +577,17 @@ export class ExtensionContextTest { ...@@ -579,21 +577,17 @@ export class ExtensionContextTest {
let result = false; let result = false;
if (gesturePath == undefined) { if (gesturePath == undefined) {
this.context.injectGesture(gesturePath, (err, res) => { this.context.injectGesture(gesturePath, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); if (err && err.code != 0) {
if (err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
result = true; result = true;
} }
if (res == undefined) {
result = true;
}
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}); });
} else { } else {
this.context.injectGesture(gesturePath, (err, res) => { this.context.injectGesture(gesturePath, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res)); console.info(caseName + " res: " + JSON.stringify(res));
result = true; result = true;
if (err.code != 0) { if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code)); console.error(caseName + " err: " + JSON.stringify(err.code));
result = false; result = false;
} }
...@@ -607,14 +601,12 @@ export class ExtensionContextTest { ...@@ -607,14 +601,12 @@ export class ExtensionContextTest {
let result = false; let result = false;
if (gesturePath == undefined) { if (gesturePath == undefined) {
this.context.injectGesture(gesturePath).then((res) => { this.context.injectGesture(gesturePath).then((res) => {
console.info(caseName + " res: " + JSON.stringify(res));
if (res == undefined) {
result = true;
}
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}).catch ((err) => { }).catch ((err) => {
console.error(caseName + 'error:' + JSON.stringify(err)); if (err && err.code != 0) {
result = true; console.error(caseName + 'error:' + JSON.stringify(err));
result = true;
}
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}); });
} else { } else {
...@@ -623,8 +615,10 @@ export class ExtensionContextTest { ...@@ -623,8 +615,10 @@ export class ExtensionContextTest {
result = true; result = true;
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}).catch ((err) => { }).catch ((err) => {
console.error(caseName + 'error:' + JSON.stringify(err)); if (err && err.code != 0) {
result = false; console.error(caseName + 'error:' + JSON.stringify(err));
result = true;
}
this.publishCaseResult(caseName, result); this.publishCaseResult(caseName, result);
}); });
} }
......
...@@ -86,7 +86,7 @@ export default function abilityTest() { ...@@ -86,7 +86,7 @@ export default function abilityTest() {
/* /*
* @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1500 * @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1500
* @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1500 * @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1500
* @tc.desc The parameter input is 'com.example.accessibleformextension', * @tc.desc The parameter input is 'com.example.accessibilityxts',
* test the setTargetBundleName() function, * test the setTargetBundleName() function,
* The result of setTargetBundleName() should be boolean type. * The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest * @tc.size SmallTest
...@@ -120,7 +120,7 @@ export default function abilityTest() { ...@@ -120,7 +120,7 @@ export default function abilityTest() {
/* /*
* @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1600 * @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1600
* @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1600 * @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1600
* @tc.desc The parameter input is 'com.example.accessibleformextension', * @tc.desc The parameter input is 'com.example.accessibilityxts',
* test the setTargetBundleName() function, * test the setTargetBundleName() function,
* The result of setTargetBundleName() should be boolean type. * The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest * @tc.size SmallTest
...@@ -154,7 +154,7 @@ export default function abilityTest() { ...@@ -154,7 +154,7 @@ export default function abilityTest() {
/* /*
* @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1700 * @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1700
* @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1700 * @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1700
* @tc.desc The parameter input is 'com.example.accessibleformextension', * @tc.desc The parameter input is 'com.example.accessibilityxts',
* test the setTargetBundleName() function, * test the setTargetBundleName() function,
* The result of setTargetBundleName() should be boolean type. * The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest * @tc.size SmallTest
...@@ -188,7 +188,7 @@ export default function abilityTest() { ...@@ -188,7 +188,7 @@ export default function abilityTest() {
/* /*
* @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1800 * @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1800
* @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1800 * @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1800
* @tc.desc The parameter input is 'com.example.accessibleformextension', * @tc.desc The parameter input is 'com.example.accessibilityxts',
* test the setTargetBundleName() function, * test the setTargetBundleName() function,
* The result of setTargetBundleName() should be boolean type. * The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest * @tc.size SmallTest
...@@ -222,7 +222,7 @@ export default function abilityTest() { ...@@ -222,7 +222,7 @@ export default function abilityTest() {
/* /*
* @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1900 * @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1900
* @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1900 * @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1900
* @tc.desc The parameter input is 'com.example.accessibleformextension', * @tc.desc The parameter input is 'com.example.accessibilityxts',
* test the setTargetBundleName() function, * test the setTargetBundleName() function,
* The result of setTargetBundleName() should be boolean type. * The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest * @tc.size SmallTest
...@@ -256,7 +256,7 @@ export default function abilityTest() { ...@@ -256,7 +256,7 @@ export default function abilityTest() {
/* /*
* @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_2000 * @tc.number AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_2000
* @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_2000 * @tc.name AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_2000
* @tc.desc The parameter input is 'com.example.accessibleformextension', * @tc.desc The parameter input is 'com.example.accessibilityxts',
* test the setTargetBundleName() function, * test the setTargetBundleName() function,
* The result of setTargetBundleName() should be boolean type. * The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest * @tc.size SmallTest
......
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
{ {
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
} }
] ]
} }
......
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
{ {
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
} }
] ]
} }
......
{
"app": {
"bundleName": "com.example.accessibilitysendaccessibilityevent",
"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("ActsAccessibilitySendAccessibilityEventTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":accessibilitysendaccessibilityevent_js_assets",
":accessibilitysendaccessibilityevent_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAccessibilitySendAccessibilityEventTest"
part_name = "accessibility"
subsystem_name = "barrierfree"
}
ohos_app_scope("accessibilitysendaccessibilityevent_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("accessibilitysendaccessibilityevent_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("accessibilitysendaccessibilityevent_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":accessibilitysendaccessibilityevent_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "240000",
"bundle-name": "com.example.accessibilitysendaccessibilityevent",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsAccessibilitySendAccessibilityEventTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell setmode 602"
],
"teardown-command":[
"bm uninstall -n com.example.accessibilitysendaccessibilityevent"
]
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
/*
* 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'
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, "MainAbility/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 router from '@ohos.router';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
aboutToAppear(){
console.info("start run testcase!!!!");
}
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 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.setUIContent(this.context, 'TestAbility/pages/index', null)
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility 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 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%')
}
}
\ 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 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'
])
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 + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ 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 './AccessibilitySendAccessibilityEvent.test.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.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"
]
}]
}],
"requestPermissions": [{
"name": "ohos.permission.READ_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.READ_ACCESSIBILITY_CONFIG"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
}
\ 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": "ActsAccessibilitySendAccessibilityEventTest"
},
{
"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"
}
]
}
...@@ -51,7 +51,7 @@ describe('AccessibleAbilityList', function () { ...@@ -51,7 +51,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0210'); console.info('AbilityList_0210');
let abilityType = 'audible'; let abilityType = 'audible';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0210 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0210 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -74,7 +74,7 @@ describe('AccessibleAbilityList', function () { ...@@ -74,7 +74,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0220'); console.info('AbilityList_0220');
let abilityType = 'generic'; let abilityType = 'generic';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0220 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0220 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -97,7 +97,7 @@ describe('AccessibleAbilityList', function () { ...@@ -97,7 +97,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0230'); console.info('AbilityList_0230');
let abilityType = 'haptic'; let abilityType = 'haptic';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0230 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0230 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -120,7 +120,7 @@ describe('AccessibleAbilityList', function () { ...@@ -120,7 +120,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0240'); console.info('AbilityList_0240');
let abilityType = 'spoken'; let abilityType = 'spoken';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0240 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0240 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -143,7 +143,7 @@ describe('AccessibleAbilityList', function () { ...@@ -143,7 +143,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0250'); console.info('AbilityList_0250');
let abilityType = 'visual'; let abilityType = 'visual';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0250 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0250 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -166,7 +166,7 @@ describe('AccessibleAbilityList', function () { ...@@ -166,7 +166,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0260'); console.info('AbilityList_0260');
let abilityType = 'all'; let abilityType = 'all';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0260 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0260 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -189,7 +189,7 @@ describe('AccessibleAbilityList', function () { ...@@ -189,7 +189,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0270'); console.info('AbilityList_0270');
let abilityType = ''; let abilityType = '';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0270 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0270 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true); expect(Array.isArray(data)).assertEqual(true);
done(); done();
...@@ -212,7 +212,7 @@ describe('AccessibleAbilityList', function () { ...@@ -212,7 +212,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0280'); console.info('AbilityList_0280');
let abilityType = null; let abilityType = null;
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0280 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0280 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true); expect(Array.isArray(data)).assertEqual(true);
done(); done();
...@@ -235,7 +235,7 @@ describe('AccessibleAbilityList', function () { ...@@ -235,7 +235,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0290'); console.info('AbilityList_0290');
let abilityState = 'enable'; let abilityState = 'enable';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0290 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0290 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -258,7 +258,7 @@ describe('AccessibleAbilityList', function () { ...@@ -258,7 +258,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0300'); console.info('AbilityList_0300');
let abilityState = 'disable'; let abilityState = 'disable';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0300 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0300 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -281,7 +281,7 @@ describe('AccessibleAbilityList', function () { ...@@ -281,7 +281,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0310'); console.info('AbilityList_0310');
let abilityState = 'install'; let abilityState = 'install';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0310 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0310 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -304,7 +304,7 @@ describe('AccessibleAbilityList', function () { ...@@ -304,7 +304,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0320'); console.info('AbilityList_0320');
let abilityState = ''; let abilityState = '';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0320 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0320 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true); expect(Array.isArray(data)).assertEqual(true);
done(); done();
...@@ -327,7 +327,7 @@ describe('AccessibleAbilityList', function () { ...@@ -327,7 +327,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0330'); console.info('AbilityList_0330');
let abilityState = null; let abilityState = null;
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0330 has error: ${err.code}`); console.error(`AccessibleAbilityList: AbilityList_0330 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true); expect(Array.isArray(data)).assertEqual(true);
done(); done();
...@@ -470,49 +470,6 @@ describe('AccessibleAbilityList', function () { ...@@ -470,49 +470,6 @@ describe('AccessibleAbilityList', function () {
}); });
}) })
/*
* @tc.number AbilityList_0400
* @tc.name AbilityList_0400
* @tc.desc The parameters input are '' and 'install', test the getAbilityLists() function,
* and the output is the list of AccessibilityAbilityInfo
* @tc.size SmallTest
* @tc.type User
*/
it('AbilityList_0400', 0, async function (done) {
console.info('AbilityList_0400');
let abilityType = '';
accessibility.getAbilityLists(abilityType, abilityState).then((result) => {
console.info(`AccessibleAbilityList: AbilityList_0400 result ${result.length}`);
expect(Array.isArray(result)).assertEqual(true);
done();
}).catch((err) => {
console.error(`AccessibleAbilityList: AbilityList_0400 has error: ${err}`);
expect(null).assertFail();
done();
});
})
/*
* @tc.number AbilityList_0410
* @tc.name AbilityList_0410
* @tc.desc The parameters input are null and 'install', test the getAbilityLists() function,
* and the output is the list of AccessibilityAbilityInfo
* @tc.size SmallTest
* @tc.type User
*/
it('AbilityList_0410', 0, async function (done) {
console.info('AbilityList_0410');
let abilityType = null;
accessibility.getAbilityLists(abilityType, abilityState).then((result) => {
console.info(`AccessibleAbilityList: AbilityList_0410 result ${result.length}`);
expect(Array.isArray(result)).assertEqual(true);
done();
}).catch((err) => {
console.error(`AccessibleAbilityList: AbilityList_0410 has error: ${err}`);
expect(null).assertFail();
done();
});
})
/* /*
* @tc.number AbilityList_0420 * @tc.number AbilityList_0420
...@@ -579,49 +536,5 @@ describe('AccessibleAbilityList', function () { ...@@ -579,49 +536,5 @@ describe('AccessibleAbilityList', function () {
done(); done();
}); });
}) })
/*
* @tc.number AbilityList_0450
* @tc.name AbilityList_0450
* @tc.desc The parameters input are 'all' and '', test the getAbilityLists() function,
* and the output is the list of AccessibilityAbilityInfo
* @tc.size SmallTest
* @tc.type User
*/
it('AbilityList_0450', 0, async function (done) {
console.info('AbilityList_0450');
let abilityState = '';
accessibility.getAbilityLists(abilityType, abilityState).then((result) => {
console.info(`AccessibleAbilityList: AbilityList_0450 result ${result.length}`);
expect(Array.isArray(result)).assertEqual(true);
done();
}).catch((err) => {
console.error(`AccessibleAbilityList: AbilityList_0450 has error: ${err}`);
expect(null).assertFail();
done();
});
})
/*
* @tc.number AbilityList_0460
* @tc.name AbilityList_0460
* @tc.desc The parameters input are 'all' and null, test the getAbilityLists() function,
* and the output is the list of AccessibilityAbilityInfo
* @tc.size SmallTest
* @tc.type User
*/
it('AbilityList_0460', 0, async function (done) {
console.info('AbilityList_0460');
let abilityState = null;
accessibility.getAbilityLists(abilityType, abilityState).then((result) => {
console.info(`AccessibleAbilityList: AbilityList_0460 result ${result.length}`);
expect(Array.isArray(result)).assertEqual(true);
done();
}).catch((err) => {
console.error(`AccessibleAbilityList: AbilityList_0460 has error: ${err}`);
expect(null).assertFail();
done();
});
})
}) })
} }
...@@ -63,40 +63,6 @@ describe('AccessibleCaptionConfiguration', function () { ...@@ -63,40 +63,6 @@ describe('AccessibleCaptionConfiguration', function () {
done(); done();
}) })
/*
* @tc.number CaptionConfiguration_0030
* @tc.name CaptionConfiguration_0030
* @tc.desc The parameter input is '', test the captionManager.on() function,
* and return undefined
* @tc.size SmallTest
* @tc.type User
*/
it('CaptionConfiguration_0030', 0, async function (done) {
console.info('CaptionConfiguration_0030');
let captionManager = accessibility.getCaptionsManager();
let stateEventType = '';
let ret = captionManager.on(stateEventType, (data) => {});
expect(ret).assertEqual(undefined);
done();
})
/*
* @tc.number CaptionConfiguration_0040
* @tc.name CaptionConfiguration_0040
* @tc.desc The parameter input is null, test the captionManager.on() function,
* and return undefined
* @tc.size SmallTest
* @tc.type User
*/
it('CaptionConfiguration_0040', 0, async function (done) {
console.info('CaptionConfiguration_0040');
let captionManager = accessibility.getCaptionsManager();
let stateEventType = null;
let ret = captionManager.on(stateEventType, (data) => {});
expect(ret).assertEqual(undefined);
done();
})
/* /*
* @tc.number CaptionConfiguration_0050 * @tc.number CaptionConfiguration_0050
* @tc.name CaptionConfiguration_0050 * @tc.name CaptionConfiguration_0050
...@@ -130,39 +96,5 @@ describe('AccessibleCaptionConfiguration', function () { ...@@ -130,39 +96,5 @@ describe('AccessibleCaptionConfiguration', function () {
expect(ret).assertEqual(undefined); expect(ret).assertEqual(undefined);
done(); done();
}) })
/*
* @tc.number CaptionConfiguration_0070
* @tc.name CaptionConfiguration_0070
* @tc.desc The parameter input is '', test the captionManager.off() function,
* and return undefined
* @tc.size SmallTest
* @tc.type User
*/
it('CaptionConfiguration_0070', 0, async function (done) {
console.info('CaptionConfiguration_0070');
let captionManager = accessibility.getCaptionsManager();
let stateEventType = '';
let ret = captionManager.off(stateEventType, (data) => {});
expect(ret).assertEqual(undefined);
done();
})
/*
* @tc.number CaptionConfiguration_0080
* @tc.name CaptionConfiguration_0080
* @tc.desc The parameter input is null, test the captionManager.off() function,
* and return undefined
* @tc.size SmallTest
* @tc.type User
*/
it('CaptionConfiguration_0080', 0, async function (done) {
console.info('CaptionConfiguration_0080');
let captionManager = accessibility.getCaptionsManager();
let stateEventType = null;
let ret = captionManager.off(stateEventType, (data) => {});
expect(ret).assertEqual(undefined);
done();
})
}) })
} }
...@@ -46,7 +46,7 @@ describe('AccessibleCheckAbility', function () { ...@@ -46,7 +46,7 @@ describe('AccessibleCheckAbility', function () {
it('CheckAbilityIsOpen_0170', 0, async function (done) { it('CheckAbilityIsOpen_0170', 0, async function (done) {
console.info('CheckAbilityIsOpen_0170'); console.info('CheckAbilityIsOpen_0170');
accessibility.isOpenAccessibility((err, data) => { accessibility.isOpenAccessibility((err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibilityApi: CheckAbilityIsOpen_0170 has error: ${err.code}`); console.error(`AccessibilityApi: CheckAbilityIsOpen_0170 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -92,7 +92,7 @@ describe('AccessibleCheckAbility', function () { ...@@ -92,7 +92,7 @@ describe('AccessibleCheckAbility', function () {
it('CheckAbilityIsOpen_0190', 0, async function (done) { it('CheckAbilityIsOpen_0190', 0, async function (done) {
console.info('CheckAbilityIsOpen_0190'); console.info('CheckAbilityIsOpen_0190');
accessibility.isOpenTouchGuide((err, data) => { accessibility.isOpenTouchGuide((err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(`AccessibilityApi: CheckAbilityIsOpen_0190 has error: ${err.code}`); console.error(`AccessibilityApi: CheckAbilityIsOpen_0190 has error: ${err.code}`);
expect(null).assertFail(); expect(null).assertFail();
done(); done();
...@@ -117,9 +117,11 @@ describe('AccessibleCheckAbility', function () { ...@@ -117,9 +117,11 @@ describe('AccessibleCheckAbility', function () {
expect(typeof (result)).assertEqual('boolean'); expect(typeof (result)).assertEqual('boolean');
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`AccessibilityApi: CheckAbilityIsOpen_0200 has error: ${err.code}`); if (err && err.code != 0){
expect(null).assertFail(); console.error(`AccessibilityApi: CheckAbilityIsOpen_0200 has error: ${err.code}`);
done(); expect(null).assertFail();
done();
}
}); });
}) })
}) })
......
...@@ -37,27 +37,6 @@ describe('AccessibleSendEvent', function () { ...@@ -37,27 +37,6 @@ describe('AccessibleSendEvent', function () {
/* are for accessibility.sendEvent() API test */ /* are for accessibility.sendEvent() API test */
/******************************************************************************** */ /******************************************************************************** */
/*
* @tc.number SendEvent_null_0010
* @tc.name SendEvent_null_0010
* @tc.desc The parameter input is null, test the sendEvent() function
* The result of sendEvent() should be equal to an error code with error
* @tc.size SmallTest
* @tc.type User
*/
it('SendEvent_null_0010', 0, async function (done) {
console.info('SendEvent_null_0010');
let event = null;
accessibility.sendEvent(event, (err, data) => {
console.info(`AccessibleSendEvent: SendEvent_null_0010 has error: ${err.code}`);
expect(err.code).assertEqual(-1);
console.info(`AccessibleSendEvent: SendEvent_null_0010 has data: ${data}`);
expect(data).assertEqual(undefined);
done();
})
})
/* /*
* @tc.number SendEvent_null_0020 * @tc.number SendEvent_null_0020
* @tc.name SendEvent_null_0020 * @tc.name SendEvent_null_0020
...@@ -76,40 +55,11 @@ describe('AccessibleSendEvent', function () { ...@@ -76,40 +55,11 @@ describe('AccessibleSendEvent', function () {
done(); done();
}).catch((err) => { }).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_null_0020 has error: ${err}`); console.info(`AccessibleSendEvent: SendEvent_null_0020 has error: ${err}`);
expect(err).assertEqual(undefined); expect(true).assertTrue();
done(); done();
}); });
}) })
/*
* @tc.number SendEvent_construct_0010
* @tc.name SendEvent_construct_0010
* @tc.desc The parameter input is EventInfo, test the sendEvent() function
* The result of sendEvent() should be equal to an error code with no error.
* Another test point is to test whether the modified constructor (EventInfo)
* works correctly.
* @tc.size SmallTest
* @tc.type User
*/
it('SendEvent_construct_0010', 0, async function (done) {
console.info('SendEvent_construct_0010');
let jsonObj = {
type : eventType,
bundleName : bundleName,
triggerAction : triggerAction,
}
let event = new accessibility.EventInfo(jsonObj);
accessibility.sendEvent(event, (err, data) => {
console.info(`AccessibleSendEventTest: SendEvent_construct_0010 has error: ${err.code}`);
expect(err.code).assertEqual(0);
console.info(`AccessibleSendEventTest: SendEvent_construct_0010 has data: ${data}`);
expect(data).assertEqual(undefined);
done();
})
})
/*********************************************************************************************************** */ /*********************************************************************************************************** */
/* Cases SendEvent_type_0010-SendEvent_itemCount_constructor_0030 /* Cases SendEvent_type_0010-SendEvent_itemCount_constructor_0030
/* are for interface accessibility.EventInfo API test */ /* are for interface accessibility.EventInfo API test */
...@@ -474,7 +424,7 @@ describe('AccessibleSendEvent', function () { ...@@ -474,7 +424,7 @@ describe('AccessibleSendEvent', function () {
done(); done();
}).catch((err) => { }).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_type_constructor_0120 has error: ${err}`); console.info(`AccessibleSendEvent: SendEvent_type_constructor_0120 has error: ${err}`);
expect(err).assertEqual(undefined); expect(true).assertTrue();
done(); done();
}); });
}) })
...@@ -508,7 +458,7 @@ describe('AccessibleSendEvent', function () { ...@@ -508,7 +458,7 @@ describe('AccessibleSendEvent', function () {
done(); done();
}).catch((err) => { }).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_type_constructor_0130 has error: ${err}`); console.info(`AccessibleSendEvent: SendEvent_type_constructor_0130 has error: ${err}`);
expect(err).assertEqual(undefined); expect(true).assertTrue();
done(); done();
}); });
}) })
...@@ -672,7 +622,7 @@ describe('AccessibleSendEvent', function () { ...@@ -672,7 +622,7 @@ describe('AccessibleSendEvent', function () {
done(); done();
}).catch((err) => { }).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_bundleName_constructor_0020 has error: ${err}`); console.info(`AccessibleSendEvent: SendEvent_bundleName_constructor_0020 has error: ${err}`);
expect(err).assertEqual(undefined); expect(true).assertTrue();
done(); done();
}); });
}) })
...@@ -705,7 +655,7 @@ describe('AccessibleSendEvent', function () { ...@@ -705,7 +655,7 @@ describe('AccessibleSendEvent', function () {
done(); done();
}).catch((err) => { }).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_bundleName_constructor_0030 has error: ${err}`); console.info(`AccessibleSendEvent: SendEvent_bundleName_constructor_0030 has error: ${err}`);
expect(err).assertEqual(undefined); expect(true).assertTrue();
done(); done();
}); });
}) })
...@@ -1545,7 +1495,7 @@ describe('AccessibleSendEvent', function () { ...@@ -1545,7 +1495,7 @@ describe('AccessibleSendEvent', function () {
done(); done();
}).catch((err) => { }).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_triggerAction_constructor_0170 has error: ${err}`); console.info(`AccessibleSendEvent: SendEvent_triggerAction_constructor_0170 has error: ${err}`);
expect(err).assertEqual(undefined); expect(true).assertTrue();
done(); done();
}); });
}) })
...@@ -1578,7 +1528,7 @@ describe('AccessibleSendEvent', function () { ...@@ -1578,7 +1528,7 @@ describe('AccessibleSendEvent', function () {
done(); done();
}).catch((err) => { }).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_triggerAction_constructor_0180 has error: ${err}`); console.info(`AccessibleSendEvent: SendEvent_triggerAction_constructor_0180 has error: ${err}`);
expect(err).assertEqual(undefined); expect(true).assertTrue();
done(); done();
}); });
}) })
......
...@@ -61,7 +61,7 @@ struct Index { ...@@ -61,7 +61,7 @@ struct Index {
.margin(5) .margin(5)
.onClick((e) => { .onClick((e) => {
accessibility.getAbilityLists('all', 'enable', (err, data) => { accessibility.getAbilityLists('all', 'enable', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(LOG_PREFIX + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.error(LOG_PREFIX + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
......
...@@ -52,7 +52,7 @@ export default function abilityTest() { ...@@ -52,7 +52,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('spoken', 'install', (err, data) => { accessibility.getAbilityLists('spoken', 'install', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -98,7 +98,7 @@ export default function abilityTest() { ...@@ -98,7 +98,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('audible', 'install', (err, data) => { accessibility.getAbilityLists('audible', 'install', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -144,7 +144,7 @@ export default function abilityTest() { ...@@ -144,7 +144,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('visual', 'install', (err, data) => { accessibility.getAbilityLists('visual', 'install', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -190,7 +190,7 @@ export default function abilityTest() { ...@@ -190,7 +190,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('haptic', 'install', (err, data) => { accessibility.getAbilityLists('haptic', 'install', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -236,7 +236,7 @@ export default function abilityTest() { ...@@ -236,7 +236,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('generic', 'install', (err, data) => { accessibility.getAbilityLists('generic', 'install', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -282,7 +282,7 @@ export default function abilityTest() { ...@@ -282,7 +282,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('all', 'enable', (err, data) => { accessibility.getAbilityLists('all', 'enable', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -306,7 +306,7 @@ export default function abilityTest() { ...@@ -306,7 +306,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('all', 'enable', (err, data) => { accessibility.getAbilityLists('all', 'enable', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -333,7 +333,7 @@ export default function abilityTest() { ...@@ -333,7 +333,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('all', 'enable', (err, data) => { accessibility.getAbilityLists('all', 'enable', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -360,7 +360,7 @@ export default function abilityTest() { ...@@ -360,7 +360,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('all', 'enable', (err, data) => { accessibility.getAbilityLists('all', 'enable', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.error(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.error(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -514,7 +514,7 @@ export default function abilityTest() { ...@@ -514,7 +514,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('all', 'disable', (err, data) => { accessibility.getAbilityLists('all', 'disable', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
...@@ -560,7 +560,7 @@ export default function abilityTest() { ...@@ -560,7 +560,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME]) disableAbility(logTag, [AUDIBLE_BUNDLE_NAME])
setTimeout(() => { setTimeout(() => {
accessibility.getAbilityLists('all', 'disable', (err, data) => { accessibility.getAbilityLists('all', 'disable', (err, data) => {
if (err.code != 0) { if (err && err.code != 0) {
console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err)) console.info(logTag + 'failed to getAbilityLists because ' + JSON.stringify(err))
return return
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"description": "$string:entry_desc", "description": "$string:entry_desc",
"mainElement": "MainAbility", "mainElement": "MainAbility",
"deviceTypes": [ "deviceTypes": [
"default", "default",
"phone", "phone",
"tablet" "tablet"
], ],
...@@ -36,13 +36,17 @@ ...@@ -36,13 +36,17 @@
], ],
"requestPermissions": [ "requestPermissions": [
{ {
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW", "name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
}, },
{ {
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
} }
] ]
} }
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"description": "$string:entry_desc", "description": "$string:entry_desc",
"mainElement": "MainAbility", "mainElement": "MainAbility",
"deviceTypes": [ "deviceTypes": [
"default", "default",
"phone", "phone",
"tablet" "tablet"
], ],
...@@ -43,14 +43,10 @@ ...@@ -43,14 +43,10 @@
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
}, },
{
"name": "ohos.permission.READ_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.READ_ACCESSIBILITY_CONFIG"
},
{ {
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG", "name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG" "reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
} }
] ]
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册