summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2011-10-12 11:08:00 +0300
committerQt by Nokia <qt-info@nokia.com>2011-11-05 23:47:02 +0100
commit8bd40fef0733a4796a308b3bc137a05296e142c4 (patch)
tree10ff24637ab73cd1516bda8c39bd121aac412e97 /tests/auto/widgets
parent4b3d88a9c67402b6a234d597bab25846f039bbdb (diff)
Support tentative commit string with input method.
Tentative commit string allows input method to notify editor what is expected to be committed in the place of preedit. This commit adds such support in QLineEdit. Change-Id: If855619bc6843652db0d6254f7e7063bb8ad0936 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/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"