diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 33 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 54 |
2 files changed, 14 insertions, 73 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 10f91895a7..4cf15879cc 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -83,7 +83,6 @@ public slots: void cleanup(); private slots: void sendEventsOnProcessEvents(); // this must be the first test - void getSetCheck(); void staticSetup(); void alert(); @@ -175,38 +174,6 @@ void tst_QApplication::sendEventsOnProcessEvents() QVERIFY(spy.recordedEvents.contains(QEvent::User + 1)); } -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_QApplication::getSetCheck() -{ - int argc = 0; - QApplication obj1(argc, 0, QApplication::GuiServer); - MyInputContext *var1 = new MyInputContext; - - // QApplication takes ownership, so check for reparenting: - obj1.setInputContext(var1); - QCOMPARE(var1->parent(), static_cast<QObject *>(&obj1)); - - // Test for self-assignment: - obj1.setInputContext(obj1.inputContext()); - QVERIFY(obj1.inputContext()); - QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext()); - - // Resetting the input context to 0 is not allowed: - QTest::ignoreMessage(QtWarningMsg, "QApplication::setInputContext: called with 0 input context"); - obj1.setInputContext(0); - - QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext()); -} class CloseEventTestWindow : public QWidget { 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<QInputContext *>(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; } |