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

!5923 无障碍 ErrCode测试

Merge pull request !5923 from Mupceet/release_1015_xts
......@@ -19,12 +19,13 @@ group("barrierfree") {
deps = [
"accessibilityconfig:ActsAccessibilityConfigTest",
"accessibilityconfigreqreadpermission:ActsAccessibilityConfigReqReadPermissionTest",
"accessibilityconfigreqwritepermission:ActsAccessibilityConfigReqWritePermissionTest",
"accessibilityelement:ActsAccessibilityElementTest",
"accessibilityerrcode:ActsAccessibilityErrCodeTest",
"accessibilityevent:ActsAccessibilityEventTest",
"accessibilityextension:ActsAccessibilityExtensionTest",
"accessibilityextensioncontext:ActsAccessibilityExtensionContextTest",
"accessibilitygestureevent:ActsAccessibilityGestureEventTest",
"accessibilitysendaccessibilityevent:ActsAccessibilitySendAccessibilityEventTest",
"accessibleabilitylist:ActsAccessibleAbilityListTest",
"accessiblecaptionconfiguration:ActsAccessibleCaptionConfigurationTest",
"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 @@
* 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 MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
......@@ -28,7 +37,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
// 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.abilityStorage = this.storage
globalThis.abilityContext = this.context
......
......@@ -13,19 +13,10 @@
* 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() {
......@@ -34,7 +25,13 @@ export default class TestAbility extends Ability {
onWindowStageCreate(windowStage) {
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;
}
......
......@@ -21,7 +21,8 @@ var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
......@@ -52,14 +53,19 @@ export default class OpenHarmonyTestRunner implements TestRunner {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
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)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
......
......@@ -14,8 +14,8 @@
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ts",
"name": "com.example.accessibilityxts.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
......@@ -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": [{
"name": "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": [
"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 @@
* 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 MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
......
......@@ -13,19 +13,10 @@
* 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() {
......@@ -34,7 +25,13 @@ export default class TestAbility extends Ability {
onWindowStageCreate(windowStage) {
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;
}
......
......@@ -21,7 +21,8 @@ var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
......@@ -52,14 +53,19 @@ export default class OpenHarmonyTestRunner implements TestRunner {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
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)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
......
......@@ -38,8 +38,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100');
config.highContrastText.set(true, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0100 has no write permission`);
expect(null).assertFail();
......@@ -62,6 +63,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_0200 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -76,8 +79,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700');
config.invertColor.set(true, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_0700 has no write permission`);
expect(null).assertFail();
......@@ -100,6 +104,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_0800 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -114,8 +120,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300');
config.contentTimeout.set(0, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1300 has no write permission`);
expect(null).assertFail();
......@@ -138,6 +145,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_1400 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -152,8 +161,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900');
config.animationOff.set(true, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_1900 has no write permission`);
expect(null).assertFail();
......@@ -176,6 +186,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_2000 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -190,8 +202,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500');
config.brightnessDiscount.set(0.1, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_2500 has no write permission`);
expect(null).assertFail();
......@@ -214,6 +227,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_2600 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -228,8 +243,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900');
config.mouseKey.set(true, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_4900 has no write permission`);
expect(null).assertFail();
......@@ -252,6 +268,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_5000 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -265,9 +283,10 @@ export default function abilityTest() {
*/
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500');
config.mouseAutoClick.set(-1, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
config.mouseAutoClick.set(1, (err, result) => {
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_5500 has no write permission`);
expect(null).assertFail();
......@@ -290,6 +309,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_5600 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -304,8 +325,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100');
config.shortkey.set(true, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6100 has no write permission`);
expect(null).assertFail();
......@@ -328,6 +350,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_6200 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -343,8 +367,9 @@ export default function abilityTest() {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700');
let value = 'teststr'
config.shortkeyTarget.set(value, (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_6700 has no write permission`);
expect(null).assertFail();
......@@ -368,6 +393,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_6800 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -382,8 +409,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900');
config.daltonizationColorFilter.set('Normal', (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_7900 has no write permission`);
expect(null).assertFail();
......@@ -402,8 +430,9 @@ export default function abilityTest() {
it('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000', 0, async function(done) {
console.info('AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000');
config.daltonizationColorFilter.set('Deuteranomaly', (err, result) => {
if (err.code != 0) {
expect(true).assertTrue();
if (err && err.code != 0) {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000 has error: ${err.code}`);
expect(201).assertEqual(err.code);
} else {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncCallback_8000 has no write permission`);
expect(null).assertFail();
......@@ -426,6 +455,8 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).catch((err) => {
console.error(`AccessibilityConfigReqReadPermissionTest_set_asyncPromise_8100 has error: ${err.code}`);
expect(201).assertEqual(err.code);
done();
});
})
......@@ -444,6 +475,50 @@ export default function abilityTest() {
expect(null).assertFail();
done();
}).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();
});
})
......
......@@ -13,8 +13,8 @@
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ts",
"name": "com.example.accessibilityxts.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
......@@ -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": [{
"name": "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": [
"TestAbility/pages/index"
"MainAbility/pages/index/index"
]
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import commonEvent from '@ohos.commonEvent';
import accessibility from '@ohos.accessibility';
const invalidString = 'xxx';
const invalidValue = 1;
export class ElementTest {
private context = undefined;
......@@ -604,7 +605,7 @@ export class ElementTest {
}
} catch (e) {
console.info('ElementTest executeAttributeValuePromise ' + caseName + ' catch(e): ' + JSON.stringify(e));
if (input == invalidString) {
if (input == invalidString && e && e.code != 0) {
result = true;
}
}
......@@ -737,12 +738,15 @@ export class ElementTest {
console.info('ElementTest executePerformActionPromise ' + caseName + ' action: ' + action + ', args: ' + JSON.stringify(args));
let ret = await element.performAction(action, args);
console.info('ElementTest executePerformActionPromise ' + caseName + ' ret: ' + JSON.stringify(ret));
if (typeof(ret) == 'boolean') {
if (typeof(ret) == 'undefined') {
result = true;
}
} catch (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;
}
}
......@@ -795,7 +799,7 @@ export class ElementTest {
}
} catch (e) {
console.info('ElementTest executeFindElementPromiseByFocusType ' + caseName + ' catch(e): ' + JSON.stringify(e));
if (condition == invalidString) {
if (condition == invalidString && e && e.code != 0) {
result = true;
}
}
......@@ -850,7 +854,9 @@ export class ElementTest {
element.attributeNames((err, names) => {
console.info('ElementTest executeAttributeNamesCallback ' + caseName + ' err: ' + JSON.stringify(err));
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;
}
this.publishCaseResult(caseName, result);
......@@ -873,9 +879,9 @@ export class ElementTest {
element.attributeValue(input, (err, value) => {
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' value: ' + JSON.stringify(value));
if (input == invalidString && err.code != 0) {
if (err && err.code != 0) {
result = true;
} else if (err.code == 0 && typeof(value) == outputType) {
} else if (typeof(value) == outputType) {
result = true;
} else {
console.warn('ElementTest executeAttributeValueCallback ' + caseName + ' valueType: ' + typeof(value));
......@@ -899,10 +905,10 @@ export class ElementTest {
element.attributeValue(input, (err, value) => {
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err));
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') {
result = true;
} else {
} else if (err) {
console.warn('ElementTest executeAttributeValueCallbackRect ' + caseName + ' valueType: ' + typeof(value));
}
this.publishCaseResult(caseName, result);
......@@ -928,7 +934,9 @@ export class ElementTest {
target.attributeValue('triggerAction', (err, value) => {
console.info('ElementTest executeAttributeValueCallbackTriggerAction ' + caseName + ' err: ' + JSON.stringify(err));
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);
}
});
......@@ -960,7 +968,9 @@ export class ElementTest {
element.attributeValue('rootElement', (err, value) => {
console.info('ElementTest executeAttributeValueCallback ' + caseName + ' err: ' + JSON.stringify(err));
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;
} else {
console.warn('ElementTest executeAttributeValueCallback ' + caseName + ' valueType: ' + typeof(value));
......@@ -978,7 +988,9 @@ export class ElementTest {
element.attributeValue(input, (err, value) => {
console.info('ElementTest executeAttributeValueCallbackArray ' + caseName + ' err: ' + JSON.stringify(err));
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)||
(value.length > 0 && typeof(value[0]) == outputType)) {
result = true;
......@@ -996,7 +1008,7 @@ export class ElementTest {
element.actionNames((err, actions) => {
console.info('ElementTest executeActionNamesCallback ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeActionNamesCallback ' + caseName + ' actions: ' + JSON.stringify(actions));
if (err.code == 0 && Array.isArray(actions)) {
if (Array.isArray(actions)) {
if ((actions.length == 0) ||
(actions.length > 0 && typeof(actions[0]) == 'string')) {
result = true;
......@@ -1016,9 +1028,12 @@ export class ElementTest {
element.performAction(action, args, (err, ret) => {
console.info('ElementTest executePerformActionCallback ' + caseName + ' err: ' + JSON.stringify(err));
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;
} else if (err.code == 0 && typeof(ret) == 'boolean') {
} else if (typeof(ret) == 'undefined') {
result = true;
}
this.publishCaseResult(caseName, result);
......@@ -1034,9 +1049,9 @@ export class ElementTest {
element.findElement('content', condition, (err, found) => {
console.info('ElementTest executeFindElementCallbackByContent ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeFindElementCallbackByContent ' + caseName + ' element: ' + JSON.stringify(found));
if (condition == invalidString && err.code != 0) {
if (condition == invalidString && err && err.code != 0) {
result = true;
} else if (err.code == 0 && Array.isArray(found)) {
} else if (Array.isArray(found)) {
if (found.length == 0 || typeof(found[0]) == 'object') {
result = true;
}
......@@ -1058,9 +1073,9 @@ export class ElementTest {
element.findElement('focusType', condition, (err, found) => {
console.info('ElementTest executeFindElementCallbackByFocusType ' + caseName + ' err: ' + JSON.stringify(err));
console.info('ElementTest executeFindElementCallbackByFocusType ' + caseName + ' element: ' + JSON.stringify(found));
if (condition == invalidString && err.code != 0) {
if (condition == invalidString && err && err.code != 0) {
result = true;
} else if (err.code == 0 && typeof(found) == 'object') {
} else if (typeof(found) == 'object') {
result = true;
}
this.publishCaseResult(caseName, result);
......@@ -1085,7 +1100,7 @@ export class ElementTest {
console.info('ElementTest executeFindElementCallbackByFocusDirection ' + caseName + ' element: ' + JSON.stringify(found));
if (condition == invalidString && err.code != 0) {
result = true;
} else if (err.code == 0 && typeof(found) == 'object') {
} else if (typeof(found) == 'object') {
result = true;
}
this.publishCaseResult(caseName, result);
......@@ -1106,7 +1121,9 @@ export class ElementTest {
element.findElement('focusDirection', 'down', (err, found) => {
console.info('ElementTest executeFindElementCallback5900 ' + caseName + ' err: ' + JSON.stringify(err));
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;
}
this.publishCaseResult(caseName, result);
......
......@@ -52,6 +52,10 @@
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
......
{
"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 @@
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
......
......@@ -52,6 +52,10 @@
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
......
......@@ -60,7 +60,7 @@ export class ExtensionContextTest {
switch (caseName) {
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1500':
bundleName = ['com.example.accessibleformextension'];
bundleName = ['com.example.accessibilityxts'];
this.setTargetBundleNameCallback(caseName, bundleName);
break;
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncCallback_1600':
......@@ -71,7 +71,7 @@ export class ExtensionContextTest {
this.setTargetBundleNameCallback(caseName, bundleName);
break;
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1800':
bundleName = ['com.example.accessibleformextension'];
bundleName = ['com.example.accessibilityxts'];
this.setTargetBundleNamePromise(caseName, bundleName);
break;
case 'AccessibilityExtensionContextTest_setTargetBundleName_asyncPromise_1900':
......@@ -240,7 +240,7 @@ export class ExtensionContextTest {
private async getDisPlayId() {
let displayId = -1;
display.getDefaultDisplay((err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error("getDisPlayId getDefaultDisplay error");
} else {
console.info("getDisPlayId getDefaultDisplay data.id: " + JSON.stringify(data.id));
......@@ -268,8 +268,7 @@ export class ExtensionContextTest {
let tartgetNode = await rootNode.findElement('content', 'button1');
console.info("setAccessibilityFocus tartgetNode: " + JSON.stringify(tartgetNode));
if (tartgetNode) {
isFocus = await tartgetNode[0].performAction("accessibilityFocus");
console.info("setAccessibilityFocus isFocus: " + JSON.stringify(isFocus));
await tartgetNode[0].performAction("accessibilityFocus");
}
}
}
......@@ -284,8 +283,7 @@ export class ExtensionContextTest {
let tartgetNode = await rootNode.findElement('content', 'button1');
console.info("setAccessibilityFocus tartgetNode: " + JSON.stringify(tartgetNode));
if (tartgetNode) {
isFocus = await tartgetNode[0].performAction("clearAccessibilityFocus");
console.info("setAccessibilityFocus isFocus: " + JSON.stringify(isFocus));
await tartgetNode[0].performAction("clearAccessibilityFocus");
}
}
}
......@@ -295,9 +293,13 @@ export class ExtensionContextTest {
let result = true;
this.context.setTargetBundleName(bundleName, (err, 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));
result = false;
if ((bundleName.length == 0 || bundleName[0] == 'aaa') && err && err.code != 0) {
result = true;
} else {
result = false;
}
}
this.publishCaseResult(caseName, result);
});
......@@ -310,7 +312,11 @@ export class ExtensionContextTest {
this.publishCaseResult(caseName, result);
}).catch((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);
});
}
......@@ -319,7 +325,7 @@ export class ExtensionContextTest {
let result = false;
this.context.getWindowRootElement(async (err, 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));
}
if (res == undefined) {
......@@ -339,21 +345,16 @@ export class ExtensionContextTest {
let result = false;
if ((windowId == -1) || (windowId == 1000)){
this.context.getWindowRootElement(-1, async (err, 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));
result = true
}
if (res == undefined) {
console.error(caseName + " res is undefined");
result = true
result = true;
}
this.publishCaseResult(caseName, result);
});
} else {
this.context.getWindowRootElement(windowId, async (err, 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));
}
if (res == undefined) {
......@@ -374,12 +375,6 @@ export class ExtensionContextTest {
let result = false;
if ((windowId == -1) || (windowId == 1000)){
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);
}).catch((error) => {
console.error(caseName + " error: " + JSON.stringify(error));
......@@ -411,7 +406,7 @@ export class ExtensionContextTest {
let result = false;
this.context.getWindows((err, 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));
}
if (res == undefined) {
......@@ -429,11 +424,11 @@ export class ExtensionContextTest {
private async getWindowsByIdCallback(caseName: string, displayId: number) {
let result = false;
console.info(caseName + " displayId: " + JSON.stringify(displayId));
if (displayId == -1) {
this.context.getWindows(displayId, (err, res) => {
if (displayId == -1 || displayId == 100) {
this.context.getWindows(-1, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code));
console.error(caseName + " err: " + JSON.stringify(err.code));
result = true;
}
this.publishCaseResult(caseName, result);
......@@ -441,7 +436,7 @@ export class ExtensionContextTest {
} else {
this.context.getWindows(displayId, (err, 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));
}
if (res) {
......@@ -458,18 +453,21 @@ export class ExtensionContextTest {
let result = false;
console.info(caseName + " displayId: " + JSON.stringify(displayId));
if (displayId == -1) {
this.context.getWindows(-1, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res));
if (err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code));
this.context.getWindows(displayId).then(async (res) => {
result = false;
this.publishCaseResult(caseName, result);
}).catch((err) => {
console.error(caseName + 'err:' + JSON.stringify(err));
if (err && err.code != 0) {
result = true;
}
this.publishCaseResult(caseName, result);
});
} else {
this.context.getWindows(displayId, (err, 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));
}
if (res) {
......@@ -486,7 +484,7 @@ export class ExtensionContextTest {
let result = false;
this.context.getFocusElement((err, 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));
result = true;
}
......@@ -510,7 +508,7 @@ export class ExtensionContextTest {
}
this.publishCaseResult(caseName, result);
} else {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(caseName + "err: " + JSON.stringify(err.code));
result = true;
}
......@@ -523,7 +521,7 @@ export class ExtensionContextTest {
} else {
this.context.getFocusElement(false, (err, 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));
result = true;
}
......@@ -579,21 +577,17 @@ export class ExtensionContextTest {
let result = false;
if (gesturePath == undefined) {
this.context.injectGesture(gesturePath, (err, 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));
result = true;
}
if (res == undefined) {
result = true;
}
this.publishCaseResult(caseName, result);
});
} else {
this.context.injectGesture(gesturePath, (err, res) => {
console.info(caseName + " res: " + JSON.stringify(res));
result = true;
if (err.code != 0) {
if (err && err.code != 0) {
console.error(caseName + " err: " + JSON.stringify(err.code));
result = false;
}
......@@ -607,14 +601,12 @@ export class ExtensionContextTest {
let result = false;
if (gesturePath == undefined) {
this.context.injectGesture(gesturePath).then((res) => {
console.info(caseName + " res: " + JSON.stringify(res));
if (res == undefined) {
result = true;
}
this.publishCaseResult(caseName, result);
}).catch ((err) => {
console.error(caseName + 'error:' + JSON.stringify(err));
result = true;
if (err && err.code != 0) {
console.error(caseName + 'error:' + JSON.stringify(err));
result = true;
}
this.publishCaseResult(caseName, result);
});
} else {
......@@ -623,8 +615,10 @@ export class ExtensionContextTest {
result = true;
this.publishCaseResult(caseName, result);
}).catch ((err) => {
console.error(caseName + 'error:' + JSON.stringify(err));
result = false;
if (err && err.code != 0) {
console.error(caseName + 'error:' + JSON.stringify(err));
result = true;
}
this.publishCaseResult(caseName, result);
});
}
......
......@@ -86,7 +86,7 @@ export default function abilityTest() {
/*
* @tc.number 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,
* The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest
......@@ -120,7 +120,7 @@ export default function abilityTest() {
/*
* @tc.number 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,
* The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest
......@@ -154,7 +154,7 @@ export default function abilityTest() {
/*
* @tc.number 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,
* The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest
......@@ -188,7 +188,7 @@ export default function abilityTest() {
/*
* @tc.number 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,
* The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest
......@@ -222,7 +222,7 @@ export default function abilityTest() {
/*
* @tc.number 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,
* The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest
......@@ -256,7 +256,7 @@ export default function abilityTest() {
/*
* @tc.number 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,
* The result of setTargetBundleName() should be boolean type.
* @tc.size SmallTest
......
......@@ -52,6 +52,10 @@
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
......
......@@ -52,6 +52,10 @@
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
"reason": "need use ohos.permission.WRITE_ACCESSIBILITY_CONFIG"
}
]
}
......
{
"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 () {
console.info('AbilityList_0210');
let abilityType = 'audible';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0210 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -74,7 +74,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0220');
let abilityType = 'generic';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0220 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -97,7 +97,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0230');
let abilityType = 'haptic';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0230 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -120,7 +120,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0240');
let abilityType = 'spoken';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0240 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -143,7 +143,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0250');
let abilityType = 'visual';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0250 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -166,7 +166,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0260');
let abilityType = 'all';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0260 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -189,7 +189,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0270');
let abilityType = '';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0270 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true);
done();
......@@ -212,7 +212,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0280');
let abilityType = null;
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0280 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true);
done();
......@@ -235,7 +235,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0290');
let abilityState = 'enable';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0290 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -258,7 +258,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0300');
let abilityState = 'disable';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0300 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -281,7 +281,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0310');
let abilityState = 'install';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0310 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -304,7 +304,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0320');
let abilityState = '';
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0320 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true);
done();
......@@ -327,7 +327,7 @@ describe('AccessibleAbilityList', function () {
console.info('AbilityList_0330');
let abilityState = null;
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibleAbilityList: AbilityList_0330 has error: ${err.code}`);
expect(Array.isArray(data)).assertEqual(true);
done();
......@@ -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
......@@ -579,49 +536,5 @@ describe('AccessibleAbilityList', function () {
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 () {
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.name CaptionConfiguration_0050
......@@ -130,39 +96,5 @@ describe('AccessibleCaptionConfiguration', function () {
expect(ret).assertEqual(undefined);
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 () {
it('CheckAbilityIsOpen_0170', 0, async function (done) {
console.info('CheckAbilityIsOpen_0170');
accessibility.isOpenAccessibility((err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibilityApi: CheckAbilityIsOpen_0170 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -92,7 +92,7 @@ describe('AccessibleCheckAbility', function () {
it('CheckAbilityIsOpen_0190', 0, async function (done) {
console.info('CheckAbilityIsOpen_0190');
accessibility.isOpenTouchGuide((err, data) => {
if (err.code != 0) {
if (err && err.code != 0) {
console.error(`AccessibilityApi: CheckAbilityIsOpen_0190 has error: ${err.code}`);
expect(null).assertFail();
done();
......@@ -117,9 +117,11 @@ describe('AccessibleCheckAbility', function () {
expect(typeof (result)).assertEqual('boolean');
done();
}).catch((err) => {
console.error(`AccessibilityApi: CheckAbilityIsOpen_0200 has error: ${err.code}`);
expect(null).assertFail();
done();
if (err && err.code != 0){
console.error(`AccessibilityApi: CheckAbilityIsOpen_0200 has error: ${err.code}`);
expect(null).assertFail();
done();
}
});
})
})
......
......@@ -37,27 +37,6 @@ describe('AccessibleSendEvent', function () {
/* 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.name SendEvent_null_0020
......@@ -76,40 +55,11 @@ describe('AccessibleSendEvent', function () {
done();
}).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_null_0020 has error: ${err}`);
expect(err).assertEqual(undefined);
expect(true).assertTrue();
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
/* are for interface accessibility.EventInfo API test */
......@@ -474,7 +424,7 @@ describe('AccessibleSendEvent', function () {
done();
}).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_type_constructor_0120 has error: ${err}`);
expect(err).assertEqual(undefined);
expect(true).assertTrue();
done();
});
})
......@@ -508,7 +458,7 @@ describe('AccessibleSendEvent', function () {
done();
}).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_type_constructor_0130 has error: ${err}`);
expect(err).assertEqual(undefined);
expect(true).assertTrue();
done();
});
})
......@@ -672,7 +622,7 @@ describe('AccessibleSendEvent', function () {
done();
}).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_bundleName_constructor_0020 has error: ${err}`);
expect(err).assertEqual(undefined);
expect(true).assertTrue();
done();
});
})
......@@ -705,7 +655,7 @@ describe('AccessibleSendEvent', function () {
done();
}).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_bundleName_constructor_0030 has error: ${err}`);
expect(err).assertEqual(undefined);
expect(true).assertTrue();
done();
});
})
......@@ -1545,7 +1495,7 @@ describe('AccessibleSendEvent', function () {
done();
}).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_triggerAction_constructor_0170 has error: ${err}`);
expect(err).assertEqual(undefined);
expect(true).assertTrue();
done();
});
})
......@@ -1578,7 +1528,7 @@ describe('AccessibleSendEvent', function () {
done();
}).catch((err) => {
console.info(`AccessibleSendEvent: SendEvent_triggerAction_constructor_0180 has error: ${err}`);
expect(err).assertEqual(undefined);
expect(true).assertTrue();
done();
});
})
......
......@@ -61,7 +61,7 @@ struct Index {
.margin(5)
.onClick((e) => {
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))
return
}
......
......@@ -52,7 +52,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -98,7 +98,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -144,7 +144,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -190,7 +190,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -236,7 +236,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -282,7 +282,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -306,7 +306,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -333,7 +333,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -360,7 +360,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -514,7 +514,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME, GENERIC_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......@@ -560,7 +560,7 @@ export default function abilityTest() {
disableAbility(logTag, [AUDIBLE_BUNDLE_NAME])
setTimeout(() => {
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))
return
}
......
......@@ -6,7 +6,7 @@
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"default",
"phone",
"tablet"
],
......@@ -36,13 +36,17 @@
],
"requestPermissions": [
{
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
"name": "ohos.permission.CAPTURE_SCREEN",
"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 @@
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"default",
"phone",
"tablet"
],
......@@ -43,14 +43,10 @@
"name": "ohos.permission.CAPTURE_SCREEN",
"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",
"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.
先完成此消息的编辑!
想要评论请 注册