summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 841fbbd955..0804f1241c 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -279,6 +279,7 @@ private slots:
void selectAndCursorPosition();
void inputMethodSelection();
+ void inputMethodTentativeCommit();
protected slots:
void editingFinished();
@@ -3831,5 +3832,30 @@ void tst_QLineEdit::inputMethodSelection()
QCOMPARE(testWidget->selectionStart(), 12);
}
+void tst_QLineEdit::inputMethodTentativeCommit()
+{
+ // test that basic tentative commit gets to text property on preedit state
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("test", attributes);
+ event.setTentativeCommitString("test");
+ QApplication::sendEvent(testWidget, &event);
+ QCOMPARE(testWidget->text(), QString("test"));
+
+ // tentative commit not allowed present in surrounding text
+ QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
+ QApplication::sendEvent(testWidget, &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
+
+ // if text with tentative commit does not validate, not allowed to be part of text property
+ testWidget->setText(""); // ensure input state is reset
+ QValidator *validator = new QIntValidator(0, 100);
+ testWidget->setValidator(validator);
+ QApplication::sendEvent(testWidget, &event);
+ QCOMPARE(testWidget->text(), QString(""));
+ testWidget->setValidator(0);
+ delete validator;
+}
+
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"