diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-14 18:32:31 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-15 16:33:48 +0200 |
commit | d5fa096056b033203d9a54497e1554f153a19d93 (patch) | |
tree | 587561be12137594d389834d1ed09f4be59b0220 /tests/auto/widgets | |
parent | 28f493a9310b370d23a874e4893587b7fb931fa5 (diff) |
Implement accessible text interface
Change-Id: I3a9143c61ecda98513be031fc554fd4bfcef7b7c
Reviewed-by: Michael Bruning <michael.bruning@digia.com>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
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("<html><body>" \ + "<input type='text' value='Good morning!'></input>" \ + "</body></html>"); + 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" |