From 8ad583b7f9cd4ab450e636bc2c0626975397aa86 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Mon, 2 Jan 2012 17:42:00 +0200 Subject: Removed QApplication::setInputContext() Obsoleted by platform input context. Setting a custom QInputContext wouldn't work properly anymore. Change-Id: I966573a82fdd7530544878513a655eae7b3ad67b Reviewed-by: Joona Petrell --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 54 ++++++----------------- 1 file changed, 14 insertions(+), 40 deletions(-) (limited to 'tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index d8d9589691..16bb5d345b 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -442,16 +442,6 @@ bool tst_QWidget::ensureScreenSize(int width, int height) return (available.width() >= width && available.height() >= height); } -class MyInputContext : public QInputContext -{ -public: - MyInputContext() : QInputContext() {} - QString identifierName() { return QString("NoName"); } - QString language() { return QString("NoLanguage"); } - void reset() {} - bool isComposing() const { return false; } -}; - // Testing get/set functions void tst_QWidget::getSetCheck() { @@ -587,13 +577,6 @@ void tst_QWidget::getSetCheck() obj1.setAcceptDrops(true); QCOMPARE(true, obj1.acceptDrops()); - // QInputContext * QWidget::inputContext() - MyInputContext *var13 = new MyInputContext; - qApp->setInputContext(var13); - QCOMPARE((QInputContext *)0, obj1.inputContext()); // The widget by default doesn't have the WA_InputMethodEnabled attribute - obj1.setAttribute(Qt::WA_InputMethodEnabled); - QCOMPARE(static_cast(var13), obj1.inputContext()); - // bool QWidget::autoFillBackground() // void QWidget::setAutoFillBackground(bool) obj1.setAutoFillBackground(false); @@ -9128,23 +9111,10 @@ void tst_QWidget::openModal_taskQTBUG_5804() delete win; } -class InputContextTester : public QInputContext -{ - Q_OBJECT -public: - QString identifierName() { return QString(); } - bool isComposing() const { return false; } - QString language() { return QString(); } - void reset() { ++resets; } - int resets; -}; - void tst_QWidget::focusProxyAndInputMethods() { - InputContextTester *inputContext = new InputContextTester; QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint); toplevel->setAttribute(Qt::WA_InputMethodEnabled, true); - qApp->setInputContext(inputContext); // ownership is transferred QWidget *child = new QWidget(toplevel); child->setFocusProxy(toplevel); @@ -9167,20 +9137,24 @@ void tst_QWidget::focusProxyAndInputMethods() // and that the input method gets the focus proxy passed // as the focus widget instead of the child widget. // otherwise input method queries go to the wrong widget + QInputContext *inputContext = qApp->inputContext(); + if (inputContext) { + QCOMPARE(inputContext->focusWidget(), toplevel); - QCOMPARE(inputContext->focusWidget(), toplevel); + child->setAttribute(Qt::WA_InputMethodEnabled, false); + QVERIFY(!inputContext->focusWidget()); - child->setAttribute(Qt::WA_InputMethodEnabled, false); - QVERIFY(!inputContext->focusWidget()); - - child->setAttribute(Qt::WA_InputMethodEnabled, true); - QCOMPARE(inputContext->focusWidget(), toplevel); + child->setAttribute(Qt::WA_InputMethodEnabled, true); + QCOMPARE(inputContext->focusWidget(), toplevel); - child->setEnabled(false); - QVERIFY(!inputContext->focusWidget()); + child->setEnabled(false); + QVERIFY(!inputContext->focusWidget()); - child->setEnabled(true); - QCOMPARE(inputContext->focusWidget(), toplevel); + child->setEnabled(true); + QCOMPARE(inputContext->focusWidget(), toplevel); + } else { + qDebug() << "No input context set, skipping QInputContext::focusWidget() test"; + } delete toplevel; } -- cgit v1.2.3