summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
diff options
context:
space:
mode:
authorDaniel Teske <qt@squorn.de>2017-06-27 15:12:05 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2017-07-20 13:46:26 +0000
commit854fdaaf76873a4f5c6d5a5046b35bc8152fcc24 (patch)
tree6965008116d8ec8020a26ecd82aaaa22967d1e72 /tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
parentd39ec44e1937c354d8770c5f0257d33b13272141 (diff)
QLineEdit: Add selectionEnd() and selectionLength()
Getting the end position of the selection was not possible. [ChangeLog][QtWidgets][QLineEdit] Added selectionEnd(), selectionLength(), complementing selectionStart(). Change-Id: Iaecc624063d7c043f9502351f07eb76f869e86f1 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp')
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 3f7fdd6f6f..fa4a2f1da3 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -3953,6 +3953,8 @@ void tst_QLineEdit::QTBUG16850_setSelection()
le.setText(" 1");
le.setSelection(3, 1);
QCOMPARE(le.selectionStart(), 3);
+ QCOMPARE(le.selectionEnd(), 4);
+ QCOMPARE(le.selectionLength(), 1);
QCOMPARE(le.selectedText(), QString("1"));
}
@@ -4147,11 +4149,16 @@ void tst_QLineEdit::inputMethodSelection()
QCOMPARE(selectionSpy.count(), 0);
QCOMPARE(testWidget->selectionStart(), -1);
+ QCOMPARE(testWidget->selectionEnd(), -1);
+ QCOMPARE(testWidget->selectionLength(), 0);
testWidget->setSelection(0,5);
QCOMPARE(selectionSpy.count(), 1);
QCOMPARE(testWidget->selectionStart(), 0);
+ QCOMPARE(testWidget->selectionEnd(), 5);
+ QCOMPARE(testWidget->selectionLength(), 5);
+
// selection gained
{
@@ -4163,6 +4170,8 @@ void tst_QLineEdit::inputMethodSelection()
QCOMPARE(selectionSpy.count(), 2);
QCOMPARE(testWidget->selectionStart(), 12);
+ QCOMPARE(testWidget->selectionEnd(), 17);
+ QCOMPARE(testWidget->selectionLength(), 5);
// selection removed
{
@@ -4173,6 +4182,10 @@ void tst_QLineEdit::inputMethodSelection()
}
QCOMPARE(selectionSpy.count(), 3);
+ QCOMPARE(testWidget->selectionStart(), -1);
+ QCOMPARE(testWidget->selectionEnd(), -1);
+ QCOMPARE(testWidget->selectionLength(), 0);
+
}
Q_DECLARE_METATYPE(Qt::InputMethodHints)