From efe67ac8c1c59fd4cf8c793b549169f4e2926ac8 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 2 Sep 2010 15:40:38 +0200 Subject: Fixed a bug where passwords would not be committed when confirming. The bug happened when you were typing a password and pressing "Done" softkey very quickly. Because of the temporarily visible character, the widget would not contain the full string at the time of softkey triggering, only the *** part. Fixed by having the input context listen for softkey (command) events and commit the temporary character before the softkey action is triggered. AutoTest: Included Task: QTBUG-12949 RevBy: Miikka Heikkinen --- tests/auto/qinputcontext/tst_qinputcontext.cpp | 124 +++++++++++++++++++++++++ 1 file changed, 124 insertions(+) (limited to 'tests/auto/qinputcontext') diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 93813f9548..52e655b3db 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #ifdef Q_OS_SYMBIAN #include @@ -80,6 +81,8 @@ private slots: void focusProxy(); void symbianTestCoeFepInputContext_data(); void symbianTestCoeFepInputContext(); + void symbianTestCoeFepAutoCommit_data(); + void symbianTestCoeFepAutoCommit(); private: bool m_phoneIsQwerty; @@ -936,5 +939,126 @@ void tst_QInputContext::symbianTestCoeFepInputContext() #endif } +void tst_QInputContext::symbianTestCoeFepAutoCommit_data() +{ +#ifdef Q_OS_SYMBIAN + QTest::addColumn ("inputMethodHints"); + QTest::addColumn ("echoMode"); + QTest::addColumn > ("keyEvents"); + QTest::addColumn ("finalString"); + + QList events; + + events << FepReplayEvent('4', '4', 0, 0); + events << FepReplayEvent('4', '4', 0, 0); + events << FepReplayEvent('0', '0', 0, 0); + events << FepReplayEvent('9', '9', 0, 0); + events << FepReplayEvent('6', '6', 0, 0); + events << FepReplayEvent('8', '8', 0, 0); + QTest::newRow("Numbers") + << Qt::InputMethodHints(Qt::ImhDigitsOnly) + << QLineEdit::Normal + << events + << QString("440968"); + QTest::newRow("Numbers and password") + << Qt::InputMethodHints(Qt::ImhDigitsOnly) + << QLineEdit::Password + << events + << QString("440968"); + QTest::newRow("Multitap") + << Qt::InputMethodHints(Qt::ImhPreferLowercase | Qt::ImhNoPredictiveText) + << QLineEdit::Normal + << events + << QString("h wmt"); + QTest::newRow("T9") + << Qt::InputMethodHints(Qt::ImhPreferLowercase) + << QLineEdit::Normal + << events + << QString("hi you"); + QTest::newRow("Multitap with password") + << Qt::InputMethodHints(Qt::ImhPreferLowercase | Qt::ImhNoPredictiveText) + << QLineEdit::Password + << events + << QString("h wmt"); + QTest::newRow("T9 with password") + << Qt::InputMethodHints(Qt::ImhPreferLowercase) + << QLineEdit::Password + << events + << QString("h wmt"); +#endif +} + +void tst_QInputContext::symbianTestCoeFepAutoCommit() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian-only test", SkipAll); +#else + QCoeFepInputContext *ic = qobject_cast(qApp->inputContext()); + if (!ic) { + QSKIP("coefep is not the active input context; skipping test", SkipAll); + } + + QFETCH(Qt::InputMethodHints, inputMethodHints); + QFETCH(QLineEdit::EchoMode, echoMode); + QFETCH(QList, keyEvents); + QFETCH(QString, finalString); + + if (m_phoneIsQwerty) { + QSKIP("Skipping advanced input method tests on QWERTY phones", SkipSingle); + } + + QWidget w; + QLayout *layout = new QVBoxLayout; + w.setLayout(layout); + QLineEdit *lineedit = new QLineEdit; + layout->addWidget(lineedit); + lineedit->setFocus(); +#ifdef QT_KEYPAD_NAVIGATION + lineedit->setEditFocus(true); +#endif + QPushButton *pushButton = new QPushButton("Done"); + layout->addWidget(pushButton); + QAction softkey("Done", &w); + softkey.setSoftKeyRole(QAction::PositiveSoftKey); + w.addAction(&softkey); + w.show(); + + lineedit->setInputMethodHints(inputMethodHints); + lineedit->setEchoMode(echoMode); + + QTest::qWait(200); + foreach(FepReplayEvent event, keyEvents) { + event.replay(lineedit); + } + QApplication::processEvents(); + + QTest::mouseClick(pushButton, Qt::LeftButton); + + QCOMPARE(lineedit->text(), finalString); + QVERIFY(ic->m_preeditString.isEmpty()); + +#ifdef Q_WS_S60 + lineedit->inputContext()->reset(); + lineedit->clear(); + lineedit->setFocus(); +#ifdef QT_KEYPAD_NAVIGATION + lineedit->setEditFocus(true); +#endif + + QTest::qWait(200); + foreach(FepReplayEvent event, keyEvents) { + event.replay(lineedit); + } + QApplication::processEvents(); + + FepReplayEvent(EStdKeyDevice0, EKeyDevice0, 0, 0).replay(lineedit); // Left softkey + + QCOMPARE(lineedit->text(), finalString); + QVERIFY(ic->m_preeditString.isEmpty()); + +#endif // Q_WS_S60 +#endif // Q_OS_SYMBIAN +} + QTEST_MAIN(tst_QInputContext) #include "tst_qinputcontext.moc" -- cgit v1.2.3