diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-10-04 06:52:13 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-10 13:26:13 +0200 |
commit | f0ee31dc93813808a59a0fe576da120de2caf074 (patch) | |
tree | 4894feb2cdf725f4bf31b7c04b91e213ed08e217 /tests/auto/corelib/tools/qtextboundaryfinder | |
parent | 008e5ba61a68846ad29c65a2fe10b8c19c74f6eb (diff) |
QTextBoundaryFinder: Introduce BoundaryReason::MandatoryBreak flag
that will be returned by boundaryReasons() when the boundary finder
is at the line end position (CR, LF, NewLine Function, End of Text, etc.).
The MandatoryBreak flag, if set, means the text should be wrapped at a given position.
Change-Id: I32d4f570935d2e015bfc5f18915396a15f009fde
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qtextboundaryfinder')
-rw-r--r-- | tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 22d3465823..a0aab340a3 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -76,6 +76,8 @@ private slots: void wordBoundaries_qtbug6498(); void isAtSoftHyphen_data(); void isAtSoftHyphen(); + void isAtMandatoryBreak_data(); + void isAtMandatoryBreak(); void thaiLineBreak(); }; @@ -659,6 +661,41 @@ void tst_QTextBoundaryFinder::isAtSoftHyphen() } } +void tst_QTextBoundaryFinder::isAtMandatoryBreak_data() +{ + QTest::addColumn<QString>("testString"); + QTest::addColumn<QList<int> >("expectedBreakPositions"); + + { + QChar s[] = { 0x000D, 0x0308, 0x000A, 0x000A }; + QString testString(s, sizeof(s)/sizeof(s[0])); + QList<int> expectedBreakPositions; + expectedBreakPositions << 0 << 1 << 3 << 4; + + QTest::newRow("+CR+FExLF+LF+") << testString << expectedBreakPositions; + } + { + QString testString(QString::fromUtf8("Aaa bbb ccc.\r\nDdd eee fff.")); + QList<int> expectedBreakPositions; + expectedBreakPositions << 0 << 14 << 26; + + QTest::newRow("data1") << testString << expectedBreakPositions; + } +} + +void tst_QTextBoundaryFinder::isAtMandatoryBreak() +{ + QFETCH(QString, testString); + QFETCH(QList<int>, expectedBreakPositions); + + QTextBoundaryFinder boundaryFinder(QTextBoundaryFinder::Line, testString); + for (int i = 0; i <= testString.size(); ++i) { + boundaryFinder.setPosition(i); + if (boundaryFinder.boundaryReasons() & QTextBoundaryFinder::MandatoryBreak) + QVERIFY(expectedBreakPositions.contains(i)); + } +} + #include <qlibrary.h> #define LIBTHAI_MAJOR 0 |