Skip to content

Commit

Permalink
Accessibility: indexOfChild is 0-based.
Browse files Browse the repository at this point in the history
Also test for it to work.

Change-Id: I3be913984e2dddce241b538c7801f3376acdd1fa
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
  • Loading branch information
Frederik Gladhorn authored and Qt by Nokia committed Jan 12, 2012
1 parent 612e8ea commit be1534e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Expand Up @@ -80,7 +80,7 @@ int QAccessibleDeclarativeView::indexOfChild(const QAccessibleInterface *iface)
if (iface) {
QDeclarativeItem *declarativeRoot = m_view->accessibleRootItem();
if (declarativeRoot == iface->object())
return 1;
return 0;
}
return -1;
}
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/accessible/quick/qaccessiblequickitem.cpp
Expand Up @@ -135,10 +135,7 @@ int QAccessibleQuickItem::navigate(QAccessible::RelationFlag rel, int entry, QAc
int QAccessibleQuickItem::indexOfChild(const QAccessibleInterface *iface) const
{
QList<QQuickItem*> kids = childItems();
int idx = kids.indexOf(static_cast<QQuickItem*>(iface->object()));
if (idx != -1)
++idx;
return idx;
return kids.indexOf(static_cast<QQuickItem*>(iface->object()));
}

QList<QQuickItem *> QAccessibleQuickItem::childItems() const
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/accessible/quick/qaccessiblequickview.cpp
Expand Up @@ -158,7 +158,7 @@ int QAccessibleQuickView::indexOfChild(const QAccessibleInterface *iface) const
if (iface) {
QQuickItem *declarativeRoot = view()->rootObject();
if (declarativeRoot == iface->object())
return 1;
return 0;
}
return -1;

Expand Down
Expand Up @@ -382,6 +382,7 @@ void tst_QDeclarativeAccessibility::basicPropertiesTest()
QCOMPARE(item->childCount(), 2);
QCOMPARE(item->rect().size(), QSize(400, 400));
QCOMPARE(item->role(), QAccessible::Pane);
QCOMPARE(iface->indexOfChild(item.data()), 0);

QAI text = QAI(item->child(0));
QVERIFY(text.data());
Expand All @@ -392,6 +393,7 @@ void tst_QDeclarativeAccessibility::basicPropertiesTest()
QCOMPARE(text->rect().x(), item->rect().x() + 100);
QCOMPARE(text->rect().y(), item->rect().y() + 20);
QCOMPARE(text->role(), QAccessible::StaticText);
QCOMPARE(item->indexOfChild(text.data()), 0);

QAI text2 = QAI(item->child(1));
QVERIFY(text2.data());
Expand All @@ -402,6 +404,10 @@ void tst_QDeclarativeAccessibility::basicPropertiesTest()
QCOMPARE(text2->rect().x(), item->rect().x() + 100);
QCOMPARE(text2->rect().y(), item->rect().y() + 40);
QCOMPARE(text2->role(), QAccessible::StaticText);
QCOMPARE(item->indexOfChild(text2.data()), 1);

QCOMPARE(iface->indexOfChild(text2.data()), -1);
QCOMPARE(text2->indexOfChild(item.data()), -1);

delete canvas;
}
Expand Down

0 comments on commit be1534e

Please sign in to comment.