diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-03-24 16:10:15 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-03-24 16:10:15 +0100 |
commit | 3b5c0bc0780f1749fed7c07bd8b691400a0282b7 (patch) | |
tree | 1022f5553ad5a0aca9b5f3b49ca38a01c2329d20 /tests/auto/other/qaccessibility/tst_qaccessibility.cpp | |
parent | c79918733a194ebbe5a2fe1617c884659f3e4b9f (diff) | |
parent | 21f1738a94fc8544ece04b3b1ee03a11986fe59b (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/gui/image/qjpeghandler.cpp
Change-Id: I9db3acea7d5c82f5da679c8eaeb29431136665f0
Diffstat (limited to 'tests/auto/other/qaccessibility/tst_qaccessibility.cpp')
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 53f74d091b..2bf8a40451 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1650,30 +1650,33 @@ void tst_QAccessibility::textEditTest() QTest::qWaitForWindowShown(&edit); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&edit); QCOMPARE(iface->text(QAccessible::Value), edit.toPlainText()); - QCOMPARE(iface->textInterface()->textAtOffset(8, QAccessible::WordBoundary, &startOffset, &endOffset), QString("world")); + QAccessibleTextInterface *textIface = iface->textInterface(); + QVERIFY(textIface); + + QCOMPARE(textIface->textAtOffset(8, QAccessible::WordBoundary, &startOffset, &endOffset), QString("world")); QCOMPARE(startOffset, 6); QCOMPARE(endOffset, 11); - QCOMPARE(iface->textInterface()->textAtOffset(15, QAccessible::LineBoundary, &startOffset, &endOffset), QString("How are you today?")); + QCOMPARE(textIface->textAtOffset(15, QAccessible::LineBoundary, &startOffset, &endOffset), QString("How are you today?")); QCOMPARE(startOffset, 13); QCOMPARE(endOffset, 31); - QCOMPARE(iface->textInterface()->characterCount(), 48); + QCOMPARE(textIface->characterCount(), 48); QFontMetrics fm(edit.currentFont()); - QCOMPARE(iface->textInterface()->characterRect(0).size(), QSize(fm.width("h"), fm.height())); - QCOMPARE(iface->textInterface()->characterRect(5).size(), QSize(fm.width(" "), fm.height())); - QCOMPARE(iface->textInterface()->characterRect(6).size(), QSize(fm.width("w"), fm.height())); + QCOMPARE(textIface->characterRect(0).size(), QSize(fm.width("h"), fm.height())); + QCOMPARE(textIface->characterRect(5).size(), QSize(fm.width(" "), fm.height())); + QCOMPARE(textIface->characterRect(6).size(), QSize(fm.width("w"), fm.height())); int offset = 10; - QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("d")); - QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset))); + QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("d")); + QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); offset = 13; - QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("H")); - QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset))); + QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("H")); + QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); offset = 21; - QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("y")); - QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset))); + QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("y")); + QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); offset = 32; - QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("I")); - QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset))); + QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("I")); + QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); QTestAccessibility::clearEvents(); @@ -1692,6 +1695,22 @@ void tst_QAccessibility::textEditTest() sel.setCursorPosition(end); sel.setSelection(0, end); QVERIFY_EVENT(&sel); + + // check that we have newlines handled + QString poem = QStringLiteral("Once upon a midnight dreary,\nwhile I pondered, weak and weary,\nOver many a quaint and curious volume of forgotten lore\n"); + QAccessibleEditableTextInterface *editableTextIface = iface->editableTextInterface(); + QVERIFY(editableTextIface); + editableTextIface->replaceText(0, end, poem); + QCOMPARE(iface->text(QAccessible::Value), poem); + QCOMPARE(textIface->text(0, poem.size()), poem); + QCOMPARE(textIface->text(28, 29), QLatin1String("\n")); + int start; + QCOMPARE(textIface->textAtOffset(42, QAccessible::LineBoundary, &start, &end), QStringLiteral("while I pondered, weak and weary,")); + QCOMPARE(start, 29); + QCOMPARE(end, 62); + QCOMPARE(textIface->textAtOffset(28, QAccessible::CharBoundary, &start, &end), QLatin1String("\n")); + QCOMPARE(start, 28); + QCOMPARE(end, 29); } QTestAccessibility::clearEvents(); } |