summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin/qlibrary
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/plugin/qlibrary')
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib/lib.pro5
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro12
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst/tst.pro9
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp40
4 files changed, 21 insertions, 45 deletions
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
index f95e6338e0..d8551faddc 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
+++ b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
@@ -10,5 +10,6 @@ wince*: DEFINES += WIN32_MSVC
win32-msvc: DEFINES += WIN32_MSVC
win32-borland: DEFINES += WIN32_BORLAND
-#no special install rule for the library used by test
-INSTALLS =
+# This project is testdata for tst_qlibrary
+target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary
+INSTALLS += target
diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
index 835240af22..7d319d644e 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
+++ b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
@@ -26,13 +26,17 @@ win32 {
src = $(DESTDIR)$(TARGET)
files = libmylib.so2 system.trolltech.test.mylib.so
}
+
+# This project is testdata for tst_qlibrary
+target.path = $$[QT_INSTALL_TESTS]$${QMAKE_DIR_SEP}tst_qlibrary
+renamed_target.path = $$target.path
+
for(file, files) {
QMAKE_POST_LINK += $$QMAKE_COPY $$src ..$$QMAKE_DIR_SEP$$file &&
+ renamed_target.extra += $$QMAKE_COPY $$src $(INSTALL_ROOT)$${target.path}$$QMAKE_DIR_SEP$$file &&
CLEAN_FILES += ../$$file
}
+renamed_target.extra = $$member(renamed_target.extra, 0, -2)
QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2)
-#no special install rule for the library used by test
-INSTALLS =
-
-
+INSTALLS += target renamed_target
diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
index a1854ad419..6e71ec8ff9 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
@@ -11,11 +11,4 @@ win32 {
}
}
-wince* {
- addFiles.files = ../*.dll ../*.dl2 ../mylib_noextension
- addFiles.path = .
- DEPLOYMENT += addFiles
- DEFINES += SRCDIR=\\\"\\\"
-} else {
- DEFINES += SRCDIR=\\\"$$PWD/../\\\"
-}
+TESTDATA += ../library_path/invalid.so
diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
index 97e38ff2ef..c1f090afc5 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
@@ -115,10 +115,6 @@ class tst_QLibrary : public QObject
{
Q_OBJECT
-public:
- tst_QLibrary();
- virtual ~tst_QLibrary();
-
enum QLibraryOperation {
Load = 1,
Unload = 2,
@@ -127,6 +123,8 @@ enum QLibraryOperation {
DontSetFileName = 0x100
};
private slots:
+ void initTestCase();
+
void load();
void load_data();
void library_data();
@@ -146,33 +144,17 @@ private slots:
void fileName_data();
void fileName();
void multipleInstancesForOneLibrary();
-
-#ifdef Q_OS_WINCE
-private:
- QCoreApplication* app;
-#endif
};
-tst_QLibrary::tst_QLibrary()
-
-{
-#ifdef Q_OS_WINCE
- char* argv = "app";
- int argc = 1;
- app = new QCoreApplication(argc,&argv);
-#endif
-}
+typedef int (*VersionFunction)(void);
-tst_QLibrary::~tst_QLibrary()
+void tst_QLibrary::initTestCase()
{
-#ifdef Q_OS_WINCE
- app->quit();
-#endif
+ // chdir to our testdata directory, and use relative paths in some tests.
+ QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath();
+ QVERIFY2(QDir::setCurrent(testdatadir), qPrintable("Could not chdir to " + testdatadir));
}
-
-typedef int (*VersionFunction)(void);
-
void tst_QLibrary::version_data()
{
QTest::addColumn<QString>("lib");
@@ -376,10 +358,6 @@ void tst_QLibrary::errorString_data()
QString currDir = QDir::currentPath();
- QString srcDir = SRCDIR;
- if (srcDir.isEmpty())
- srcDir = currDir;
-
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
@@ -394,7 +372,7 @@ void tst_QLibrary::errorString_data()
// QTest::newRow("bad unload") << (int)Unload << QString("nosuchlib.dll") << false << QString("QLibrary::unload_sys: Cannot unload nosuchlib.dll (The specified module could not be found.)");
#elif defined Q_OS_MAC
#else
- QTest::newRow("load invalid file") << (int)Load << srcDir + "/library_path/invalid.so" << false << QString("Cannot load library.*");
+ QTest::newRow("load invalid file") << (int)Load << QFINDTESTDATA("library_path/invalid.so") << false << QString("Cannot load library.*");
#endif
}
@@ -569,5 +547,5 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
QCOMPARE(lib2.isLoaded(), true);
}
-QTEST_APPLESS_MAIN(tst_QLibrary)
+QTEST_MAIN(tst_QLibrary)
#include "tst_qlibrary.moc"