Multiple simultaneous request support to Communication
[qtmeetings] / tests / IO / Communication / TestCommunication.cpp
index df94925..65fc2a7 100644 (file)
@@ -21,9 +21,9 @@ void TestCommunication::initTestCase()
     delete conn;
     conn = NULL;
        connect( iComm,
-                        SIGNAL( requestFinished( int, QHttp::Error ) ),
+                        SIGNAL( requestFinished( int, int ) ),
                         this,
-                        SLOT( requestFinished( int, QHttp::Error ) )
+                        SLOT( requestFinished( int, int ) )
                        );
 }
 
@@ -42,8 +42,7 @@ void TestCommunication::testPublicSignals()
        QCOMPARE( rp.isValid(), true );
        QSignalSpy rs( iComm, SIGNAL(requestStarted( int )) );
        QCOMPARE( rs.isValid(), true );
-       qRegisterMetaType<QHttp::Error>("QHttp::Error");
-       QSignalSpy rf( iComm, SIGNAL(requestFinished( int, QHttp::Error )) );
+       QSignalSpy rf( iComm, SIGNAL(requestFinished( int, int )) );
        QCOMPARE( rf.isValid(), true );
        
        iRequestId = iComm->request( "", QString("").toAscii() );
@@ -59,7 +58,7 @@ void TestCommunication::testPublicSignals()
        QCOMPARE( rf.count(), 1 );
        args = rf.takeFirst();
        QCOMPARE( args.at(0).type(), QVariant::Int );
-       QCOMPARE( args.at(1).typeName(), "QHttp::Error" );
+       QCOMPARE( args.at(1).type(), QVariant::Int );
        
        //verify readProgress
        QCOMPARE( rp.count(), 1 );
@@ -79,22 +78,36 @@ void TestCommunication::testRequestAndResponse()
     }
     QByteArray content = file.readAll();
 
-       iRequestId = iComm->request( command, content );
+       iError = 0;
+       int id_ok = iComm->request( command, content );
+       iRequestId = id_ok; 
        int id_fail = iComm->request( "", QString("").toAscii() );
        QVERIFY( iRequestId != 0 );
-       QCOMPARE( id_fail, 0 );
+       QVERIFY( id_fail != 0 );
+       qDebug() << "id_ok:" << id_ok;
+       qDebug() << "id_fail: " << id_fail;
        for(int i=0; iRequestId != 0 && i < 5000/250; i++ )
                QTest::qWait( 250 );
-       const QByteArray& response = iComm->response( 0 );
-       QVERIFY( response.contains("GetUserAvailabilityResponse") );
-       iRequestId = iComm->request( "", QString("").toAscii() );
-       QVERIFY( iRequestId != 0 );
-       QVERIFY( response.isEmpty() );
+       qDebug() << "iError:" << iError;
+       QVERIFY( iError == 0 );
+       QByteArray* response = iComm->response( id_ok );
+       QVERIFY( response != NULL );
+       QVERIFY( !response->isEmpty() );
+       if( response->contains("GetUserAvailabilityResponse") == FALSE )
+       {
+               QWARN( *response );
+       }
+       QVERIFY( response->contains("GetUserAvailabilityResponse") );
+       delete response;
+       response = iComm->response( 0 );
+       QVERIFY( response == NULL );
 }
 
-void TestCommunication::requestFinished( int aRequestId, QHttp::Error /*aError*/ )
+void TestCommunication::requestFinished( int aRequestId, int aError )
 {
-       QCOMPARE( aRequestId, iRequestId );
+       qDebug() << "TestCommunication::requestFinished:" << aRequestId << aError;
+       if( aRequestId == iRequestId )
+               iError = aError;
        iRequestId = 0;
 }