Fixed QLineEdit::inputMethodQuery() for Qt::ImHints
authorTasuku Suzuki <tasuku.suzuki@nokia.com>
Mon, 21 May 2012 18:05:00 +0000 (03:05 +0900)
committerQt by Nokia <qt-info@nokia.com>
Tue, 22 May 2012 23:11:27 +0000 (01:11 +0200)
It should return QWidget::inputMethodHints() instead of QVariant()

Change-Id: I01f5de8f2087ac67d125f54f08abed523653eb92
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
src/widgets/widgets/qlineedit.cpp
tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp

index cd3019b..a74c529 100644 (file)
@@ -1682,7 +1682,7 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
         else
             return QVariant(d->control->selectionStart());
     default:
-        return QVariant();
+        return QWidget::inputMethodQuery(property);
     }
 }
 
index 91827ec..7fe71b0 100644 (file)
@@ -283,6 +283,9 @@ private slots:
     void inputMethod();
     void inputMethodSelection();
 
+    void inputMethodQueryImHints_data();
+    void inputMethodQueryImHints();
+
 protected slots:
     void editingFinished();
 
@@ -3924,6 +3927,24 @@ void tst_QLineEdit::inputMethodSelection()
     QCOMPARE(selectionSpy.count(), 3);
 }
 
+Q_DECLARE_METATYPE(Qt::InputMethodHints)
+void tst_QLineEdit::inputMethodQueryImHints_data()
+{
+    QTest::addColumn<Qt::InputMethodHints>("hints");
+
+    QTest::newRow("None") << static_cast<Qt::InputMethodHints>(Qt::ImhNone);
+    QTest::newRow("Password") << static_cast<Qt::InputMethodHints>(Qt::ImhHiddenText);
+    QTest::newRow("Normal") << static_cast<Qt::InputMethodHints>(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+}
+
+void tst_QLineEdit::inputMethodQueryImHints()
+{
+    QFETCH(Qt::InputMethodHints, hints);
+    testWidget->setInputMethodHints(hints);
+
+    QVariant value = testWidget->inputMethodQuery(Qt::ImHints);
+    QCOMPARE(static_cast<Qt::InputMethodHints>(value.toInt()), hints);
+}
 
 QTEST_MAIN(tst_QLineEdit)
 #include "tst_qlineedit.moc"