diff options
Diffstat (limited to 'tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp')
-rw-r--r-- | tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 7eb739611a..6e472bff02 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -304,7 +304,7 @@ private slots: void QTBUG59957_clearButtonLeftmostAction(); void QTBUG_60319_setInputMaskCheckImSurroundingText(); void testQuickSelectionWithMouse(); - + void inputRejected(); protected slots: void editingFinished(); @@ -4820,5 +4820,44 @@ void tst_QLineEdit::testQuickSelectionWithMouse() QVERIFY(lineEdit.selectedText().endsWith(suffix)); } +void tst_QLineEdit::inputRejected() +{ + QLineEdit *testWidget = ensureTestWidget(); + QSignalSpy spyInputRejected(testWidget, SIGNAL(inputRejected())); + + QTest::keyClicks(testWidget, "abcde"); + QCOMPARE(spyInputRejected.count(), 0); + testWidget->setText("fghij"); + QCOMPARE(spyInputRejected.count(), 0); + testWidget->insert("k"); + QCOMPARE(spyInputRejected.count(), 0); + + testWidget->clear(); + testWidget->setMaxLength(5); + QTest::keyClicks(testWidget, "abcde"); + QCOMPARE(spyInputRejected.count(), 0); + QTest::keyClicks(testWidget, "fgh"); + QCOMPARE(spyInputRejected.count(), 3); + + testWidget->setMaxLength(INT_MAX); + testWidget->clear(); + spyInputRejected.clear(); + QIntValidator intValidator(1, 100); + testWidget->setValidator(&intValidator); + QTest::keyClicks(testWidget, "11"); + QCOMPARE(spyInputRejected.count(), 0); + QTest::keyClicks(testWidget, "a#"); + QCOMPARE(spyInputRejected.count(), 2); + + testWidget->clear(); + testWidget->setValidator(0); + spyInputRejected.clear(); + testWidget->setInputMask("999.999.999.999;_"); + QTest::keyClicks(testWidget, "11"); + QCOMPARE(spyInputRejected.count(), 0); + QTest::keyClicks(testWidget, "a#"); + QCOMPARE(spyInputRejected.count(), 2); +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" |