diff options
author | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2011-08-16 15:19:09 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-23 16:12:29 +0200 |
commit | b8cd3fe7b66130200af65eadaf17671136015441 (patch) | |
tree | 48078e780ad42c8511ac2422e1734f0ec8c467d6 /tests | |
parent | a2cbaf9137b6e3a1c66b0bfb82345b1409ce5f1f (diff) |
Implemented QAccessibleTextEdit::attributes()
Handling font properties and colors
Created test: tst_QAccessibility::textAttributes
Merge-request: 2626
Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
(cherry picked from commit f1a6766432f66220275aa7902e4c2414a3069cd1)
Change-Id: I388bc660af20149934110d7894840eccecf81f2a
Reviewed-on: http://codereview.qt.nokia.com/3036
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qaccessibility/tst_qaccessibility.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 8390de0de5..1d99cc1dc5 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -230,6 +230,7 @@ private slots: void navigateHierarchy(); void navigateSlider(); void navigateCovered(); + void textAttributes(); void hideShowTest(); void userActionCount(); @@ -862,6 +863,60 @@ void tst_QAccessibility::accessibleName() QTestAccessibility::clearEvents(); } +void tst_QAccessibility::textAttributes() +{ + QTextEdit textEdit; + int startOffset; + int endOffset; + QString attributes; + QString text("<html><head></head><body>" + "Hello, <b>this</b> is an <i><b>example</b> text</i>." + "<span style=\"font-family: monospace\">Multiple fonts are used.</span>" + "Multiple <span style=\"font-size: 8pt\">text sizes</span> are used." + "Let's give some color to <span style=\"color:#f0f1f2; background-color:#14f01e\">Qt</span>." + "</body></html>"); + + textEdit.setText(text); + QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit); + + QAccessibleTextInterface *textInterface=interface->textInterface(); + + QVERIFY(textInterface); + QCOMPARE(textInterface->characterCount(), 112); + + attributes = textInterface->attributes(10, &startOffset, &endOffset); + QCOMPARE(startOffset, 7); + QCOMPARE(endOffset, 11); + attributes.prepend(';'); + QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;"))); + + attributes = textInterface->attributes(18, &startOffset, &endOffset); + QCOMPARE(startOffset, 18); + QCOMPARE(endOffset, 25); + attributes.prepend(';'); + QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;"))); + QVERIFY(attributes.contains(QLatin1String(";font-style:italic;"))); + + attributes = textInterface->attributes(34, &startOffset, &endOffset); + QCOMPARE(startOffset, 31); + QCOMPARE(endOffset, 55); + attributes.prepend(';'); + QVERIFY(attributes.contains(QLatin1String(";font-family:\"monospace\";"))); + + attributes = textInterface->attributes(65, &startOffset, &endOffset); + QCOMPARE(startOffset, 64); + QCOMPARE(endOffset, 74); + attributes.prepend(';'); + QVERIFY(attributes.contains(QLatin1String(";font-size:8pt;"))); + + attributes = textInterface->attributes(110, &startOffset, &endOffset); + QCOMPARE(startOffset, 109); + QCOMPARE(endOffset, 111); + attributes.prepend(';'); + QVERIFY(attributes.contains(QLatin1String(";background-color:rgb(20,240,30);"))); + QVERIFY(attributes.contains(QLatin1String(";color:rgb(240,241,242);"))); +} + void tst_QAccessibility::hideShowTest() { QWidget * const window = new QWidget(); |