Remove all references to QAccessible::(Up|Down|Left|Right)
authorJan-Arve Saether <jan-arve.saether@nokia.com>
Fri, 6 Jan 2012 14:51:53 +0000 (15:51 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 12 Jan 2012 14:05:57 +0000 (15:05 +0100)
It is now the resonsibility of the bridge to support this
(by querying for QAccessibleInterface::rect())

The windows bridge (currently the only bridge in need of this) has
already been updated to reflect this in commit
7dca461620ee6d8cce3a74acf2e1530d4497bff9

Change-Id: Ief1339ab6edc118e2d47e3875e09fa885db65c2f
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
src/gui/accessible/qaccessible.h
src/plugins/accessible/widgets/complexwidgets.cpp
src/plugins/accessible/widgets/complexwidgets.h
src/plugins/accessible/widgets/qaccessiblemenu.cpp
src/plugins/accessible/widgets/qaccessiblewidgets.cpp
src/plugins/accessible/widgets/qaccessiblewidgets.h
src/plugins/platforms/windows/qwindowsaccessibility.cpp
tests/auto/other/qaccessibility/tst_qaccessibility.cpp

index 2126cfd..e41898f 100644 (file)
@@ -276,10 +276,6 @@ public:
         Unrelated     = 0x00000000,
         Self          = 0x00000001,
 
-        Up            = 0x00000100,
-        Down          = 0x00000200,
-        Left          = 0x00000400,
-        Right         = 0x00000800,
         Covers        = 0x00001000,
         Covered       = 0x00002000,
         GeometryMask  = 0x0000ff00,
index 94eb535..a8f477e 100644 (file)
@@ -414,120 +414,6 @@ bool QAccessibleAbstractScrollArea::isValid() const
     return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport());
 }
 
