summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2014-12-05 10:22:28 +0100
committerAndy Shaw <andy.shaw@digia.com>2014-12-19 15:55:07 +0100
commita07120d496c43d45792dc5ca92d93eea37f32cec (patch)
treeb1f7646e5e32b68a96def7be1c01d9ee0ab983cd /tests
parent7393bb0af4c98cabef3138e4db60692e70d4c444 (diff)
Don't clear lineedit in non normal echo mode when validation is invalid
This fixes a regression introduced with c09e9f71173a698670d6c728291ee24f53d50800 which caused the lineedit to clear the whole text when an invalid character was entered into a lineedit with an echo mode that was not Normal and a validator was set. Now if undo() is called directly then it will still clear the text as it is considered to be called as a user. Whereas the validation will take care of the invalid entry by using internalUndo() as before which avoids the clearing of the entire text. Task-number: QTBUG-29318 Change-Id: I5ff5777a75ab864de2217441b5f518f50646bd8f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp51
1 files changed, 37 insertions, 14 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index bf4d1f2ebd..fec79326c8 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -2512,6 +2512,7 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
QTest::addColumn<QString>("expectedText");
QTest::addColumn<bool>("useKeys");
QTest::addColumn<bool>("is_valid");
+ QTest::addColumn<uint>("echoMode");
for (int i=0; i<2; i++) {
bool useKeys = false;
@@ -2528,7 +2529,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("1")
<< QString("1")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] valid '3'").toLatin1())
<< 3
@@ -2536,7 +2538,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("3")
<< QString("3")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] valid '7'").toLatin1())
<< 3
@@ -2544,7 +2547,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("7")
<< QString("7")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,100] valid '9'").toLatin1())
<< 0
@@ -2552,7 +2556,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("9")
<< QString("9")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,100] valid '12'").toLatin1())
<< 0
@@ -2560,7 +2565,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("12")
<< QString("12")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [-100,100] valid '-12'").toLatin1())
<< -100
@@ -2568,7 +2574,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("-12")
<< QString("-12")
<< bool(useKeys)
- << bool(true);
+ << bool(true)
+ << uint(QLineEdit::Normal);
// invalid data
// characters not allowed in QIntValidator
@@ -2578,7 +2585,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("a")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,9] inv 'A'").toLatin1())
<< 0
@@ -2586,7 +2594,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("A")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
// minus sign only allowed with a range on the negative side
QTest::newRow(QString(inputMode + "range [0,100] inv '-'").toLatin1())
<< 0
@@ -2594,36 +2603,48 @@ void tst_QLineEdit::setValidator_QIntValidator_data()
<< QString("-")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [0,100] int '153'").toLatin1())
<< 0
<< 100
<< QString("153")
<< QString(useKeys ? "15" : "")
<< bool(useKeys)
- << bool(useKeys ? true : false);
+ << bool(useKeys ? true : false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [-100,100] int '-153'").toLatin1())
<< -100
<< 100
<< QString("-153")
<< QString(useKeys ? "-15" : "")
<< bool(useKeys)
- << bool(useKeys ? true : false);
+ << bool(useKeys ? true : false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] int '2'").toLatin1())
<< 3
<< 7
<< QString("2")
<< QString("2")
<< bool(useKeys)
- << bool(false);
-
+ << bool(false)
+ << uint(QLineEdit::Normal);
QTest::newRow(QString(inputMode + "range [3,7] int '8'").toLatin1())
<< 3
<< 7
<< QString("8")
<< QString("")
<< bool(useKeys)
- << bool(false);
+ << bool(false)
+ << uint(QLineEdit::Normal);
+ QTest::newRow(QString(inputMode + "range [0,99] inv 'a-a'").toLatin1())
+ << 0
+ << 99
+ << QString("19a")
+ << QString(useKeys ? "19" : "")
+ << bool(useKeys)
+ << bool(useKeys ? true : false)
+ << uint(QLineEdit::Password);
}
}
@@ -2635,9 +2656,11 @@ void tst_QLineEdit::setValidator_QIntValidator()
QFETCH(QString, expectedText);
QFETCH(bool, useKeys);
QFETCH(bool, is_valid);
+ QFETCH(uint, echoMode);
QIntValidator intValidator(mini, maxi, 0);
QLineEdit *testWidget = ensureTestWidget();
+ testWidget->setEchoMode((QLineEdit::EchoMode)echoMode);
testWidget->setValidator(&intValidator);
QVERIFY(testWidget->text().isEmpty());
//qDebug("1 input: '" + input + "' Exp: '" + expectedText + "'");