summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-09-27 11:37:14 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-10-01 05:02:34 (GMT)
commit4175e45658abd6913b5152a7637f8a23477b7c2d (patch)
treed83a1236eaf60456559905fc6f197202bf42fc43
parent89f383cdd9aa9d928341b15f99ecd9396b2f43cb (diff)
downloadQt-4175e45658abd6913b5152a7637f8a23477b7c2d.zip
Qt-4175e45658abd6913b5152a7637f8a23477b7c2d.tar.gz
Qt-4175e45658abd6913b5152a7637f8a23477b7c2d.tar.bz2
Fixed regression when typing in QTextControl based widgets on Symbian
The bug was that when querying for the maximum text length, the case where an invalid QVariant was returned (which is allowed) was not handled properly. This would lead to input being blocked by the input context when it shouldn't. RevBy: Sami Merila (cherry picked from commit 3bb3af84bef3c0472ca8ed0d5c6bb3c82320956d)
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp6
-rw-r--r--tests/auto/qinputcontext/tst_qinputcontext.cpp257
2 files changed, 208 insertions, 55 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index af86d77..4a1b9b9 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -238,8 +238,10 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event)
}
QString widgetText = focusWidget()->inputMethodQuery(Qt::ImSurroundingText).toString();
- int maxLength = focusWidget()->inputMethodQuery(Qt::ImMaximumTextLength).toInt();
- if (!keyEvent->text().isEmpty() && widgetText.size() + m_preeditString.size() >= maxLength) {
+ bool validLength;
+ int maxLength = focusWidget()->inputMethodQuery(Qt::ImMaximumTextLength).toInt(&validLength);
+ if (!keyEvent->text().isEmpty() && validLength
+ && widgetText.size() + m_preeditString.size() >= maxLength) {
// Don't send key events with string content if the widget is "full".
return true;
}
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp
index d077bc1..700a49b 100644
--- a/tests/auto/qinputcontext/tst_qinputcontext.cpp
+++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp
@@ -67,6 +67,8 @@ public:
tst_QInputContext() : m_phoneIsQwerty(false) {}
virtual ~tst_QInputContext() {}
+ template <class WidgetType> void symbianTestCoeFepInputContext_addData();
+
public slots:
void initTestCase();
void cleanupTestCase() {}
@@ -467,6 +469,7 @@ void tst_QInputContext::focusProxy()
void tst_QInputContext::symbianTestCoeFepInputContext_data()
{
#ifdef Q_OS_SYMBIAN
+ QTest::addColumn<QWidget *> ("editwidget");
QTest::addColumn<bool> ("inputMethodEnabled");
QTest::addColumn<Qt::InputMethodHints> ("inputMethodHints");
QTest::addColumn<int> ("maxLength"); // Zero for no limit
@@ -474,7 +477,23 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
QTest::addColumn<QList<FepReplayEvent> > ("keyEvents");
QTest::addColumn<QString> ("finalString");
QTest::addColumn<QString> ("preeditString");
+
+ symbianTestCoeFepInputContext_addData<QLineEdit>();
+ symbianTestCoeFepInputContext_addData<QPlainTextEdit>();
+ symbianTestCoeFepInputContext_addData<QTextEdit>();
+#endif
+}
+
+Q_DECLARE_METATYPE(QWidget *)
+Q_DECLARE_METATYPE(QLineEdit *)
+Q_DECLARE_METATYPE(QPlainTextEdit *)
+Q_DECLARE_METATYPE(QTextEdit *)
+
+template <class WidgetType>
+void tst_QInputContext::symbianTestCoeFepInputContext_addData()
+{
QList<FepReplayEvent> events;
+ QWidget *editwidget;
events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
@@ -487,7 +506,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
events << FepReplayEvent('2', '2', 0, 0);
events << FepReplayEvent('1', '1', 0, 0);
- QTest::newRow("Numbers (no FEP)")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers (no FEP)").toLocal8Bit())
+ << editwidget
<< false
<< Qt::InputMethodHints(Qt::ImhNone)
<< 0
@@ -495,7 +517,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("521")
<< QString("");
- QTest::newRow("Numbers and password mode (no FEP)")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers and password mode (no FEP)").toLocal8Bit())
+ << editwidget
<< false
<< Qt::InputMethodHints(Qt::ImhNone)
<< 0
@@ -503,7 +528,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("521")
<< QString("");
- QTest::newRow("Numbers")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 0
@@ -511,7 +539,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("521")
<< QString("");
- QTest::newRow("Numbers max length (no FEP)")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers max length (no FEP)").toLocal8Bit())
+ << editwidget
<< false
<< Qt::InputMethodHints(Qt::ImhNone)
<< 2
@@ -519,7 +550,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("21")
<< QString("");
- QTest::newRow("Numbers max length")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers max length").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 2
@@ -534,7 +568,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent(EEventKey, '5', '5', 0, 1);
events << FepReplayEvent(EEventKey, '5', '5', 0, 1);
events << FepReplayEvent(EEventKeyUp, '5', 0, 0, 0);
- QTest::newRow("Numbers and autorepeat (no FEP)")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers and autorepeat (no FEP)").toLocal8Bit())
+ << editwidget
<< false
<< Qt::InputMethodHints(Qt::ImhNone)
<< 0
@@ -552,7 +589,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent('5', '5', 0, 0);
events << FepReplayEvent('5', '5', 0, 0);
events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
- QTest::newRow("Multitap")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText)
<< 0
@@ -560,7 +600,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("Adh")
<< QString("");
- QTest::newRow("Multitap with no auto uppercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with no auto uppercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase)
<< 0
@@ -568,7 +611,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("adh")
<< QString("");
- QTest::newRow("Multitap with uppercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with uppercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferUppercase)
<< 0
@@ -576,7 +622,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("ADH")
<< QString("");
- QTest::newRow("Multitap with lowercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with lowercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
<< 0
@@ -584,7 +633,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("adh")
<< QString("");
- QTest::newRow("Multitap with forced uppercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with forced uppercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhUppercaseOnly)
<< 0
@@ -592,7 +644,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("ADH")
<< QString("");
- QTest::newRow("Multitap with forced lowercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with forced lowercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhLowercaseOnly)
<< 0
@@ -611,7 +666,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent('5', '5', 0, 0);
events << FepReplayEvent('5', '5', 0, 0);
events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
- QTest::newRow("Multitap with mode switch")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with mode switch").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText)
<< 0
@@ -626,7 +684,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent('8', '8', 0, 0);
events << FepReplayEvent('9', '9', 0, 0);
events << FepReplayEvent('9', '9', 0, 0);
- QTest::newRow("Multitap with unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText)
<< 0
@@ -635,7 +696,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< QString("Qt")
<< QString("x");
events << FepReplayEvent(2000);
- QTest::newRow("Multitap with committed text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with committed text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText)
<< 0
@@ -671,7 +735,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent('8', '8', 0, 0);
events << FepReplayEvent(2000);
events << FepReplayEvent(EStdKeyDevice3, EKeyDevice3, 0, 0); // Select key
- QTest::newRow("Multitap and numbers")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap and numbers").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText)
<< 0
@@ -679,7 +746,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("H778wmt")
<< QString("");
- QTest::newRow("T9 and numbers")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 and numbers").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 0
@@ -692,7 +762,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent('4', '4', 0, 0);
events << FepReplayEvent('4', '4', 0, 0);
events << FepReplayEvent(EStdKeyDevice3, EKeyDevice3, 0, 0); // Select key
- QTest::newRow("T9")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 0
@@ -700,7 +773,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("hi")
<< QString("");
- QTest::newRow("T9 with uppercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with uppercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferUppercase)
<< 0
@@ -708,7 +784,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("HI")
<< QString("");
- QTest::newRow("T9 with forced lowercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with forced lowercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhLowercaseOnly)
<< 0
@@ -716,7 +795,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("hi")
<< QString("");
- QTest::newRow("T9 with forced uppercase")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with forced uppercase").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhUppercaseOnly)
<< 0
@@ -724,7 +806,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("HI")
<< QString("");
- QTest::newRow("T9 with maxlength")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with maxlength").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhLowercaseOnly)
<< 1
@@ -746,7 +831,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
events << FepReplayEvent('8', '8', 0, 0);
events << FepReplayEvent('8', '8', 0, 0);
- QTest::newRow("T9 with movement and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with movement and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 0
@@ -754,7 +842,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("you hi")
<< QString("tv");
- QTest::newRow("T9 with movement, password and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with movement, password and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 0
@@ -762,7 +853,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wmt h")
<< QString("u");
- QTest::newRow("T9 with movement, maxlength, password and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with movement, maxlength, password and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 2
@@ -770,7 +864,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wh")
<< QString("");
- QTest::newRow("T9 with movement, maxlength and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with movement, maxlength and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 2
@@ -778,7 +875,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("hi")
<< QString("");
- QTest::newRow("Multitap with movement and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with movement and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
<< 0
@@ -786,7 +886,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wmt h")
<< QString("u");
- QTest::newRow("Multitap with movement, maxlength and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with movement, maxlength and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
<< 2
@@ -794,7 +897,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wh")
<< QString("");
- QTest::newRow("Numbers with movement")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers with movement").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 0
@@ -802,7 +908,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("96804488")
<< QString("");
- QTest::newRow("Numbers with movement and maxlength")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers with movement and maxlength").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 2
@@ -810,7 +919,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("44")
<< QString("");
- QTest::newRow("Numbers with movement, password and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers with movement, password and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 0
@@ -818,7 +930,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("9680448")
<< QString("8");
- QTest::newRow("Numbers with movement, maxlength, password and unfinished text")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers with movement, maxlength, password and unfinished text").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 2
@@ -827,7 +942,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< QString("44")
<< QString("");
events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
- QTest::newRow("T9 with movement")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with movement").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 0
@@ -835,7 +953,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("you htvi")
<< QString("");
- QTest::newRow("T9 with movement and password")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with movement and password").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 0
@@ -843,7 +964,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wmt hu")
<< QString("");
- QTest::newRow("T9 with movement, maxlength and password")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": T9 with movement, maxlength and password").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhPreferLowercase)
<< 2
@@ -851,7 +975,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wh")
<< QString("");
- QTest::newRow("Multitap with movement")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with movement").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
<< 0
@@ -859,7 +986,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wmt hu")
<< QString("");
- QTest::newRow("Multitap with movement and maxlength")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Multitap with movement and maxlength").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
<< 2
@@ -867,7 +997,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("wh")
<< QString("");
- QTest::newRow("Numbers with movement and password")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers with movement and password").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 0
@@ -875,7 +1008,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("96804488")
<< QString("");
- QTest::newRow("Numbers with movement, maxlength and password")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Numbers with movement, maxlength and password").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 2
@@ -888,7 +1024,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
// Test that the symbol key successfully does nothing when in number-only mode.
events << FepReplayEvent(EEventKeyDown, EStdKeyLeftFunc, 0, 0, 0);
events << FepReplayEvent(EEventKeyUp, EStdKeyLeftFunc, 0, 0, 0);
- QTest::newRow("Dead symbols key")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Dead symbols key").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 0
@@ -896,7 +1035,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< events
<< QString("")
<< QString("");
- QTest::newRow("Dead symbols key and password")
+ editwidget = new WidgetType;
+ QTest::newRow(QString(QString::fromLatin1(editwidget->metaObject()->className())
+ + ": Dead symbols key and password").toLocal8Bit())
+ << editwidget
<< true
<< Qt::InputMethodHints(Qt::ImhDigitsOnly)
<< 0
@@ -905,7 +1047,6 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data()
<< QString("")
<< QString("");
events.clear();
-#endif
}
void tst_QInputContext::symbianTestCoeFepInputContext()
@@ -918,6 +1059,7 @@ void tst_QInputContext::symbianTestCoeFepInputContext()
QSKIP("coefep is not the active input context; skipping test", SkipAll);
}
+ QFETCH(QWidget *, editwidget);
QFETCH(bool, inputMethodEnabled);
QFETCH(Qt::InputMethodHints, inputMethodHints);
QFETCH(int, maxLength);
@@ -933,30 +1075,39 @@ void tst_QInputContext::symbianTestCoeFepInputContext()
QWidget w;
QLayout *layout = new QVBoxLayout;
w.setLayout(layout);
- QLineEdit *lineedit = new QLineEdit;
- layout->addWidget(lineedit);
- lineedit->setFocus();
+
+ layout->addWidget(editwidget);
+ editwidget->setFocus();
#ifdef QT_KEYPAD_NAVIGATION
- lineedit->setEditFocus(true);
+ editwidget->setEditFocus(true);
#endif
w.show();
- lineedit->setAttribute(Qt::WA_InputMethodEnabled, inputMethodEnabled);
- lineedit->setInputMethodHints(inputMethodHints);
- if (maxLength > 0)
- lineedit->setMaxLength(maxLength);
- lineedit->setEchoMode(echoMode);
+ editwidget->setAttribute(Qt::WA_InputMethodEnabled, inputMethodEnabled);
+ editwidget->setInputMethodHints(inputMethodHints);
+ QLineEdit *lineedit = qobject_cast<QLineEdit *>(editwidget);
+ if (lineedit) {
+ if (maxLength > 0)
+ lineedit->setMaxLength(maxLength);
+ lineedit->setEchoMode(echoMode);
+ } else if (maxLength > 0 || echoMode != QLineEdit::Normal) {
+ // Only QLineEdits support these features so don't attempt any tests using those
+ // on other widgets.
+ return;
+ }
QTest::qWait(200);
foreach(FepReplayEvent event, keyEvents) {
- event.replay(lineedit);
+ event.replay(editwidget);
}
QApplication::processEvents();
- QCOMPARE(lineedit->text(), finalString);
+ QCOMPARE(editwidget->inputMethodQuery(Qt::ImSurroundingText).toString(), finalString);
QCOMPARE(ic->m_preeditString, preeditString);
+
+ delete editwidget;
#endif
}