diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-18 17:59:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-25 11:58:23 +0100 |
commit | 9a5ab30d52257f88931d6d09a376b4d75da69c5a (patch) | |
tree | 3e6e0e8948ec921faa61ca138a7088a2a7d7def7 /tests/auto/other | |
parent | 48c73540ad2a507963db0fba57484faf66462ad7 (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>
Diffstat (limited to 'tests/auto/other')
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
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() |