summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp7
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h1
-rw-r--r--tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp4
3 files changed, 12 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 71d854ac..b11af3e7 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -265,6 +265,13 @@ QAccessibleInterface *QWebEngineViewAccessible::child(int index) const
return Q_NULLPTR;
}
+int QWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const
+{
+ if (c == child(0))
+ return 0;
+ return -1;
+}
+
QT_END_NAMESPACE
#include "moc_qwebengineview.cpp"
diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h
index 8a657538..b3156a35 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -72,6 +72,7 @@ public:
int childCount() const Q_DECL_OVERRIDE;
QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
private:
QWebEngineView *view() const { return static_cast<QWebEngineView*>(object()); }
diff --git a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
index 76b668b2..9fd008ab 100644
--- a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
+++ b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
@@ -98,15 +98,18 @@ void tst_QWebEngineView::hierarchy()
QAccessibleInterface *document = view->child(0);
QCOMPARE(document->role(), QAccessible::Document);
QCOMPARE(document->parent(), view);
+ QCOMPARE(view->indexOfChild(document), 0);
QCOMPARE(document->childCount(), 1);
QAccessibleInterface *grouping = document->child(0);
QVERIFY(grouping);
QCOMPARE(grouping->parent(), document);
+ QCOMPARE(document->indexOfChild(grouping), 0);
QCOMPARE(grouping->childCount(), 2);
QAccessibleInterface *text = grouping->child(0);
QCOMPARE(text->role(), QAccessible::StaticText);
QCOMPARE(text->parent(), grouping);
+ QCOMPARE(grouping->indexOfChild(text), 0);
QEXPECT_FAIL("", "FIXME: static text should probably not have a child element", Continue);
QCOMPARE(text->childCount(), 0);
QCOMPARE(text->text(QAccessible::Name), QString());
@@ -116,6 +119,7 @@ void tst_QWebEngineView::hierarchy()
QAccessibleInterface *input = grouping->child(1);
QCOMPARE(input->role(), QAccessible::EditableText);
QCOMPARE(input->parent(), grouping);
+ QCOMPARE(grouping->indexOfChild(input), 1);
QCOMPARE(input->childCount(), 0);
QCOMPARE(input->text(QAccessible::Name), QString());
QCOMPARE(input->text(QAccessible::Description), QString());