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

!4638 添加对rect属性及onAccessibilityEvent中的timestamp的测试case

Merge pull request !4638 from Mupceet/release_0726_xts
......@@ -100,7 +100,7 @@ export class ElementTest {
result = await this.executeAttributeValuePromise(caseName, 'textLengthLimit', 'number');
break;
case 'AccessibilityElementTest_attributeValue_asyncPromise_1500':
result = await this.executeAttributeValuePromise(caseName, 'rect', 'object');
result = await this.executeAttributeValuePromiseRect(caseName, 'rect');
break;
case 'AccessibilityElementTest_attributeValue_asyncPromise_1600':
result = await this.executeAttributeValuePromise(caseName, 'checkable', 'boolean');
......@@ -184,7 +184,7 @@ export class ElementTest {
result = await this.executeAttributeValuePromise(caseName, 'isActive', 'boolean', true);
break;
case 'AccessibilityElementTest_attributeValue_asyncPromise_5300':
result = await this.executeAttributeValuePromise(caseName, 'screenRect', 'object', true);
result = await this.executeAttributeValuePromiseRect(caseName, 'screenRect', true);
break;
case 'AccessibilityElementTest_attributeValue_asyncPromise_5400':
result = await this.executeAttributeValuePromise(caseName, 'layer', 'number', true);
......@@ -334,7 +334,7 @@ export class ElementTest {
await this.executeAttributeValueCallback(caseName, 'textLengthLimit', 'number');
return;
case 'AccessibilityElementTest_attributeValue_asyncCallback_1500':
await this.executeAttributeValueCallback(caseName, 'rect', 'object');
await this.executeAttributeValueCallbackRect(caseName, 'rect');
return;
case 'AccessibilityElementTest_attributeValue_asyncCallback_1600':
await this.executeAttributeValueCallback(caseName, 'checkable', 'boolean');
......@@ -418,7 +418,7 @@ export class ElementTest {
await this.executeAttributeValueCallback(caseName, 'isActive', 'boolean', true);
return;
case 'AccessibilityElementTest_attributeValue_asyncCallback_5300':
await this.executeAttributeValueCallback(caseName, 'screenRect', 'object', true);
await this.executeAttributeValueCallbackRect(caseName, 'screenRect', true);
return;
case 'AccessibilityElementTest_attributeValue_asyncCallback_5400':
await this.executeAttributeValueCallback(caseName, 'layer', 'number', true);
......@@ -600,6 +600,33 @@ export class ElementTest {
return result;
}
private async executeAttributeValuePromiseRect(caseName: string, input: string, isWindow: boolean = false): Promise<boolean> {
let element = undefined;
if (isWindow) {
element = await this.getWindowElement();
} else {
element = await this.getBaseElement();
}
let result = false;
if (element) {
try {
console.info('ElementTest executeAttributeValuePromiseRect ' + caseName);
let value = await element.attributeValue(input);
console.info('ElementTest executeAttributeValuePromiseRect ' + caseName + ' value: ' + JSON.stringify(value));
if (typeof(value) == 'object' && typeof(value.left) == 'number' && typeof(value.top) == 'number'
&& typeof(value.width) == 'number' && typeof(value.height) == 'number') {
result = true;
} else {
console.warn('ElementTest executeAttributeValuePromiseRect ' + caseName + ' valueType: ' + typeof(value));
}
} catch (e) {
console.info('ElementTest executeAttributeValuePromiseRect ' + caseName + ' catch(e): ' + JSON.stringify(e));
}
}
return result;
}
private async executeAttributeValuePromiseTriggerAction(caseName: string) {
console.info('ElementTest executeAttributeValuePromiseTriggerAction ' + caseName + ' start');
let event = new accessibility.EventInfo({});
......@@ -846,6 +873,31 @@ export class ElementTest {
}
}
private async executeAttributeValueCallbackRect(caseName: string, input: string, isWindow: boolean = false) {
let element = undefined;
if (isWindow) {
element = await this.getWindowElement();
} else {
element = await this.getBaseElement();
}
let result = false;
if (element) {
console.info('ElementTest executeAttributeValueCallbackRect ' + caseName);
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'
&& typeof(value.top) == 'number' && typeof(value.width) == 'number' && typeof(value.height) == 'number') {
result = true;
} else {
console.warn('ElementTest executeAttributeValueCallbackRect ' + caseName + ' valueType: ' + typeof(value));
}
this.publishCaseResult(caseName, result);
});
}
}
private async executeAttributeValueCallbackTriggerAction(caseName: string) {
console.info('ElementTest executeAttributeValueCallbackTriggerAction ' + caseName + ' start');
let event = new accessibility.EventInfo({});
......
......@@ -50,7 +50,9 @@ class AccessibilityExtAbility extends AccessibilityExtensionAbility {
let commonEventPublishData = {
data: 'accessibilityEvent',
parameters: {
eventType: accessibilityEvent.eventType
eventType: accessibilityEvent.eventType,
haveTarget: (typeof(accessibilityEvent.target) == 'object'),
timeStamp: accessibilityEvent.timeStamp
}
}
commonEvent.publish('accessibilityEvent', commonEventPublishData, publishCallback);
......
......@@ -20,7 +20,7 @@ export default function abilityTest(abilityContext) {
let targetBundleName = 'com.example.myapplication';
let subScriber = undefined;
let isConnected: boolean = false;
let eventTypes: Array<string> = [];
let events: Array<any> = [];
describe('AccessibilityEventTest', function () {
beforeAll(async function (done) {
......@@ -33,7 +33,7 @@ export default function abilityTest(abilityContext) {
} else if (data.data == 'disconnect') {
isConnected = false;
} else if (data.data == 'accessibilityEvent') {
eventTypes.push(data.parameters.eventType);
events.push(data.parameters);
}
});
......@@ -58,7 +58,7 @@ export default function abilityTest(abilityContext) {
beforeEach(async function (done) {
console.info(`AccessibilityEventTest: beforeEach`);
eventTypes.length = 0;
events.length = 0;
setTimeout(done, 2000);
})
......@@ -86,10 +86,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -117,10 +116,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -148,10 +146,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -179,10 +176,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -210,10 +206,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -241,10 +236,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -272,10 +266,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -303,10 +296,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -365,10 +357,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -396,10 +387,9 @@ export default function abilityTest(abilityContext) {
await accessibility.sendEvent(event);
setTimeout(() => {
let types = eventTypes;
let findResult = false;
for (let type of types) {
if (type == eventType) {
for (let item of events) {
if (item.eventType == eventType) {
findResult = true;
}
}
......@@ -408,5 +398,67 @@ export default function abilityTest(abilityContext) {
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_1200
* @tc.name AccessibilityEventTest_1200
* @tc.desc The parameter input is 'scroll', test the Ability event function,
* and return void, verify existence of 'target'.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_1200', 0, async function (done) {
console.info(`AccessibilityEventTest_1200`);
let eventType = 'scroll';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'scrollForward';
await accessibility.sendEvent(event);
setTimeout(() => {
let findResult = false;
for (let item of events) {
console.info(`AccessibilityEventTest_1200 haveTarget: ${item.haveTarget}`);
if (item.eventType == eventType && item.haveTarget) {
findResult = true;
}
}
console.info('AccessibilityEventTest_1200 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
/*
* @tc.number AccessibilityEventTest_1300
* @tc.name AccessibilityEventTest_1300
* @tc.desc The parameter input is 'scroll', test the Ability event function,
* and return void, verify existence of 'timeStamp'.
* @tc.size SmallTest
* @tc.type User
*/
it('AccessibilityEventTest_1300', 0, async function (done) {
console.info(`AccessibilityEventTest_1300`);
let eventType = 'scroll';
let event = new accessibility.EventInfo({});
event.type = eventType;
event.bundleName = targetBundleName;
event.triggerAction = 'scrollForward';
await accessibility.sendEvent(event);
setTimeout(() => {
let findResult = false;
for (let item of events) {
console.info(`AccessibilityEventTest_1300 timeStamp: ${item.timeStamp}`);
if (item.eventType == eventType && typeof(item.timeStamp) == 'number') {
findResult = true;
}
}
console.info('AccessibilityEventTest_1300 case: ' + findResult);
expect(findResult).assertTrue();
done();
}, 3000);
})
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册