summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-09-02 13:40:38 (GMT)
committeraxis <qt-info@nokia.com>2010-09-02 14:15:33 (GMT)
commitefe67ac8c1c59fd4cf8c793b549169f4e2926ac8 (patch)
tree7c7a59ed6d8000f67d8aa706b644536123d4dd73 /tests
parentf8c789a70ee3061dd81307ead82c47bb0f8041d5 (diff)
downloadQt-efe67ac8c1c59fd4cf8c793b549169f4e2926ac8.zip
Qt-efe67ac8c1c59fd4cf8c793b549169f4e2926ac8.tar.gz
Qt-efe67ac8c1c59fd4cf8c793b549169f4e2926ac8.tar.bz2
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
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qinputcontext/tst_qinputcontext.cpp124
1 files changed, 124 insertions, 0 deletions
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp
index 93813f9..52e655b 100644
--- a/tests/auto/qinputcontext/tst_qinputcontext.cpp
+++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp
@@ -49,6 +49,7 @@
#include <qradiobutton.h>
#include <qwindowsstyle.h>
#include <qdesktopwidget.h>
+#include <qpushbutton.h>
#ifdef Q_OS_SYMBIAN
#include <private/qt_s60_p.h>
@@ -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<Qt::InputMethodHints> ("inputMethodHints");
+ QTest::addColumn<QLineEdit::EchoMode> ("echoMode");
+ QTest::addColumn<QList<FepReplayEvent> > ("keyEvents");
+ QTest::addColumn<QString> ("finalString");
+
+ QList<FepReplayEvent> 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<QCoeFepInputContext *>(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<FepReplayEvent>, 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"