From 962a44bb6113d095b64eb90fa5e6c70944c9c16a Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 13 Aug 2009 13:48:47 +0200 Subject: We feel that test case should be changed, as we cant expect that order of the event hansling will be same on all platforms. For example, on Symbian quit will happen first, on Linux not. It is better to check if we processed 2 events in total. Reviewed by: Axis --- tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp | 28 +++++++--------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp index 501f257..8f9dab9 100644 --- a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp @@ -70,10 +70,9 @@ tst_QSocketNotifier::~tst_QSocketNotifier() class UnexpectedDisconnectTester : public QObject { Q_OBJECT - int sequence; - public: QNativeSocketEngine *readEnd1, *readEnd2; + int sequence; UnexpectedDisconnectTester(QNativeSocketEngine *s1, QNativeSocketEngine *s2) : readEnd1(s1), readEnd2(s2), sequence(0) @@ -86,25 +85,18 @@ public: connect(notifier2, SIGNAL(activated(int)), SLOT(handleActivated())); } - const int getSequence() { - return sequence; - } - - void incSequence() { - ++sequence; - } - public slots: void handleActivated() { char data1[1], data2[1]; - incSequence(); - if (getSequence() == 1) { + ++sequence; + if (sequence == 1) { // read from both ends (void) readEnd1->read(data1, sizeof(data1)); (void) readEnd2->read(data2, sizeof(data2)); emit finished(); - } else if (getSequence() == 2) { + } else if (sequence == 2) { + // we should never get here QCOMPARE(readEnd2->read(data2, sizeof(data2)), qint64(-2)); QVERIFY(readEnd2->isValid()); } @@ -169,16 +161,12 @@ void tst_QSocketNotifier::unexpectedDisconnection() // we have to wait until sequence value changes // as any event can make us jump out processing QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); - } while(tester.getSequence() <= 0); + } while(tester.sequence <= 0); QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState); QVERIFY(readEnd2.state() == QAbstractSocket::ConnectedState); -#if defined(Q_OS_WIN) - qWarning("### Windows returns 1 activation, Unix returns 2."); - QCOMPARE(tester.getSequence(), 1); -#else - QCOMPARE(tester.getSequence(), 2); -#endif + + QCOMPARE(tester.sequence, 2); readEnd1.close(); readEnd2.close(); -- cgit v0.12