tests/auto/qftp/tst_qftp.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   616     } else {
   616     } else {
   617         addCommand( QFtp::Get, ftp->get( file ) );
   617         addCommand( QFtp::Get, ftp->get( file ) );
   618     }
   618     }
   619     addCommand( QFtp::Close, ftp->close() );
   619     addCommand( QFtp::Close, ftp->close() );
   620 
   620 
   621     QTestEventLoop::instance().enterLoop( 30 );
   621     QTestEventLoop::instance().enterLoop( 50 );
   622     delete ftp;
   622     delete ftp;
   623     if ( QTestEventLoop::instance().timeout() )
   623     if ( QTestEventLoop::instance().timeout() )
   624         QFAIL( "Network operation timed out" );
   624         QFAIL( "Network operation timed out" );
   625 
   625 
   626     ResMapIt it = resultMap.find( QFtp::Get );
   626     ResMapIt it = resultMap.find( QFtp::Get );
  1018         addCommand( QFtp::ConnectToHost, ftp->connectToHost( host ) );
  1018         addCommand( QFtp::ConnectToHost, ftp->connectToHost( host ) );
  1019         addCommand( QFtp::Login, ftp->login( user, password ) );
  1019         addCommand( QFtp::Login, ftp->login( user, password ) );
  1020         addCommand( QFtp::Put, ftp->put( QByteArray(), createFile ) );
  1020         addCommand( QFtp::Put, ftp->put( QByteArray(), createFile ) );
  1021         addCommand( QFtp::Close, ftp->close() );
  1021         addCommand( QFtp::Close, ftp->close() );
  1022 
  1022 
  1023         QTestEventLoop::instance().enterLoop( 30 );
  1023         QTestEventLoop::instance().enterLoop( 50 );
  1024         delete ftp;
  1024         delete ftp;
  1025         if ( QTestEventLoop::instance().timeout() )
  1025         if ( QTestEventLoop::instance().timeout() )
  1026             QFAIL( "Network operation timed out" );
  1026             QFAIL( "Network operation timed out" );
  1027 
  1027 
  1028         ResMapIt it = resultMap.find( QFtp::Put );
  1028         ResMapIt it = resultMap.find( QFtp::Put );
  1293     QTest::newRow( "get_fluke02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/rfc3252") << QByteArray();
  1293     QTest::newRow( "get_fluke02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/rfc3252") << QByteArray();
  1294 
  1294 
  1295     // Qt/CE and Symbian test environment has to less memory for this test
  1295     // Qt/CE and Symbian test environment has to less memory for this test
  1296 #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
  1296 #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
  1297     QByteArray bigData( 10*1024*1024, 0 );
  1297     QByteArray bigData( 10*1024*1024, 0 );
       
  1298 #else
       
  1299     QByteArray bigData( 1*1024*1024, 0 );
       
  1300 #endif
  1298     bigData.fill( 'B' );
  1301     bigData.fill( 'B' );
  1299 
       
  1300     QTest::newRow( "put_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/upload/abort_put") << bigData;
  1302     QTest::newRow( "put_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/upload/abort_put") << bigData;
  1301 #endif
       
  1302 }
  1303 }
  1303 
  1304 
  1304 void tst_QFtp::abort()
  1305 void tst_QFtp::abort()
  1305 {
  1306 {
       
  1307     // In case you wonder where the abort() actually happens, look into
       
  1308     // tst_QFtp::dataTransferProgress
       
  1309     //
  1306     QFETCH( QString, host );
  1310     QFETCH( QString, host );
  1307     QFETCH( uint, port );
  1311     QFETCH( uint, port );
  1308     QFETCH( QString, file );
  1312     QFETCH( QString, file );
  1309     QFETCH( QByteArray, uploadData );
  1313     QFETCH( QByteArray, uploadData );
  1310 
  1314 
  1322     else
  1326     else
  1323         addCommand( cmd, ftp->put( uploadData, file ) );
  1327         addCommand( cmd, ftp->put( uploadData, file ) );
  1324     addCommand( QFtp::Close, ftp->close() );
  1328     addCommand( QFtp::Close, ftp->close() );
  1325 
  1329 
  1326     for(int time = 0; time <= uploadData.length() / 30000; time += 30) {
  1330     for(int time = 0; time <= uploadData.length() / 30000; time += 30) {
  1327         QTestEventLoop::instance().enterLoop( 30 );
  1331         QTestEventLoop::instance().enterLoop( 50 );
  1328         if(ftp->currentCommand() == QFtp::None)
  1332         if(ftp->currentCommand() == QFtp::None)
  1329             break;
  1333             break;
  1330     }
  1334     }
  1331     delete ftp;
  1335     delete ftp;
  1332     if ( QTestEventLoop::instance().timeout() )
  1336     if ( QTestEventLoop::instance().timeout() )
  1402     addCommand( QFtp::Login, ftp->login() );
  1406     addCommand( QFtp::Login, ftp->login() );
  1403     addCommand( QFtp::Get, ftp->get( file ) );
  1407     addCommand( QFtp::Get, ftp->get( file ) );
  1404     if ( type != 0 )
  1408     if ( type != 0 )
  1405         addCommand( QFtp::Close, ftp->close() );
  1409         addCommand( QFtp::Close, ftp->close() );
  1406 
  1410 
  1407     QTestEventLoop::instance().enterLoop( 30 );
  1411     QTestEventLoop::instance().enterLoop( 40 );
  1408     if ( QTestEventLoop::instance().timeout() )
  1412     if ( QTestEventLoop::instance().timeout() )
  1409         QFAIL( "Network operation timed out" );
  1413         QFAIL( "Network operation timed out" );
  1410 
  1414 
  1411     ResMapIt it = resultMap.find( QFtp::Get );
  1415     ResMapIt it = resultMap.find( QFtp::Get );
  1412     QVERIFY( it != resultMap.end() );
  1416     QVERIFY( it != resultMap.end() );
  1491     addCommand( QFtp::ConnectToHost, ftp->connectToHost( host, port ) );
  1495     addCommand( QFtp::ConnectToHost, ftp->connectToHost( host, port ) );
  1492     addCommand( QFtp::Login, ftp->login( user, password ) );
  1496     addCommand( QFtp::Login, ftp->login( user, password ) );
  1493     addCommand( QFtp::Cd, ftp->cd( dir ) );
  1497     addCommand( QFtp::Cd, ftp->cd( dir ) );
  1494     addCommand( QFtp::List, ftp->list() );
  1498     addCommand( QFtp::List, ftp->list() );
  1495 
  1499 
  1496     QTestEventLoop::instance().enterLoop( 30 );
  1500     QTestEventLoop::instance().enterLoop( 50 );
  1497 
  1501 
  1498     delete ftp;
  1502     delete ftp;
  1499     if ( QTestEventLoop::instance().timeout() ) {
  1503     if ( QTestEventLoop::instance().timeout() ) {
  1500         QFAIL( "Network operation timed out" );
  1504         QFAIL( "Network operation timed out" );
  1501     }
  1505     }
  1919     inFileDirExistsFunction = TRUE;
  1923     inFileDirExistsFunction = TRUE;
  1920     QTestEventLoop::instance().enterLoop( 30 );
  1924     QTestEventLoop::instance().enterLoop( 30 );
  1921     delete ftp;
  1925     delete ftp;
  1922     if ( QTestEventLoop::instance().timeout() ) {
  1926     if ( QTestEventLoop::instance().timeout() ) {
  1923         // ### make this test work
  1927         // ### make this test work
  1924         qWarning("Network operation timed out");
  1928         qWarning("tst_QFtp::fileExists: Network operation timed out");
  1925         return FALSE;
  1929         return FALSE;
  1926     }
  1930     }
  1927     inFileDirExistsFunction = FALSE;
  1931     inFileDirExistsFunction = FALSE;
  1928 
  1932 
  1929     ResMapIt it = resultMap.find( QFtp::ConnectToHost );
  1933     ResMapIt it = resultMap.find( QFtp::ConnectToHost );
  1970     QTestEventLoop::instance().enterLoop( 30 );
  1974     QTestEventLoop::instance().enterLoop( 30 );
  1971     delete ftp;
  1975     delete ftp;
  1972     if ( QTestEventLoop::instance().timeout() ) {
  1976     if ( QTestEventLoop::instance().timeout() ) {
  1973         // ### make this test work
  1977         // ### make this test work
  1974         // QFAIL( "Network operation timed out" );
  1978         // QFAIL( "Network operation timed out" );
       
  1979         qWarning("tst_QFtp::dirExists: Network operation timed out");
  1975         return FALSE;
  1980         return FALSE;
  1976     }
  1981     }
  1977     inFileDirExistsFunction = FALSE;
  1982     inFileDirExistsFunction = FALSE;
  1978 
  1983 
  1979     ResMapIt it = resultMap.find( QFtp::Cd );
  1984     ResMapIt it = resultMap.find( QFtp::Cd );