diff options
Diffstat (limited to 'tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp')
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index ec698e5db4..e49d8c3b07 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -86,6 +86,7 @@ private slots: void cursorToXForSetColumns(); void cursorToXForTrailingSpaces_data(); void cursorToXForTrailingSpaces(); + void cursorToXInvalidInput(); void horizontalAlignment_data(); void horizontalAlignment(); void horizontalAlignmentMultiline_data(); @@ -674,6 +675,28 @@ void tst_QTextLayout::cursorToXForTrailingSpaces() QCOMPARE(line.cursorToX(6), cursorAt6); } +void tst_QTextLayout::cursorToXInvalidInput() +{ + QTextLayout layout("aaa", testFont); + + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(5); + layout.endLayout(); + + int cursorPos; + + cursorPos = 0; + layout.lineAt(0).cursorToX(&cursorPos); + QCOMPARE(cursorPos, 0); + cursorPos = -300; + layout.lineAt(0).cursorToX(&cursorPos); + QCOMPARE(cursorPos, 0); + cursorPos = 300; + layout.lineAt(0).cursorToX(&cursorPos); + QCOMPARE(cursorPos, 3); +} + void tst_QTextLayout::horizontalAlignment_data() { qreal width = TESTFONT_SIZE * 4; |