From cc57a2e90f18a39ce3c74b6ad0db9a64aa135ddf Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 2 Apr 2014 19:49:08 +0200 Subject: Accessibility text updates for QTextEdit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For Mac this makes QTextEdit work nicely with VoiceOver. Task-number: QTBUG-37204 Change-Id: I1326d24ca6a932ad667ee395f62881b6ec64e892 Reviewed-by: Jan Arve Sæther --- .../other/qaccessibility/tst_qaccessibility.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 9f0540173a..fcc5581bea 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1711,6 +1711,48 @@ void tst_QAccessibility::textEditTest() QCOMPARE(textIface->textAtOffset(28, QAccessible::CharBoundary, &start, &end), QLatin1String("\n")); QCOMPARE(start, 28); QCOMPARE(end, 29); + + edit.clear(); + QTestAccessibility::clearEvents(); + + // make sure we get notifications when typing text + QTestEventList keys; + keys.addKeyClick('A'); + keys.simulate(&edit); + keys.clear(); + QAccessibleTextInsertEvent insertA(&edit, 0, "A"); + QVERIFY_EVENT(&insertA); + QAccessibleTextCursorEvent move1(&edit, 1); + QVERIFY_EVENT(&move1); + + + keys.addKeyClick('c'); + keys.simulate(&edit); + keys.clear(); + QAccessibleTextInsertEvent insertC(&edit, 1, "c"); + QVERIFY_EVENT(&insertC); + QAccessibleTextCursorEvent move2(&edit, 2); + QVERIFY_EVENT(&move2); + + keys.addKeyClick(Qt::Key_Backspace); + keys.simulate(&edit); + keys.clear(); + + // FIXME this should get a proper string instead of space + QAccessibleTextRemoveEvent del(&edit, 1, " "); + QVERIFY_EVENT(&del); + QVERIFY_EVENT(&move1); + + // it would be nicer to get a text update event, but the current implementation + // instead does remove and insert which is also fine + edit.setText(QStringLiteral("Accessibility rocks")); + QAccessibleTextRemoveEvent remove(&edit, 0, " "); + QVERIFY_EVENT(&remove); + + // FIXME the new text is not there yet + QEXPECT_FAIL("", "Inserting should always contain the new text", Continue); + QAccessibleTextInsertEvent insert(&edit, 0, "Accessibility rocks"); + QVERIFY_EVENT(&insert); } QTestAccessibility::clearEvents(); } -- cgit v1.2.3