tests/auto/qlibrary/tst_qlibrary.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   216 #if defined(Q_OS_SYMBIAN)
   216 #if defined(Q_OS_SYMBIAN)
   217     QString currDir;
   217     QString currDir;
   218 #else
   218 #else
   219     QString currDir = QDir::currentPath();
   219     QString currDir = QDir::currentPath();
   220 #endif
   220 #endif
   221     QTest::newRow( "ok00" ) << currDir + "/mylib" << (bool)true;
   221     QTest::newRow( "ok00" ) << currDir + "/mylib" << true;
   222     QTest::newRow( "notexist" ) << currDir + "/nolib" << (bool)false;
   222     QTest::newRow( "notexist" ) << currDir + "/nolib" << false;
   223     QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << (bool)false;
   223     QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << false;
   224 
   224 
   225 #ifdef Q_OS_MAC
   225 #ifdef Q_OS_MAC
   226     QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<(bool)true;
   226     QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<true;
   227 #endif
   227 #endif
   228 
   228 
   229 # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
   229 # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
   230     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << (bool)true;
   230     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << true;
   231     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << (bool)true;
   231     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << true;
   232     QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << (bool)true;
   232     QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << true;
   233 # elif defined Q_OS_UNIX
   233 # elif defined Q_OS_UNIX
   234     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << (bool)true;
   234     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << true;
   235     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << (bool)true;
   235     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << true;
   236     QTest::newRow( "ok03 (with non-standard suffix)" ) << currDir + "/system.trolltech.test.mylib.so" << (bool)true;
   236     QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << true;
   237 # endif  // Q_OS_UNIX
   237 # endif  // Q_OS_UNIX
   238 }
   238 }
   239 
   239 
   240 void tst_QLibrary::load()
   240 void tst_QLibrary::load()
   241 {
   241 {
   260     QString currDir;
   260     QString currDir;
   261 #else
   261 #else
   262     QString currDir = QDir::currentPath();
   262     QString currDir = QDir::currentPath();
   263 #endif
   263 #endif
   264 
   264 
   265     QTest::newRow( "mylib" ) << currDir + "/mylib" << (bool)TRUE;
   265     QTest::newRow( "mylib" ) << currDir + "/mylib" << true;
   266 #ifdef Q_WS_MAC
   266 #ifdef Q_WS_MAC
   267     if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3)
   267     if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3)
   268         QEXPECT_FAIL("mylib", "dlcompat cannot unload libraries", Continue);
   268         QEXPECT_FAIL("mylib", "dlcompat cannot unload libraries", Continue);
   269 #endif
   269 #endif
   270     QTest::newRow( "ok01" ) << currDir + "/nolib" << (bool)FALSE;
   270     QTest::newRow( "ok01" ) << currDir + "/nolib" << false;
   271 }
   271 }
   272 
   272 
   273 void tst_QLibrary::unload()
   273 void tst_QLibrary::unload()
   274 {
   274 {
   275     QFETCH( QString, lib );
   275     QFETCH( QString, lib );
   310     QString currDir;
   310     QString currDir;
   311 #else
   311 #else
   312     QString currDir = QDir::currentPath();
   312     QString currDir = QDir::currentPath();
   313 #endif
   313 #endif
   314 
   314 
   315     QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << (bool)TRUE;
   315     QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << true;
   316     QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << (bool)FALSE;
   316     QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << false;
   317     QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << (bool)FALSE;
   317     QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << false;
   318 }
   318 }
   319 
   319 
   320 void tst_QLibrary::resolve()
   320 void tst_QLibrary::resolve()
   321 {
   321 {
   322 #if defined(Q_OS_SYMBIAN)
   322 #if defined(Q_OS_SYMBIAN)
   477 
   477 
   478     QLibrary::LoadHints lh;
   478     QLibrary::LoadHints lh;
   479 #if defined(Q_OS_AIX)
   479 #if defined(Q_OS_AIX)
   480     if (QFile::exists("/usr/lib/libGL.a") || QFile::exists("/usr/X11R6/lib/libGL.a")) {
   480     if (QFile::exists("/usr/lib/libGL.a") || QFile::exists("/usr/X11R6/lib/libGL.a")) {
   481 # if QT_POINTER_SIZE == 4
   481 # if QT_POINTER_SIZE == 4
   482         QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr.o)" << int(QLibrary::LoadArchiveMemberHint) << (bool)TRUE;
   482         QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr.o)" << int(QLibrary::LoadArchiveMemberHint) << true;
   483 # else
   483 # else
   484         QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr_64.o)" << int(QLibrary::LoadArchiveMemberHint) << (bool)TRUE;
   484         QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr_64.o)" << int(QLibrary::LoadArchiveMemberHint) << true;
   485 #endif
   485 #endif
   486     }
   486     }
   487 #endif
   487 #endif
   488 
   488 
   489 #if defined(Q_OS_SYMBIAN)
   489 #if defined(Q_OS_SYMBIAN)
   492     QString currDir = QDir::currentPath();
   492     QString currDir = QDir::currentPath();
   493 #endif
   493 #endif
   494 
   494 
   495     lh |= QLibrary::ResolveAllSymbolsHint;
   495     lh |= QLibrary::ResolveAllSymbolsHint;
   496 # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
   496 # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
   497     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << (bool)TRUE;
   497     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << true;
   498     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << (bool)TRUE;
   498     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << true;
   499     QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << int(lh) << (bool)TRUE;
   499     QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << int(lh) << true;
   500 # elif defined Q_OS_UNIX
   500 # elif defined Q_OS_UNIX
   501     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << int(lh) << (bool)TRUE;
   501     QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << int(lh) << true;
   502     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << (bool)TRUE;
   502     QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << true;
   503     QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << int(lh) << (bool)TRUE;
   503     QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << int(lh) << true;
   504 # endif  // Q_OS_UNIX
   504 # endif  // Q_OS_UNIX
   505 }
   505 }
   506 
   506 
   507 void tst_QLibrary::loadHints()
   507 void tst_QLibrary::loadHints()
   508 {
   508 {
   533 
   533 
   534     QTest::newRow( "ok02" ) << sys_qualifiedLibraryName(QLatin1String("mylib"))
   534     QTest::newRow( "ok02" ) << sys_qualifiedLibraryName(QLatin1String("mylib"))
   535                             << sys_qualifiedLibraryName(QLatin1String("mylib"));
   535                             << sys_qualifiedLibraryName(QLatin1String("mylib"));
   536 #ifdef Q_WS_WIN
   536 #ifdef Q_WS_WIN
   537 #ifndef Q_OS_WINCE
   537 #ifndef Q_OS_WINCE
   538     QTest::newRow( "ok02" ) << "user32"
   538     QTest::newRow( "ok03" ) << "user32"
   539                             << "USER32.dll";
   539                             << "USER32.dll";
   540 #else
   540 #else
   541     QTest::newRow( "ok02" ) << "coredll"
   541     QTest::newRow( "ok03" ) << "coredll"
   542                             << "coredll.dll";
   542                             << "coredll.dll";
   543 #endif
   543 #endif
   544 #endif
   544 #endif
   545 }
   545 }
   546 
   546