From d5fa096056b033203d9a54497e1554f153a19d93 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 14 Jul 2014 18:32:31 +0200 Subject: Implement accessible text interface Change-Id: I3a9143c61ecda98513be031fc554fd4bfcef7b7c Reviewed-by: Michael Bruning --- .../tst_qwebengineaccessibility.cpp | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp index 9fd008ab1..9bf4c69e2 100644 --- a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp +++ b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp @@ -38,6 +38,7 @@ public Q_SLOTS: private Q_SLOTS: void noPage(); void hierarchy(); + void text(); }; // This will be called before the first test function is executed. @@ -126,5 +127,39 @@ void tst_QWebEngineView::hierarchy() QCOMPARE(input->text(QAccessible::Value), QStringLiteral("some text")); } +void tst_QWebEngineView::text() +{ + QWebEngineView webView; + webView.setHtml("" \ + "" \ + ""); + webView.show(); + ::waitForSignal(&webView, SIGNAL(loadFinished(bool))); + + QAccessibleInterface *view = QAccessible::queryAccessibleInterface(&webView); + // Wait for accessibility to be fully initialized + QTRY_VERIFY(view->child(0)->childCount() == 1); + QAccessibleInterface *document = view->child(0); + QAccessibleInterface *grouping = document->child(0); + QVERIFY(grouping); + + QAccessibleInterface *input = grouping->child(0); + QCOMPARE(input->role(), QAccessible::EditableText); + QCOMPARE(input->text(QAccessible::Name), QString()); + QCOMPARE(input->text(QAccessible::Description), QString()); + QCOMPARE(input->text(QAccessible::Value), QStringLiteral("Good morning!")); + + QAccessibleTextInterface *textInterface = input->textInterface(); + QVERIFY(textInterface); + QCOMPARE(textInterface->characterCount(), 13); + QCOMPARE(textInterface->selectionCount(), 0); + QCOMPARE(textInterface->text(2, 9), QStringLiteral("od morn")); + int start = -1; + int end = -1; + QCOMPARE(textInterface->textAtOffset(8, QAccessible::WordBoundary, &start, &end), QStringLiteral("morning")); + textInterface->setCursorPosition(3); + QTRY_COMPARE(textInterface->cursorPosition(), 3); +} + QTEST_MAIN(tst_QWebEngineView) #include "tst_qwebengineaccessibility.moc" -- cgit v1.2.3