From 4ca298f42bfdc908815cca06236827e5158a5f67 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 25 Jan 2012 09:40:10 +1000 Subject: Changed qlibrary unittest to use applicationDirPath() - Changed unittest to use QCoreApplication::applicationDirPath() instead of QDir::currentPath(). Change-Id: I398f7ea8b4426be85432d0eb3767ef6d59488d0a Reviewed-by: Kurt Korbatits Reviewed-by: Jason McDonald Reviewed-by: Rohan McGovern --- .../auto/corelib/plugin/qlibrary/tst_qlibrary.cpp | 68 +++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index c3f5eaa6a0..cff98de54f 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -103,8 +103,8 @@ static QString sys_qualifiedLibraryName(const QString &fileName) { - QString currDir = QDir::currentPath(); - return currDir + "/" + PREFIX + fileName + SUFFIX; + QString appDir = QCoreApplication::applicationDirPath(); + return appDir + "/" + PREFIX + fileName + SUFFIX; } QT_FORWARD_DECLARE_CLASS(QLibrary) @@ -170,8 +170,8 @@ void tst_QLibrary::version() QFETCH( int, resultversion ); #if !defined(Q_OS_AIX) && !defined(Q_OS_WIN) - QString currDir = QDir::currentPath(); - QLibrary library( currDir + QLatin1Char('/') + lib, loadversion ); + QString appDir = QCoreApplication::applicationDirPath(); + QLibrary library( appDir + QLatin1Char('/') + lib, loadversion ); QVERIFY2(library.load(), qPrintable(library.errorString())); VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion"); @@ -190,24 +190,24 @@ void tst_QLibrary::load_data() QTest::addColumn("lib"); QTest::addColumn("result"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); - QTest::newRow( "ok00" ) << currDir + "/mylib" << true; - QTest::newRow( "notexist" ) << currDir + "/nolib" << false; - QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << false; + QTest::newRow( "ok00" ) << appDir + "/mylib" << true; + QTest::newRow( "notexist" ) << appDir + "/nolib" << false; + QTest::newRow( "badlibrary" ) << appDir + "/qlibrary.pro" << false; #ifdef Q_OS_MAC - QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <("lib"); QTest::addColumn("result"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); - QTest::newRow( "mylib" ) << currDir + "/mylib" << true; + QTest::newRow( "mylib" ) << appDir + "/mylib" << true; #ifdef Q_OS_MAC if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3) QEXPECT_FAIL("mylib", "dlcompat cannot unload libraries", Continue); #endif - QTest::newRow( "ok01" ) << currDir + "/nolib" << false; + QTest::newRow( "ok01" ) << appDir + "/nolib" << false; } void tst_QLibrary::unload() @@ -272,11 +272,11 @@ void tst_QLibrary::resolve_data() QTest::addColumn("symbol"); QTest::addColumn("goodPointer"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); - QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << true; - QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << false; - QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << false; + QTest::newRow( "ok00" ) << appDir + "/mylib" << QString("mylibversion") << true; + QTest::newRow( "bad00" ) << appDir + "/mylib" << QString("nosym") << false; + QTest::newRow( "bad01" ) << appDir + "/nolib" << QString("nosym") << false; } void tst_QLibrary::resolve() @@ -353,16 +353,16 @@ void tst_QLibrary::errorString_data() QTest::addColumn("success"); QTest::addColumn("errorString"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*"); QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error"); #ifdef Q_OS_WINCE - QTest::newRow("bad resolve") << (int)Resolve << currDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in .*: .*"); + QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in .*: .*"); #else - QTest::newRow("bad resolve") << (int)Resolve << currDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*"); + QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*"); #endif - QTest::newRow("good resolve") << (int)Resolve << currDir + "/mylib" << true << QString("Unknown error"); + QTest::newRow("good resolve") << (int)Resolve << appDir + "/mylib" << true << QString("Unknown error"); #ifdef Q_OS_WIN QTest::newRow("bad load() with .dll suffix") << (int)Load << QString("nosuchlib.dll") << false << QString("Cannot load library nosuchlib.dll: The specified module could not be found."); @@ -431,17 +431,17 @@ void tst_QLibrary::loadHints_data() } #endif - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); lh |= QLibrary::ResolveAllSymbolsHint; # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << true; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.qt.test.mylib.dll" << int(lh) << true; + QTest::newRow( "ok01 (with suffix)" ) << appDir + "/mylib.dll" << int(lh) << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/mylib.dl2" << int(lh) << true; + QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << int(lh) << true; # elif defined Q_OS_UNIX - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << int(lh) << true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << true; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.qt.test.mylib.so" << int(lh) << true; + QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << int(lh) << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << int(lh) << true; + QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << int(lh) << true; # endif // Q_OS_UNIX } @@ -504,7 +504,7 @@ void tst_QLibrary::fileName() void tst_QLibrary::multipleInstancesForOneLibrary() { - QString lib = QDir::currentPath() + "/mylib"; + QString lib = QCoreApplication::applicationDirPath() + "/mylib"; { QLibrary lib1(lib); -- cgit v1.2.3