summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-22 23:34:30 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-23 19:42:16 +0200
commit9526e8dc332a0306fd61f78a0af53d413bb70082 (patch)
tree0021b57f408f02590598f9de9364a252a36b0961 /tests/auto/other
parentc3d3e7312499189dde2ff9c0cb14bd608d6fd1cd (diff)
macOS: Extend accessibility testing of treeview
Check that we can navigate to rows and columns, and that we get the right text back for cells. We see API failures in CI on some macOS nodes, accompanies by the debug message: AXUIElementCopyAttributeValue( "AXTitle" ) returned error = AXError(value=-25201, name=kAXErrorIllegalArgument, description="An illegal argument was passed to the function.") On hosts where the test fails, we always see this warning, so extend the test helper with an errorOccurred boolean that we can test and if set skip the test. Pick-to: 6.5 Change-Id: Iacad4c41f8597243abeff36ca91cf290446c13a1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm38
1 files changed, 30 insertions, 8 deletions
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm
index 730e8f7e96..41ebc1eaf1 100644
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm
+++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm
@@ -62,6 +62,7 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
@interface TestAXObject : NSObject
{
AXUIElementRef reference;
+ bool axError;
}
@property (readonly) NSString *role;
@property (readonly) NSString *title;
@@ -77,11 +78,13 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
if ((self = [super init])) {
reference = ref;
+ axError = false;
}
return self;
}
- (AXUIElementRef) ref { return reference; }
+- (bool)errorOccurred { return axError; }
- (void) print {
NSLog(@"Accessible Object role: '%@', title: '%@', description: '%@', value: '%@', rect: '%@'", self.role, self.title, self.description, self.value, NSStringFromRect(NSRectFromCGRect(self.rect)));
NSLog(@" Children: %ld", [[self childList] count]);
@@ -225,8 +228,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
CFTypeRef value = NULL;
AXError err;
- if (kAXErrorSuccess != (err = AXUIElementCopyAttributeValue(reference, attribute, &value)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementCopyAttributeValue(reference, attribute, &value))) {
+ axError = true;
qDebug() << "AXUIElementCopyAttributeValue(" << QString::fromCFString(attribute) << ") returned error = " << AXErrorTag(err);
}
return value;
@@ -272,8 +275,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
CFTypeRef value = NULL;
AXError err;
- if (kAXErrorSuccess != (err = AXUIElementCopyParameterizedAttributeValue(reference, attribute, parameter, &value)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementCopyParameterizedAttributeValue(reference, attribute, parameter, &value))) {
+ axError = true;
CFStringRef description = CFCopyDescription(parameter);
qDebug() << "AXUIElementCopyParameterizedAttributeValue(" << QString::fromCFString(attribute) << ", parameter=" << QString::fromCFString(description) << ") returned error = " << AXErrorTag(err);
CFRelease(description);
@@ -311,8 +314,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
AXError err;
CFArrayRef actions;
- if (kAXErrorSuccess != (err = AXUIElementCopyActionNames(reference, &actions)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementCopyActionNames(reference, &actions))) {
+ axError = true;
qDebug() << "AXUIElementCopyActionNames(...) returned error = " << AXErrorTag(err);
}
@@ -323,8 +326,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
{
AXError err;
- if (kAXErrorSuccess != (err = AXUIElementPerformAction(reference, action)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementPerformAction(reference, action))) {
+ axError = true;
qDebug() << "AXUIElementPerformAction(" << QString::fromCFString(action) << ") returned error = " << AXErrorTag(err);
}
}
@@ -780,6 +783,25 @@ void tst_QAccessibilityMac::treeViewTest()
// this should not trigger any assert
tw->setCurrentItem(lastChild);
+
+ bool errorOccurred = false;
+
+ const auto cellText = [rowArray, &errorOccurred](int rowIndex, int columnIndex) -> QString {
+ TestAXObject *row = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)rowArray[rowIndex]];
+ Q_ASSERT(row);
+ TestAXObject *cell = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)[row childList][columnIndex]];
+ Q_ASSERT(cell);
+ const QString result = QString::fromNSString(cell.title);
+ errorOccurred = cell.errorOccurred;
+ return result;
+ };
+
+ QString text = cellText(0, 0);
+ if (errorOccurred)
+ QSKIP("Cocoa Accessibility API error, aborting");
+ QCOMPARE(text, root->text(0));
+ QCOMPARE(cellText(1, 0), users->text(0));
+ QCOMPARE(cellText(1, 1), users->text(1));
}
QTEST_MAIN(tst_QAccessibilityMac)