diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2014-04-04 07:31:24 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-04 19:32:21 +0200 |
commit | 330f6e359897f77cf50f67141d09e94c371121ff (patch) | |
tree | 239a336b0270b45c682070092e76d9fdf056d1c0 /tests/auto/other/qcomplextext | |
parent | 47056e78d3d963272e449e8f917ae3208b7aa940 (diff) |
QTextLayout: Fix cursor movement from invalid position
Actually guarantee cursor doesn't move in this case for both logical
and visual modes (just what the documentation says we already do ;)
Change-Id: Iabdca7aa1d205672386a0095e3487e585611cdb5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/other/qcomplextext')
-rw-r--r-- | tests/auto/other/qcomplextext/tst_qcomplextext.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp index 7eb8479372..cc444872ec 100644 --- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp @@ -71,6 +71,8 @@ private slots: void bidiCursorMovement(); void bidiCursorLogicalMovement_data(); void bidiCursorLogicalMovement(); + void bidiInvalidCursorNoMovement_data(); + void bidiInvalidCursorNoMovement(); }; tst_QComplexText::tst_QComplexText() @@ -272,6 +274,37 @@ void tst_QComplexText::bidiCursorLogicalMovement() } while (moved); } +void tst_QComplexText::bidiInvalidCursorNoMovement_data() +{ + bidiCursorMovement_data(); +} + +void tst_QComplexText::bidiInvalidCursorNoMovement() +{ + QFETCH(QString, logical); + QFETCH(int, basicDir); + + QTextLayout layout(logical); + + QTextOption option = layout.textOption(); + option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft); + layout.setTextOption(option); + + // visual + QCOMPARE(layout.rightCursorPosition(-1000), -1000); + QCOMPARE(layout.rightCursorPosition(1000), 1000); + + QCOMPARE(layout.leftCursorPosition(-1000), -1000); + QCOMPARE(layout.leftCursorPosition(1000), 1000); + + // logical + QCOMPARE(layout.nextCursorPosition(-1000), -1000); + QCOMPARE(layout.nextCursorPosition(1000), 1000); + + QCOMPARE(layout.previousCursorPosition(-1000), -1000); + QCOMPARE(layout.previousCursorPosition(1000), 1000); +} + void tst_QComplexText::bidiCursor_PDF() { QString str = QString::fromUtf8("\342\200\252hello\342\200\254"); |