summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-01-18 17:59:52 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-25 11:58:23 +0100
commit9a5ab30d52257f88931d6d09a376b4d75da69c5a (patch)
tree3e6e0e8948ec921faa61ca138a7088a2a7d7def7
parent48c73540ad2a507963db0fba57484faf66462ad7 (diff)
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>
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp2
-rw-r--r--src/plugins/accessible/widgets/main.cpp3
-rw-r--r--src/plugins/accessible/widgets/widgets.json4
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp32
5 files changed, 40 insertions, 3 deletions
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp
index bbdbb9ee68..c1ef71e1fa 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/gui/accessible/qaccessibleobject.cpp
@@ -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());
}
diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp
index 9a42474910..92cda9f3ca 100644
--- a/src/plugins/accessible/widgets/main.cpp
+++ b/src/plugins/accessible/widgets/main.cpp
@@ -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);
}
diff --git a/src/plugins/accessible/widgets/widgets.json b/src/plugins/accessible/widgets/widgets.json
index 69584b9bc8..094987daf5 100644
--- a/src/plugins/accessible/widgets/widgets.json
+++ b/src/plugins/accessible/widgets/widgets.json
@@ -47,5 +47,7 @@
"QScrollArea",
"QCalendarWidget",
"QDockWidget",
- "QAccessibleWidget" ]
+ "QAccessibleWidget",
+ "QDesktopScreenWidget"
+ ]
}
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
index bed0480059..254ecc92dd 100644
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -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()));
}
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 1b718d6487..2276260016 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -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()