From ce16d49569367fabe2fe6c69bb53cad4a8dd795d Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Mon, 3 Sep 2012 16:58:03 +0300 Subject: Avoid usage of deprecated QInputMethod::inputItem() in tests Change-Id: Ie6e37ab23b1bef99d294fe8a0acd95429a37a527 Reviewed-by: Joona Petrell --- .../qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 6 ++++-- .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'tests/auto/declarative') 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()); - 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()); - 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()); - 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); -- cgit v1.2.3