diff options
author | Andy Shaw <andy.shaw@qt.io> | 2017-07-13 14:37:00 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2017-07-24 09:51:17 +0000 |
commit | fcfee98f62b8a8b8c3b1ac11cbb23620788a586c (patch) | |
tree | 136e33e78f0afdafba23ff060a751e9414881435 /tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | |
parent | 3becc8527e632e5d54e3d05d5c4f72246100c963 (diff) |
QLineEdit: Don't move the cursor after internalInsert() has done so
internalInsert() will set the cursor to the right position which accounts
for any input mask set on the control as well. Therefore it will already
be placed at the next correct position and should not be changed again
after that.
Task-number: QTBUG-40943
Change-Id: Ic0f5fad6999ddd367e435ec4409a5db5b9eacb7b
Reviewed-by: Daniel Teske <qt@squorn.de>
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp')
-rw-r--r-- | tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 3f7fdd6f6f..b434e48500 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -147,6 +147,7 @@ private slots: void keypress_inputMask_data(); void keypress_inputMask(); + void keypress_inputMethod_inputMask(); void inputMaskAndValidator_data(); void inputMaskAndValidator(); @@ -803,6 +804,37 @@ void tst_QLineEdit::keypress_inputMask() QCOMPARE(testWidget->displayText(), expectedDisplayText); } +void tst_QLineEdit::keypress_inputMethod_inputMask() +{ + // Similar to the keypress_inputMask test, but this is done solely via + // input methods + QLineEdit *testWidget = ensureTestWidget(); + testWidget->setInputMask("AA.AA.AA"); + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("EE"); + QApplication::sendEvent(testWidget, &event); + } + QCOMPARE(testWidget->cursorPosition(), 3); + QCOMPARE(testWidget->text(), QStringLiteral("EE..")); + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("EE"); + QApplication::sendEvent(testWidget, &event); + } + QCOMPARE(testWidget->cursorPosition(), 6); + QCOMPARE(testWidget->text(), QStringLiteral("EE.EE.")); + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("EE"); + QApplication::sendEvent(testWidget, &event); + } + QCOMPARE(testWidget->cursorPosition(), 8); + QCOMPARE(testWidget->text(), QStringLiteral("EE.EE.EE")); +} void tst_QLineEdit::hasAcceptableInputMask_data() { |