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/io | |
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/io')
47 files changed, 375 insertions, 559 deletions
diff --git a/tests/auto/corelib/io/qdatastream/qdatastream.pro b/tests/auto/corelib/io/qdatastream/qdatastream.pro index b8af1b461e..84d34b09e0 100644 --- a/tests/auto/corelib/io/qdatastream/qdatastream.pro +++ b/tests/auto/corelib/io/qdatastream/qdatastream.pro @@ -3,11 +3,4 @@ TARGET = tst_qdatastream QT += widgets testlib SOURCES = tst_qdatastream.cpp -wince* { - addFiles.files = datastream.q42 - addFiles.path = . - DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +TESTDATA += datastream.q42 diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index db54db661d..00cb43effe 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -2917,7 +2917,7 @@ void tst_QDataStream::streamRealDataTypes() for (int i = 0; i < 2; ++i) { QFile file; if (i == 0) { - file.setFileName(SRCDIR "datastream.q42"); + file.setFileName(QFINDTESTDATA("datastream.q42")); } else { file.setFileName("datastream.tmp"); diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index c26262e826..14f2d8812a 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -4,11 +4,4 @@ QT = core testlib SOURCES = tst_qdir.cpp RESOURCES += qdir.qrc -wince* { - DirFiles.files = testdir testData searchdir resources entrylist types tst_qdir.cpp - DirFiles.path = . - DEPLOYMENT += DirFiles - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index d6944eada8..fc63d6ef67 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -75,6 +75,8 @@ class tst_QDir : public QObject Q_OBJECT private slots: + void init(); + void getSetCheck(); void construction(); @@ -184,8 +186,21 @@ private slots: void isRelative(); void isReadable(); + +private: + QString m_dataPath; }; +void tst_QDir::init() +{ + // Directory under which testdata can be found. + m_dataPath = QFileInfo(QFINDTESTDATA("testData")).absolutePath(); + QVERIFY2(!m_dataPath.isEmpty(), "test data not found"); + + // Some tests want to use "." as relative path to data. + QVERIFY2(QDir::setCurrent(m_dataPath), qPrintable("Could not chdir to " + m_dataPath)); +} + // Testing get/set functions void tst_QDir::getSetCheck() { @@ -328,8 +343,8 @@ void tst_QDir::exists_data() QTest::newRow("resource0") << QString(":/tst_qdir/") << true; QTest::newRow("resource1") << QString(":/I/Do_not_expect_this_resource_to_exist/") << false; - QTest::newRow("simple dir") << SRCDIR "resources" << true; - QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; + QTest::newRow("simple dir") << (m_dataPath + "/resources") << true; + QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true; @@ -438,19 +453,19 @@ void tst_QDir::entryList_data() QTest::addColumn<int>("filterspec"); QTest::addColumn<int>("sortspec"); QTest::addColumn<QStringList>("expected"); - QTest::newRow("spaces1") << SRCDIR "testdir/spaces" << QStringList("*. bar") + QTest::newRow("spaces1") << (m_dataPath + "/testdir/spaces") << QStringList("*. bar") << (int)(QDir::NoFilter) << (int)(QDir::NoSort) << QStringList("foo. bar"); // notice how spaces5 works - QTest::newRow("spaces2") << SRCDIR "testdir/spaces" << QStringList("*.bar") + QTest::newRow("spaces2") << (m_dataPath + "/testdir/spaces") << QStringList("*.bar") << (int)(QDir::NoFilter) << (int)(QDir::NoSort) << QStringList("foo.bar"); - QTest::newRow("spaces3") << SRCDIR "testdir/spaces" << QStringList("foo.*") + QTest::newRow("spaces3") << (m_dataPath + "/testdir/spaces") << QStringList("foo.*") << (int)(QDir::NoFilter) << (int)(QDir::NoSort) << QString("foo. bar,foo.bar").split(','); - QTest::newRow("files1") << SRCDIR "testdir/dir" << QString("*r.cpp *.pro").split(" ") + QTest::newRow("files1") << (m_dataPath + "/testdir/dir") << QString("*r.cpp *.pro").split(" ") << (int)(QDir::NoFilter) << (int)(QDir::NoSort) << QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(','); - QTest::newRow("testdir1") << SRCDIR "testdir" << QStringList() + QTest::newRow("testdir1") << (m_dataPath + "/testdir") << QStringList() << (int)(QDir::AllDirs) << (int)(QDir::NoSort) << QString(".,..,dir,spaces").split(','); QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data") @@ -460,107 +475,107 @@ void tst_QDir::entryList_data() << (int)(QDir::Files) << (int)(QDir::NoSort) << QString("file1.data,file2.data,file3.data").split(','); - QTest::newRow("nofilter") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("nofilter") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::NoFilter) << int(QDir::Name) << filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::AllEntries") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllEntries") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllEntries) << int(QDir::Name) << filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::Files") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Files") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Files) << int(QDir::Name) << filterLinks(QString("file,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::Dirs") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Dirs") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Dirs) << int(QDir::Name) << filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); - QTest::newRow("QDir::Dirs | QDir::NoDotAndDotDot") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Dirs | QDir::NoDotAndDotDot") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Dirs | QDir::NoDotAndDotDot) << int(QDir::Name) << filterLinks(QString("directory,linktodirectory.lnk").split(',')); - QTest::newRow("QDir::AllDirs") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllDirs") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllDirs) << int(QDir::Name) << filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); - QTest::newRow("QDir::AllDirs | QDir::Dirs") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllDirs | QDir::Dirs") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllDirs | QDir::Dirs) << int(QDir::Name) << filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); - QTest::newRow("QDir::AllDirs | QDir::Files") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllDirs | QDir::Files") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllDirs | QDir::Files) << int(QDir::Name) << filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::AllEntries | QDir::NoSymLinks") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllEntries | QDir::NoSymLinks") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllEntries | QDir::NoSymLinks) << int(QDir::Name) << filterLinks(QString(".,..,directory,file,writable").split(',')); - QTest::newRow("QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot) << int(QDir::Name) << filterLinks(QString("directory,file,writable").split(',')); - QTest::newRow("QDir::Files | QDir::NoSymLinks") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Files | QDir::NoSymLinks") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Files | QDir::NoSymLinks) << int(QDir::Name) << filterLinks(QString("file,writable").split(',')); - QTest::newRow("QDir::Dirs | QDir::NoSymLinks") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Dirs | QDir::NoSymLinks") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Dirs | QDir::NoSymLinks) << int(QDir::Name) << filterLinks(QString(".,..,directory").split(',')); - QTest::newRow("QDir::Drives | QDir::Files | QDir::NoDotAndDotDot") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Drives | QDir::Files | QDir::NoDotAndDotDot") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Drives | QDir::Files | QDir::NoDotAndDotDot) << int(QDir::Name) << filterLinks(QString("file,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::System") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::System") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::System) << int(QDir::Name) << filterLinks(QStringList("brokenlink.lnk")); - QTest::newRow("QDir::Hidden") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Hidden") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Hidden) << int(QDir::Name) << QStringList(); - QTest::newRow("QDir::System | QDir::Hidden") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::System | QDir::Hidden") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::System | QDir::Hidden) << int(QDir::Name) << filterLinks(QStringList("brokenlink.lnk")); - QTest::newRow("QDir::AllDirs | QDir::NoSymLinks") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllDirs | QDir::NoSymLinks") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllDirs | QDir::NoSymLinks) << int(QDir::Name) << filterLinks(QString(".,..,directory").split(',')); - QTest::newRow("QDir::AllEntries | QDir::Hidden | QDir::System") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllEntries | QDir::Hidden | QDir::System") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllEntries | QDir::Hidden | QDir::System) << int(QDir::Name) << filterLinks(QString(".,..,brokenlink.lnk,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::AllEntries | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllEntries | QDir::Readable") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllEntries | QDir::Readable) << int(QDir::Name) << filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::AllEntries | QDir::Writable") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::AllEntries | QDir::Writable") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::AllEntries | QDir::Writable) << int(QDir::Name) << filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(',')); - QTest::newRow("QDir::Files | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Files | QDir::Readable") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Files | QDir::Readable) << int(QDir::Name) << filterLinks(QString("file,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::Dirs | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("QDir::Dirs | QDir::Readable") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::Dirs | QDir::Readable) << int(QDir::Name) << filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); - QTest::newRow("Namefilters b*") << SRCDIR "entrylist/" << QStringList("d*") + QTest::newRow("Namefilters b*") << (m_dataPath + "/entrylist/") << QStringList("d*") << int(QDir::NoFilter) << int(QDir::Name) << filterLinks(QString("directory").split(',')); - QTest::newRow("Namefilters f*") << SRCDIR "entrylist/" << QStringList("f*") + QTest::newRow("Namefilters f*") << (m_dataPath + "/entrylist/") << QStringList("f*") << int(QDir::NoFilter) << int(QDir::Name) << filterLinks(QString("file").split(',')); - QTest::newRow("Namefilters link*") << SRCDIR "entrylist/" << QStringList("link*") + QTest::newRow("Namefilters link*") << (m_dataPath + "/entrylist/") << QStringList("link*") << int(QDir::NoFilter) << int(QDir::Name) << filterLinks(QString("linktodirectory.lnk,linktofile.lnk").split(',')); - QTest::newRow("Namefilters *to*") << SRCDIR "entrylist/" << QStringList("*to*") + QTest::newRow("Namefilters *to*") << (m_dataPath + "/entrylist/") << QStringList("*to*") << int(QDir::NoFilter) << int(QDir::Name) << filterLinks(QString("directory,linktodirectory.lnk,linktofile.lnk").split(',')); - QTest::newRow("Sorting QDir::Name") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("Sorting QDir::Name") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::NoFilter) << int(QDir::Name) << filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("Sorting QDir::Name | QDir::Reversed") << SRCDIR "entrylist/" << QStringList("*") + QTest::newRow("Sorting QDir::Name | QDir::Reversed") << (m_dataPath + "/entrylist/") << QStringList("*") << int(QDir::NoFilter) << int(QDir::Name | QDir::Reversed) << filterLinks(QString("writable,linktofile.lnk,linktodirectory.lnk,file,directory,..,.").split(',')); - QTest::newRow("Sorting QDir::Type") << SRCDIR "types/" << QStringList("*") + QTest::newRow("Sorting QDir::Type") << (m_dataPath + "/types/") << QStringList("*") << int(QDir::NoFilter) << int(QDir::Type) << QString(".,..,a,b,c,d,e,f,a.a,b.a,c.a,d.a,e.a,f.a,a.b,b.b,c.b,d.b,e.b,f.b,a.c,b.c,c.c,d.c,e.c,f.c").split(','); - QTest::newRow("Sorting QDir::Type | QDir::Reversed") << SRCDIR "types/" << QStringList("*") + QTest::newRow("Sorting QDir::Type | QDir::Reversed") << (m_dataPath + "/types/") << QStringList("*") << int(QDir::NoFilter) << int(QDir::Type | QDir::Reversed) << QString("f.c,e.c,d.c,c.c,b.c,a.c,f.b,e.b,d.b,c.b,b.b,a.b,f.a,e.a,d.a,c.a,b.a,a.a,f,e,d,c,b,a,..,.").split(','); - QTest::newRow("Sorting QDir::Type | QDir::DirsLast") << SRCDIR "types/" << QStringList("*") + QTest::newRow("Sorting QDir::Type | QDir::DirsLast") << (m_dataPath + "/types/") << QStringList("*") << int(QDir::NoFilter) << int(QDir::Type | QDir::DirsLast) << QString("a,b,c,a.a,b.a,c.a,a.b,b.b,c.b,a.c,b.c,c.c,.,..,d,e,f,d.a,e.a,f.a,d.b,e.b,f.b,d.c,e.c,f.c").split(','); - QTest::newRow("Sorting QDir::Type | QDir::DirsFirst") << SRCDIR "types/" << QStringList("*") + QTest::newRow("Sorting QDir::Type | QDir::DirsFirst") << (m_dataPath + "/types/") << QStringList("*") << int(QDir::NoFilter) << int(QDir::Type | QDir::DirsFirst) << QString(".,..,d,e,f,d.a,e.a,f.a,d.b,e.b,f.b,d.c,e.c,f.c,a,b,c,a.a,b.a,c.a,a.b,b.b,c.b,a.c,b.c,c.c").split(','); - QTest::newRow("Sorting QDir::Size") << SRCDIR "types/" << QStringList("*") + QTest::newRow("Sorting QDir::Size") << (m_dataPath + "/types/") << QStringList("*") << int(QDir::AllEntries|QDir::NoDotAndDotDot) << int(QDir::Size | QDir::DirsFirst) << QString("d,d.a,d.b,d.c,e,e.a,e.b,e.c,f,f.a,f.b,f.c,c.a,c.b,c.c,b.a,b.c,b.b,a.c,a.b,a.a,a,b,c").split(','); - QTest::newRow("Sorting QDir::Size | QDir::Reversed") << SRCDIR "types/" << QStringList("*") + QTest::newRow("Sorting QDir::Size | QDir::Reversed") << (m_dataPath + "/types/") << QStringList("*") << int(QDir::AllEntries|QDir::NoDotAndDotDot) << int(QDir::Size | QDir::Reversed | QDir::DirsLast) << QString("c,b,a,a.a,a.b,a.c,b.b,b.c,b.a,c.c,c.b,c.a,f.c,f.b,f.a,f,e.c,e.b,e.a,e,d.c,d.b,d.a,d").split(','); } @@ -573,14 +588,15 @@ void tst_QDir::entryList() QFETCH(int, sortspec); QFETCH(QStringList, expected); - QFile(SRCDIR "entrylist/writable").open(QIODevice::ReadWrite); - QFile(SRCDIR "entrylist/file").setPermissions(QFile::ReadOwner | QFile::ReadUser); - QFile::remove(SRCDIR "entrylist/linktofile"); - QFile::remove(SRCDIR "entrylist/linktodirectory"); - QFile::remove(SRCDIR "entrylist/linktofile.lnk"); - QFile::remove(SRCDIR "entrylist/linktodirectory.lnk"); - QFile::remove(SRCDIR "entrylist/brokenlink.lnk"); - QFile::remove(SRCDIR "entrylist/brokenlink"); + QString entrylistPath = (m_dataPath + "/entrylist/"); + QFile(entrylistPath + "writable").open(QIODevice::ReadWrite); + QFile(entrylistPath + "file").setPermissions(QFile::ReadOwner | QFile::ReadUser); + QFile::remove(entrylistPath + "linktofile"); + QFile::remove(entrylistPath + "linktodirectory"); + QFile::remove(entrylistPath + "linktofile.lnk"); + QFile::remove(entrylistPath + "linktodirectory.lnk"); + QFile::remove(entrylistPath + "brokenlink.lnk"); + QFile::remove(entrylistPath + "brokenlink"); // WinCE does not have . and .. in the directory listing #if defined(Q_OS_WINCE) @@ -591,13 +607,14 @@ void tst_QDir::entryList() #ifndef Q_NO_SYMLINKS #if defined(Q_OS_WIN) // ### Sadly, this is a platform difference right now. - QFile::link(SRCDIR "entryList/file", SRCDIR "entrylist/linktofile.lnk"); - QFile::link(SRCDIR "entryList/directory", SRCDIR "entrylist/linktodirectory.lnk"); - QFile::link(SRCDIR "entryList/nothing", SRCDIR "entrylist/brokenlink.lnk"); + // Note we are using capital L in entryList on one side here, to test case-insensitivity + QFile::link((m_dataPath + "/entryList/") + "file", entrylistPath + "linktofile.lnk"); + QFile::link((m_dataPath + "/entryList/") + "directory", entrylistPath + "linktodirectory.lnk"); + QFile::link((m_dataPath + "/entryList/") + "nothing"), entrylistPath + "brokenlink.lnk"); #else - QFile::link("file", SRCDIR "entrylist/linktofile.lnk"); - QFile::link("directory", SRCDIR "entrylist/linktodirectory.lnk"); - QFile::link("nothing", SRCDIR "entrylist/brokenlink.lnk"); + QFile::link("file", entrylistPath + "linktofile.lnk"); + QFile::link("directory", entrylistPath + "linktodirectory.lnk"); + QFile::link("nothing", entrylistPath + "brokenlink.lnk"); #endif #endif //Q_NO_SYMLINKS @@ -625,13 +642,13 @@ void tst_QDir::entryList() QCOMPARE(actual.count(), expected.count()); } - QFile::remove(SRCDIR "entrylist/writable"); - QFile::remove(SRCDIR "entrylist/linktofile"); - QFile::remove(SRCDIR "entrylist/linktodirectory"); - QFile::remove(SRCDIR "entrylist/linktofile.lnk"); - QFile::remove(SRCDIR "entrylist/linktodirectory.lnk"); - QFile::remove(SRCDIR "entrylist/brokenlink.lnk"); - QFile::remove(SRCDIR "entrylist/brokenlink"); + QFile::remove(entrylistPath + "writable"); + QFile::remove(entrylistPath + "linktofile"); + QFile::remove(entrylistPath + "linktodirectory"); + QFile::remove(entrylistPath + "linktofile.lnk"); + QFile::remove(entrylistPath + "linktodirectory.lnk"); + QFile::remove(entrylistPath + "brokenlink.lnk"); + QFile::remove(entrylistPath + "brokenlink"); } void tst_QDir::entryListSimple_data() @@ -641,11 +658,11 @@ void tst_QDir::entryListSimple_data() QTest::newRow("data2") << "do_not_expect_this_path_to_exist/" << 0; #if defined(Q_OS_WINCE) - QTest::newRow("simple dir") << SRCDIR "resources" << 0; - QTest::newRow("simple dir with slash") << SRCDIR "resources/" << 0; + QTest::newRow("simple dir") << (m_dataPath + "/resources") << 0; + QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 0; #else - QTest::newRow("simple dir") << SRCDIR "resources" << 2; - QTest::newRow("simple dir with slash") << SRCDIR "resources/" << 2; + QTest::newRow("simple dir") << (m_dataPath + "/resources") << 2; + QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2; #endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -721,27 +738,14 @@ void tst_QDir::canonicalPath_data() { QTest::addColumn<QString>("path"); QTest::addColumn<QString>("canonicalPath"); - QString appPath = SRCDIR; - if (appPath.isEmpty()) - appPath = QCoreApplication::instance()->applicationDirPath(); - else - appPath.chop(1); // remove the ending slash -#if defined Q_OS_WIN - if (appPath.endsWith("release", Qt::CaseInsensitive) || appPath.endsWith("debug", Qt::CaseInsensitive)) { - QDir appDir(appPath); - QVERIFY(appDir.cdUp()); - appPath = appDir.absolutePath(); - } -#endif - - QTest::newRow("relative") << "." << appPath; - QTest::newRow("relativeSubDir") << "./testData/../testData" << appPath + "/testData"; + QTest::newRow("relative") << "." << m_dataPath; + QTest::newRow("relativeSubDir") << "./testData/../testData" << m_dataPath + "/testData"; #ifndef Q_OS_WIN - QTest::newRow("absPath") << appPath + "/testData/../testData" << appPath + "/testData"; + QTest::newRow("absPath") << m_dataPath + "/testData/../testData" << m_dataPath + "/testData"; #else - QTest::newRow("absPath") << appPath + "\\testData\\..\\testData" << appPath + "/testData"; + QTest::newRow("absPath") << m_dataPath + "\\testData\\..\\testData" << m_dataPath + "/testData"; #endif QTest::newRow("nonexistant") << "testd" << QString(); @@ -768,16 +772,12 @@ void tst_QDir::canonicalPath_data() void tst_QDir::canonicalPath() { - QDir srcPath; - if (strlen(SRCDIR) > 0) - srcPath = QDir(SRCDIR); - else - srcPath = QDir("."); - if (srcPath.absolutePath() != srcPath.canonicalPath()) + QDir dataDir(m_dataPath); + if (dataDir.absolutePath() != dataDir.canonicalPath()) QSKIP("This test does not work if this directory path consists of symlinks."); QString oldpwd = QDir::currentPath(); - QDir::setCurrent(srcPath.absolutePath()); + QDir::setCurrent(dataDir.absolutePath()); QFETCH(QString, path); QFETCH(QString, canonicalPath); @@ -796,37 +796,23 @@ void tst_QDir::current_data() { QTest::addColumn<QString>("path"); QTest::addColumn<QString>("currentDir"); - QString appPath = SRCDIR; - if (appPath.isEmpty()) - appPath = QCoreApplication::instance()->applicationDirPath(); - else - appPath.chop(1); // remove the ending slash -#if defined Q_OS_WIN - if (appPath.endsWith("release", Qt::CaseInsensitive)) - appPath = appPath.left(appPath.length()-8); - else if (appPath.endsWith("debug", Qt::CaseInsensitive)) - appPath = appPath.left(appPath.length()-6); -#endif - QTest::newRow("startup") << QString() << appPath; - QTest::newRow("relPath") << "testData" << appPath + "/testData"; + QTest::newRow("startup") << QString() << m_dataPath; + QTest::newRow("relPath") << "testData" << m_dataPath + "/testData"; #ifndef Q_OS_WIN - QTest::newRow("absPath") << appPath + "/testData" << appPath + "/testData"; + QTest::newRow("absPath") << m_dataPath + "/testData" << m_dataPath + "/testData"; #else - QTest::newRow("absPath") << appPath + "\\testData" << appPath + "/testData"; + QTest::newRow("absPath") << m_dataPath + "\\testData" << m_dataPath + "/testData"; #endif QTest::newRow("nonexistant") << "testd" << QString(); - QTest::newRow("parent") << ".." << appPath.left(appPath.lastIndexOf('/')); + QTest::newRow("parent") << ".." << m_dataPath.left(m_dataPath.lastIndexOf('/')); } void tst_QDir::current() { QString oldDir = QDir::currentPath(); - QString appPath = SRCDIR; - if (appPath.isEmpty()) - appPath = QCoreApplication::instance()->applicationDirPath(); - QDir::setCurrent(appPath); + QDir::setCurrent(m_dataPath); QFETCH(QString, path); QFETCH(QString, currentDir); @@ -855,17 +841,16 @@ void tst_QDir::cd_data() QTest::addColumn<bool>("successExpected"); QTest::addColumn<QString>("newDir"); - QString appPath = QDir::currentPath(); - int index = appPath.lastIndexOf("/"); - QTest::newRow("cdUp") << QDir::currentPath() << ".." << true << appPath.left(index==0?1:index); - QTest::newRow("noChange") << QDir::currentPath() << "." << true << appPath; + int index = m_dataPath.lastIndexOf("/"); + QTest::newRow("cdUp") << m_dataPath << ".." << true << m_dataPath.left(index==0?1:index); + QTest::newRow("noChange") << m_dataPath << "." << true << m_dataPath; #if defined(Q_OS_WIN) // on windows QDir::root() is usually c:/ but cd "/" will not force it to be root - QTest::newRow("absolute") << QDir::currentPath() << "/" << true << "/"; + QTest::newRow("absolute") << m_dataPath << "/" << true << "/"; #else - QTest::newRow("absolute") << QDir::currentPath() << "/" << true << QDir::root().absolutePath(); + QTest::newRow("absolute") << m_dataPath << "/" << true << QDir::root().absolutePath(); #endif - QTest::newRow("non existant") << "." << "../anonexistingdir" << false << QDir::currentPath(); - QTest::newRow("self") << "." << (QString("../") + QFileInfo(QDir::currentPath()).fileName()) << true << QDir::currentPath(); + QTest::newRow("non existant") << "." << "../anonexistingdir" << false << m_dataPath; + QTest::newRow("self") << "." << (QString("../") + QFileInfo(m_dataPath).fileName()) << true << m_dataPath; QTest::newRow("file") << "." << "qdir.pro" << false << ""; } @@ -892,19 +877,13 @@ void tst_QDir::setNameFilters_data() QTest::addColumn<QStringList>("nameFilters"); QTest::addColumn<QStringList>("expected"); - QString appPath = SRCDIR; - if (appPath.isEmpty()) - appPath = QCoreApplication::instance()->applicationDirPath(); - if (!appPath.endsWith("/")) - appPath.append("/"); - - QTest::newRow("spaces1") << appPath + "testdir/spaces" << QStringList("*. bar") + QTest::newRow("spaces1") << m_dataPath + "/testdir/spaces" << QStringList("*. bar") << QStringList("foo. bar"); - QTest::newRow("spaces2") << appPath + "testdir/spaces" << QStringList("*.bar") + QTest::newRow("spaces2") << m_dataPath + "/testdir/spaces" << QStringList("*.bar") << QStringList("foo.bar"); - QTest::newRow("spaces3") << appPath + "testdir/spaces" << QStringList("foo.*") + QTest::newRow("spaces3") << m_dataPath + "/testdir/spaces" << QStringList("foo.*") << QString("foo. bar,foo.bar").split(","); - QTest::newRow("files1") << appPath + "testdir/dir" << QString("*r.cpp *.pro").split(" ") + QTest::newRow("files1") << m_dataPath + "/testdir/dir" << QString("*r.cpp *.pro").split(" ") << QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(","); QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data") << QString("file1.data,file2.data,file3.data").split(','); @@ -1170,8 +1149,7 @@ void tst_QDir::exists2() QFETCH(bool, exists); QString oldpwd = QDir::currentPath(); - if (strlen(SRCDIR) > 0) - QDir::setCurrent(SRCDIR); + QDir::setCurrent((m_dataPath + "/.")); if (path.isEmpty()) QTest::ignoreMessage(QtWarningMsg, "QDir::exists: Empty or null file name"); @@ -1223,7 +1201,7 @@ void tst_QDir::dotAndDotDot() #if defined(Q_OS_WINCE) QSKIP("WinCE does not have . nor .."); #else - QDir dir(QString(SRCDIR "testdir/")); + QDir dir(QString((m_dataPath + "/testdir/"))); QStringList entryList = dir.entryList(QDir::Dirs); QCOMPARE(entryList, QStringList() << QString(".") << QString("..") << QString("dir") << QString("spaces")); entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); @@ -1309,26 +1287,22 @@ void tst_QDir::searchPaths_data() QTest::addColumn<QString>("searchPaths"); QTest::addColumn<QString>("expectedAbsolutePath"); - QString srcdir = SRCDIR; - if (srcdir.isEmpty()) - srcdir = QDir::currentPath(); - else - srcdir.chop(1); // remove ending slash - QString searchDir = srcdir + "/searchdir"; + QString searchDir = (m_dataPath + "/searchdir"); + QString srcdir = QFileInfo(searchDir).absolutePath(); // sanity QTest::newRow("nopath") << "picker.png" << QString() << QString() << QString(); QTest::newRow("emptysearchpath") << "subdir1/picker.png" << QString() << QString() << QString(); - QTest::newRow("searchpathwithoutprefix") << SRCDIR "searchdir/subdir1/picker.png" << QString("searchpath") << QString("searchdir") << (searchDir+"/subdir1/picker.png"); + QTest::newRow("searchpathwithoutprefix") << (m_dataPath + "/searchdir/subdir1/picker.png") << QString("searchpath") << QString("searchdir") << (searchDir+"/subdir1/picker.png"); // new QTest::newRow("novalidsearchpath") << "searchpath:subdir1/picker.png" << QString() << QString() << QString(); QTest::newRow("invalidsearchpath") << "searchpath:subdir1/picker.png" << QString("invalid") << QString("invalid") << QString(); - QTest::newRow("onlyvalidsearchpath") << "searchpath:subdir1/picker.png" << QString("searchpath") << QString(SRCDIR "searchdir") << (searchDir+"/subdir1/picker.png"); - QTest::newRow("validandinvalidsearchpath") << "searchpath:subdir1/picker.png" << QString("invalid;searchpath") << QString("invalid;" SRCDIR "searchdir") << (searchDir+"/subdir1/picker.png"); - QTest::newRow("precedence1") << "searchpath:picker.png" << QString("invalid;searchpath") << QString("invalid;" SRCDIR "searchdir/subdir1," SRCDIR "searchdir/subdir2") << (searchDir+"/subdir1/picker.png"); - QTest::newRow("precedence2") << "searchpath:picker.png" << QString("invalid;searchpath") << QString("invalid;" SRCDIR "searchdir/subdir2," SRCDIR "searchdir/subdir1") << (searchDir+"/subdir2/picker.png"); - QTest::newRow("precedence3") << "searchpath2:picker.png" << QString("searchpath1;searchpath2") << QString(SRCDIR "searchdir/subdir1;" SRCDIR "searchdir/subdir2") << (searchDir+"/subdir2/picker.png"); + QTest::newRow("onlyvalidsearchpath") << "searchpath:subdir1/picker.png" << QString("searchpath") << QString((m_dataPath + "/searchdir")) << (searchDir+"/subdir1/picker.png"); + QTest::newRow("validandinvalidsearchpath") << "searchpath:subdir1/picker.png" << QString("invalid;searchpath") << ("invalid;" + (m_dataPath + "/searchdir")) << (searchDir+"/subdir1/picker.png"); + QTest::newRow("precedence1") << "searchpath:picker.png" << QString("invalid;searchpath") << ("invalid;" + (m_dataPath + "/searchdir/subdir1") + "," + (m_dataPath + "/searchdir/subdir2")) << (searchDir+"/subdir1/picker.png"); + QTest::newRow("precedence2") << "searchpath:picker.png" << QString("invalid;searchpath") << ("invalid;" + (m_dataPath + "/searchdir/subdir2") + "," + (m_dataPath + "/searchdir/subdir1")) << (searchDir+"/subdir2/picker.png"); + QTest::newRow("precedence3") << "searchpath2:picker.png" << QString("searchpath1;searchpath2") << ((m_dataPath + "/searchdir/subdir1") + ";" + (m_dataPath + "/searchdir/subdir2")) << (searchDir+"/subdir2/picker.png"); // re } @@ -1729,8 +1703,8 @@ void tst_QDir::drives() void tst_QDir::arrayOperator() { - QDir dir1(SRCDIR "entrylist/"); - QDir dir2(SRCDIR "entrylist/"); + QDir dir1((m_dataPath + "/entrylist/")); + QDir dir2((m_dataPath + "/entrylist/")); QStringList entries(dir1.entryList()); int i = dir2.count(); @@ -1753,8 +1727,8 @@ void tst_QDir::equalityOperator_data() QTest::addColumn<int>("rightFilters"); QTest::addColumn<bool>("expected"); - QTest::newRow("same") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) - << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) + QTest::newRow("same") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files) << true; QTest::newRow("relativepaths") << "entrylist/" << "*.cpp" << int(QDir::Name) << int(QDir::Files) @@ -1789,16 +1763,16 @@ void tst_QDir::equalityOperator_data() << "another-dir-that-dont-exist" << "*.cpp" << int(QDir::Name) << int(QDir::Files) << false; - QTest::newRow("diff-filters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) - << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Dirs) + QTest::newRow("diff-filters") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << m_dataPath << "*.cpp" << int(QDir::Name) << int(QDir::Dirs) << false; - QTest::newRow("diff-sort") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) - << SRCDIR << "*.cpp" << int(QDir::Time) << int(QDir::Files) + QTest::newRow("diff-sort") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << m_dataPath << "*.cpp" << int(QDir::Time) << int(QDir::Files) << false; - QTest::newRow("diff-namefilters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) - << SRCDIR << "*.jpg" << int(QDir::Name) << int(QDir::Files) + QTest::newRow("diff-namefilters") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << m_dataPath << "*.jpg" << int(QDir::Name) << int(QDir::Files) << false; } diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro index b51a734d10..cfb3201c43 100644 --- a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro @@ -4,4 +4,6 @@ QT = core testlib SOURCES = tst_qdiriterator.cpp RESOURCES += qdiriterator.qrc +TESTDATA += entrylist + wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1 diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index eef504b90d..e331d09b64 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -66,10 +66,6 @@ class tst_QDirIterator : public QObject { Q_OBJECT -public: - tst_QDirIterator(); - virtual ~tst_QDirIterator(); - private: // convenience functions QStringList createdDirectories; QStringList createdFiles; @@ -106,6 +102,8 @@ private: // convenience functions } private slots: + void initTestCase(); + void cleanupTestCase(); void iterateRelativeDirectory_data(); void iterateRelativeDirectory(); void iterateResource_data(); @@ -124,8 +122,12 @@ private slots: void hiddenDirs_hiddenFiles(); }; -tst_QDirIterator::tst_QDirIterator() +void tst_QDirIterator::initTestCase() { + // chdir into testdata directory, then find testdata by relative paths. + QString testdata_dir = QFileInfo(QFINDTESTDATA("entrylist")).absolutePath(); + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); + QFile::remove("entrylist/entrylist1.lnk"); QFile::remove("entrylist/entrylist2.lnk"); QFile::remove("entrylist/entrylist3.lnk"); @@ -187,7 +189,7 @@ tst_QDirIterator::tst_QDirIterator() #endif } -tst_QDirIterator::~tst_QDirIterator() +void tst_QDirIterator::cleanupTestCase() { Q_FOREACH(QString fileName, createdFiles) QFile::remove(fileName); diff --git a/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro b/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro index bf791ffc61..8e463e4cef 100644 --- a/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro +++ b/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro @@ -3,4 +3,6 @@ QT = core CONFIG -= app_bundle debug_and_release_target CONFIG += console - +# This app is testdata for tst_qfile +target.path = $$[QT_INSTALL_TESTS]/tst_qfile/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro index aca034b098..2f1e50010c 100644 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ b/tests/auto/corelib/io/qfile/test/test.pro @@ -1,24 +1,13 @@ CONFIG += testcase +QT = core network testlib TARGET = ../tst_qfile SOURCES = ../tst_qfile.cpp RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc -wince* { - QT = core gui testlib - files.files += ..\\dosfile.txt ..\\noendofline.txt ..\\testfile.txt \ - ..\\testlog.txt ..\\two.dots.file ..\\tst_qfile.cpp \ - ..\\Makefile ..\\forCopying.txt ..\\forRenaming.txt - files.path = . - resour.files += ..\\resources\\file1.ext1 - resour.path = resources - - DEPLOYMENT += files resour - SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp # needed for QT_OPEN - DEFINES += SRCDIR=\\\"\\\" -} else { - QT = core network testlib - DEFINES += SRCDIR=\\\"$$PWD/../\\\" -} +TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \ + ../testlog.txt ../two.dots.file ../tst_qfile.cpp \ + ../Makefile ../forCopying.txt ../forRenaming.txt \ + ../resources/file1.ext1 win32 { CONFIG(debug, debug|release) { diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 2b71bb738c..07f6b44a4d 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -348,6 +348,10 @@ void tst_QFile::cleanup() void tst_QFile::initTestCase() { + // chdir to testdata directory and use relative paths. + QString testdata_dir = QFileInfo(QFINDTESTDATA("testfile.txt")).absolutePath(); + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); + QFile::remove("noreadfile"); // create a file and make it read-only @@ -404,7 +408,7 @@ void tst_QFile::cleanupTestCase() void tst_QFile::exists() { - QFile f( SRCDIR "testfile.txt" ); + QFile f( QFINDTESTDATA("testfile.txt") ); QCOMPARE( f.exists(), (bool)TRUE ); QFile file("nobodyhassuchafile"); @@ -443,7 +447,7 @@ void tst_QFile::open_data() static const QString denied("Permission denied"); #endif QTest::newRow( "exist_readOnly" ) - << QString(SRCDIR "testfile.txt") << int(QIODevice::ReadOnly) + << QString(QFINDTESTDATA("testfile.txt")) << int(QIODevice::ReadOnly) << (bool)TRUE << QFile::NoError; QTest::newRow( "exist_writeOnly" ) @@ -469,7 +473,7 @@ void tst_QFile::open_data() QTest::newRow("nullfile") << QString() << int(QIODevice::ReadOnly) << (bool)FALSE << QFile::OpenError; - QTest::newRow("two-dots") << QString(SRCDIR "two.dots.file") << int(QIODevice::ReadOnly) << (bool)TRUE + QTest::newRow("two-dots") << QString(QFINDTESTDATA("two.dots.file")) << int(QIODevice::ReadOnly) << (bool)TRUE << QFile::NoError; QTest::newRow("readonlyfile") << QString("readonlyfile") << int(QIODevice::WriteOnly) @@ -512,7 +516,7 @@ void tst_QFile::open() void tst_QFile::openUnbuffered() { - QFile file(SRCDIR "testfile.txt"); + QFile file(QFINDTESTDATA("testfile.txt")); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)); char c = '\0'; QVERIFY(file.seek(1)); @@ -545,7 +549,7 @@ void tst_QFile::size_data() QTest::addColumn<QString>("filename"); QTest::addColumn<qint64>("size"); - QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << (qint64)245; + QTest::newRow( "exist01" ) << QString(QFINDTESTDATA("testfile.txt")) << (qint64)245; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Only test UNC on Windows./ QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testshare/test.pri") << (qint64)34; @@ -687,7 +691,7 @@ void tst_QFile::setSizeSeek() void tst_QFile::atEnd() { - QFile f( SRCDIR "testfile.txt" ); + QFile f( QFINDTESTDATA("testfile.txt") ); QVERIFY(f.open( QIODevice::ReadOnly )); int size = f.size(); @@ -700,7 +704,7 @@ void tst_QFile::atEnd() void tst_QFile::readLine() { - QFile f( SRCDIR "testfile.txt" ); + QFile f( QFINDTESTDATA("testfile.txt") ); QVERIFY(f.open( QIODevice::ReadOnly )); int i = 0; @@ -720,7 +724,7 @@ void tst_QFile::readLine() void tst_QFile::readLine2() { - QFile f( SRCDIR "testfile.txt" ); + QFile f( QFINDTESTDATA("testfile.txt") ); f.open( QIODevice::ReadOnly ); char p[128]; @@ -755,13 +759,13 @@ void tst_QFile::readAll_data() { QTest::addColumn<bool>("textMode"); QTest::addColumn<QString>("fileName"); - QTest::newRow( "TextMode unixfile" ) << true << SRCDIR "testfile.txt"; - QTest::newRow( "BinaryMode unixfile" ) << false << SRCDIR "testfile.txt"; - QTest::newRow( "TextMode dosfile" ) << true << SRCDIR "dosfile.txt"; - QTest::newRow( "BinaryMode dosfile" ) << false << SRCDIR "dosfile.txt"; - QTest::newRow( "TextMode bigfile" ) << true << SRCDIR "tst_qfile.cpp"; - QTest::newRow( "BinaryMode bigfile" ) << false << SRCDIR "tst_qfile.cpp"; - QVERIFY(QFile(SRCDIR "tst_qfile.cpp").size() > 64*1024); + QTest::newRow( "TextMode unixfile" ) << true << QFINDTESTDATA("testfile.txt"); + QTest::newRow( "BinaryMode unixfile" ) << false << QFINDTESTDATA("testfile.txt"); + QTest::newRow( "TextMode dosfile" ) << true << QFINDTESTDATA("dosfile.txt"); + QTest::newRow( "BinaryMode dosfile" ) << false << QFINDTESTDATA("dosfile.txt"); + QTest::newRow( "TextMode bigfile" ) << true << QFINDTESTDATA("tst_qfile.cpp"); + QTest::newRow( "BinaryMode bigfile" ) << false << QFINDTESTDATA("tst_qfile.cpp"); + QVERIFY(QFile(QFINDTESTDATA("tst_qfile.cpp")).size() > 64*1024); } void tst_QFile::readAll() @@ -923,7 +927,7 @@ void tst_QFile::readLineStdin_lineByLine() void tst_QFile::text() { // dosfile.txt is a binary CRLF file - QFile file(SRCDIR "dosfile.txt"); + QFile file(QFINDTESTDATA("dosfile.txt")); QVERIFY(file.open(QFile::Text | QFile::ReadOnly)); QCOMPARE(file.readLine(), QByteArray("/dev/system/root / reiserfs acl,user_xattr 1 1\n")); @@ -936,7 +940,7 @@ void tst_QFile::text() void tst_QFile::missingEndOfLine() { - QFile file(SRCDIR "noendofline.txt"); + QFile file(QFINDTESTDATA("noendofline.txt")); QVERIFY(file.open(QFile::ReadOnly)); int nlines = 0; @@ -950,7 +954,7 @@ void tst_QFile::missingEndOfLine() void tst_QFile::readBlock() { - QFile f( SRCDIR "testfile.txt" ); + QFile f( QFINDTESTDATA("testfile.txt") ); f.open( QIODevice::ReadOnly ); int length = 0; @@ -965,7 +969,7 @@ void tst_QFile::readBlock() void tst_QFile::getch() { - QFile f( SRCDIR "testfile.txt" ); + QFile f( QFINDTESTDATA("testfile.txt") ); f.open( QIODevice::ReadOnly ); char c; @@ -982,7 +986,7 @@ void tst_QFile::getch() void tst_QFile::ungetChar() { - QFile f(SRCDIR "testfile.txt"); + QFile f(QFINDTESTDATA("testfile.txt")); QVERIFY(f.open(QIODevice::ReadOnly)); QByteArray array = f.readLine(); @@ -1083,7 +1087,7 @@ void tst_QFile::permissions_data() QTest::addColumn<bool>("expected"); QTest::newRow("data0") << QCoreApplication::instance()->applicationFilePath() << uint(QFile::ExeUser) << true; - QTest::newRow("data1") << SRCDIR "tst_qfile.cpp" << uint(QFile::ReadUser) << true; + QTest::newRow("data1") << QFINDTESTDATA("tst_qfile.cpp") << uint(QFile::ReadUser) << true; QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::ReadUser) << true; QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::WriteUser) << false; QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::ExeUser) << false; @@ -1121,8 +1125,8 @@ void tst_QFile::copy() QFile::setPermissions("tst_qfile_copy.cpp", QFile::WriteUser); QFile::remove("tst_qfile_copy.cpp"); QFile::remove("test2"); - QVERIFY(QFile::copy(SRCDIR "tst_qfile.cpp", "tst_qfile_copy.cpp")); - QFile in1(SRCDIR "tst_qfile.cpp"), in2("tst_qfile_copy.cpp"); + QVERIFY(QFile::copy(QFINDTESTDATA("tst_qfile.cpp"), "tst_qfile_copy.cpp")); + QFile in1(QFINDTESTDATA("tst_qfile.cpp")), in2("tst_qfile_copy.cpp"); QVERIFY(in1.open(QFile::ReadOnly)); QVERIFY(in2.open(QFile::ReadOnly)); QByteArray data1 = in1.readAll(), data2 = in2.readAll(); @@ -1169,9 +1173,9 @@ void tst_QFile::copyAfterFail() void tst_QFile::copyRemovesTemporaryFile() const { const QString newName(QLatin1String("copyRemovesTemporaryFile")); - QVERIFY(QFile::copy(SRCDIR "forCopying.txt", newName)); + QVERIFY(QFile::copy(QFINDTESTDATA("forCopying.txt"), newName)); - QVERIFY(!QFile::exists(QLatin1String( SRCDIR "qt_temp.XXXXXX"))); + QVERIFY(!QFile::exists(QFINDTESTDATA("qt_temp.XXXXXX"))); QVERIFY(QFile::remove(newName)); } @@ -1179,7 +1183,7 @@ void tst_QFile::copyShouldntOverwrite() { // Copy should not overwrite existing files. QFile::remove("tst_qfile.cpy"); - QFile file(SRCDIR "tst_qfile.cpp"); + QFile file(QFINDTESTDATA("tst_qfile.cpp")); QVERIFY(file.copy("tst_qfile.cpy")); bool ok = QFile::setPermissions("tst_qfile.cpy", QFile::WriteOther); @@ -1271,10 +1275,10 @@ void tst_QFile::link() { QFile::remove("myLink.lnk"); - QFileInfo info1(SRCDIR "tst_qfile.cpp"); + QFileInfo info1(QFINDTESTDATA("tst_qfile.cpp")); QString referenceTarget = QDir::cleanPath(info1.absoluteFilePath()); - QVERIFY(QFile::link(SRCDIR "tst_qfile.cpp", "myLink.lnk")); + QVERIFY(QFile::link(QFINDTESTDATA("tst_qfile.cpp"), "myLink.lnk")); QFileInfo info2("myLink.lnk"); QVERIFY(info2.isSymLink()); @@ -1386,13 +1390,13 @@ void tst_QFile::readTextFile() void tst_QFile::readTextFile2() { { - QFile file(SRCDIR "testlog.txt"); + QFile file(QFINDTESTDATA("testlog.txt")); QVERIFY(file.open(QIODevice::ReadOnly)); file.read(4097); } { - QFile file(SRCDIR "testlog.txt"); + QFile file(QFINDTESTDATA("testlog.txt")); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); file.read(4097); } @@ -2015,7 +2019,7 @@ public: { if (fileName.startsWith(":!")) { QDir dir; - QString realFile = SRCDIR + fileName.mid(2); + QString realFile = QFINDTESTDATA(fileName.mid(2)); if (dir.exists(realFile)) return new QFSFileEngine(realFile); } @@ -2379,7 +2383,7 @@ void tst_QFile::renameWithAtEndSpecialFile() const /* Cleanup, so we're a bit more robust. */ QFile::remove(newName); - const QString originalName(QString(SRCDIR "forRenaming.txt")); + const QString originalName(QString(QFINDTESTDATA("forRenaming.txt"))); PeculiarAtEnd file; file.setFileName(originalName); @@ -2502,7 +2506,7 @@ void tst_QFile::handle() { int fd; #if !defined(Q_OS_WINCE) - QFile file(SRCDIR "tst_qfile.cpp"); + QFile file(QFINDTESTDATA("tst_qfile.cpp")); QVERIFY(file.open(QIODevice::ReadOnly)); fd = int(file.handle()); QVERIFY(fd > 2); @@ -2533,7 +2537,7 @@ void tst_QFile::handle() //test round trip of adopted stdio file handle QFile file2; - FILE *fp = fopen(SRCDIR "tst_qfile.cpp", "r"); + FILE *fp = fopen(qPrintable(QFINDTESTDATA("tst_qfile.cpp")), "r"); file2.open(fp, QIODevice::ReadOnly); QCOMPARE(int(file2.handle()), int(fileno(fp))); QCOMPARE(int(file2.handle()), int(fileno(fp))); @@ -2542,7 +2546,7 @@ void tst_QFile::handle() //test round trip of adopted posix file handle #ifdef Q_OS_UNIX QFile file3; - fd = QT_OPEN(SRCDIR "tst_qfile.cpp", QT_OPEN_RDONLY); + fd = QT_OPEN(qPrintable(QFINDTESTDATA("tst_qfile.cpp")), QT_OPEN_RDONLY); file3.open(fd, QIODevice::ReadOnly); QCOMPARE(int(file3.handle()), fd); QT_CLOSE(fd); @@ -2599,8 +2603,8 @@ void tst_QFile::readEof_data() QTest::addColumn<QString>("filename"); QTest::addColumn<int>("imode"); - QTest::newRow("buffered") << SRCDIR "testfile.txt" << 0; - QTest::newRow("unbuffered") << SRCDIR "testfile.txt" << int(QIODevice::Unbuffered); + QTest::newRow("buffered") << QFINDTESTDATA("testfile.txt") << 0; + QTest::newRow("unbuffered") << QFINDTESTDATA("testfile.txt") << int(QIODevice::Unbuffered); #if defined(Q_OS_UNIX) QTest::newRow("sequential,buffered") << "/dev/null" << 0; @@ -2945,7 +2949,7 @@ void tst_QFile::mapOpenMode() void tst_QFile::openDirectory() { - QFile f1(SRCDIR "resources"); + QFile f1(QFINDTESTDATA("resources")); // it's a directory, it must exist QVERIFY(f1.exists()); @@ -3070,7 +3074,7 @@ void tst_QFile::resize() void tst_QFile::objectConstructors() { QObject ob; - QFile* file1 = new QFile(SRCDIR "testfile.txt", &ob); + QFile* file1 = new QFile(QFINDTESTDATA("testfile.txt"), &ob); QFile* file2 = new QFile(&ob); QVERIFY(file1->exists()); QVERIFY(!file2->exists()); diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index 2f3fa3fded..4f00d3446e 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -4,14 +4,6 @@ QT = core-private testlib SOURCES = tst_qfileinfo.cpp RESOURCES += qfileinfo.qrc -wince* { - deploy.files += qfileinfo.qrc tst_qfileinfo.cpp - res.files = resources\\file1 resources\\file1.ext1 resources\\file1.ext1.ext2 - res.path = resources - DEPLOYMENT += deploy res - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +TESTDATA += qfileinfo.qrc qfileinfo.pro tst_qfileinfo.cpp resources/file1 resources/file1.ext1 resources/file1.ext1.ext2 win32*:LIBS += -ladvapi32 -lnetapi32 diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index d5de61f4ed..81b4c1bb12 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -286,7 +286,7 @@ void tst_QFileInfo::isFile_data() QTest::addColumn<bool>("expected"); QTest::newRow("data0") << QDir::currentPath() << false; - QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << true; + QTest::newRow("data1") << QFINDTESTDATA("tst_qfileinfo.cpp") << true; QTest::newRow("data2") << ":/tst_qfileinfo/resources/" << false; QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << true; QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false; @@ -319,13 +319,13 @@ void tst_QFileInfo::isDir_data() QTest::addColumn<bool>("expected"); QTest::newRow("data0") << QDir::currentPath() << true; - QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << false; + QTest::newRow("data1") << QFINDTESTDATA("tst_qfileinfo.cpp") << false; QTest::newRow("data2") << ":/tst_qfileinfo/resources/" << true; QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << false; QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false; - QTest::newRow("simple dir") << SRCDIR "resources" << true; - QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; + QTest::newRow("simple dir") << QFINDTESTDATA("resources") << true; + QTest::newRow("simple dir with slash") << QFINDTESTDATA("resources/") << true; QTest::newRow("broken link") << "brokenlink.lnk" << false; @@ -365,8 +365,8 @@ void tst_QFileInfo::isRoot_data() QTest::newRow("data4") << ":/tst_qfileinfo/resources/" << false; QTest::newRow("data5") << ":/" << true; - QTest::newRow("simple dir") << SRCDIR "resources" << false; - QTest::newRow("simple dir with slash") << SRCDIR "resources/" << false; + QTest::newRow("simple dir") << QFINDTESTDATA("resources") << false; + QTest::newRow("simple dir with slash") << QFINDTESTDATA("resources/") << false; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) QTest::newRow("drive 1") << "c:" << false; QTest::newRow("drive 2") << "c:/" << true; @@ -397,21 +397,21 @@ void tst_QFileInfo::exists_data() QTest::addColumn<bool>("expected"); QTest::newRow("data0") << QDir::currentPath() << true; - QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << true; + QTest::newRow("data1") << QFINDTESTDATA("tst_qfileinfo.cpp") << true; QTest::newRow("data2") << "/I/do_not_expect_this_path_to_exist/" << false; QTest::newRow("data3") << ":/tst_qfileinfo/resources/" << true; QTest::newRow("data4") << ":/tst_qfileinfo/resources/file1" << true; QTest::newRow("data5") << ":/I/do_not_expect_this_path_to_exist/" << false; - QTest::newRow("data6") << SRCDIR "resources/*" << false; - QTest::newRow("data7") << SRCDIR "resources/*.foo" << false; - QTest::newRow("data8") << SRCDIR "resources/*.ext1" << false; - QTest::newRow("data9") << SRCDIR "resources/file?.ext1" << false; + QTest::newRow("data6") << (QFINDTESTDATA("resources/") + "*") << false; + QTest::newRow("data7") << (QFINDTESTDATA("resources/") + "*.foo") << false; + QTest::newRow("data8") << (QFINDTESTDATA("resources/") + "*.ext1") << false; + QTest::newRow("data9") << (QFINDTESTDATA("resources/") + "file?.ext1") << false; QTest::newRow("data10") << "." << true; QTest::newRow("data11") << ". " << false; QTest::newRow("empty") << "" << false; - QTest::newRow("simple dir") << SRCDIR "resources" << true; - QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; + QTest::newRow("simple dir") << QFINDTESTDATA("resources") << true; + QTest::newRow("simple dir with slash") << QFINDTESTDATA("resources/") << true; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; @@ -557,7 +557,7 @@ void tst_QFileInfo::canonicalFilePath() // test symlinks QFile::remove("link.lnk"); { - QFile file(SRCDIR "tst_qfileinfo.cpp"); + QFile file(QFINDTESTDATA("tst_qfileinfo.cpp")); if (file.link("link.lnk")) { QFileInfo info1(file); QFileInfo info2("link.lnk"); @@ -583,7 +583,7 @@ void tst_QFileInfo::canonicalFilePath() QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); QFileInfo info3(link + QDir::separator() + "link.lnk"); - QFileInfo info4(SRCDIR "tst_qfileinfo.cpp"); + QFileInfo info4(QFINDTESTDATA("tst_qfileinfo.cpp")); QVERIFY(!info3.canonicalFilePath().isEmpty()); QCOMPARE(info4.canonicalFilePath(), info3.canonicalFilePath()); @@ -830,7 +830,7 @@ void tst_QFileInfo::permission_data() QTest::addColumn<bool>("expected"); QTest::newRow("data0") << QCoreApplication::instance()->applicationFilePath() << int(QFile::ExeUser) << true; - QTest::newRow("data1") << SRCDIR "tst_qfileinfo.cpp" << int(QFile::ReadUser) << true; + QTest::newRow("data1") << QFINDTESTDATA("tst_qfileinfo.cpp") << int(QFile::ReadUser) << true; QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ReadUser) << true; QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::WriteUser) << false; QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ExeUser) << false; @@ -898,11 +898,11 @@ void tst_QFileInfo::compare_data() #endif QTest::newRow("data0") - << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") - << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") + << QFINDTESTDATA("tst_qfileinfo.cpp") + << QFINDTESTDATA("tst_qfileinfo.cpp") << true; QTest::newRow("data1") - << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") + << QFINDTESTDATA("tst_qfileinfo.cpp") << QString::fromLatin1("/tst_qfileinfo.cpp") << false; QTest::newRow("data2") @@ -910,8 +910,8 @@ void tst_QFileInfo::compare_data() << QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp") << true; QTest::newRow("casesense1") - << QString::fromLatin1(SRCDIR "tst_qfileInfo.cpp") - << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") + << QFINDTESTDATA("tst_qfileinfo.cpp").replace("info", "Info") + << QFINDTESTDATA("tst_qfileinfo.cpp") #if defined(Q_OS_WIN) << true; #elif defined(Q_OS_MAC) @@ -1098,7 +1098,7 @@ void tst_QFileInfo::isSymLink_data() QFile::remove("brokenlink.lnk"); QFile::remove("dummyfile"); - QFile file1(SRCDIR "tst_qfileinfo.cpp"); + QFile file1(QFINDTESTDATA("tst_qfileinfo.cpp")); QVERIFY(file1.link("link.lnk")); QFile file2("dummyfile"); @@ -1110,8 +1110,8 @@ void tst_QFileInfo::isSymLink_data() QTest::addColumn<bool>("isSymLink"); QTest::addColumn<QString>("linkTarget"); - QTest::newRow("existent file") << SRCDIR "tst_qfileinfo.cpp" << false << ""; - QTest::newRow("link") << "link.lnk" << true << QFileInfo(SRCDIR "tst_qfileinfo.cpp").absoluteFilePath(); + QTest::newRow("existent file") << QFINDTESTDATA("tst_qfileinfo.cpp") << false << ""; + QTest::newRow("link") << "link.lnk" << true << QFileInfo(QFINDTESTDATA("tst_qfileinfo.cpp")).absoluteFilePath(); QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); } @@ -1347,7 +1347,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() } { //File symlinks - QFileInfo target(SRCDIR "tst_qfileinfo.cpp"); + QFileInfo target(QFINDTESTDATA("tst_qfileinfo.cpp")); QString absTarget = QDir::toNativeSeparators(target.absoluteFilePath()); QString absSymlink = QDir::toNativeSeparators(pwd.absolutePath()).append("\\abs_symlink.cpp"); QString relTarget = QDir::toNativeSeparators(pwd.relativeFilePath(target.absoluteFilePath())); @@ -1462,7 +1462,7 @@ void tst_QFileInfo::isExecutable() QFileInfo fi(appPath); QCOMPARE(fi.isExecutable(), true); - QCOMPARE(QFileInfo(SRCDIR "qfileinfo.pro").isExecutable(), false); + QCOMPARE(QFileInfo(QFINDTESTDATA("qfileinfo.pro")).isExecutable(), false); #ifdef Q_OS_UNIX QFile::remove("link.lnk"); @@ -1474,7 +1474,7 @@ void tst_QFileInfo::isExecutable() QFile::remove("link.lnk"); // Symlink to .pro file - QFile proFile(SRCDIR "qfileinfo.pro"); + QFile proFile(QFINDTESTDATA("qfileinfo.pro")); QVERIFY(proFile.link("link.lnk")); QCOMPARE(QFileInfo("link.lnk").isExecutable(), false); QFile::remove("link.lnk"); diff --git a/tests/auto/corelib/io/qiodevice/qiodevice.pro b/tests/auto/corelib/io/qiodevice/qiodevice.pro index 2a90ca100b..a8295ec79b 100644 --- a/tests/auto/corelib/io/qiodevice/qiodevice.pro +++ b/tests/auto/corelib/io/qiodevice/qiodevice.pro @@ -3,15 +3,7 @@ TARGET = tst_qiodevice QT = core network testlib SOURCES = tst_qiodevice.cpp -wince* { - addFiles.files = tst_qiodevice.cpp - addFiles.path = . - DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"\\\" - !wince50standard-x86-msvc2005: DEFINES += WINCE_EMULATOR_TEST=1 -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +TESTDATA += tst_qiodevice.cpp MOC_DIR=tmp mac: CONFIG += insignificant_test # QTBUG-22766 diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 02a04a5fe5..c3d4e54c37 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -147,7 +147,7 @@ void tst_QIODevice::constructing_QFile() QVERIFY(!device->isOpen()); - file.setFileName(SRCDIR "tst_qiodevice.cpp"); + file.setFileName(QFINDTESTDATA("tst_qiodevice.cpp")); QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(device->isOpen()); QCOMPARE((int) device->openMode(), (int) QFile::ReadOnly); @@ -176,7 +176,7 @@ void tst_QIODevice::constructing_QFile() void tst_QIODevice::read_QByteArray() { - QFile f(SRCDIR "tst_qiodevice.cpp"); + QFile f(QFINDTESTDATA("tst_qiodevice.cpp")); f.open(QIODevice::ReadOnly); QByteArray b = f.read(10); diff --git a/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro b/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro index c9f87ba361..360981f83c 100644 --- a/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro +++ b/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro @@ -4,7 +4,6 @@ CONFIG -= app_bundle QT = core DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index bb21f76dd1..39ce734c56 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -3,92 +3,13 @@ QT = core testlib network embedded: QT += gui SOURCES = ../tst_qprocess.cpp -!wince*: { - TARGET = ../tst_qprocess - win32: { - CONFIG(debug, debug|release) { - TARGET = ../../debug/tst_qprocess - } else { - TARGET = ../../release/tst_qprocess - } +TARGET = ../tst_qprocess +win32 { + CONFIG(debug, debug|release) { + TARGET = ../../debug/tst_qprocess + } else { + TARGET = ../../release/tst_qprocess } -} else { - TARGET = tst_qprocess - addFile_fileWriterProcess.files = $$OUT_PWD/../fileWriterProcess/fileWriterProcess.exe - addFile_fileWriterProcess.path = fileWriterProcess - - addFile_testBatFiles.files = $$PWD/../testBatFiles/* - addFile_testBatFiles.path = testBatFiles - - addFile_testDetached.files = $$OUT_PWD/../testDetached/testDetached.exe - addFile_testDetached.path = testDetached - - addFile_testExitCodes.files = $$OUT_PWD/../testExitCodes/testExitCodes.exe - addFile_testExitCodes.path = testExitCodes - - addFile_testGuiProcess.files = $$OUT_PWD/../testGuiProcess/testGuiProcess.exe - addFile_testGuiProcess.path = testGuiProcess - - addFile_testProcessCrash.files = $$OUT_PWD/../testProcessCrash/testProcessCrash.exe - addFile_testProcessCrash.path = testProcessCrash - - addFile_testProcessDeadWhileReading.files = $$OUT_PWD/../testProcessDeadWhileReading/testProcessDeadWhileReading.exe - addFile_testProcessDeadWhileReading.path = testProcessDeadWhileReading - - addFile_testProcessEcho.files = $$OUT_PWD/../testProcessEcho/testProcessEcho.exe - addFile_testProcessEcho.path = testProcessEcho - - addFile_testProcessEcho2.files = $$OUT_PWD/../testProcessEcho2/testProcessEcho2.exe - addFile_testProcessEcho2.path = testProcessEcho2 - - addFile_testProcessEcho3.files = $$OUT_PWD/../testProcessEcho3/testProcessEcho3.exe - addFile_testProcessEcho3.path = testProcessEcho3 - - addFile_testProcessEOF.files = $$OUT_PWD/../testProcessEOF/testProcessEOF.exe - addFile_testProcessEOF.path = testProcessEOF - - addFile_testProcessLoopback.files = $$OUT_PWD/../testProcessLoopback/testProcessLoopback.exe - addFile_testProcessLoopback.path = testProcessLoopback - - addFile_testProcessNormal.files = $$OUT_PWD/../testProcessNormal/testProcessNormal.exe - addFile_testProcessNormal.path = testProcessNormal - - addFile_testProcessOutput.files = $$OUT_PWD/../testProcessOutput/testProcessOutput.exe - addFile_testProcessOutput.path = testProcessOutput - - addFile_testProcessNoSpacesArgs.files = $$OUT_PWD/../testProcessSpacesArgs/nospace.exe - addFile_testProcessNoSpacesArgs.path = testProcessSpacesArgs - - addFile_testProcessOneSpacesArgs.files = $$OUT_PWD/../testProcessSpacesArgs/"one space".exe - addFile_testProcessOneSpacesArgs.path = testProcessSpacesArgs - - addFile_testProcessTwoSpacesArgs.files = $$OUT_PWD/../testProcessSpacesArgs/"two space s".exe - addFile_testProcessTwoSpacesArgs.path = testProcessSpacesArgs - - addFile_testSoftExit.files = $$OUT_PWD/../testSoftExit/testSoftExit.exe - addFile_testSoftExit.path = testSoftExit - - addFile_testSpaceInName.files = $$OUT_PWD/../"test Space In Name"/testSpaceInName.exe - addFile_testSpaceInName.path = "test Space In Name" - - DEPLOYMENT += addFile_fileWriterProcess \ - addFile_testBatFiles \ - addFile_testDetached \ - addFile_testExitCodes \ - addFile_testGuiProcess \ - addFile_testProcessCrash \ - addFile_testProcessDeadWhileReading \ - addFile_testProcessEcho \ - addFile_testProcessEcho2 \ - addFile_testProcessEcho3 \ - addFile_testProcessEchoGui \ - addFile_testProcessEOF \ - addFile_testProcessLoopback \ - addFile_testProcessNormal \ - addFile_testProcessOutput \ - addFile_testProcessNoSpacesArgs \ - addFile_testProcessOneSpacesArgs \ - addFile_testProcessTwoSpacesArgs \ - addFile_testSoftExit \ - addFile_testSpaceInName } + +TESTDATA += ../testBatFiles/* diff --git a/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro b/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro index 8d1fcba624..e307379014 100644 --- a/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro +++ b/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro @@ -4,3 +4,7 @@ CONFIG += console CONFIG -= app_bundle INSTALLS = DESTDIR = ./ + +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro b/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro index b08371804f..afa8e4ccab 100644 --- a/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro +++ b/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro @@ -3,3 +3,7 @@ CONFIG -= qt app_bundle CONFIG += console DESTDIR = ./ + +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro b/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro index b26a583dee..992188b443 100644 --- a/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro +++ b/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro @@ -3,3 +3,6 @@ QT += widgets CONFIG += console DESTDIR = ./ +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro b/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro index abd8167313..98c5b966f2 100644 --- a/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro +++ b/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro @@ -4,5 +4,6 @@ CONFIG -= qt app_bundle DESTDIR = ./ -# no install rule for application used by test -INSTALLS = +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro index 2168ba5672..a5f4697605 100644 --- a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro +++ b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro @@ -4,7 +4,6 @@ CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro b/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro index 756bd23bb0..4efdad997d 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro @@ -5,5 +5,6 @@ CONFIG += console win32:!win32-g++*:!equals(TEMPLATE_PREFIX, "vc"):QMAKE_CXXFLAGS += /GS- DESTDIR = ./ - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro b/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro index a14c1fe163..f8dc695c17 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro @@ -3,6 +3,6 @@ CONFIG -= qt CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro b/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro index d8a303a22b..f8dc695c17 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro @@ -3,8 +3,6 @@ CONFIG -= qt CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro b/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro index 3b8f2fb0d7..f8dc695c17 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro @@ -3,7 +3,6 @@ CONFIG -= qt CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro b/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro index b3be74cbd1..65b408fc85 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro @@ -6,8 +6,6 @@ win32 { CONFIG -= qt DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro b/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro index 14ddae50f3..43378b6e17 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro @@ -7,6 +7,6 @@ mac { CONFIG -= app_bundle } -# no install rule for application used by test -INSTALLS = - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro b/tests/auto/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro index a14c1fe163..f8dc695c17 100644 --- a/tests/auto/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro +++ b/tests/auto/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro @@ -3,6 +3,6 @@ CONFIG -= qt CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro b/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro index 3c6a595d85..98c5b966f2 100644 --- a/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro +++ b/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro @@ -4,6 +4,6 @@ CONFIG -= qt app_bundle DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro b/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro index 3b8f2fb0d7..f8dc695c17 100644 --- a/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro +++ b/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro @@ -3,7 +3,6 @@ CONFIG -= qt CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro index f55f02e425..93d0afb79f 100644 --- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro +++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro @@ -3,7 +3,6 @@ CONFIG -= qt app_bundle CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - +# This app is testdata for tst_qproces +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro index 2a56a95606..f53e5790ea 100644 --- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro +++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro @@ -3,9 +3,8 @@ CONFIG -= qt app_bundle CONFIG += console DESTDIR = ./ -TARGET = "one space" - -# no install rule for application used by test -INSTALLS = - +TARGET = one space +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro index d7c74a64c9..a4ee0cfd83 100644 --- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro +++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro @@ -3,10 +3,8 @@ CONFIG -= qt app_bundle CONFIG += console DESTDIR = ./ -TARGET = "two space s" - -# no install rule for application used by test -INSTALLS = - - +TARGET = two space s +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro index b723604171..d6cc96b1e8 100644 --- a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro +++ b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro @@ -2,6 +2,6 @@ SOURCES = main.cpp CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro index 922035907a..5d4ec4fc21 100644 --- a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro +++ b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro @@ -10,7 +10,6 @@ CONFIG -= qt app_bundle CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - - +# This app is testdata for tst_qprocess +target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro b/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro index 913e868d03..eac0b59d9a 100644 --- a/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro +++ b/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro @@ -7,7 +7,6 @@ mac { CONFIG -= app_bundle } -# no install rule for application used by test -INSTALLS = - - +# This app is testdata for tst_qprocess +target.path = "$$[QT_INSTALL_TESTS]/tst_qprocess/test Space In Name" +INSTALLS += target diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 32cd6b7266..f5754c07aa 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -73,10 +73,9 @@ class tst_QProcess : public QObject { Q_OBJECT -#ifdef QT_NO_PROCESS public slots: void initTestCase(); -#else +#ifndef QT_NO_PROCESS private slots: void getSetCheck(); void constructing(); @@ -166,13 +165,18 @@ private: #endif }; -#ifdef QT_NO_PROCESS void tst_QProcess::initTestCase() { +#ifdef QT_NO_PROCESS QSKIP("This test requires QProcess support"); +#else + // chdir to our testdata path and execute helper apps relative to that. + QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessNormal")).absolutePath(); + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); +#endif } -#else +#ifndef QT_NO_PROCESS // Testing get/set functions void tst_QProcess::getSetCheck() diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index 1bb7bd9a90..d6e2cb3171 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -10,26 +10,14 @@ runtime_resource.commands = $$QMAKE_RCC -root /runtime_resource/ -binary $${runt QMAKE_EXTRA_TARGETS = runtime_resource PRE_TARGETDEPS += $${runtime_resource.target} -wince* { - deploy.files += runtime_resource.rcc parentdir.txt - test.files = testqrc/* - test.path = testqrc - alias.files = testqrc/aliasdir/* - alias.path = testqrc/aliasdir - other.files = testqrc/otherdir/* - other.path = testqrc/otherdir - search1.files = testqrc/searchpath1/* - search1.path = testqrc/searchpath1 - search2.files = testqrc/searchpath2/* - search2.path = testqrc/searchpath2 - sub.files = testqrc/subdir/* - sub.path = testqrc/subdir - testsub.files = testqrc/test/* - testsub.path = testqrc/test - testsub2.files = testqrc/test/test/* - testsub2.path = testqrc/test/test - DEPLOYMENT += deploy test alias other search1 search2 sub testsub testsub2 - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +TESTDATA += \ + parentdir.txt \ + testqrc/* + +# Special case needed for runtime_resource.rcc installation, +# since it does not exist at qmake runtime. +load(testcase) # to get value of target.path +runtime_resource_install.CONFIG = no_check_exist +runtime_resource_install.files = $$OUT_PWD/$${runtime_resource.target} +runtime_resource_install.path = $${target.path} +INSTALLS += runtime_resource_install diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 4a2dfb3f22..2a40a64580 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -59,9 +59,6 @@ private slots: void searchPath(); void doubleSlashInRoot(); void setLocale(); - -private: - QString builddir; }; Q_DECLARE_METATYPE(QLocale) @@ -69,26 +66,15 @@ Q_DECLARE_METATYPE(qlonglong) void tst_QResourceEngine::initTestCase() { - QVERIFY(QResource::registerResource("runtime_resource.rcc")); - QVERIFY(QResource::registerResource("runtime_resource.rcc", "/secondary_root/")); - QString srcdir(QLatin1String(SRCDIR)); - if (!srcdir.isEmpty()) { - builddir = QDir::current().absolutePath(); - if (!builddir.endsWith(QDir::separator())) - builddir.append(QDir::separator()); - QDir::setCurrent(srcdir); - } + QVERIFY(QResource::registerResource(QFINDTESTDATA("runtime_resource.rcc"))); + QVERIFY(QResource::registerResource(QFINDTESTDATA("runtime_resource.rcc"), "/secondary_root/")); } void tst_QResourceEngine::cleanupTestCase() { - if (!builddir.isEmpty()) { - QDir::setCurrent(builddir); - } - // make sure we don't leak memory - QVERIFY(QResource::unregisterResource("runtime_resource.rcc")); - QVERIFY(QResource::unregisterResource("runtime_resource.rcc", "/secondary_root/")); + QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc"))); + QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc"), "/secondary_root/")); } void tst_QResourceEngine::checkStructure_data() @@ -182,7 +168,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(0); - info = QFileInfo("testqrc/test/test/test1.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test1.txt")); QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test1.txt") << QString("abc") << QStringList() @@ -190,7 +176,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/blahblah.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/blahblah.txt")); QTest::newRow(QString(root + "text no slashes").toLatin1().constData()) << QString(root + "withoutslashes/blahblah.txt") << QString("qwerty") << QStringList() @@ -199,7 +185,7 @@ void tst_QResourceEngine::checkStructure_data() << qlonglong(info.size()); - info = QFileInfo("testqrc/test/test/test2.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test2.txt")); QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test2.txt") << QString("def") << QStringList() @@ -207,7 +193,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/currentdir.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/currentdir.txt")); QTest::newRow(QString(root + "currentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir.txt") << QString("\"This is the current dir\" ") << QStringList() @@ -215,7 +201,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/currentdir2.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/currentdir2.txt")); QTest::newRow(QString(root + "currentdir text2").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir2.txt") << QString("\"This is also the current dir\" ") << QStringList() @@ -223,7 +209,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("parentdir.txt"); + info = QFileInfo(QFINDTESTDATA("parentdir.txt")); QTest::newRow(QString(root + "parentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/parentdir.txt") << QString("abcdefgihklmnopqrstuvwxyz ") << QStringList() @@ -231,7 +217,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/subdir/subdir.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/subdir/subdir.txt")); QTest::newRow(QString(root + "subdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/subdir/subdir.txt") << QString("\"This is in the sub directory\" ") << QStringList() @@ -239,7 +225,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/test/testdir.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir.txt")); QTest::newRow(QString(root + "testdir text").toLatin1().constData()) << QString(root + "test/testdir.txt") << QString("\"This is in the test directory\" ") << QStringList() @@ -247,7 +233,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/otherdir/otherdir.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/otherdir/otherdir.txt")); QTest::newRow(QString(root + "otherdir text").toLatin1().constData()) << QString(root + "otherdir/otherdir.txt") << QString("\"This is the other dir\" ") << QStringList() @@ -255,7 +241,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/test/testdir2.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir2.txt")); QTest::newRow(QString(root + "alias text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") << QString("\"This is another file in this directory\" ") << QStringList() @@ -263,7 +249,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale::c() << qlonglong(info.size()); - info = QFileInfo("testqrc/aliasdir/aliasdir.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt")); QTest::newRow(QString(root + "korean text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") << QString("\"This is a korean text file\" ") << QStringList() @@ -271,7 +257,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale("ko") << qlonglong(info.size()); - info = QFileInfo("testqrc/aliasdir/aliasdir.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt")); QTest::newRow(QString(root + "korean text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") << QString("\"This is a korean text file\" ") << QStringList() @@ -279,7 +265,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale("ko_KR") << qlonglong(info.size()); - info = QFileInfo("testqrc/test/german.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt")); QTest::newRow(QString(root + "german text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") << QString("Deutsch") << QStringList() @@ -287,7 +273,7 @@ void tst_QResourceEngine::checkStructure_data() << QLocale("de") << qlonglong(info.size()); - info = QFileInfo("testqrc/test/german.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt")); QTest::newRow(QString(root + "german text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") << QString("Deutsch") << QStringList() @@ -295,9 +281,9 @@ void tst_QResourceEngine::checkStructure_data() << QLocale("de_DE") << qlonglong(info.size()); - QFile file("testqrc/aliasdir/compressme.txt"); + QFile file(QFINDTESTDATA("testqrc/aliasdir/compressme.txt")); file.open(QFile::ReadOnly); - info = QFileInfo("testqrc/aliasdir/compressme.txt"); + info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/compressme.txt")); QTest::newRow(QString(root + "compressed text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") << QString(file.readAll()) << QStringList() @@ -416,9 +402,9 @@ void tst_QResourceEngine::checkUnregisterResource_data() QTest::addColumn<QString>("file_check"); QTest::addColumn<int>("size"); - QTest::newRow("currentdir.txt") << builddir + QString("runtime_resource.rcc") << QString("/check_unregister/") + QTest::newRow("currentdir.txt") << QFINDTESTDATA("runtime_resource.rcc") << QString("/check_unregister/") << QString(":/check_unregister/runtime_resource/test/abc/123/+++/currentdir.txt") - << (int)QFileInfo("testqrc/currentdir.txt").size(); + << (int)QFileInfo(QFINDTESTDATA("testqrc/currentdir.txt")).size(); } void tst_QResourceEngine::checkUnregisterResource() diff --git a/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro b/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro index c39204af51..2ceef978cc 100644 --- a/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro +++ b/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro @@ -2,10 +2,4 @@ CONFIG += testcase parallel_test TARGET = tst_qstandardpaths QT = core testlib SOURCES = tst_qstandardpaths.cpp - -wince* { - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - +TESTDATA += tst_qstandardpaths.cpp qstandardpaths.pro diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 67abd0939b..be0c85e380 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -73,8 +73,7 @@ private slots: private: void setCustomLocations() { - m_thisDir = QFile::decodeName(SRCDIR); - m_thisDir.chop(1); // remove trailing slash! + m_thisDir = QFileInfo(QFINDTESTDATA("tst_qstandardpaths.cpp")).absolutePath(); qputenv("XDG_CONFIG_HOME", QFile::encodeName(m_thisDir)); QDir parent(m_thisDir); @@ -116,6 +115,8 @@ void tst_qstandardpaths::testCustomLocations() // test writableLocation() QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), m_thisDir); + QString thisDir_base = QFileInfo(m_thisDir).fileName(); + // test locate() const QString thisFileName = QString::fromLatin1("tst_qstandardpaths.cpp"); QVERIFY(QFile::exists(m_thisDir + '/' + thisFileName)); @@ -123,9 +124,9 @@ void tst_qstandardpaths::testCustomLocations() QVERIFY(!thisFile.isEmpty()); QVERIFY(thisFile.endsWith(thisFileName)); - const QString dir = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString::fromLatin1("../qstandardpaths"), QStandardPaths::LocateDirectory); + const QString dir = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString::fromLatin1("../") + thisDir_base, QStandardPaths::LocateDirectory); QVERIFY(!dir.isEmpty()); - const QString thisDirAsFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString::fromLatin1("../qstandardpaths")); + const QString thisDirAsFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString::fromLatin1("../") + thisDir_base); QVERIFY(thisDirAsFile.isEmpty()); // not a file const QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation); diff --git a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro index b9650b8dde..e06265b83f 100644 --- a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -2,4 +2,4 @@ CONFIG += testcase parallel_test TARGET = tst_qtemporaryfile QT = core testlib SOURCES = tst_qtemporaryfile.cpp -DEFINES += SRCDIR=\\\"$$PWD/\\\" +TESTDATA += tst_qtemporaryfile.cpp diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index dd8b7829ff..fb459e98d8 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -418,7 +418,7 @@ void tst_QTemporaryFile::renameFdLeak() static const int count = 10; int bunch_of_files[count]; for (int i = 0; i < count; ++i) { - bunch_of_files[i] = ::open(SRCDIR "tst_qtemporaryfile.cpp", O_RDONLY); + bunch_of_files[i] = ::open(qPrintable(QFINDTESTDATA("tst_qtemporaryfile.cpp")), O_RDONLY); QVERIFY(bunch_of_files[i] != -1); } diff --git a/tests/auto/corelib/io/qtextstream/readAllStdinProcess/readAllStdinProcess.pro b/tests/auto/corelib/io/qtextstream/readAllStdinProcess/readAllStdinProcess.pro index 9cf4d19387..4a4c091dcb 100644 --- a/tests/auto/corelib/io/qtextstream/readAllStdinProcess/readAllStdinProcess.pro +++ b/tests/auto/corelib/io/qtextstream/readAllStdinProcess/readAllStdinProcess.pro @@ -4,4 +4,6 @@ CONFIG += console CONFIG -= app_bundle DESTDIR = ./ - +# This app is testdata for tst_qtextstream +target.path = $$[QT_INSTALL_TESTS]/tst_qtextstream/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qtextstream/readLineStdinProcess/readLineStdinProcess.pro b/tests/auto/corelib/io/qtextstream/readLineStdinProcess/readLineStdinProcess.pro index 9cf4d19387..4a4c091dcb 100644 --- a/tests/auto/corelib/io/qtextstream/readLineStdinProcess/readLineStdinProcess.pro +++ b/tests/auto/corelib/io/qtextstream/readLineStdinProcess/readLineStdinProcess.pro @@ -4,4 +4,6 @@ CONFIG += console CONFIG -= app_bundle DESTDIR = ./ - +# This app is testdata for tst_qtextstream +target.path = $$[QT_INSTALL_TESTS]/tst_qtextstream/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qtextstream/stdinProcess/stdinProcess.pro b/tests/auto/corelib/io/qtextstream/stdinProcess/stdinProcess.pro index 9cf4d19387..4a4c091dcb 100644 --- a/tests/auto/corelib/io/qtextstream/stdinProcess/stdinProcess.pro +++ b/tests/auto/corelib/io/qtextstream/stdinProcess/stdinProcess.pro @@ -4,4 +4,6 @@ CONFIG += console CONFIG -= app_bundle DESTDIR = ./ - +# This app is testdata for tst_qtextstream +target.path = $$[QT_INSTALL_TESTS]/tst_qtextstream/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/io/qtextstream/test/test.pro b/tests/auto/corelib/io/qtextstream/test/test.pro index def79218f2..577f52972d 100644 --- a/tests/auto/corelib/io/qtextstream/test/test.pro +++ b/tests/auto/corelib/io/qtextstream/test/test.pro @@ -12,15 +12,12 @@ win32 { } } -wince* { - addFiles.files = ../rfc3261.txt ../shift-jis.txt ../task113817.txt ../qtextstream.qrc ../tst_qtextstream.cpp - addFiles.path = . - res.files = ../resources - res.path = . - DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/../\\\" -} +TESTDATA += \ + ../rfc3261.txt \ + ../shift-jis.txt \ + ../task113817.txt \ + ../qtextstream.qrc \ + ../tst_qtextstream.cpp \ + ../resources mac: CONFIG += insignificant_test # QTBUG-22767 diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 049ab2d8f1..86a5ac1e0a 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -47,7 +47,6 @@ #include <QBuffer> #include <QByteArray> -#include <QCoreApplication> #include <QDebug> #include <QFile> #include <QTcpSocket> @@ -247,16 +246,16 @@ private: void tst_QTextStream::initTestCase() { QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + + // chdir into the testdata dir and refer to our helper apps with relative paths + QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath(); + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); } // Testing get/set functions void tst_QTextStream::getSetCheck() { // Initialize codecs - int argc = 0; - char **argv = 0; - QCoreApplication app(argc, argv); - QTextStream obj1; // QTextCodec * QTextStream::codec() // void QTextStream::setCodec(QTextCodec *) @@ -753,7 +752,7 @@ void tst_QTextStream::generateAllData(bool for_QString) // ------------------------------------------------------------------------------ void tst_QTextStream::readLineUntilNull() { - QFile file(SRCDIR "rfc3261.txt"); + QFile file(QFINDTESTDATA("rfc3261.txt")); QVERIFY(file.open(QFile::ReadOnly)); QTextStream stream(&file); @@ -872,7 +871,7 @@ void tst_QTextStream::lineCount_data() QTest::newRow("buffersize+1 line") << QByteArray(16384, '\n') << 16384; QTest::newRow("buffersize+2 line") << QByteArray(16385, '\n') << 16385; - QFile file(SRCDIR "rfc3261.txt"); file.open(QFile::ReadOnly); + QFile file(QFINDTESTDATA("rfc3261.txt")); file.open(QFile::ReadOnly); QTest::newRow("rfc3261") << file.readAll() << 15067; } @@ -908,7 +907,7 @@ void tst_QTextStream::performance() stopWatch.restart(); int nlines1 = 0; - QFile file(SRCDIR "rfc3261.txt"); + QFile file(QFINDTESTDATA("rfc3261.txt")); QVERIFY(file.open(QFile::ReadOnly)); while (!file.atEnd()) { @@ -920,7 +919,7 @@ void tst_QTextStream::performance() stopWatch.restart(); int nlines2 = 0; - QFile file2(SRCDIR "rfc3261.txt"); + QFile file2(QFINDTESTDATA("rfc3261.txt")); QVERIFY(file2.open(QFile::ReadOnly)); QTextStream stream(&file2); @@ -1089,11 +1088,7 @@ void tst_QTextStream::ws_manipulator() // ------------------------------------------------------------------------------ void tst_QTextStream::stillOpenWhenAtEnd() { - int argc = 0; - char **argv = 0; - QCoreApplication app(argc, argv); - - QFile file(SRCDIR "tst_qtextstream.cpp"); + QFile file(QFINDTESTDATA("tst_qtextstream.cpp")); QVERIFY(file.open(QFile::ReadOnly)); QTextStream stream(&file); @@ -1141,7 +1136,7 @@ void tst_QTextStream::readNewlines() // ------------------------------------------------------------------------------ void tst_QTextStream::seek() { - QFile file(SRCDIR "rfc3261.txt"); + QFile file(QFINDTESTDATA("rfc3261.txt")); QVERIFY(file.open(QFile::ReadOnly)); QTextStream stream(&file); @@ -1189,8 +1184,6 @@ void tst_QTextStream::seek() // ------------------------------------------------------------------------------ void tst_QTextStream::pos() { - int argc = 1; - QCoreApplication app(argc, 0); { // Strings QString str("this is a test"); @@ -1236,7 +1229,7 @@ void tst_QTextStream::pos() } { // Latin1 device - QFile file(SRCDIR "rfc3261.txt"); + QFile file(QFINDTESTDATA("rfc3261.txt")); QVERIFY(file.open(QIODevice::ReadOnly)); QTextStream stream(&file); @@ -1268,7 +1261,7 @@ void tst_QTextStream::pos() { // Shift-JIS device for (int i = 0; i < 2; ++i) { - QFile file(SRCDIR "shift-jis.txt"); + QFile file(QFINDTESTDATA("shift-jis.txt")); if (i == 0) QVERIFY(file.open(QIODevice::ReadOnly)); else @@ -2870,22 +2863,6 @@ void tst_QTextStream::int_write_with_locale() // ------------------------------------------------------------------------------ -// like QTEST_APPLESS_MAIN, but initialising the locale on Unix -#if defined (Q_OS_UNIX) -QT_BEGIN_NAMESPACE -extern bool qt_locale_initialized; -QT_END_NAMESPACE -#endif - -int main(int argc, char *argv[]) -{ -#if defined (Q_OS_UNIX) - ::setlocale(LC_ALL, ""); - qt_locale_initialized = true; -#endif - tst_QTextStream tc; - return QTest::qExec(&tc, argc, argv); -} - +QTEST_MAIN(tst_QTextStream) #include "tst_qtextstream.moc" |