diff options
author | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2011-11-22 18:08:05 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-19 12:27:45 +0100 |
commit | 74c9f9d83f9f5cb934d0b62b468c74df5a3b9a0d (patch) | |
tree | ea5e783b8d025ce2d525dab5c524aaee298dd6b9 /tests/auto/other | |
parent | 7e12d2d30f74b5fe1f80fac7192416cf6eb22d4d (diff) |
Accessibility: childAt returns interface
childAt used to return an integer.
Return an interface instead.
Not requiring a direct child to be returned allows optimizing
by bypassing iterating through the hierarchy of accessibles.
For QtQuick this is the only sensible way of implementing this.
The bridges are still responsible for finding the top-most element.
The default implementation in QAccessibleObject is sufficient
to return direct children. The implementation in
QAccessibleApplication is therfore no longer needed.
Change-Id: Id7100dd5bcc3a98de516a7f4a12eaaa41cb46d26
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'tests/auto/other')
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 2a838c0e3d..9b14fb9e22 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -89,7 +89,6 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, // QAccessibleInterface::indexOfChild(): // Verify that indexOfChild() returns an index equal to the index passed in int indexFromIndexOfChild = interface->indexOfChild(childInterface); - delete childInterface; if (indexFromIndexOfChild != index) { qWarning("tst_QAccessibility::verifyChild (indexOfChild()):"); qWarning() << "Expected:" << index; @@ -109,13 +108,21 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, // Calculate global child position and check that the interface // returns the correct index for that position. QPoint globalChildPos = child->mapToGlobal(QPoint(0, 0)); - int indexFromChildAt = interface->childAt(globalChildPos.x(), globalChildPos.y()); - if (indexFromChildAt != index) { + QAccessibleInterface *childAtInterface = interface->childAt(globalChildPos.x(), globalChildPos.y()); + if (!childAtInterface) { qWarning("tst_QAccessibility::verifyChild (childAt()):"); - qWarning() << "Expected:" << index; - qWarning() << "Actual: " << indexFromChildAt; + qWarning() << "Expected:" << childInterface; + qWarning() << "Actual: no child"; + return false; + } + if (childAtInterface->object() != childInterface->object()) { + qWarning("tst_QAccessibility::verifyChild (childAt()):"); + qWarning() << "Expected:" << childInterface; + qWarning() << "Actual: " << childAtInterface; return false; } + delete childInterface; + delete childAtInterface; // QAccessibleInterface::rect(): // Calculate global child geometry and check that the interface @@ -1931,11 +1938,14 @@ void tst_QAccessibility::mdiSubWindowTest() QCOMPARE(childRect(interface), QRect(globalWidgetPos, widgetGeometry.size())); // childAt - QCOMPARE(interface->childAt(-10, 0), -1); - QCOMPARE(interface->childAt(globalPos.x(), globalPos.y()), 0); - QCOMPARE(interface->childAt(globalWidgetPos.x(), globalWidgetPos.y()), 1); + QCOMPARE(interface->childAt(-10, 0), static_cast<QAccessibleInterface*>(0)); + QCOMPARE(interface->childAt(globalPos.x(), globalPos.y()), static_cast<QAccessibleInterface*>(0)); + QAccessibleInterface *child = interface->childAt(globalWidgetPos.x(), globalWidgetPos.y()); + QCOMPARE(child->role(), QAccessible::PushButton); + QCOMPARE(child->text(QAccessible::Name), QString("QAccessibilityTest")); + delete child; testWindow->widget()->hide(); - QCOMPARE(interface->childAt(globalWidgetPos.x(), globalWidgetPos.y()), 0); + QCOMPARE(interface->childAt(globalWidgetPos.x(), globalWidgetPos.y()), static_cast<QAccessibleInterface*>(0)); } QTestAccessibility::clearEvents(); @@ -2288,7 +2298,7 @@ void tst_QAccessibility::abstractScrollAreaTest() QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&abstractScrollArea); QVERIFY(interface); QVERIFY(!interface->rect().isValid()); - QCOMPARE(interface->childAt(200, 200), -1); + QCOMPARE(interface->childAt(200, 200), static_cast<QAccessibleInterface*>(0)); abstractScrollArea.resize(400, 400); abstractScrollArea.show(); @@ -2767,7 +2777,7 @@ void tst_QAccessibility::calendarWidgetTest() QVERIFY(interface); QCOMPARE(interface->role(), QAccessible::Table); QVERIFY(!interface->rect().isValid()); - QCOMPARE(interface->childAt(200, 200), -1); + QCOMPARE(interface->childAt(200, 200), static_cast<QAccessibleInterface*>(0)); calendarWidget.resize(400, 300); calendarWidget.show(); @@ -2903,9 +2913,11 @@ void tst_QAccessibility::dockWidgetTest() QPoint globalPos = dock1->mapToGlobal(QPoint(0,0)); globalPos.rx()+=5; //### query style globalPos.ry()+=5; - int entry = accDock1->childAt(globalPos.x(), globalPos.y()); //### - QCOMPARE(entry, 1); - QAccessibleInterface *accTitleBar = accDock1->child(entry - 1); + QAccessibleInterface *childAt = accDock1->childAt(globalPos.x(), globalPos.y()); //### + QCOMPARE(childAt->role(), QAccessible::TitleBar); + int index = accDock1->indexOfChild(childAt); + delete childAt; + QAccessibleInterface *accTitleBar = accDock1->child(index - 1); QCOMPARE(accTitleBar->role(), QAccessible::TitleBar); QCOMPARE(accDock1->indexOfChild(accTitleBar), 1); |