summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2012-02-15 14:30:44 +0200
committerQt by Nokia <qt-info@nokia.com>2012-02-17 04:28:49 +0100
commitc79f36c51f24905c188a1a6a7e2b38960713f093 (patch)
tree9982302a6b605ba5a0704eec1065f9536c7905ce /tests
parentece70ccba8718804bf8f42dafdcda00f8caa4d1a (diff)
Have input method hints on only classes using them
Removed inputMethodHints setter and getter from QQuickItem. No need to consume memory for input method hints on every item when only QQuickTextInput and QQuickTextEdit actually use them. Additionally introduced change signals on the editor hint properties. Change-Id: Ice380d4f4dd47fdde73d2468f4a44a7d1540ad45 Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com> Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp7
-rw-r--r--tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp20
2 files changed, 23 insertions, 4 deletions
diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
index eb8e711e6a..41c8546688 100644
--- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
@@ -1715,8 +1715,15 @@ void tst_qquicktextedit::inputMethodHints()
QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
QVERIFY(textEditObject != 0);
QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
+ QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged()));
textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+ textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+
+ QQuickTextEdit plainTextEdit;
+ QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone);
}
void tst_qquicktextedit::positionAt()
diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
index 16577376f0..c1768bd98a 100644
--- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
@@ -1948,14 +1948,23 @@ void tst_qquicktextinput::inputMethods()
QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
QVERIFY(input != 0);
QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText);
+ QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged()));
input->setInputMethodHints(Qt::ImhUppercaseOnly);
QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+ input->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+
+ // default value
+ QQuickTextInput plainInput;
+ QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone);
input->setFocus(true);
QVERIFY(input->hasActiveFocus() == true);
// test that input method event is committed
QInputMethodEvent event;
event.setCommitString( "My ", -12, 0);
+ QTRY_COMPARE(qGuiApp->focusObject(), input);
QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
QCOMPARE(input->text(), QString("My Hello world!"));
@@ -2589,7 +2598,7 @@ void tst_qquicktextinput::echoMode()
//Normal
ref &= ~Qt::ImhHiddenText;
ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
input->setEchoMode(QQuickTextInput::NoEcho);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String(""));
@@ -2597,14 +2606,17 @@ void tst_qquicktextinput::echoMode()
//NoEcho
ref |= Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
input->setEchoMode(QQuickTextInput::Password);
//Password
ref |= Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("********"));
- QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ // clearing input hints do not clear bits set by echo mode
+ input->setInputMethodHints(Qt::ImhNone);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
input->setPasswordCharacter(QChar('Q'));
QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
QCOMPARE(input->text(), initial);
@@ -2613,7 +2625,7 @@ void tst_qquicktextinput::echoMode()
//PasswordEchoOnEdit
ref &= ~Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));