summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-03-23 14:48:09 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-03-30 07:12:57 +0000
commit086317d72a6b6964bf26df4ebedcb6d321b2d56b (patch)
treed2860a5e441409d32401f7109a6ed74e38d38479 /tests
parentc35795b413c6aedd6b02f03fdcaa5fb4888084d5 (diff)
QTextEdit::inputMethodQuery(): Preserve types when applying offset.
The old code converted QRectF into QRect when applying the offset. Change the offset point to QPointF and change the conversions accordingly. Add an autotest similar to that of QPlainTextEdit. This minimizes rounding errors and prevents conversions since the input method logic mostly uses qreal. Task-number: QTBUG-51923 Change-Id: I0c2f80ccae028d8bbbb97ec603f8782f69959c76 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 0cc812cbca..b81e4df123 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -191,6 +191,7 @@ private slots:
void inputMethodQuery();
void inputMethodQueryImHints_data();
void inputMethodQueryImHints();
+ void inputMethodCursorRect();
void highlightLongLine();
@@ -2473,6 +2474,18 @@ void tst_QTextEdit::inputMethodQueryImHints()
QCOMPARE(static_cast<Qt::InputMethodHints>(value.toInt()), hints);
}
+// QTBUG-51923: Verify that the cursor rectangle returned by the input
+// method query correctly reflects the viewport offset.
+void tst_QTextEdit::inputMethodCursorRect()
+{
+ ed->setPlainText("Line1\nLine2Line3\nLine3");
+ ed->moveCursor(QTextCursor::End);
+ const QRectF cursorRect = ed->cursorRect();
+ const QVariant cursorRectV = ed->inputMethodQuery(Qt::ImCursorRectangle);
+ QCOMPARE(cursorRectV.type(), QVariant::RectF);
+ QCOMPARE(cursorRectV.toRect(), cursorRect.toRect());
+}
+
void tst_QTextEdit::highlightLongLine()
{
QTextEdit edit;