From 3592724b1f7e635904c31ba09a61d6b7259c93e5 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 3 Jun 2009 13:11:29 +0200 Subject: Fixed failing test case. We are not guaranteed that the checked-for event is the last event, so we look for it in a list instead. --- tests/auto/qinputcontext/tst_qinputcontext.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 444672e..67a6819 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -87,7 +87,7 @@ void tst_QInputContext::maximumTextLength() class QFilterInputContext : public QInputContext { public: - QFilterInputContext() : lastType(QEvent::None) {} + QFilterInputContext() {} ~QFilterInputContext() {} QString identifierName() { return QString(); } @@ -99,12 +99,12 @@ public: bool filterEvent( const QEvent *event ) { - lastType = event->type(); + lastTypes.append(event->type()); return false; } public: - QEvent::Type lastType; + QList lastTypes; }; void tst_QInputContext::filterMouseEvents() @@ -117,7 +117,7 @@ void tst_QInputContext::filterMouseEvents() le.setInputContext(ic); QTest::mouseClick(&le, Qt::LeftButton); - QCOMPARE(ic->lastType, QEvent::MouseButtonRelease); + QVERIFY(ic->lastTypes.indexOf(QEvent::MouseButtonRelease) >= 0); le.setInputContext(0); } @@ -145,18 +145,20 @@ void tst_QInputContext::requestSoftwareInputPanel() // Testing single click panel activation. qApp->setAutoSipOnMouseFocus(true); QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(ic2->lastType, QEvent::RequestSoftwareInputPanel); + QVERIFY(ic2->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) >= 0); + ic2->lastTypes.clear(); // Testing double click panel activation. qApp->setAutoSipOnMouseFocus(false); QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QVERIFY(ic1->lastType != QEvent::RequestSoftwareInputPanel); + QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) < 0); QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(ic1->lastType, QEvent::RequestSoftwareInputPanel); + QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) >= 0); + ic1->lastTypes.clear(); // Testing right mouse button QTest::mouseClick(le1, Qt::RightButton, Qt::NoModifier, QPoint(5, 5)); - QVERIFY(ic1->lastType != QEvent::RequestSoftwareInputPanel); + QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) < 0); } void tst_QInputContext::closeSoftwareInputPanel() @@ -185,11 +187,11 @@ void tst_QInputContext::closeSoftwareInputPanel() // Testing that panel doesn't close between two input methods aware widgets. QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QVERIFY(ic2->lastType != QEvent::CloseSoftwareInputPanel); + QVERIFY(ic2->lastTypes.indexOf(QEvent::CloseSoftwareInputPanel) < 0); // Testing that panel closes when focusing non-aware widget. QTest::mouseClick(rb, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(ic2->lastType, QEvent::CloseSoftwareInputPanel); + QVERIFY(ic2->lastTypes.indexOf(QEvent::CloseSoftwareInputPanel) >= 0); } void tst_QInputContext::selections() -- cgit v0.12