diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-11-24 10:36:10 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-01 09:12:52 +0100 |
commit | 3385fb91e1e55e1bfa1f78dfb8ce2e9f3fdaedef (patch) | |
tree | b77bb527bf3a21dc95a317248b2640c73751f629 /tests/auto/corelib/plugin/qlibrary | |
parent | 13eba9ddf47d570fc4562c20fcfbacd1dfa4a61a (diff) |
Fixed installation of corelib tests
In .pro files, removed wince/symbian-specific DEPLOYMENT cases and
replaced them with TESTDATA where appropriate.
In .cpp files, removed SRCDIR and relative paths to testdata and
replaced them with the QFINDTESTDATA macro where appropriate.
Modified test helper apps/libs to install themselves under the test
they relate to.
This change allows corelib tests to be correctly installed, along with
their testdata, via `make install'.
Change-Id: I5e202e2f3b577af7e39072d5c9fe13e0ca125304
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'tests/auto/corelib/plugin/qlibrary')
-rw-r--r-- | tests/auto/corelib/plugin/qlibrary/lib/lib.pro | 5 | ||||
-rw-r--r-- | tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro | 12 | ||||
-rw-r--r-- | tests/auto/corelib/plugin/qlibrary/tst/tst.pro | 9 | ||||
-rw-r--r-- | tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp | 40 |
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" |