added missing protocol messages

This commit is contained in:
Volker Fischer 2013-08-18 18:05:28 +00:00
parent 0d93612214
commit f85115d548

View File

@ -42,16 +42,17 @@ class CTestbench : public QObject
public: public:
CTestbench ( QString sNewAddress, quint16 iNewPort ) : CTestbench ( QString sNewAddress, quint16 iNewPort ) :
sAddress ( sNewAddress ), iPort ( iNewPort ) sAddress ( sNewAddress ),
iPort ( iNewPort )
{ {
// bind socket (try 100 port numbers) // bind socket (try 100 port numbers)
quint16 iPortIncrement = 0; // start value: port nubmer plus ten quint16 iPortIncrement = 0; // start value: port nubmer plus ten
bool bSuccess = false; // initialization for while loop bool bSuccess = false; // initialization for while loop
while ( !bSuccess && ( iPortIncrement <= 100 ) ) while ( !bSuccess && ( iPortIncrement <= 100 ) )
{ {
bSuccess = UdpSocket.bind ( bSuccess = UdpSocket.bind ( QHostAddress( QHostAddress::Any ),
QHostAddress( QHostAddress::Any ), 22222 + iPortIncrement );
22222 + iPortIncrement );
iPortIncrement++; iPortIncrement++;
} }
@ -76,12 +77,14 @@ protected:
QString GenRandomString() const QString GenRandomString() const
{ {
const int iLen = GenRandomIntInRange ( 0, 111 ); const int iLen = GenRandomIntInRange ( 0, 111 );
QString strReturn = ""; QString strReturn = "";
for ( int i = 0; i < iLen; i++ ) for ( int i = 0; i < iLen; i++ )
{ {
strReturn += static_cast<char> ( GenRandomIntInRange ( 0, 255 ) ); strReturn += static_cast<char> ( GenRandomIntInRange ( 0, 255 ) );
} }
return strReturn; return strReturn;
} }
@ -99,9 +102,10 @@ public slots:
CServerCoreInfo ServerInfo; CServerCoreInfo ServerInfo;
CVector<CServerInfo> vecServerInfo ( 1 ); CVector<CServerInfo> vecServerInfo ( 1 );
CHostAddress CurHostAddress ( QHostAddress ( sAddress ), iPort ); CHostAddress CurHostAddress ( QHostAddress ( sAddress ), iPort );
CChannelCoreInfo ChannelCoreInfo;
// generate random protocol message // generate random protocol message
switch ( GenRandomIntInRange ( 0, 21 ) ) switch ( GenRandomIntInRange ( 0, 25 ) )
{ {
case 0: case 0:
Protocol.CreateJitBufMes ( GenRandomIntInRange ( 0, 10 ) ); Protocol.CreateJitBufMes ( GenRandomIntInRange ( 0, 10 ) );
@ -113,7 +117,7 @@ public slots:
case 2: case 2:
Protocol.CreateChanGainMes ( GenRandomIntInRange ( 0, 20 ), Protocol.CreateChanGainMes ( GenRandomIntInRange ( 0, 20 ),
GenRandomIntInRange ( -100, 100 ) ); GenRandomIntInRange ( -100, 100 ) );
break; break;
case 3: case 3:
@ -125,22 +129,48 @@ public slots:
break; break;
case 4: case 4:
Protocol.CreateReqConnClientsList(); vecChanInfo[0].iChanID = GenRandomIntInRange ( -2, 20 );
vecChanInfo[0].iIpAddr = GenRandomIntInRange ( 0, 100000 );
vecChanInfo[0].strName = GenRandomString();
Protocol.CreateConClientListMes ( vecChanInfo );
break; break;
case 5: case 5:
Protocol.CreateChanNameMes ( GenRandomString() ); Protocol.CreateReqConnClientsList();
break; break;
case 6: case 6:
Protocol.CreateReqChanInfoMes(); Protocol.CreateChanNameMes ( GenRandomString() );
break; break;
case 7: case 7:
Protocol.CreateChatTextMes ( GenRandomString() ); ChannelCoreInfo.eCountry =
static_cast<QLocale::Country> ( GenRandomIntInRange ( 0, 100 ) );
ChannelCoreInfo.eSkillLevel =
static_cast<ESkillLevel> ( GenRandomIntInRange ( 0, 3 ) );
ChannelCoreInfo.iInstrument = GenRandomIntInRange ( 0, 100000 );
ChannelCoreInfo.strCity = GenRandomString();
ChannelCoreInfo.strName = GenRandomString();
Protocol.CreateChanInfoMes ( ChannelCoreInfo );
break; break;
case 8: case 8:
Protocol.CreateReqChanInfoMes();
break;
case 9:
Protocol.CreateChatTextMes ( GenRandomString() );
break;
case 10:
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ) );
break;
case 11:
NetTrProps.eAudioCodingType = NetTrProps.eAudioCodingType =
static_cast<EAudComprType> ( GenRandomIntInRange ( 0, 2 ) ); static_cast<EAudComprType> ( GenRandomIntInRange ( 0, 2 ) );
@ -154,26 +184,30 @@ public slots:
Protocol.CreateNetwTranspPropsMes ( NetTrProps ); Protocol.CreateNetwTranspPropsMes ( NetTrProps );
break; break;
case 9: case 12:
Protocol.CreateReqNetwTranspPropsMes(); Protocol.CreateReqNetwTranspPropsMes();
break; break;
case 10: case 13:
Protocol.CreateOpusSupportedMes();
break;
case 14:
Protocol.CreateCLPingMes ( CurHostAddress, Protocol.CreateCLPingMes ( CurHostAddress,
GenRandomIntInRange ( -2, 1000 ) ); GenRandomIntInRange ( -2, 1000 ) );
break; break;
case 11: case 15:
Protocol.CreateCLPingWithNumClientsMes ( CurHostAddress, Protocol.CreateCLPingWithNumClientsMes ( CurHostAddress,
GenRandomIntInRange ( -2, 1000 ), GenRandomIntInRange ( -2, 1000 ),
GenRandomIntInRange ( -2, 1000 ) ); GenRandomIntInRange ( -2, 1000 ) );
break; break;
case 12: case 16:
Protocol.CreateCLServerFullMes ( CurHostAddress ); Protocol.CreateCLServerFullMes ( CurHostAddress );
break; break;
case 13: case 17:
ServerInfo.bPermanentOnline = ServerInfo.bPermanentOnline =
static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) ); static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) );
@ -190,11 +224,11 @@ public slots:
ServerInfo ); ServerInfo );
break; break;
case 14: case 18:
Protocol.CreateCLUnregisterServerMes ( CurHostAddress ); Protocol.CreateCLUnregisterServerMes ( CurHostAddress );
break; break;
case 15: case 19:
vecServerInfo[0].bPermanentOnline = vecServerInfo[0].bPermanentOnline =
static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) ); static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) );
@ -212,29 +246,29 @@ public slots:
vecServerInfo ); vecServerInfo );
break; break;
case 16: case 20:
Protocol.CreateCLReqServerListMes ( CurHostAddress ); Protocol.CreateCLReqServerListMes ( CurHostAddress );
break; break;
case 17: case 21:
Protocol.CreateCLSendEmptyMesMes ( CurHostAddress, Protocol.CreateCLSendEmptyMesMes ( CurHostAddress,
CurHostAddress ); CurHostAddress );
break; break;
case 18: case 22:
Protocol.CreateCLEmptyMes ( CurHostAddress ); Protocol.CreateCLEmptyMes ( CurHostAddress );
break; break;
case 19: case 23:
Protocol.CreateCLDisconnection ( CurHostAddress ); Protocol.CreateCLDisconnection ( CurHostAddress );
break; break;
case 20: case 24:
Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ), Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ),
GenRandomIntInRange ( -100, 100 ) ); GenRandomIntInRange ( -100, 100 ) );
break; break;
case 21: case 25:
// arbitrary "audio" packet (with random sizes) // arbitrary "audio" packet (with random sizes)
CVector<uint8_t> vecMessage ( GenRandomIntInRange ( 1, 1000 ) ); CVector<uint8_t> vecMessage ( GenRandomIntInRange ( 1, 1000 ) );
OnSendProtMessage ( vecMessage ); OnSendProtMessage ( vecMessage );