summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp11
2 files changed, 11 insertions, 6 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 17b74687..36bab0c7 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -90,7 +90,8 @@ void sendPreeditText(const QString &text, int cursor)
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor,
text.length(), QVariant()));
QInputMethodEvent event(text, attributes);
- QApplication::sendEvent(qApp->inputMethod()->inputItem(), &event);
+ if (qApp->focusObject())
+ QApplication::sendEvent(qApp->focusObject(), &event);
}
@@ -2502,7 +2503,8 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
sendPreeditText(preeditText, 0);
ic.clear();
QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(qApp->inputMethod()->inputItem(), &imEvent);
+ if (qApp->focusObject())
+ QApplication::sendEvent(qApp->focusObject(), &imEvent);
currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
QCOMPARE(currentRect, previousRect);
#if defined(Q_WS_X11)
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index dbce1881..255625f7 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -84,7 +84,7 @@ void sendPreeditText(const QString &text, int cursor)
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor,
text.length(), QVariant()));
QInputMethodEvent event(text, attributes);
- QApplication::sendEvent(qApp->inputMethod()->inputItem(), &event);
+ QApplication::sendEvent(qApp->focusObject(), &event);
}
@@ -2672,7 +2672,8 @@ void tst_qdeclarativetextinput::inputMethodComposing()
{
QInputMethodEvent inputEvent(text.mid(3), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(qApp->inputMethod()->inputItem(), &inputEvent);
+ if (qApp->focusObject())
+ QApplication::sendEvent(qApp->focusObject(), &inputEvent);
}
QCOMPARE(input.isInputMethodComposing(), true);
@@ -2680,7 +2681,8 @@ void tst_qdeclarativetextinput::inputMethodComposing()
{
QInputMethodEvent inputEvent(text.mid(12), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(qApp->inputMethod()->inputItem(), &inputEvent);
+ if (qApp->focusObject())
+ QApplication::sendEvent(qApp->focusObject(), &inputEvent);
}
QCOMPARE(input.isInputMethodComposing(), true);
@@ -2688,7 +2690,8 @@ void tst_qdeclarativetextinput::inputMethodComposing()
{
QInputMethodEvent inputEvent;
- QApplication::sendEvent(qApp->inputMethod()->inputItem(), &inputEvent);
+ if (qApp->focusObject())
+ QApplication::sendEvent(qApp->focusObject(), &inputEvent);
}
QCOMPARE(input.isInputMethodComposing(), false);
QCOMPARE(spy.count(), 2);