summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlineedit
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-04-22 12:10:50 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2010-04-22 12:16:30 +0200
commitcc37d494c2c6ef5768e4bc30cad62f24fee033c3 (patch)
treedee88dbf9aa875b25ceda0d2e1e7a5282a3f7ba1 /tests/auto/qlineedit
parent2f14520ce72f0798a751f796baf93dd3f77a276d (diff)
Fix regression: auto completion text cursor problem in Q3FileDialog
This was another regression in QLineEdit introduced with the move to QLineControl setCursorPosition clear the selection, and setSelection move the cursor position. So the case where we want the position at the beginning of the selection need to be handled separately (by doing the selection reverse) This does not cover the case where the position is in the middle, or outside the selection, but it is not possible to do. Task-number: QTBUG-10019 Reviewed-by: jbache
Diffstat (limited to 'tests/auto/qlineedit')
-rw-r--r--tests/auto/qlineedit/qlineedit.pro1
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp33
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qlineedit/qlineedit.pro b/tests/auto/qlineedit/qlineedit.pro
index f00a2d81b3..88527ce21f 100644
--- a/tests/auto/qlineedit/qlineedit.pro
+++ b/tests/auto/qlineedit/qlineedit.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT += qt3support
SOURCES += tst_qlineedit.cpp
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index ca84b38814..592c1cb33a 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -273,6 +273,11 @@ private slots:
void taskQTBUG_4679_selectToStartEndOfBlock();
void taskQTBUG_7395_readOnlyShortcut();
+#ifdef QT3_SUPPORT
+ void validateAndSet_data();
+ void validateAndSet();
+#endif
+
protected slots:
#ifdef QT3_SUPPORT
void lostFocus();
@@ -1488,6 +1493,34 @@ void tst_QLineEdit::lostFocus()
{
editingFinished();
}
+
+void tst_QLineEdit::validateAndSet_data()
+{
+ QTest::addColumn<QString>("newText");
+ QTest::addColumn<int>("newPos");
+ QTest::addColumn<int>("newMarkAnchor");
+ QTest::addColumn<int>("newMarkDrag");
+
+ QTest::newRow("1") << QString("Hello World") << 3 << 3 << 5;
+ QTest::newRow("2") << QString("Hello World") << 5 << 3 << 5;
+}
+
+void tst_QLineEdit::validateAndSet()
+{
+ QFETCH(QString, newText);
+ QFETCH(int, newPos);
+ QFETCH(int, newMarkAnchor);
+ QFETCH(int, newMarkDrag);
+
+ QLineEdit e;
+ e.validateAndSet(newText, newPos, newMarkAnchor, newMarkDrag);
+ QCOMPARE(e.text(), newText);
+ QCOMPARE(e.cursorPosition(), newPos);
+ QCOMPARE(e.selectedText(), newText.mid(newMarkAnchor, newMarkDrag-newMarkAnchor));
+}
+
+
+
#endif
void tst_QLineEdit::editingFinished()
{