diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-05-25 16:02:41 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-29 08:54:52 +0200 |
commit | fbc66c4f42c23fdcec999d374018dff969f77140 (patch) | |
tree | 76504ada3cf740ba50d1b9c83ba7e2f5c3ed1fdb | |
parent | fd94887439dcc65ce30feda13ff8cbf0e30321db (diff) |
Update the cursor rectangle when password echo timer expires.
Ensures the cursor is positioned correctly is if the echo mask glyph
has a different width to the character it replaced.
Change-Id: I924234d4ae29cbb2e61638918005fcc3dc230993
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextinput/data/echoMode.qml | 4 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 13 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 06a572681a..95368fd465 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -3995,6 +3995,7 @@ void QQuickTextInput::timerEvent(QTimerEvent *event) } else if (event->timerId() == d->m_passwordEchoTimer.timerId()) { d->m_passwordEchoTimer.stop(); d->updateDisplayText(); + updateCursorRectangle(); } } diff --git a/tests/auto/quick/qquicktextinput/data/echoMode.qml b/tests/auto/quick/qquicktextinput/data/echoMode.qml index f8a6cf1c89..94e0a0e3a7 100644 --- a/tests/auto/quick/qquicktextinput/data/echoMode.qml +++ b/tests/auto/quick/qquicktextinput/data/echoMode.qml @@ -6,6 +6,10 @@ Rectangle { width: 400; height: 200; color: "green" TextInput { id: input; focus: true + width: 400; height: 200 text: "ABCDefgh" + cursorDelegate: Rectangle { + objectName: "cursor" + } } } diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 0a213d7f84..d857d9ce6b 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -2970,6 +2970,10 @@ void tst_qquicktextinput::passwordEchoDelay() QVERIFY(canvas.rootObject() != 0); QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput"))); + QVERIFY(input); + + QQuickItem *cursor = input->findChild<QQuickItem *>("cursor"); + QVERIFY(cursor); QChar fillChar = QLatin1Char('*'); @@ -2989,8 +2993,17 @@ void tst_qquicktextinput::passwordEchoDelay() QCOMPARE(input->displayText(), QString(4, fillChar)); QTest::keyPress(&canvas, '4'); QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); + QCOMPARE(input->cursorRectangle().topLeft(), cursor->pos()); + + // Verify the last character entered is replaced by the fill character after a delay. + // Also check the cursor position is updated to accomdate a size difference between + // the fill character and the replaced character. + QSignalSpy cursorSpy(input, SIGNAL(cursorRectangleChanged())); QTest::qWait(maskDelay); QTRY_COMPARE(input->displayText(), QString(5, fillChar)); + QCOMPARE(cursorSpy.count(), 1); + QCOMPARE(input->cursorRectangle().topLeft(), cursor->pos()); + QTest::keyPress(&canvas, '5'); QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5')); input->setFocus(false); |