+ const QAccessibleInterface *accessibleIntefaceOfCurrentlyFocusedObject = QAccessible::queryAccessibleInterface(currentlyFocusedObject);
+ QVERIFY(accessibleIntefaceOfCurrentlyFocusedObject);
+
+ /// Test that each object reachable by Tab or Shift+Tab has at least some accessible information. Objects without any accessible information
+ /// are even less useful to accessibility software users than unlabeled buttons are e.g. to sighted users, because unlabeled buttons at least
+ /// convey some information through their placement and icon.
+ if (currentlyFocusedObject != m_mainWindow->m_activeViewContainer->view()->m_container) { // Skip the custom container widget which has no
+ // accessible name on purpose.
+ /**
+ * The first ancestor with an accessible name is interesting because it is sometimes used to identify an object if the object itself has no
+ * name. We keep it in mind to check if two subsequent objects without a name can at least be told apart by their first named ancestor.
+ */
+ QAccessibleInterface *firstNamedAncestor = accessibleIntefaceOfCurrentlyFocusedObject->parent();
+ while (firstNamedAncestor) {
+ if (!firstNamedAncestor->text(QAccessible::Name).isEmpty()) {
+ break;
+ }
+ firstNamedAncestor = firstNamedAncestor->parent();
+ }
+ QTRY_VERIFY2(!accessibleIntefaceOfCurrentlyFocusedObject->text(QAccessible::Name).isEmpty()
+ || (firstNamedAncestor && firstNamedAncestor != firstNamedAncestorOfPreviousIteration),
+ qPrintable(QStringLiteral("%1's accessibleInterface does not have an accessible name and can not be distinguished from the object"
+ " that had focus previously. Please fix this. You can find this %1 within its parent %2.")
+ .arg(currentlyFocusedObject->metaObject()->className())
+ .arg(currentlyFocusedObject->parent()->metaObject()->className())));
+ firstNamedAncestorOfPreviousIteration = firstNamedAncestor;
+ }