diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-06-08 23:36:28 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-06-08 23:36:28 (GMT) |
commit | 410cf259cd0a1ec7e6aa97f7dc907186633ee12f (patch) | |
tree | 6f705e7c0b697714705ee090d17cef383e3d8b34 /tests/auto | |
parent | 5bbf8c5dd98b49d28c7eeb755bc9e645b2ad0186 (diff) | |
parent | e2773c35eb06f5a17c8ef40a949c6af48c4175fd (diff) | |
download | Qt-410cf259cd0a1ec7e6aa97f7dc907186633ee12f.zip Qt-410cf259cd0a1ec7e6aa97f7dc907186633ee12f.tar.gz Qt-410cf259cd0a1ec7e6aa97f7dc907186633ee12f.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (32 commits)
Fix autotest on Windows
Compile on Mac OS X
Ammend last commit
Implemented QAccessibleTextEdit::attributes()
Changing cursor position in all boundaries
code clean-up for QSystemSemaphore
simplify QSharedMemoryPrivate::cleanHandle()
minor improvements for QSharedMemory
fix potential keyfile leaking
refactoring of the QWSSharedMemory class
allow the user to averride QT_QWS_TEMP_DIR in qplatformdefs.h
minor typo fix
minor code simplification
minor code simplification
avoid the QT_NO_ASCII warning
remove an unused headers
nano optimization
don't reallocate memory if the old buffer has sufficient capacity
fix potential memory leaking
don't delete the lock if it was not created by this surface
...
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qaccessibility/tst_qaccessibility.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 92e3a8b..109afbc 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -238,6 +238,7 @@ private slots: void navigateControllers(); void navigateLabels(); void text(); + void textAttributes(); void setText(); void hideShowTest(); @@ -1563,6 +1564,60 @@ void tst_QAccessibility::text() #endif // !QT3_SUPPORT } +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::setText() { #if !defined(QT3_SUPPORT) @@ -2645,6 +2700,8 @@ void tst_QAccessibility::textEditTest() { { QTextEdit edit; + int startOffset; + int endOffset; QString text = "hello world\nhow are you today?\n"; edit.setText(text); edit.show(); @@ -2654,6 +2711,12 @@ void tst_QAccessibility::textEditTest() QCOMPARE(iface->childCount(), 6); QCOMPARE(iface->text(QAccessible::Value, 4), QString("hello world")); QCOMPARE(iface->text(QAccessible::Value, 5), QString("how are you today?")); + QCOMPARE(iface->textInterface()->textAtOffset(8, QAccessible2::WordBoundary, &startOffset, &endOffset), QString("world")); + QCOMPARE(startOffset, 6); + QCOMPARE(endOffset, 11); + QCOMPARE(iface->textInterface()->textAtOffset(14, QAccessible2::LineBoundary, &startOffset, &endOffset), QString("how are you today?")); + QCOMPARE(startOffset, 12); + QCOMPARE(endOffset, 30); QCOMPARE(iface->text(QAccessible::Value, 6), QString()); QCOMPARE(iface->textInterface()->characterCount(), 31); QFontMetrics fm(edit.font()); |