-int QAccessibleAbstractScrollArea::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
-    if (!target)
-        return -1;
-
-    *target = 0;
-
-    QWidget *targetWidget = 0;
-    QWidget *entryWidget = 0;
-
-    if (relation == QAccessible::Left || relation == QAccessible::Up || relation == QAccessible::Right || relation == QAccessible::Down) {
-        QWidgetList children = accessibleChildren();
-        if (entry < 0 || entry > children.count())
-            return -1;
-
-        if (entry == Self)
-            entryWidget = abstractScrollArea();
-        else
-            entryWidget = children.at(entry - 1);
-        AbstractScrollAreaElement entryElement = elementType(entryWidget);
-
-        // Not one of the most beautiful switches I've ever seen, but I believe it has
-        // to be like this since each case need special handling.
-        // It might be possible to make it more general, but I'll leave that as an exercise
-        // to the reader. :-)
-        switch (relation) {
-        case QAccessible::Left:
-            if (entry < 1)
-                break;
-            switch (entryElement) {
-            case Viewport:
-                if (!isLeftToRight())
-                    targetWidget = abstractScrollArea()->verticalScrollBar();
-                break;
-            case HorizontalContainer:
-                if (!isLeftToRight())
-                    targetWidget = abstractScrollArea()->cornerWidget();
-                break;
-            case VerticalContainer:
-                if (isLeftToRight())
-                    targetWidget = abstractScrollArea()->viewport();
-                break;
-            case CornerWidget:
-                if (isLeftToRight())
-                    targetWidget = abstractScrollArea()->horizontalScrollBar();
-                break;
-            default:
-                break;
-            }
-            break;
-        case QAccessible::Right:
-            if (entry < 1)
-                break;
-            switch (entryElement) {
-            case Viewport:
-                if (isLeftToRight())
-                    targetWidget = abstractScrollArea()->verticalScrollBar();
-                break;
-            case HorizontalContainer:
-                targetWidget = abstractScrollArea()->cornerWidget();
-                break;
-            case VerticalContainer:
-                if (!isLeftToRight())
-                    targetWidget = abstractScrollArea()->viewport();
-                break;
-            case CornerWidget:
-                if (!isLeftToRight())
-                    targetWidget = abstractScrollArea()->horizontalScrollBar();
-                break;
-            default:
-                break;
-            }
-            break;
-        case QAccessible::Up:
-            if (entry < 1)
-                break;
-            switch (entryElement) {
-            case HorizontalContainer:
-                targetWidget = abstractScrollArea()->viewport();
-                break;
-            case CornerWidget:
-                targetWidget = abstractScrollArea()->verticalScrollBar();
-                break;
-            default:
-                break;
-            }
-            break;
-        case QAccessible::Down:
-            if (entry < 1)
-                break;
-            switch (entryElement) {
-            case Viewport:
-                targetWidget = abstractScrollArea()->horizontalScrollBar();
-                break;
-            case VerticalContainer:
-                targetWidget = abstractScrollArea()->cornerWidget();
-                break;
-            default:
-                break;
-            }
-            break;
-        default:
-            break;
-        }
-    } else {
-        return QAccessibleWidget::navigate(relation, entry, target);
-    }
-
-    if (qobject_cast<const QScrollBar *>(targetWidget))
-        targetWidget = targetWidget->parentWidget();
-    *target = QAccessible::queryAccessibleInterface(targetWidget);
-    return *target ? 0: -1;
-}
-
 QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const
 {
     if (!abstractScrollArea()->isVisible())
index 24c033b..3145c52 100644 (file)
@@ -79,7 +79,6 @@ public:
     int childCount() const;
     int indexOfChild(const QAccessibleInterface *child) const;
     bool isValid() const;
-    int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
     QAccessibleInterface *childAt(int x, int y) const;
 
 //protected:
index e188db2..77157d1 100644 (file)
@@ -206,31 +206,10 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const
 
 int QAccessibleMenuItem::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
 {
+    Q_UNUSED(relation);
+    Q_UNUSED(entry);
     *target = 0;
-    if (entry < 0) {
-        return -1;
-    }
-
-    switch (relation) {
-    case QAccessible::Up:
-    case QAccessible::Down:{
-        QAccessibleInterface *parentIface = parent();
-        if (parentIface) {
-            int index = parentIface->indexOfChild(this);
-            if (index != -1) {
-                index += (relation == QAccessible::Down ? +1 : -1);
-                if (index >= 0)
-                    *target = parentIface->child(index);
-            }
-        }
-        delete parentIface;
-        break;
-    }
-    default:
-        break;
-
-    }
-    return *target ? 0 : -1;
+    return -1;
 }
 
 void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t)
index a067ada..1d6638e 100644 (file)
@@ -98,121 +98,6 @@ QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
     return widgets;
 }
 
