diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2010-06-28 13:39:54 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-06-28 13:39:54 (GMT) |
commit | ace1efa0fb7552de0fbe845543ee9560d8b89a65 (patch) | |
tree | eb5506cdfeee7412dbe04f601dd2b7c2b015e30c /tests/auto/qtextlayout | |
parent | b1b87a73012342dc1619a8e907ea9954d59ca564 (diff) | |
download | Qt-ace1efa0fb7552de0fbe845543ee9560d8b89a65.zip Qt-ace1efa0fb7552de0fbe845543ee9560d8b89a65.tar.gz Qt-ace1efa0fb7552de0fbe845543ee9560d8b89a65.tar.bz2 |
add some QTextLayout subtests
Merge-request: 685
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'tests/auto/qtextlayout')
-rw-r--r-- | tests/auto/qtextlayout/tst_qtextlayout.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 1a5f493..8758092 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -85,6 +85,7 @@ private slots: void cursorToXForSetColumns(); void defaultWordSeparators_data(); void defaultWordSeparators(); + void cursorMovementFromInvalidPositions(); void cursorMovementInsideSpaces(); void charWordStopOnLineSeparator(); void xToCursorAtEndOfLine(); @@ -542,6 +543,10 @@ void tst_QTextLayout::defaultWordSeparators_data() QTest::newRow("lineseparator") << QString::fromLatin1("abcd") + QString(QChar::LineSeparator) + QString::fromLatin1("efgh") << 0 << 5; + + QTest::newRow("empty") + << QString() + << 0 << 0; } void tst_QTextLayout::defaultWordSeparators() @@ -555,12 +560,31 @@ void tst_QTextLayout::defaultWordSeparators() QCOMPARE(layout.previousCursorPosition(endPos, QTextLayout::SkipWords), startPos); } +void tst_QTextLayout::cursorMovementFromInvalidPositions() +{ + int badpos = 10000; + + QTextLayout layout("ABC", testFont); + + QCOMPARE(layout.previousCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos); + QCOMPARE(layout.nextCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos); + + QCOMPARE(layout.previousCursorPosition(badpos, QTextLayout::SkipCharacters), badpos); + QCOMPARE(layout.nextCursorPosition(badpos, QTextLayout::SkipCharacters), badpos); +} + void tst_QTextLayout::cursorMovementInsideSpaces() { QTextLayout layout("ABC DEF", testFont); QCOMPARE(layout.previousCursorPosition(6, QTextLayout::SkipWords), 0); QCOMPARE(layout.nextCursorPosition(6, QTextLayout::SkipWords), 15); + + + QTextLayout layout2("ABC\t\t\t\t\t\t\t\t\t\t\t\tDEF", testFont); + + QCOMPARE(layout2.previousCursorPosition(6, QTextLayout::SkipWords), 0); + QCOMPARE(layout2.nextCursorPosition(6, QTextLayout::SkipWords), 15); } void tst_QTextLayout::charWordStopOnLineSeparator() |