Improve QAccessibleApplication
Add more testing. This uncovers that currently the QDesktopScreenWidget shows up as child of the app. Fixed by not creating QAccessibleInterfaces for QDesktopScreenWidget. Also don't crash in indexOfChild when called with 0. Change-Id: I9fb1e47e8f1f33189e6125f56f274a7b94ecd0dd Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
parent
48c73540ad
commit
9a5ab30d52
@ -193,6 +193,8 @@ int QAccessibleApplication::childCount() const
|
||||
/*! \reimp */
|
||||
int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) const
|
||||
{
|
||||
if (!child)
|
||||
return -1;
|
||||
const QObjectList tlw(topLevelObjects());
|
||||
return tlw.indexOf(child->object());
|
||||
}
|
||||
|
@ -251,6 +251,9 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec
|
||||
} else if (classname == QLatin1String("QDockWidget")) {
|
||||
iface = new QAccessibleDockWidget(widget);
|
||||
#endif
|
||||
|
||||
} else if (classname == QLatin1String("QDesktopScreenWidget")) {
|
||||
iface = 0;
|
||||
} else {
|
||||
iface = new QAccessibleWidget(widget);
|
||||
}
|
||||
|
@ -47,5 +47,7 @@
|
||||
"QScrollArea",
|
||||
"QCalendarWidget",
|
||||
"QDockWidget",
|
||||
"QAccessibleWidget" ]
|
||||
"QAccessibleWidget",
|
||||
"QDesktopScreenWidget"
|
||||
]
|
||||
}
|
||||
|
@ -383,6 +383,8 @@ int QAccessibleWidget::childCount() const
|
||||
/*! \reimp */
|
||||
int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const
|
||||
{
|
||||
if (!child)
|
||||
return -1;
|
||||
QWidgetList cl = childWidgets(widget());
|
||||
return cl.indexOf(qobject_cast<QWidget *>(child->object()));
|
||||
}
|
||||
|
@ -768,12 +768,40 @@ void tst_QAccessibility::actionTest()
|
||||
|
||||
void tst_QAccessibility::applicationTest()
|
||||
{
|
||||
{
|
||||
QLatin1String name = QLatin1String("My Name");
|
||||
qApp->setApplicationName(name);
|
||||
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(qApp);
|
||||
QAIPtr interface(QAccessible::queryAccessibleInterface(qApp));
|
||||
QCOMPARE(interface->text(QAccessible::Name), name);
|
||||
QCOMPARE(interface->text(QAccessible::Description), qApp->applicationFilePath());
|
||||
QCOMPARE(interface->text(QAccessible::Value), QString());
|
||||
QCOMPARE(interface->role(), QAccessible::Application);
|
||||
delete interface;
|
||||
QCOMPARE(interface->window(), static_cast<QWindow*>(0));
|
||||
QCOMPARE(interface->parent(), static_cast<QAccessibleInterface*>(0));
|
||||
QCOMPARE(interface->focusChild(), static_cast<QAccessibleInterface*>(0));
|
||||
QCOMPARE(interface->indexOfChild(0), -1);
|
||||
QCOMPARE(interface->child(0), static_cast<QAccessibleInterface*>(0));
|
||||
QCOMPARE(interface->child(-1), static_cast<QAccessibleInterface*>(0));
|
||||
QCOMPARE(interface->child(1), static_cast<QAccessibleInterface*>(0));
|
||||
QCOMPARE(interface->childCount(), 0);
|
||||
|
||||
QWidget widget;
|
||||
widget.show();
|
||||
qApp->setActiveWindow(&widget);
|
||||
QVERIFY(QTest::qWaitForWindowActive(&widget));
|
||||
|
||||
QAIPtr widgetIface(QAccessible::queryAccessibleInterface(&widget));
|
||||
QCOMPARE(interface->childCount(), 1);
|
||||
QAIPtr focus(interface->focusChild());
|
||||
QCOMPARE(focus->object(), &widget);
|
||||
QCOMPARE(interface->indexOfChild(0), -1);
|
||||
QCOMPARE(interface->indexOfChild(widgetIface.data()), 0);
|
||||
QAIPtr child(interface->child(0));
|
||||
QCOMPARE(child->object(), &widget);
|
||||
QCOMPARE(interface->child(-1), static_cast<QAccessibleInterface*>(0));
|
||||
QCOMPARE(interface->child(1), static_cast<QAccessibleInterface*>(0));
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
}
|
||||
|
||||
void tst_QAccessibility::mainWindowTest()
|
||||
|
Loading…
Reference in New Issue
Block a user