-static inline int distance(QWidget *source, QWidget *target,
-                           QAccessible::RelationFlag relation)
-{
-    if (!source || !target)
-        return -1;
-
-    int returnValue = -1;
-    switch (relation) {
-    case QAccessible::Up:
-        if (target->y() <= source->y())
-            returnValue = source->y() - target->y();
-        break;
-    case QAccessible::Down:
-        if (target->y() >= source->y() + source->height())
-            returnValue = target->y() - (source->y() + source->height());
-        break;
-    case QAccessible::Right:
-        if (target->x() >= source->x() + source->width())
-            returnValue = target->x() - (source->x() + source->width());
-        break;
-    case QAccessible::Left:
-        if (target->x() <= source->x())
-            returnValue = source->x() - target->x();
-        break;
-    default:
-        break;
-    }
-    return returnValue;
-}
-
-static inline QWidget *mdiAreaNavigate(QWidget *area,
-                                       QAccessible::RelationFlag relation, int entry)
-{
-#if defined(QT_NO_MDIAREA) && defined(QT_NO_WORKSPACE)
-    Q_UNUSED(area);
-#endif
-#ifndef QT_NO_MDIAREA
-    const QMdiArea *mdiArea = qobject_cast<QMdiArea *>(area);
-#endif
-#ifndef QT_NO_WORKSPACE
-    const QWorkspace *workspace = qobject_cast<QWorkspace *>(area);
-#endif
-    if (true
-#ifndef QT_NO_MDIAREA
-        && !mdiArea
-#endif
-#ifndef QT_NO_WORKSPACE
-    && !workspace
-#endif
-    )
-        return 0;
-
-    QWidgetList windows;
-#ifndef QT_NO_MDIAREA
-    if (mdiArea) {
-        foreach (QMdiSubWindow *window, mdiArea->subWindowList())
-            windows.append(window);
-    } else
-#endif
-    {
-#ifndef QT_NO_WORKSPACE
-        foreach (QWidget *window, workspace->windowList())
-            windows.append(window->parentWidget());
-#endif
-    }
-
-    if (windows.isEmpty() || entry < 1 || entry > windows.count())
-        return 0;
-
-    QWidget *source = windows.at(entry - 1);
-    QMap<int, QWidget *> candidates;
-    foreach (QWidget *window, windows) {
-        if (source == window)
-            continue;
-        int candidateDistance = distance(source, window, relation);
-        if (candidateDistance >= 0)
-            candidates.insert(candidateDistance, window);
-    }
-
-    int minimumDistance = INT_MAX;
-    QWidget *target = 0;
-    foreach (QWidget *candidate, candidates) {
-        switch (relation) {
-        case QAccessible::Up:
-        case QAccessible::Down:
-            if (qAbs(candidate->x() - source->x()) < minimumDistance) {
-                target = candidate;
-                minimumDistance = qAbs(candidate->x() - source->x());
-            }
-            break;
-        case QAccessible::Left:
-        case QAccessible::Right:
-            if (qAbs(candidate->y() - source->y()) < minimumDistance) {
-                target = candidate;
-                minimumDistance = qAbs(candidate->y() - source->y());
-            }
-            break;
-        default:
-            break;
-        }
-        if (minimumDistance == 0)
-            break;
-    }
-
-#ifndef QT_NO_WORKSPACE
-    if (workspace) {
-        foreach (QWidget *widget, workspace->windowList()) {
-            if (widget->parentWidget() == target)
-                target = widget;
-        }
-    }
-#endif
-    return target;
-}
-
 #ifndef QT_NO_TEXTEDIT
 
 /*!
@@ -790,24 +675,6 @@ int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const
     return -1;
 }
 
-int QAccessibleMdiArea::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
-    *target = 0;
-    QWidget *targetObject = 0;
-    switch (relation) {
-    case QAccessible::Up:
-    case QAccessible::Down:
-    case QAccessible::Left:
-    case QAccessible::Right:
-        targetObject = mdiAreaNavigate(mdiArea(), relation, entry);
-        break;
-    default:
-        return QAccessibleWidget::navigate(relation, entry, target);
-    }
-    *target = QAccessible::queryAccessibleInterface(targetObject);
-    return *target ? 0: -1;
-}
-
 QMdiArea *QAccessibleMdiArea::mdiArea() const
 {
     return static_cast<QMdiArea *>(object());
@@ -881,44 +748,6 @@ int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) con
     return -1;
 }
 
-int QAccessibleMdiSubWindow::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
-    *target = 0;
-
-    if (!mdiSubWindow()->parent())
-        return QAccessibleWidget::navigate(relation, entry, target);
-
-    QWidget *targetObject = 0;
-    QMdiSubWindow *source = mdiSubWindow();
-    switch (relation) {
-    case QAccessible::Up:
-    case QAccessible::Down:
-    case QAccessible::Left:
-    case QAccessible::Right: {
-        if (entry != 0)
-            break;
-        QWidget *parent = source->parentWidget();
-        while (parent && !parent->inherits("QMdiArea"))
-            parent = parent->parentWidget();
-        QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parent);
-        if (!mdiArea)
-            break;
-        int index = mdiArea->subWindowList().indexOf(source);
-        if (index == -1)
-            break;
-        if (QWidget *dest = mdiAreaNavigate(mdiArea, relation, index + 1)) {
-            *target = QAccessible::queryAccessibleInterface(dest);
-            return *target ? 0 : -1;
-        }
-        break;
-    }
-    default:
-        return QAccessibleWidget::navigate(relation, entry, target);
-    }
-    *target = QAccessible::queryAccessibleInterface(targetObject);
-    return *target ? 0: -1;
-}
-
 QRect QAccessibleMdiSubWindow::rect() const
 {
     if (mdiSubWindow()->isHidden())
@@ -967,24 +796,6 @@ int QAccessibleWorkspace::indexOfChild(const QAccessibleInterface *child) const
     return -1;
 }
 
-int QAccessibleWorkspace::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
-    *target = 0;
-    QWidget *targetObject = 0;
-    switch (relation) {
-    case QAccessible::Up:
-    case QAccessible::Down:
-    case QAccessible::Left:
-    case QAccessible::Right:
-        targetObject = mdiAreaNavigate(workspace(), relation, entry);
-        break;
-    default:
-        return QAccessibleWidget::navigate(relation, entry, target);
-    }
-    *target = QAccessible::queryAccessibleInterface(targetObject);
-    return *target ? 0: -1;
-}
-
 QWorkspace *QAccessibleWorkspace::workspace() const
 {
     return static_cast<QWorkspace *>(object());
@@ -1056,28 +867,6 @@ QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const
     return QAccessible::queryAccessibleInterface(calendarView());
 }
 
-int QAccessibleCalendarWidget::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
-    *target = 0;
-    if (entry <= 0 || entry > childCount())
-        return QAccessibleWidget::navigate(relation, entry, target);
-    QWidget *targetWidget = 0;
-    switch (relation) {
-    case QAccessible::Up:
-        if (entry == 2)
-            targetWidget = navigationBar();
-        break;
-    case QAccessible::Down:
-        if (entry == 1 && childCount() == 2)
-            targetWidget = calendarView();
-        break;
-    default:
-        return QAccessibleWidget::navigate(relation, entry, target);
-    }
-    *target = QAccessible::queryAccessibleInterface(targetWidget);
-    return *target ? 0 : -1;
-}
-
 QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const
 {
     return static_cast<QCalendarWidget *>(object());
index e60ed06..c1c1cbb 100644 (file)
@@ -154,7 +154,6 @@ public:
     int childCount() const;
     QAccessibleInterface *child(int index) const;
     int indexOfChild(const QAccessibleInterface *child) const;
-    int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
 
 protected:
     QMdiArea *mdiArea() const;
@@ -171,7 +170,6 @@ public:
     int childCount() const;
     QAccessibleInterface *child(int index) const;
     int indexOfChild(const QAccessibleInterface *child) const;
-    int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
     QRect rect() const;
 
 protected:
@@ -188,7 +186,6 @@ public:
     int childCount() const;
     QAccessibleInterface *child(int index) const;
     int indexOfChild(const QAccessibleInterface *child) const;
-    int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
 
 protected:
     QWorkspace *workspace() const;
@@ -221,7 +218,6 @@ public:
 
     int childCount() const;
     int indexOfChild(const QAccessibleInterface *child) const;
-    int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
 
     QAccessibleInterface *child(int index) const;
 
index 82e65f6..4de4294 100644 (file)
@@ -827,8 +827,14 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accChild(VARIANT varChildID, I
         if (childIndex) {
             acc = accessible->child(childIndex - 1);
         } else {
-            // FIXME
-            Q_ASSERT(0);
+            // Yes, some AT clients (Active Accessibility Object Inspector)
+            // actually ask for the same object. As a consequence, we need to clone ourselves:
+            if (QAccessibleInterface *par = accessible->parent()) {
+                const int indexOf = par->indexOfChild(accessible);
+                QAccessibleInterface *clone = par->child(indexOf);
+                delete par;
+                acc = clone;
+            }
         }
     }
 
index 2d21fbb..3190ef7 100644 (file)
@@ -1450,7 +1450,6 @@ void tst_QAccessibility::menuTest()
     QAccessibleInterface *iface2 = 0;
 
     // traverse siblings with navigate(Sibling, ...)
-    int entry;
     iface = interface->child(0);
     QVERIFY(iface);
     QCOMPARE(iface->role(), QAccessible::MenuItem);
@@ -1470,36 +1469,6 @@ void tst_QAccessibility::menuTest()
     }
     delete iface;
 
-    // traverse menu items with navigate(Down, ...)
-    iface = interface->child(0);
-    QVERIFY(iface);
-    QCOMPARE(iface->role(), QAccessible::MenuItem);
-
-    for (int child = 0; child < 4; ++child) {
-        entry = iface->navigate(QAccessible::Down, 1, &iface2);
-        delete iface;
-        iface = iface2;
-        QCOMPARE(entry, 0);
-        QVERIFY(iface);
-        QCOMPARE(iface->role(), fileRoles[child + 1]);
-    }
-    delete iface;
-
-    // traverse menu items with navigate(Up, ...)
-    iface = interface->child(interface->childCount() - 1);
-    QVERIFY(iface);
-    QCOMPARE(iface->role(), QAccessible::MenuItem);
-
-    for (int child = 3; child >= 0; --child) {
-        entry = iface->navigate(QAccessible::Up, 1, &iface2);
-        delete iface;
-        iface = iface2;
-        QCOMPARE(entry, 0);
-        QVERIFY(iface);
-        QCOMPARE(iface->role(), fileRoles[child]);
-    }
-    delete iface;
-
     // "New" item
     iface = interface->child(0);
     QVERIFY(iface);
@@ -1509,7 +1478,6 @@ void tst_QAccessibility::menuTest()
     iface2 = iface->child(0);
     delete iface;
     iface = iface2;
-    QCOMPARE(entry, 0);
     QVERIFY(iface);
     QCOMPARE(iface->role(), QAccessible::PopupMenu);
 
@@ -1701,37 +1669,6 @@ void tst_QAccessibility::mdiAreaTest()
     QVERIFY(interface);
     QCOMPARE(interface->childCount(), subWindowCount);
 
-    // Right, right, right, ...
-    for (int i = 0; i < subWindowCount; ++i) {
-        QAccessibleInterface *destination = 0;
-        int index = interface->navigate(QAccessible::Right, i + 1, &destination);
-        if (i == subWindowCount - 1) {
-            QVERIFY(!destination);
-            QCOMPARE(index, -1);
-        } else {
-            QVERIFY(destination);
-            QCOMPARE(index, 0);
-            QCOMPARE(destination->object(), (QObject*)subWindows.at(i + 1));
-            delete destination;
-        }
-    }
-
-    // Left, left, left, ...
-    for (int i = subWindowCount; i > 0; --i) {
-        QAccessibleInterface *destination = 0;
-        int index = interface->navigate(QAccessible::Left, i, &destination);
-        if (i == 1) {
-            QVERIFY(!destination);
-            QCOMPARE(index, -1);
-        } else {
-            QVERIFY(destination);
-            QCOMPARE(index, 0);
-            QCOMPARE(destination->object(), (QObject*)subWindows.at(i - 2));
-            delete destination;
-        }
-    }
-    // ### Add test for Up and Down.
-
     }
     QTestAccessibility::clearEvents();
 }
@@ -1747,7 +1684,6 @@ void tst_QAccessibility::mdiSubWindowTest()
     QTest::qWait(150);
 #endif
 
-    bool isSubWindowsPlacedNextToEachOther = false;
     const int subWindowCount =  5;
     for (int i = 0; i < subWindowCount; ++i) {
         QMdiSubWindow *window = mdiArea.addSubWindow(new QPushButton("QAccessibilityTest"));
@@ -1762,8 +1698,6 @@ void tst_QAccessibility::mdiSubWindowTest()
             QCoreApplication::processEvents();
             QTest::qWait(100);
 #endif
-            if (mdiArea.width() >= minimumWidth)
-                isSubWindowsPlacedNextToEachOther = true;
         }
     }
 
@@ -1816,23 +1750,6 @@ void tst_QAccessibility::mdiSubWindowTest()
     QVERIFY(interface->state().focused);
     testWindow->setGeometry(originalGeometry);
 
-    if (isSubWindowsPlacedNextToEachOther) {
-        // This part of the test can only be run if the sub windows are
-        // placed next to each other.
-        QAccessibleInterface *destination = interface->child(0);
-        QVERIFY(destination);
-        QCOMPARE(destination->object(), (QObject*)testWindow->widget());
-        delete destination;
-        QCOMPARE(interface->navigate(QAccessible::Left, 0, &destination), 0);
-        QVERIFY(destination);
-        QCOMPARE(destination->object(), (QObject*)subWindows.at(2));
-        delete destination;
-        QCOMPARE(interface->navigate(QAccessible::Right, 0, &destination), 0);
-        QVERIFY(destination);
-        QCOMPARE(destination->object(), (QObject*)subWindows.at(4));
-        delete destination;
-    }
-
     // rect
     const QPoint globalPos = testWindow->mapToGlobal(QPoint(0, 0));
     QCOMPARE(interface->rect(), QRect(globalPos, testWindow->size()));
@@ -2009,37 +1926,6 @@ void tst_QAccessibility::workspaceTest()
     QVERIFY(interface);
     QCOMPARE(interface->childCount(), subWindowCount);
 
-    // Right, right, right, ...
-    for (int i = 0; i < subWindowCount; ++i) {
-        QAccessibleInterface *destination = 0;
-        int index = interface->navigate(QAccessible::Right, i + 1, &destination);
-        if (i == subWindowCount - 1) {
-            QVERIFY(!destination);
-            QCOMPARE(index, -1);
-        } else {
-            QVERIFY(destination);
-            QCOMPARE(index, 0);
-            QCOMPARE(destination->object(), (QObject*)subWindows.at(i + 1));
-            delete destination;
-        }
-    }
-
-    // Left, left, left, ...
-    for (int i = subWindowCount; i > 0; --i) {
-        QAccessibleInterface *destination = 0;
-        int index = interface->navigate(QAccessible::Left, i, &destination);
-        if (i == 1) {
-            QVERIFY(!destination);
-            QCOMPARE(index, -1);
-        } else {
-            QVERIFY(destination);
-            QCOMPARE(index, 0);
-            QCOMPARE(destination->object(), (QObject*)subWindows.at(i - 2));
-            delete destination;
-        }
-    }
-    // ### Add test for Up and Down.
-
     }
     QTestAccessibility::clearEvents();
 }
@@ -2274,79 +2160,6 @@ void tst_QAccessibility::abstractScrollAreaTest()
     QWidget *cornerWidget = abstractScrollArea.cornerWidget();
     QVERIFY(verifyChild(cornerWidget, interface, 3, globalGeometry));
 
-    // Test navigate.
-    QAccessibleInterface *target = 0;
-
-    // viewport -> Up -> NOTHING
-    const int viewportIndex = indexOfChild(interface, viewport);
-    QVERIFY(viewportIndex != -1);
-    QCOMPARE(interface->navigate(QAccessible::Up, viewportIndex, &target), -1);
-    QVERIFY(!target);
-
-    // viewport -> Left -> NOTHING
-    QCOMPARE(interface->navigate(QAccessible::Left, viewportIndex, &target), -1);
-    QVERIFY(!target);
-
-    // viewport -> Down -> horizontalScrollBarContainer
-    const int horizontalScrollBarContainerIndex = indexOfChild(interface, horizontalScrollBarContainer);
-    QVERIFY(horizontalScrollBarContainerIndex != -1);
-    QCOMPARE(interface->navigate(QAccessible::Down, viewportIndex + 1, &target), 0);
-    QVERIFY(target);
-    QCOMPARE(target->object(), static_cast<QObject *>(horizontalScrollBarContainer));
-    delete target;
-    target = 0;
-
-    // horizontalScrollBarContainer -> Left -> NOTHING
-    QCOMPARE(interface->navigate(QAccessible::Left, horizontalScrollBarContainerIndex + 1, &target), -1);
-    QVERIFY(!target);
-
-    // horizontalScrollBarContainer -> Down -> NOTHING
-    QVERIFY(horizontalScrollBarContainerIndex != -1);
-    QCOMPARE(interface->navigate(QAccessible::Down, horizontalScrollBarContainerIndex + 1, &target), -1);
-    QVERIFY(!target);
-
-    // horizontalScrollBarContainer -> Right -> cornerWidget
-    const int cornerWidgetIndex = indexOfChild(interface, cornerWidget);
-    QVERIFY(cornerWidgetIndex != -1);
-    QCOMPARE(interface->navigate(QAccessible::Right, horizontalScrollBarContainerIndex + 1, &target), 0);
-    QVERIFY(target);
-    QCOMPARE(target->object(), static_cast<QObject *>(cornerWidget));
-    delete target;
-    target = 0;
-
-    // cornerWidget -> Down -> NOTHING
-    QCOMPARE(interface->navigate(QAccessible::Down, cornerWidgetIndex + 1, &target), -1);
-    QVERIFY(!target);
-
-    // cornerWidget -> Right -> NOTHING
-    QVERIFY(cornerWidgetIndex != -1);
-    QCOMPARE(interface->navigate(QAccessible::Right, cornerWidgetIndex + 1, &target), -1);
-    QVERIFY(!target);
-
-    // cornerWidget -> Up ->  verticalScrollBarContainer
-    const int verticalScrollBarContainerIndex = indexOfChild(interface, verticalScrollBarContainer);
-    QVERIFY(verticalScrollBarContainerIndex != -1);
-    QCOMPARE(interface->navigate(QAccessible::Up, cornerWidgetIndex + 1, &target), 0);
-    QVERIFY(target);
-    QCOMPARE(target->object(), static_cast<QObject *>(verticalScrollBarContainer));
-    delete target;
-    target = 0;
-
-    // verticalScrollBarContainer -> Right -> NOTHING
-    QCOMPARE(interface->navigate(QAccessible::Right, verticalScrollBarContainerIndex + 1, &target), -1);
-    QVERIFY(!target);
-
-    // verticalScrollBarContainer -> Up -> NOTHING
-    QCOMPARE(interface->navigate(QAccessible::Up, verticalScrollBarContainerIndex + 1, &target), -1);
-    QVERIFY(!target);
-
-    // verticalScrollBarContainer -> Left -> viewport
-    QCOMPARE(interface->navigate(QAccessible::Left, verticalScrollBarContainerIndex + 1, &target), 0);
-    QVERIFY(target);
-    QCOMPARE(target->object(), static_cast<QObject *>(viewport));
-    delete target;
-    target = 0;
-
     QCOMPARE(verifyHierarchy(interface), 0);
 
     delete interface;
@@ -2750,29 +2563,19 @@ void tst_QAccessibility::calendarWidgetTest()
     QAccessibleInterface *navigationBarInterface = interface->child(0);
     QVERIFY(navigationBarInterface);
     QCOMPARE(navigationBarInterface->object(), (QObject*)navigationBar);
-    delete navigationBarInterface;
-    navigationBarInterface = 0;
 
     // Navigate to the view via Child.
     QAccessibleInterface *calendarViewInterface = interface->child(1);
     QVERIFY(calendarViewInterface);
     QCOMPARE(calendarViewInterface->object(), (QObject*)calendarView);
-    delete calendarViewInterface;
-    calendarViewInterface = 0;
 
     QVERIFY(!interface->child(-1));
 
-    // Navigate from navigation bar -> view (Down).
-    QCOMPARE(interface->navigate(QAccessible::Down, 1, &calendarViewInterface), 0);
-    QVERIFY(calendarViewInterface);
-    QCOMPARE(calendarViewInterface->object(), (QObject*)calendarView);
+    // In order for geometric navigation to work they must share the same parent
+    QCOMPARE(navigationBarInterface->parent()->object(), calendarViewInterface->parent()->object());
+    QVERIFY(navigationBarInterface->rect().bottom() < calendarViewInterface->rect().top());
     delete calendarViewInterface;
     calendarViewInterface = 0;
-
-    // Navigate from view -> navigation bar (Up).
-    QCOMPARE(interface->navigate(QAccessible::Up, 2, &navigationBarInterface), 0);
-    QVERIFY(navigationBarInterface);
-    QCOMPARE(navigationBarInterface->object(), (QObject*)navigationBar);
     delete navigationBarInterface;
     navigationBarInterface = 0;