diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-06-19 18:49:59 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-30 20:52:41 +0200 |
commit | d71f9d8c05d70053f2ce46dbb2203309addc0f93 (patch) | |
tree | 6edffca89fc49f0cc0bcfac21998c450fc1f235c /tests/auto/other/qaccessibility/tst_qaccessibility.cpp | |
parent | d448725403fea283a586aae5a23860c866597752 (diff) |
Accessibility: Top level widgets should only be in the hierarchy once
On Linux for example Orca gets confused when showing a dialog that is a
child of another widget since it would show up twice in the hierarchy.
Task-number: QTBUG-39444
Change-Id: I84773ecc3d6774a652dbeb29ad201779f5b3191c
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'tests/auto/other/qaccessibility/tst_qaccessibility.cpp')
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 6068391ce1..c9df497b07 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -251,6 +251,7 @@ private slots: void applicationTest(); void mainWindowTest(); + void subWindowTest(); void buttonTest(); void scrollBarTest(); void tabTest(); @@ -1003,6 +1004,66 @@ void tst_QAccessibility::mainWindowTest() } } +// Dialogs and other sub-windows must appear in the +// accessibility hierarchy exactly once as top level objects +void tst_QAccessibility::subWindowTest() +{ + { + QWidget mainWidget; + mainWidget.setGeometry(100, 100, 100, 100); + mainWidget.show(); + QLabel label(QStringLiteral("Window Contents"), &mainWidget); + mainWidget.setLayout(new QHBoxLayout()); + mainWidget.layout()->addWidget(&label); + + QDialog d(&mainWidget); + d.show(); + + QAccessibleInterface *app = QAccessible::queryAccessibleInterface(qApp); + QVERIFY(app); + QCOMPARE(app->childCount(), 2); + + QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(&mainWidget); + QVERIFY(windowIface); + QCOMPARE(windowIface->childCount(), 1); + QCOMPARE(app->child(0), windowIface); + QCOMPARE(windowIface->parent(), app); + + QAccessibleInterface *dialogIface = QAccessible::queryAccessibleInterface(&d); + QVERIFY(dialogIface); + QCOMPARE(app->child(1), dialogIface); + QCOMPARE(dialogIface->parent(), app); + QCOMPARE(dialogIface->parent(), app); + } + + { + QMainWindow mainWindow; + mainWindow.setGeometry(100, 100, 100, 100); + mainWindow.show(); + QLabel label(QStringLiteral("Window Contents"), &mainWindow); + mainWindow.setCentralWidget(&label); + + QDialog d(&mainWindow); + d.show(); + + QAccessibleInterface *app = QAccessible::queryAccessibleInterface(qApp); + QVERIFY(app); + QCOMPARE(app->childCount(), 2); + + QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(&mainWindow); + QVERIFY(windowIface); + QCOMPARE(windowIface->childCount(), 1); + QCOMPARE(app->child(0), windowIface); + + QAccessibleInterface *dialogIface = QAccessible::queryAccessibleInterface(&d); + QVERIFY(dialogIface); + QCOMPARE(app->child(1), dialogIface); + QCOMPARE(dialogIface->parent(), app); + QCOMPARE(windowIface->parent(), app); + } + QTestAccessibility::clearEvents(); +} + class CounterButton : public QPushButton { Q_OBJECT public: |