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>
This commit is contained in:
Rohan McGovern 2011-11-24 10:36:10 +10:00 committed by Qt by Nokia
parent 13eba9ddf4
commit 3385fb91e1
84 changed files with 499 additions and 764 deletions

View File

@ -2,23 +2,12 @@ CONFIG += testcase
QT += testlib QT += testlib
SOURCES = ../tst_qtextcodec.cpp SOURCES = ../tst_qtextcodec.cpp
!wince* { TARGET = ../tst_qtextcodec
TARGET = ../tst_qtextcodec win32 {
win32: { CONFIG(debug, debug|release) {
CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qtextcodec
TARGET = ../../debug/tst_qtextcodec } else {
} else { TARGET = ../../release/tst_qtextcodec
TARGET = ../../release/tst_qtextcodec
}
} }
DEFINES += SRCDIR=\\\"$$PWD/../\\\"
} else {
TARGET = tst_qtextcodec
addFiles.files = ../*.txt
addFiles.path = .
DEPLOYMENT += addFiles
qt_not_deployed {
DEPLOYMENT_PLUGIN += qcncodecs qjpcodecs qkrcodecs qtwcodecs
}
DEFINES += SRCDIR=\\\"\\\"
} }
TESTDATA += ../*.txt

View File

@ -110,8 +110,8 @@ void tst_QTextCodec::toUnicode_data()
QTest::addColumn<QString>("fileName"); QTest::addColumn<QString>("fileName");
QTest::addColumn<QString>("codecName"); QTest::addColumn<QString>("codecName");
QTest::newRow( "korean-eucKR" ) << SRCDIR "korean.txt" << "eucKR"; QTest::newRow( "korean-eucKR" ) << QFINDTESTDATA("korean.txt") << "eucKR";
QTest::newRow( "UTF-8" ) << SRCDIR "utf8.txt" << "UTF-8"; QTest::newRow( "UTF-8" ) << QFINDTESTDATA("utf8.txt") << "UTF-8";
} }
void tst_QTextCodec::toUnicode() void tst_QTextCodec::toUnicode()
@ -288,7 +288,7 @@ void tst_QTextCodec::fromUnicode()
void tst_QTextCodec::toUnicode_codecForHtml() void tst_QTextCodec::toUnicode_codecForHtml()
{ {
QFile file(QString(SRCDIR "QT4-crashtest.txt")); QFile file(QFINDTESTDATA("QT4-crashtest.txt"));
QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(file.open(QFile::ReadOnly));
QByteArray data = file.readAll(); QByteArray data = file.readAll();

View File

@ -3,11 +3,4 @@ TARGET = tst_qdatastream
QT += widgets testlib QT += widgets testlib
SOURCES = tst_qdatastream.cpp SOURCES = tst_qdatastream.cpp
wince* { TESTDATA += datastream.q42
addFiles.files = datastream.q42
addFiles.path = .
DEPLOYMENT += addFiles
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}

View File

@ -2917,7 +2917,7 @@ void tst_QDataStream::streamRealDataTypes()
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
QFile file; QFile file;
if (i == 0) { if (i == 0) {
file.setFileName(SRCDIR "datastream.q42"); file.setFileName(QFINDTESTDATA("datastream.q42"));
} else { } else {
file.setFileName("datastream.tmp"); file.setFileName("datastream.tmp");

View File

@ -4,11 +4,4 @@ QT = core testlib
SOURCES = tst_qdir.cpp SOURCES = tst_qdir.cpp
RESOURCES += qdir.qrc RESOURCES += qdir.qrc
wince* { TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp
DirFiles.files = testdir testData searchdir resources entrylist types tst_qdir.cpp
DirFiles.path = .
DEPLOYMENT += DirFiles
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}

View File

@ -75,6 +75,8 @@ class tst_QDir : public QObject
Q_OBJECT Q_OBJECT
private slots: private slots:
void init();
void getSetCheck(); void getSetCheck();
void construction(); void construction();
@ -184,8 +186,21 @@ private slots:
void isRelative(); void isRelative();
void isReadable(); 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 // Testing get/set functions
void tst_QDir::getSetCheck() void tst_QDir::getSetCheck()
{ {
@ -328,8 +343,8 @@ void tst_QDir::exists_data()
QTest::newRow("resource0") << QString(":/tst_qdir/") << true; QTest::newRow("resource0") << QString(":/tst_qdir/") << true;
QTest::newRow("resource1") << QString(":/I/Do_not_expect_this_resource_to_exist/") << false; QTest::newRow("resource1") << QString(":/I/Do_not_expect_this_resource_to_exist/") << false;
QTest::newRow("simple dir") << SRCDIR "resources" << true; QTest::newRow("simple dir") << (m_dataPath + "/resources") << true;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
QTest::newRow("unc 2") << "//" + 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>("filterspec");
QTest::addColumn<int>("sortspec"); QTest::addColumn<int>("sortspec");
QTest::addColumn<QStringList>("expected"); 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) << (int)(QDir::NoFilter) << (int)(QDir::NoSort)
<< QStringList("foo. bar"); // notice how spaces5 works << 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) << (int)(QDir::NoFilter) << (int)(QDir::NoSort)
<< QStringList("foo.bar"); << 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) << (int)(QDir::NoFilter) << (int)(QDir::NoSort)
<< QString("foo. bar,foo.bar").split(','); << 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) << (int)(QDir::NoFilter) << (int)(QDir::NoSort)
<< QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(','); << 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) << (int)(QDir::AllDirs) << (int)(QDir::NoSort)
<< QString(".,..,dir,spaces").split(','); << QString(".,..,dir,spaces").split(',');
QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data") 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) << (int)(QDir::Files) << (int)(QDir::NoSort)
<< QString("file1.data,file2.data,file3.data").split(','); << 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) << int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); << 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) << int(QDir::AllEntries) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); << 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) << int(QDir::Files) << int(QDir::Name)
<< filterLinks(QString("file,linktofile.lnk,writable").split(',')); << 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) << int(QDir::Dirs) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); << 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) << int(QDir::Dirs | QDir::NoDotAndDotDot) << int(QDir::Name)
<< filterLinks(QString("directory,linktodirectory.lnk").split(',')); << 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) << int(QDir::AllDirs) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); << 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) << int(QDir::AllDirs | QDir::Dirs) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); << 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) << int(QDir::AllDirs | QDir::Files) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); << 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) << int(QDir::AllEntries | QDir::NoSymLinks) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,file,writable").split(',')); << 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) << int(QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot) << int(QDir::Name)
<< filterLinks(QString("directory,file,writable").split(',')); << 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) << int(QDir::Files | QDir::NoSymLinks) << int(QDir::Name)
<< filterLinks(QString("file,writable").split(',')); << 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) << int(QDir::Dirs | QDir::NoSymLinks) << int(QDir::Name)
<< filterLinks(QString(".,..,directory").split(',')); << 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) << int(QDir::Drives | QDir::Files | QDir::NoDotAndDotDot) << int(QDir::Name)
<< filterLinks(QString("file,linktofile.lnk,writable").split(',')); << 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) << int(QDir::System) << int(QDir::Name)
<< filterLinks(QStringList("brokenlink.lnk")); << 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) << int(QDir::Hidden) << int(QDir::Name)
<< QStringList(); << 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) << int(QDir::System | QDir::Hidden) << int(QDir::Name)
<< filterLinks(QStringList("brokenlink.lnk")); << 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) << int(QDir::AllDirs | QDir::NoSymLinks) << int(QDir::Name)
<< filterLinks(QString(".,..,directory").split(',')); << 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) << int(QDir::AllEntries | QDir::Hidden | QDir::System) << int(QDir::Name)
<< filterLinks(QString(".,..,brokenlink.lnk,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); << 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) << int(QDir::AllEntries | QDir::Readable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); << 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) << int(QDir::AllEntries | QDir::Writable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(',')); << 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) << int(QDir::Files | QDir::Readable) << int(QDir::Name)
<< filterLinks(QString("file,linktofile.lnk,writable").split(',')); << 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) << int(QDir::Dirs | QDir::Readable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk").split(',')); << 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) << int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString("directory").split(',')); << 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) << int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString("file").split(',')); << 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) << int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString("linktodirectory.lnk,linktofile.lnk").split(',')); << 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) << int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString("directory,linktodirectory.lnk,linktofile.lnk").split(',')); << 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) << int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); << 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) << int(QDir::NoFilter) << int(QDir::Name | QDir::Reversed)
<< filterLinks(QString("writable,linktofile.lnk,linktodirectory.lnk,file,directory,..,.").split(',')); << 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) << 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(','); << 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) << 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(','); << 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) << 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(','); << 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) << 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(','); << 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) << 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(','); << 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) << 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(','); << 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(int, sortspec);
QFETCH(QStringList, expected); QFETCH(QStringList, expected);
QFile(SRCDIR "entrylist/writable").open(QIODevice::ReadWrite); QString entrylistPath = (m_dataPath + "/entrylist/");
QFile(SRCDIR "entrylist/file").setPermissions(QFile::ReadOwner | QFile::ReadUser); QFile(entrylistPath + "writable").open(QIODevice::ReadWrite);
QFile::remove(SRCDIR "entrylist/linktofile"); QFile(entrylistPath + "file").setPermissions(QFile::ReadOwner | QFile::ReadUser);
QFile::remove(SRCDIR "entrylist/linktodirectory"); QFile::remove(entrylistPath + "linktofile");
QFile::remove(SRCDIR "entrylist/linktofile.lnk"); QFile::remove(entrylistPath + "linktodirectory");
QFile::remove(SRCDIR "entrylist/linktodirectory.lnk"); QFile::remove(entrylistPath + "linktofile.lnk");
QFile::remove(SRCDIR "entrylist/brokenlink.lnk"); QFile::remove(entrylistPath + "linktodirectory.lnk");
QFile::remove(SRCDIR "entrylist/brokenlink"); QFile::remove(entrylistPath + "brokenlink.lnk");
QFile::remove(entrylistPath + "brokenlink");
// WinCE does not have . and .. in the directory listing // WinCE does not have . and .. in the directory listing
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
@ -591,13 +607,14 @@ void tst_QDir::entryList()
#ifndef Q_NO_SYMLINKS #ifndef Q_NO_SYMLINKS
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
// ### Sadly, this is a platform difference right now. // ### Sadly, this is a platform difference right now.
QFile::link(SRCDIR "entryList/file", SRCDIR "entrylist/linktofile.lnk"); // Note we are using capital L in entryList on one side here, to test case-insensitivity
QFile::link(SRCDIR "entryList/directory", SRCDIR "entrylist/linktodirectory.lnk"); QFile::link((m_dataPath + "/entryList/") + "file", entrylistPath + "linktofile.lnk");
QFile::link(SRCDIR "entryList/nothing", SRCDIR "entrylist/brokenlink.lnk"); QFile::link((m_dataPath + "/entryList/") + "directory", entrylistPath + "linktodirectory.lnk");
QFile::link((m_dataPath + "/entryList/") + "nothing"), entrylistPath + "brokenlink.lnk");
#else #else
QFile::link("file", SRCDIR "entrylist/linktofile.lnk"); QFile::link("file", entrylistPath + "linktofile.lnk");
QFile::link("directory", SRCDIR "entrylist/linktodirectory.lnk"); QFile::link("directory", entrylistPath + "linktodirectory.lnk");
QFile::link("nothing", SRCDIR "entrylist/brokenlink.lnk"); QFile::link("nothing", entrylistPath + "brokenlink.lnk");
#endif #endif
#endif //Q_NO_SYMLINKS #endif //Q_NO_SYMLINKS
@ -625,13 +642,13 @@ void tst_QDir::entryList()
QCOMPARE(actual.count(), expected.count()); QCOMPARE(actual.count(), expected.count());
} }
QFile::remove(SRCDIR "entrylist/writable"); QFile::remove(entrylistPath + "writable");
QFile::remove(SRCDIR "entrylist/linktofile"); QFile::remove(entrylistPath + "linktofile");
QFile::remove(SRCDIR "entrylist/linktodirectory"); QFile::remove(entrylistPath + "linktodirectory");
QFile::remove(SRCDIR "entrylist/linktofile.lnk"); QFile::remove(entrylistPath + "linktofile.lnk");
QFile::remove(SRCDIR "entrylist/linktodirectory.lnk"); QFile::remove(entrylistPath + "linktodirectory.lnk");
QFile::remove(SRCDIR "entrylist/brokenlink.lnk"); QFile::remove(entrylistPath + "brokenlink.lnk");
QFile::remove(SRCDIR "entrylist/brokenlink"); QFile::remove(entrylistPath + "brokenlink");
} }
void tst_QDir::entryListSimple_data() 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; QTest::newRow("data2") << "do_not_expect_this_path_to_exist/" << 0;
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
QTest::newRow("simple dir") << SRCDIR "resources" << 0; QTest::newRow("simple dir") << (m_dataPath + "/resources") << 0;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << 0; QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 0;
#else #else
QTest::newRow("simple dir") << SRCDIR "resources" << 2; QTest::newRow("simple dir") << (m_dataPath + "/resources") << 2;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << 2; QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2;
#endif #endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #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>("path");
QTest::addColumn<QString>("canonicalPath"); 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 QTest::newRow("relative") << "." << m_dataPath;
if (appPath.endsWith("release", Qt::CaseInsensitive) || appPath.endsWith("debug", Qt::CaseInsensitive)) { QTest::newRow("relativeSubDir") << "./testData/../testData" << m_dataPath + "/testData";
QDir appDir(appPath);
QVERIFY(appDir.cdUp());
appPath = appDir.absolutePath();
}
#endif
QTest::newRow("relative") << "." << appPath;
QTest::newRow("relativeSubDir") << "./testData/../testData" << appPath + "/testData";
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
QTest::newRow("absPath") << appPath + "/testData/../testData" << appPath + "/testData"; QTest::newRow("absPath") << m_dataPath + "/testData/../testData" << m_dataPath + "/testData";
#else #else
QTest::newRow("absPath") << appPath + "\\testData\\..\\testData" << appPath + "/testData"; QTest::newRow("absPath") << m_dataPath + "\\testData\\..\\testData" << m_dataPath + "/testData";
#endif #endif
QTest::newRow("nonexistant") << "testd" << QString(); QTest::newRow("nonexistant") << "testd" << QString();
@ -768,16 +772,12 @@ void tst_QDir::canonicalPath_data()
void tst_QDir::canonicalPath() void tst_QDir::canonicalPath()
{ {
QDir srcPath; QDir dataDir(m_dataPath);
if (strlen(SRCDIR) > 0) if (dataDir.absolutePath() != dataDir.canonicalPath())
srcPath = QDir(SRCDIR);
else
srcPath = QDir(".");
if (srcPath.absolutePath() != srcPath.canonicalPath())
QSKIP("This test does not work if this directory path consists of symlinks."); QSKIP("This test does not work if this directory path consists of symlinks.");
QString oldpwd = QDir::currentPath(); QString oldpwd = QDir::currentPath();
QDir::setCurrent(srcPath.absolutePath()); QDir::setCurrent(dataDir.absolutePath());
QFETCH(QString, path); QFETCH(QString, path);
QFETCH(QString, canonicalPath); QFETCH(QString, canonicalPath);
@ -796,37 +796,23 @@ void tst_QDir::current_data()
{ {
QTest::addColumn<QString>("path"); QTest::addColumn<QString>("path");
QTest::addColumn<QString>("currentDir"); 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("startup") << QString() << m_dataPath;
QTest::newRow("relPath") << "testData" << appPath + "/testData"; QTest::newRow("relPath") << "testData" << m_dataPath + "/testData";
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
QTest::newRow("absPath") << appPath + "/testData" << appPath + "/testData"; QTest::newRow("absPath") << m_dataPath + "/testData" << m_dataPath + "/testData";
#else #else
QTest::newRow("absPath") << appPath + "\\testData" << appPath + "/testData"; QTest::newRow("absPath") << m_dataPath + "\\testData" << m_dataPath + "/testData";
#endif #endif
QTest::newRow("nonexistant") << "testd" << QString(); 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() void tst_QDir::current()
{ {
QString oldDir = QDir::currentPath(); QString oldDir = QDir::currentPath();
QString appPath = SRCDIR; QDir::setCurrent(m_dataPath);
if (appPath.isEmpty())
appPath = QCoreApplication::instance()->applicationDirPath();
QDir::setCurrent(appPath);
QFETCH(QString, path); QFETCH(QString, path);
QFETCH(QString, currentDir); QFETCH(QString, currentDir);
@ -855,17 +841,16 @@ void tst_QDir::cd_data()
QTest::addColumn<bool>("successExpected"); QTest::addColumn<bool>("successExpected");
QTest::addColumn<QString>("newDir"); QTest::addColumn<QString>("newDir");
QString appPath = QDir::currentPath(); int index = m_dataPath.lastIndexOf("/");
int index = appPath.lastIndexOf("/"); QTest::newRow("cdUp") << m_dataPath << ".." << true << m_dataPath.left(index==0?1:index);
QTest::newRow("cdUp") << QDir::currentPath() << ".." << true << appPath.left(index==0?1:index); QTest::newRow("noChange") << m_dataPath << "." << true << m_dataPath;
QTest::newRow("noChange") << QDir::currentPath() << "." << true << appPath;
#if defined(Q_OS_WIN) // on windows QDir::root() is usually c:/ but cd "/" will not force it to be root #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 #else
QTest::newRow("absolute") << QDir::currentPath() << "/" << true << QDir::root().absolutePath(); QTest::newRow("absolute") << m_dataPath << "/" << true << QDir::root().absolutePath();
#endif #endif
QTest::newRow("non existant") << "." << "../anonexistingdir" << false << QDir::currentPath(); QTest::newRow("non existant") << "." << "../anonexistingdir" << false << m_dataPath;
QTest::newRow("self") << "." << (QString("../") + QFileInfo(QDir::currentPath()).fileName()) << true << QDir::currentPath(); QTest::newRow("self") << "." << (QString("../") + QFileInfo(m_dataPath).fileName()) << true << m_dataPath;
QTest::newRow("file") << "." << "qdir.pro" << false << ""; QTest::newRow("file") << "." << "qdir.pro" << false << "";
} }
@ -892,19 +877,13 @@ void tst_QDir::setNameFilters_data()
QTest::addColumn<QStringList>("nameFilters"); QTest::addColumn<QStringList>("nameFilters");
QTest::addColumn<QStringList>("expected"); QTest::addColumn<QStringList>("expected");
QString appPath = SRCDIR; QTest::newRow("spaces1") << m_dataPath + "/testdir/spaces" << QStringList("*. bar")
if (appPath.isEmpty())
appPath = QCoreApplication::instance()->applicationDirPath();
if (!appPath.endsWith("/"))
appPath.append("/");
QTest::newRow("spaces1") << appPath + "testdir/spaces" << QStringList("*. bar")
<< QStringList("foo. bar"); << QStringList("foo. bar");
QTest::newRow("spaces2") << appPath + "testdir/spaces" << QStringList("*.bar") QTest::newRow("spaces2") << m_dataPath + "/testdir/spaces" << QStringList("*.bar")
<< QStringList("foo.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(","); << 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(","); << QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(",");
QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data") QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data")
<< QString("file1.data,file2.data,file3.data").split(','); << QString("file1.data,file2.data,file3.data").split(',');
@ -1170,8 +1149,7 @@ void tst_QDir::exists2()
QFETCH(bool, exists); QFETCH(bool, exists);
QString oldpwd = QDir::currentPath(); QString oldpwd = QDir::currentPath();
if (strlen(SRCDIR) > 0) QDir::setCurrent((m_dataPath + "/."));
QDir::setCurrent(SRCDIR);
if (path.isEmpty()) if (path.isEmpty())
QTest::ignoreMessage(QtWarningMsg, "QDir::exists: Empty or null file name"); QTest::ignoreMessage(QtWarningMsg, "QDir::exists: Empty or null file name");
@ -1223,7 +1201,7 @@ void tst_QDir::dotAndDotDot()
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
QSKIP("WinCE does not have . nor .."); QSKIP("WinCE does not have . nor ..");
#else #else
QDir dir(QString(SRCDIR "testdir/")); QDir dir(QString((m_dataPath + "/testdir/")));
QStringList entryList = dir.entryList(QDir::Dirs); QStringList entryList = dir.entryList(QDir::Dirs);
QCOMPARE(entryList, QStringList() << QString(".") << QString("..") << QString("dir") << QString("spaces")); QCOMPARE(entryList, QStringList() << QString(".") << QString("..") << QString("dir") << QString("spaces"));
entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
@ -1309,26 +1287,22 @@ void tst_QDir::searchPaths_data()
QTest::addColumn<QString>("searchPaths"); QTest::addColumn<QString>("searchPaths");
QTest::addColumn<QString>("expectedAbsolutePath"); QTest::addColumn<QString>("expectedAbsolutePath");
QString srcdir = SRCDIR; QString searchDir = (m_dataPath + "/searchdir");
if (srcdir.isEmpty()) QString srcdir = QFileInfo(searchDir).absolutePath();
srcdir = QDir::currentPath();
else
srcdir.chop(1); // remove ending slash
QString searchDir = srcdir + "/searchdir";
// sanity // sanity
QTest::newRow("nopath") << "picker.png" << QString() << QString() << QString(); QTest::newRow("nopath") << "picker.png" << QString() << QString() << QString();
QTest::newRow("emptysearchpath") << "subdir1/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 // new
QTest::newRow("novalidsearchpath") << "searchpath:subdir1/picker.png" << QString() << QString() << QString(); QTest::newRow("novalidsearchpath") << "searchpath:subdir1/picker.png" << QString() << QString() << QString();
QTest::newRow("invalidsearchpath") << "searchpath:subdir1/picker.png" << QString("invalid") << QString("invalid") << 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("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") << QString("invalid;" SRCDIR "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") << QString("invalid;" SRCDIR "searchdir/subdir1," SRCDIR "searchdir/subdir2") << (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") << QString("invalid;" SRCDIR "searchdir/subdir2," SRCDIR "searchdir/subdir1") << (searchDir+"/subdir2/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") << QString(SRCDIR "searchdir/subdir1;" SRCDIR "searchdir/subdir2") << (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 // re
} }
@ -1729,8 +1703,8 @@ void tst_QDir::drives()
void tst_QDir::arrayOperator() void tst_QDir::arrayOperator()
{ {
QDir dir1(SRCDIR "entrylist/"); QDir dir1((m_dataPath + "/entrylist/"));
QDir dir2(SRCDIR "entrylist/"); QDir dir2((m_dataPath + "/entrylist/"));
QStringList entries(dir1.entryList()); QStringList entries(dir1.entryList());
int i = dir2.count(); int i = dir2.count();
@ -1753,8 +1727,8 @@ void tst_QDir::equalityOperator_data()
QTest::addColumn<int>("rightFilters"); QTest::addColumn<int>("rightFilters");
QTest::addColumn<bool>("expected"); QTest::addColumn<bool>("expected");
QTest::newRow("same") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) QTest::newRow("same") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< true; << true;
QTest::newRow("relativepaths") << "entrylist/" << "*.cpp" << int(QDir::Name) << int(QDir::Files) 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) << "another-dir-that-dont-exist" << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< false; << false;
QTest::newRow("diff-filters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) QTest::newRow("diff-filters") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Dirs) << m_dataPath << "*.cpp" << int(QDir::Name) << int(QDir::Dirs)
<< false; << false;
QTest::newRow("diff-sort") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) QTest::newRow("diff-sort") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< SRCDIR << "*.cpp" << int(QDir::Time) << int(QDir::Files) << m_dataPath << "*.cpp" << int(QDir::Time) << int(QDir::Files)
<< false; << false;
QTest::newRow("diff-namefilters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) QTest::newRow("diff-namefilters") << (m_dataPath + "/.") << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< SRCDIR << "*.jpg" << int(QDir::Name) << int(QDir::Files) << m_dataPath << "*.jpg" << int(QDir::Name) << int(QDir::Files)
<< false; << false;
} }

View File

@ -4,4 +4,6 @@ QT = core testlib
SOURCES = tst_qdiriterator.cpp SOURCES = tst_qdiriterator.cpp
RESOURCES += qdiriterator.qrc RESOURCES += qdiriterator.qrc
TESTDATA += entrylist
wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1 wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1

View File

@ -66,10 +66,6 @@ class tst_QDirIterator : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
tst_QDirIterator();
virtual ~tst_QDirIterator();
private: // convenience functions private: // convenience functions
QStringList createdDirectories; QStringList createdDirectories;
QStringList createdFiles; QStringList createdFiles;
@ -106,6 +102,8 @@ private: // convenience functions
} }
private slots: private slots:
void initTestCase();
void cleanupTestCase();
void iterateRelativeDirectory_data(); void iterateRelativeDirectory_data();
void iterateRelativeDirectory(); void iterateRelativeDirectory();
void iterateResource_data(); void iterateResource_data();
@ -124,8 +122,12 @@ private slots:
void hiddenDirs_hiddenFiles(); 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/entrylist1.lnk");
QFile::remove("entrylist/entrylist2.lnk"); QFile::remove("entrylist/entrylist2.lnk");
QFile::remove("entrylist/entrylist3.lnk"); QFile::remove("entrylist/entrylist3.lnk");
@ -187,7 +189,7 @@ tst_QDirIterator::tst_QDirIterator()
#endif #endif
} }
tst_QDirIterator::~tst_QDirIterator() void tst_QDirIterator::cleanupTestCase()
{ {
Q_FOREACH(QString fileName, createdFiles) Q_FOREACH(QString fileName, createdFiles)
QFile::remove(fileName); QFile::remove(fileName);

View File

@ -3,4 +3,6 @@ QT = core
CONFIG -= app_bundle debug_and_release_target CONFIG -= app_bundle debug_and_release_target
CONFIG += console CONFIG += console
# This app is testdata for tst_qfile
target.path = $$[QT_INSTALL_TESTS]/tst_qfile/$$TARGET
INSTALLS += target

View File

@ -1,24 +1,13 @@
CONFIG += testcase CONFIG += testcase
QT = core network testlib
TARGET = ../tst_qfile TARGET = ../tst_qfile
SOURCES = ../tst_qfile.cpp SOURCES = ../tst_qfile.cpp
RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc
wince* { TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \
QT = core gui testlib ../testlog.txt ../two.dots.file ../tst_qfile.cpp \
files.files += ..\\dosfile.txt ..\\noendofline.txt ..\\testfile.txt \ ../Makefile ../forCopying.txt ../forRenaming.txt \
..\\testlog.txt ..\\two.dots.file ..\\tst_qfile.cpp \ ../resources/file1.ext1
..\\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/../\\\"
}
win32 { win32 {
CONFIG(debug, debug|release) { CONFIG(debug, debug|release) {

View File

@ -348,6 +348,10 @@ void tst_QFile::cleanup()
void tst_QFile::initTestCase() 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"); QFile::remove("noreadfile");
// create a file and make it read-only // create a file and make it read-only
@ -404,7 +408,7 @@ void tst_QFile::cleanupTestCase()
void tst_QFile::exists() void tst_QFile::exists()
{ {
QFile f( SRCDIR "testfile.txt" ); QFile f( QFINDTESTDATA("testfile.txt") );
QCOMPARE( f.exists(), (bool)TRUE ); QCOMPARE( f.exists(), (bool)TRUE );
QFile file("nobodyhassuchafile"); QFile file("nobodyhassuchafile");
@ -443,7 +447,7 @@ void tst_QFile::open_data()
static const QString denied("Permission denied"); static const QString denied("Permission denied");
#endif #endif
QTest::newRow( "exist_readOnly" ) QTest::newRow( "exist_readOnly" )
<< QString(SRCDIR "testfile.txt") << int(QIODevice::ReadOnly) << QString(QFINDTESTDATA("testfile.txt")) << int(QIODevice::ReadOnly)
<< (bool)TRUE << QFile::NoError; << (bool)TRUE << QFile::NoError;
QTest::newRow( "exist_writeOnly" ) QTest::newRow( "exist_writeOnly" )
@ -469,7 +473,7 @@ void tst_QFile::open_data()
QTest::newRow("nullfile") << QString() << int(QIODevice::ReadOnly) << (bool)FALSE QTest::newRow("nullfile") << QString() << int(QIODevice::ReadOnly) << (bool)FALSE
<< QFile::OpenError; << 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; << QFile::NoError;
QTest::newRow("readonlyfile") << QString("readonlyfile") << int(QIODevice::WriteOnly) QTest::newRow("readonlyfile") << QString("readonlyfile") << int(QIODevice::WriteOnly)
@ -512,7 +516,7 @@ void tst_QFile::open()
void tst_QFile::openUnbuffered() void tst_QFile::openUnbuffered()
{ {
QFile file(SRCDIR "testfile.txt"); QFile file(QFINDTESTDATA("testfile.txt"));
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered));
char c = '\0'; char c = '\0';
QVERIFY(file.seek(1)); QVERIFY(file.seek(1));
@ -545,7 +549,7 @@ void tst_QFile::size_data()
QTest::addColumn<QString>("filename"); QTest::addColumn<QString>("filename");
QTest::addColumn<qint64>("size"); 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) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// Only test UNC on Windows./ // Only test UNC on Windows./
QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testshare/test.pri") << (qint64)34; QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testshare/test.pri") << (qint64)34;
@ -687,7 +691,7 @@ void tst_QFile::setSizeSeek()
void tst_QFile::atEnd() void tst_QFile::atEnd()
{ {
QFile f( SRCDIR "testfile.txt" ); QFile f( QFINDTESTDATA("testfile.txt") );
QVERIFY(f.open( QIODevice::ReadOnly )); QVERIFY(f.open( QIODevice::ReadOnly ));
int size = f.size(); int size = f.size();
@ -700,7 +704,7 @@ void tst_QFile::atEnd()
void tst_QFile::readLine() void tst_QFile::readLine()
{ {
QFile f( SRCDIR "testfile.txt" ); QFile f( QFINDTESTDATA("testfile.txt") );
QVERIFY(f.open( QIODevice::ReadOnly )); QVERIFY(f.open( QIODevice::ReadOnly ));
int i = 0; int i = 0;
@ -720,7 +724,7 @@ void tst_QFile::readLine()
void tst_QFile::readLine2() void tst_QFile::readLine2()
{ {
QFile f( SRCDIR "testfile.txt" ); QFile f( QFINDTESTDATA("testfile.txt") );
f.open( QIODevice::ReadOnly ); f.open( QIODevice::ReadOnly );
char p[128]; char p[128];
@ -755,13 +759,13 @@ void tst_QFile::readAll_data()
{ {
QTest::addColumn<bool>("textMode"); QTest::addColumn<bool>("textMode");
QTest::addColumn<QString>("fileName"); QTest::addColumn<QString>("fileName");
QTest::newRow( "TextMode unixfile" ) << true << SRCDIR "testfile.txt"; QTest::newRow( "TextMode unixfile" ) << true << QFINDTESTDATA("testfile.txt");
QTest::newRow( "BinaryMode unixfile" ) << false << SRCDIR "testfile.txt"; QTest::newRow( "BinaryMode unixfile" ) << false << QFINDTESTDATA("testfile.txt");
QTest::newRow( "TextMode dosfile" ) << true << SRCDIR "dosfile.txt"; QTest::newRow( "TextMode dosfile" ) << true << QFINDTESTDATA("dosfile.txt");
QTest::newRow( "BinaryMode dosfile" ) << false << SRCDIR "dosfile.txt"; QTest::newRow( "BinaryMode dosfile" ) << false << QFINDTESTDATA("dosfile.txt");
QTest::newRow( "TextMode bigfile" ) << true << SRCDIR "tst_qfile.cpp"; QTest::newRow( "TextMode bigfile" ) << true << QFINDTESTDATA("tst_qfile.cpp");
QTest::newRow( "BinaryMode bigfile" ) << false << SRCDIR "tst_qfile.cpp"; QTest::newRow( "BinaryMode bigfile" ) << false << QFINDTESTDATA("tst_qfile.cpp");
QVERIFY(QFile(SRCDIR "tst_qfile.cpp").size() > 64*1024); QVERIFY(QFile(QFINDTESTDATA("tst_qfile.cpp")).size() > 64*1024);
} }
void tst_QFile::readAll() void tst_QFile::readAll()
@ -923,7 +927,7 @@ void tst_QFile::readLineStdin_lineByLine()
void tst_QFile::text() void tst_QFile::text()
{ {
// dosfile.txt is a binary CRLF file // dosfile.txt is a binary CRLF file
QFile file(SRCDIR "dosfile.txt"); QFile file(QFINDTESTDATA("dosfile.txt"));
QVERIFY(file.open(QFile::Text | QFile::ReadOnly)); QVERIFY(file.open(QFile::Text | QFile::ReadOnly));
QCOMPARE(file.readLine(), QCOMPARE(file.readLine(),
QByteArray("/dev/system/root / reiserfs acl,user_xattr 1 1\n")); QByteArray("/dev/system/root / reiserfs acl,user_xattr 1 1\n"));
@ -936,7 +940,7 @@ void tst_QFile::text()
void tst_QFile::missingEndOfLine() void tst_QFile::missingEndOfLine()
{ {
QFile file(SRCDIR "noendofline.txt"); QFile file(QFINDTESTDATA("noendofline.txt"));
QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(file.open(QFile::ReadOnly));
int nlines = 0; int nlines = 0;
@ -950,7 +954,7 @@ void tst_QFile::missingEndOfLine()
void tst_QFile::readBlock() void tst_QFile::readBlock()
{ {
QFile f( SRCDIR "testfile.txt" ); QFile f( QFINDTESTDATA("testfile.txt") );
f.open( QIODevice::ReadOnly ); f.open( QIODevice::ReadOnly );
int length = 0; int length = 0;
@ -965,7 +969,7 @@ void tst_QFile::readBlock()
void tst_QFile::getch() void tst_QFile::getch()
{ {
QFile f( SRCDIR "testfile.txt" ); QFile f( QFINDTESTDATA("testfile.txt") );
f.open( QIODevice::ReadOnly ); f.open( QIODevice::ReadOnly );
char c; char c;
@ -982,7 +986,7 @@ void tst_QFile::getch()
void tst_QFile::ungetChar() void tst_QFile::ungetChar()
{ {
QFile f(SRCDIR "testfile.txt"); QFile f(QFINDTESTDATA("testfile.txt"));
QVERIFY(f.open(QIODevice::ReadOnly)); QVERIFY(f.open(QIODevice::ReadOnly));
QByteArray array = f.readLine(); QByteArray array = f.readLine();
@ -1083,7 +1087,7 @@ void tst_QFile::permissions_data()
QTest::addColumn<bool>("expected"); QTest::addColumn<bool>("expected");
QTest::newRow("data0") << QCoreApplication::instance()->applicationFilePath() << uint(QFile::ExeUser) << true; 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("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::ReadUser) << true;
QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::WriteUser) << false; QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::WriteUser) << false;
QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::ExeUser) << 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::setPermissions("tst_qfile_copy.cpp", QFile::WriteUser);
QFile::remove("tst_qfile_copy.cpp"); QFile::remove("tst_qfile_copy.cpp");
QFile::remove("test2"); QFile::remove("test2");
QVERIFY(QFile::copy(SRCDIR "tst_qfile.cpp", "tst_qfile_copy.cpp")); QVERIFY(QFile::copy(QFINDTESTDATA("tst_qfile.cpp"), "tst_qfile_copy.cpp"));
QFile in1(SRCDIR "tst_qfile.cpp"), in2("tst_qfile_copy.cpp"); QFile in1(QFINDTESTDATA("tst_qfile.cpp")), in2("tst_qfile_copy.cpp");
QVERIFY(in1.open(QFile::ReadOnly)); QVERIFY(in1.open(QFile::ReadOnly));
QVERIFY(in2.open(QFile::ReadOnly)); QVERIFY(in2.open(QFile::ReadOnly));
QByteArray data1 = in1.readAll(), data2 = in2.readAll(); QByteArray data1 = in1.readAll(), data2 = in2.readAll();
@ -1169,9 +1173,9 @@ void tst_QFile::copyAfterFail()
void tst_QFile::copyRemovesTemporaryFile() const void tst_QFile::copyRemovesTemporaryFile() const
{ {
const QString newName(QLatin1String("copyRemovesTemporaryFile")); 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)); QVERIFY(QFile::remove(newName));
} }
@ -1179,7 +1183,7 @@ void tst_QFile::copyShouldntOverwrite()
{ {
// Copy should not overwrite existing files. // Copy should not overwrite existing files.
QFile::remove("tst_qfile.cpy"); QFile::remove("tst_qfile.cpy");
QFile file(SRCDIR "tst_qfile.cpp"); QFile file(QFINDTESTDATA("tst_qfile.cpp"));
QVERIFY(file.copy("tst_qfile.cpy")); QVERIFY(file.copy("tst_qfile.cpy"));
bool ok = QFile::setPermissions("tst_qfile.cpy", QFile::WriteOther); bool ok = QFile::setPermissions("tst_qfile.cpy", QFile::WriteOther);
@ -1271,10 +1275,10 @@ void tst_QFile::link()
{ {
QFile::remove("myLink.lnk"); QFile::remove("myLink.lnk");
QFileInfo info1(SRCDIR "tst_qfile.cpp"); QFileInfo info1(QFINDTESTDATA("tst_qfile.cpp"));
QString referenceTarget = QDir::cleanPath(info1.absoluteFilePath()); 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"); QFileInfo info2("myLink.lnk");
QVERIFY(info2.isSymLink()); QVERIFY(info2.isSymLink());
@ -1386,13 +1390,13 @@ void tst_QFile::readTextFile()
void tst_QFile::readTextFile2() void tst_QFile::readTextFile2()
{ {
{ {
QFile file(SRCDIR "testlog.txt"); QFile file(QFINDTESTDATA("testlog.txt"));
QVERIFY(file.open(QIODevice::ReadOnly)); QVERIFY(file.open(QIODevice::ReadOnly));
file.read(4097); file.read(4097);
} }
{ {
QFile file(SRCDIR "testlog.txt"); QFile file(QFINDTESTDATA("testlog.txt"));
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
file.read(4097); file.read(4097);
} }
@ -2015,7 +2019,7 @@ public:
{ {
if (fileName.startsWith(":!")) { if (fileName.startsWith(":!")) {
QDir dir; QDir dir;
QString realFile = SRCDIR + fileName.mid(2); QString realFile = QFINDTESTDATA(fileName.mid(2));
if (dir.exists(realFile)) if (dir.exists(realFile))
return new QFSFileEngine(realFile); return new QFSFileEngine(realFile);
} }
@ -2379,7 +2383,7 @@ void tst_QFile::renameWithAtEndSpecialFile() const
/* Cleanup, so we're a bit more robust. */ /* Cleanup, so we're a bit more robust. */
QFile::remove(newName); QFile::remove(newName);
const QString originalName(QString(SRCDIR "forRenaming.txt")); const QString originalName(QString(QFINDTESTDATA("forRenaming.txt")));
PeculiarAtEnd file; PeculiarAtEnd file;
file.setFileName(originalName); file.setFileName(originalName);
@ -2502,7 +2506,7 @@ void tst_QFile::handle()
{ {
int fd; int fd;
#if !defined(Q_OS_WINCE) #if !defined(Q_OS_WINCE)
QFile file(SRCDIR "tst_qfile.cpp"); QFile file(QFINDTESTDATA("tst_qfile.cpp"));
QVERIFY(file.open(QIODevice::ReadOnly)); QVERIFY(file.open(QIODevice::ReadOnly));
fd = int(file.handle()); fd = int(file.handle());
QVERIFY(fd > 2); QVERIFY(fd > 2);
@ -2533,7 +2537,7 @@ void tst_QFile::handle()
//test round trip of adopted stdio file handle //test round trip of adopted stdio file handle
QFile file2; QFile file2;
FILE *fp = fopen(SRCDIR "tst_qfile.cpp", "r"); FILE *fp = fopen(qPrintable(QFINDTESTDATA("tst_qfile.cpp")), "r");
file2.open(fp, QIODevice::ReadOnly); file2.open(fp, QIODevice::ReadOnly);
QCOMPARE(int(file2.handle()), int(fileno(fp))); QCOMPARE(int(file2.handle()), int(fileno(fp)));
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 //test round trip of adopted posix file handle
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
QFile file3; 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); file3.open(fd, QIODevice::ReadOnly);
QCOMPARE(int(file3.handle()), fd); QCOMPARE(int(file3.handle()), fd);
QT_CLOSE(fd); QT_CLOSE(fd);
@ -2599,8 +2603,8 @@ void tst_QFile::readEof_data()
QTest::addColumn<QString>("filename"); QTest::addColumn<QString>("filename");
QTest::addColumn<int>("imode"); QTest::addColumn<int>("imode");
QTest::newRow("buffered") << SRCDIR "testfile.txt" << 0; QTest::newRow("buffered") << QFINDTESTDATA("testfile.txt") << 0;
QTest::newRow("unbuffered") << SRCDIR "testfile.txt" << int(QIODevice::Unbuffered); QTest::newRow("unbuffered") << QFINDTESTDATA("testfile.txt") << int(QIODevice::Unbuffered);
#if defined(Q_OS_UNIX) #if defined(Q_OS_UNIX)
QTest::newRow("sequential,buffered") << "/dev/null" << 0; QTest::newRow("sequential,buffered") << "/dev/null" << 0;
@ -2945,7 +2949,7 @@ void tst_QFile::mapOpenMode()
void tst_QFile::openDirectory() void tst_QFile::openDirectory()
{ {
QFile f1(SRCDIR "resources"); QFile f1(QFINDTESTDATA("resources"));
// it's a directory, it must exist // it's a directory, it must exist
QVERIFY(f1.exists()); QVERIFY(f1.exists());
@ -3070,7 +3074,7 @@ void tst_QFile::resize()
void tst_QFile::objectConstructors() void tst_QFile::objectConstructors()
{ {
QObject ob; QObject ob;
QFile* file1 = new QFile(SRCDIR "testfile.txt", &ob); QFile* file1 = new QFile(QFINDTESTDATA("testfile.txt"), &ob);
QFile* file2 = new QFile(&ob); QFile* file2 = new QFile(&ob);
QVERIFY(file1->exists()); QVERIFY(file1->exists());
QVERIFY(!file2->exists()); QVERIFY(!file2->exists());

View File

@ -4,14 +4,6 @@ QT = core-private testlib
SOURCES = tst_qfileinfo.cpp SOURCES = tst_qfileinfo.cpp
RESOURCES += qfileinfo.qrc RESOURCES += qfileinfo.qrc
wince* { TESTDATA += qfileinfo.qrc qfileinfo.pro tst_qfileinfo.cpp resources/file1 resources/file1.ext1 resources/file1.ext1.ext2
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/\\\"
}
win32*:LIBS += -ladvapi32 -lnetapi32 win32*:LIBS += -ladvapi32 -lnetapi32

View File

@ -286,7 +286,7 @@ void tst_QFileInfo::isFile_data()
QTest::addColumn<bool>("expected"); QTest::addColumn<bool>("expected");
QTest::newRow("data0") << QDir::currentPath() << false; 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("data2") << ":/tst_qfileinfo/resources/" << false;
QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << true; QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << true;
QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false; QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false;
@ -319,13 +319,13 @@ void tst_QFileInfo::isDir_data()
QTest::addColumn<bool>("expected"); QTest::addColumn<bool>("expected");
QTest::newRow("data0") << QDir::currentPath() << true; 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("data2") << ":/tst_qfileinfo/resources/" << true;
QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << false; QTest::newRow("data3") << ":/tst_qfileinfo/resources/file1" << false;
QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false; QTest::newRow("data4") << ":/tst_qfileinfo/resources/afilethatshouldnotexist" << false;
QTest::newRow("simple dir") << SRCDIR "resources" << true; QTest::newRow("simple dir") << QFINDTESTDATA("resources") << true;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; QTest::newRow("simple dir with slash") << QFINDTESTDATA("resources/") << true;
QTest::newRow("broken link") << "brokenlink.lnk" << false; 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("data4") << ":/tst_qfileinfo/resources/" << false;
QTest::newRow("data5") << ":/" << true; QTest::newRow("data5") << ":/" << true;
QTest::newRow("simple dir") << SRCDIR "resources" << false; QTest::newRow("simple dir") << QFINDTESTDATA("resources") << false;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << false; QTest::newRow("simple dir with slash") << QFINDTESTDATA("resources/") << false;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
QTest::newRow("drive 1") << "c:" << false; QTest::newRow("drive 1") << "c:" << false;
QTest::newRow("drive 2") << "c:/" << true; QTest::newRow("drive 2") << "c:/" << true;
@ -397,21 +397,21 @@ void tst_QFileInfo::exists_data()
QTest::addColumn<bool>("expected"); QTest::addColumn<bool>("expected");
QTest::newRow("data0") << QDir::currentPath() << true; 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("data2") << "/I/do_not_expect_this_path_to_exist/" << false;
QTest::newRow("data3") << ":/tst_qfileinfo/resources/" << true; QTest::newRow("data3") << ":/tst_qfileinfo/resources/" << true;
QTest::newRow("data4") << ":/tst_qfileinfo/resources/file1" << true; QTest::newRow("data4") << ":/tst_qfileinfo/resources/file1" << true;
QTest::newRow("data5") << ":/I/do_not_expect_this_path_to_exist/" << false; QTest::newRow("data5") << ":/I/do_not_expect_this_path_to_exist/" << false;
QTest::newRow("data6") << SRCDIR "resources/*" << false; QTest::newRow("data6") << (QFINDTESTDATA("resources/") + "*") << false;
QTest::newRow("data7") << SRCDIR "resources/*.foo" << false; QTest::newRow("data7") << (QFINDTESTDATA("resources/") + "*.foo") << false;
QTest::newRow("data8") << SRCDIR "resources/*.ext1" << false; QTest::newRow("data8") << (QFINDTESTDATA("resources/") + "*.ext1") << false;
QTest::newRow("data9") << SRCDIR "resources/file?.ext1" << false; QTest::newRow("data9") << (QFINDTESTDATA("resources/") + "file?.ext1") << false;
QTest::newRow("data10") << "." << true; QTest::newRow("data10") << "." << true;
QTest::newRow("data11") << ". " << false; QTest::newRow("data11") << ". " << false;
QTest::newRow("empty") << "" << false; QTest::newRow("empty") << "" << false;
QTest::newRow("simple dir") << SRCDIR "resources" << true; QTest::newRow("simple dir") << QFINDTESTDATA("resources") << true;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; QTest::newRow("simple dir with slash") << QFINDTESTDATA("resources/") << true;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
@ -557,7 +557,7 @@ void tst_QFileInfo::canonicalFilePath()
// test symlinks // test symlinks
QFile::remove("link.lnk"); QFile::remove("link.lnk");
{ {
QFile file(SRCDIR "tst_qfileinfo.cpp"); QFile file(QFINDTESTDATA("tst_qfileinfo.cpp"));
if (file.link("link.lnk")) { if (file.link("link.lnk")) {
QFileInfo info1(file); QFileInfo info1(file);
QFileInfo info2("link.lnk"); QFileInfo info2("link.lnk");
@ -583,7 +583,7 @@ void tst_QFileInfo::canonicalFilePath()
QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath());
QFileInfo info3(link + QDir::separator() + "link.lnk"); QFileInfo info3(link + QDir::separator() + "link.lnk");
QFileInfo info4(SRCDIR "tst_qfileinfo.cpp"); QFileInfo info4(QFINDTESTDATA("tst_qfileinfo.cpp"));
QVERIFY(!info3.canonicalFilePath().isEmpty()); QVERIFY(!info3.canonicalFilePath().isEmpty());
QCOMPARE(info4.canonicalFilePath(), info3.canonicalFilePath()); QCOMPARE(info4.canonicalFilePath(), info3.canonicalFilePath());
@ -830,7 +830,7 @@ void tst_QFileInfo::permission_data()
QTest::addColumn<bool>("expected"); QTest::addColumn<bool>("expected");
QTest::newRow("data0") << QCoreApplication::instance()->applicationFilePath() << int(QFile::ExeUser) << true; 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("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ReadUser) << true;
QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::WriteUser) << false; QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::WriteUser) << false;
QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ExeUser) << false; QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ExeUser) << false;
@ -898,11 +898,11 @@ void tst_QFileInfo::compare_data()
#endif #endif
QTest::newRow("data0") QTest::newRow("data0")
<< QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") << QFINDTESTDATA("tst_qfileinfo.cpp")
<< QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") << QFINDTESTDATA("tst_qfileinfo.cpp")
<< true; << true;
QTest::newRow("data1") QTest::newRow("data1")
<< QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") << QFINDTESTDATA("tst_qfileinfo.cpp")
<< QString::fromLatin1("/tst_qfileinfo.cpp") << QString::fromLatin1("/tst_qfileinfo.cpp")
<< false; << false;
QTest::newRow("data2") QTest::newRow("data2")
@ -910,8 +910,8 @@ void tst_QFileInfo::compare_data()
<< QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp") << QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp")
<< true; << true;
QTest::newRow("casesense1") QTest::newRow("casesense1")
<< QString::fromLatin1(SRCDIR "tst_qfileInfo.cpp") << QFINDTESTDATA("tst_qfileinfo.cpp").replace("info", "Info")
<< QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") << QFINDTESTDATA("tst_qfileinfo.cpp")
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
<< true; << true;
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
@ -1098,7 +1098,7 @@ void tst_QFileInfo::isSymLink_data()
QFile::remove("brokenlink.lnk"); QFile::remove("brokenlink.lnk");
QFile::remove("dummyfile"); QFile::remove("dummyfile");
QFile file1(SRCDIR "tst_qfileinfo.cpp"); QFile file1(QFINDTESTDATA("tst_qfileinfo.cpp"));
QVERIFY(file1.link("link.lnk")); QVERIFY(file1.link("link.lnk"));
QFile file2("dummyfile"); QFile file2("dummyfile");
@ -1110,8 +1110,8 @@ void tst_QFileInfo::isSymLink_data()
QTest::addColumn<bool>("isSymLink"); QTest::addColumn<bool>("isSymLink");
QTest::addColumn<QString>("linkTarget"); QTest::addColumn<QString>("linkTarget");
QTest::newRow("existent file") << SRCDIR "tst_qfileinfo.cpp" << false << ""; QTest::newRow("existent file") << QFINDTESTDATA("tst_qfileinfo.cpp") << false << "";
QTest::newRow("link") << "link.lnk" << true << QFileInfo(SRCDIR "tst_qfileinfo.cpp").absoluteFilePath(); QTest::newRow("link") << "link.lnk" << true << QFileInfo(QFINDTESTDATA("tst_qfileinfo.cpp")).absoluteFilePath();
QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath();
} }
@ -1347,7 +1347,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
} }
{ {
//File symlinks //File symlinks
QFileInfo target(SRCDIR "tst_qfileinfo.cpp"); QFileInfo target(QFINDTESTDATA("tst_qfileinfo.cpp"));
QString absTarget = QDir::toNativeSeparators(target.absoluteFilePath()); QString absTarget = QDir::toNativeSeparators(target.absoluteFilePath());
QString absSymlink = QDir::toNativeSeparators(pwd.absolutePath()).append("\\abs_symlink.cpp"); QString absSymlink = QDir::toNativeSeparators(pwd.absolutePath()).append("\\abs_symlink.cpp");
QString relTarget = QDir::toNativeSeparators(pwd.relativeFilePath(target.absoluteFilePath())); QString relTarget = QDir::toNativeSeparators(pwd.relativeFilePath(target.absoluteFilePath()));
@ -1462,7 +1462,7 @@ void tst_QFileInfo::isExecutable()
QFileInfo fi(appPath); QFileInfo fi(appPath);
QCOMPARE(fi.isExecutable(), true); QCOMPARE(fi.isExecutable(), true);
QCOMPARE(QFileInfo(SRCDIR "qfileinfo.pro").isExecutable(), false); QCOMPARE(QFileInfo(QFINDTESTDATA("qfileinfo.pro")).isExecutable(), false);
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
QFile::remove("link.lnk"); QFile::remove("link.lnk");
@ -1474,7 +1474,7 @@ void tst_QFileInfo::isExecutable()
QFile::remove("link.lnk"); QFile::remove("link.lnk");
// Symlink to .pro file // Symlink to .pro file
QFile proFile(SRCDIR "qfileinfo.pro"); QFile proFile(QFINDTESTDATA("qfileinfo.pro"));
QVERIFY(proFile.link("link.lnk")); QVERIFY(proFile.link("link.lnk"));
QCOMPARE(QFileInfo("link.lnk").isExecutable(), false); QCOMPARE(QFileInfo("link.lnk").isExecutable(), false);
QFile::remove("link.lnk"); QFile::remove("link.lnk");

View File

@ -3,15 +3,7 @@ TARGET = tst_qiodevice
QT = core network testlib QT = core network testlib
SOURCES = tst_qiodevice.cpp SOURCES = tst_qiodevice.cpp
wince* { TESTDATA += tst_qiodevice.cpp
addFiles.files = tst_qiodevice.cpp
addFiles.path = .
DEPLOYMENT += addFiles
DEFINES += SRCDIR=\\\"\\\"
!wince50standard-x86-msvc2005: DEFINES += WINCE_EMULATOR_TEST=1
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
MOC_DIR=tmp MOC_DIR=tmp
mac: CONFIG += insignificant_test # QTBUG-22766 mac: CONFIG += insignificant_test # QTBUG-22766

View File

@ -147,7 +147,7 @@ void tst_QIODevice::constructing_QFile()
QVERIFY(!device->isOpen()); QVERIFY(!device->isOpen());
file.setFileName(SRCDIR "tst_qiodevice.cpp"); file.setFileName(QFINDTESTDATA("tst_qiodevice.cpp"));
QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(file.open(QFile::ReadOnly));
QVERIFY(device->isOpen()); QVERIFY(device->isOpen());
QCOMPARE((int) device->openMode(), (int) QFile::ReadOnly); QCOMPARE((int) device->openMode(), (int) QFile::ReadOnly);
@ -176,7 +176,7 @@ void tst_QIODevice::constructing_QFile()
void tst_QIODevice::read_QByteArray() void tst_QIODevice::read_QByteArray()
{ {
QFile f(SRCDIR "tst_qiodevice.cpp"); QFile f(QFINDTESTDATA("tst_qiodevice.cpp"));
f.open(QIODevice::ReadOnly); f.open(QIODevice::ReadOnly);
QByteArray b = f.read(10); QByteArray b = f.read(10);

View File

@ -4,7 +4,6 @@ CONFIG -= app_bundle
QT = core QT = core
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,92 +3,13 @@ QT = core testlib network
embedded: QT += gui embedded: QT += gui
SOURCES = ../tst_qprocess.cpp SOURCES = ../tst_qprocess.cpp
!wince*: { TARGET = ../tst_qprocess
TARGET = ../tst_qprocess win32 {
win32: { CONFIG(debug, debug|release) {
CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qprocess
TARGET = ../../debug/tst_qprocess } else {
} else { TARGET = ../../release/tst_qprocess
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/*

View File

@ -4,3 +4,7 @@ CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
INSTALLS = INSTALLS =
DESTDIR = ./ DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,3 +3,7 @@ CONFIG -= qt app_bundle
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,3 +3,6 @@ QT += widgets
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -4,5 +4,6 @@ CONFIG -= qt app_bundle
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -4,7 +4,6 @@ CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -5,5 +5,6 @@ CONFIG += console
win32:!win32-g++*:!equals(TEMPLATE_PREFIX, "vc"):QMAKE_CXXFLAGS += /GS- win32:!win32-g++*:!equals(TEMPLATE_PREFIX, "vc"):QMAKE_CXXFLAGS += /GS-
DESTDIR = ./ DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,6 +3,6 @@ CONFIG -= qt
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,8 +3,6 @@ CONFIG -= qt
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,7 +3,6 @@ CONFIG -= qt
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -6,8 +6,6 @@ win32 {
CONFIG -= qt CONFIG -= qt
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -7,6 +7,6 @@ mac {
CONFIG -= app_bundle CONFIG -= app_bundle
} }
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,6 +3,6 @@ CONFIG -= qt
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -4,6 +4,6 @@ CONFIG -= qt app_bundle
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,7 +3,6 @@ CONFIG -= qt
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,7 +3,6 @@ CONFIG -= qt app_bundle
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qproces
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs
INSTALLS += target

View File

@ -3,9 +3,8 @@ CONFIG -= qt app_bundle
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
TARGET = "one space" TARGET = one space
# no install rule for application used by test
INSTALLS =
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs
INSTALLS += target

View File

@ -3,10 +3,8 @@ CONFIG -= qt app_bundle
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
TARGET = "two space s" TARGET = two space s
# no install rule for application used by test
INSTALLS =
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs
INSTALLS += target

View File

@ -2,6 +2,6 @@ SOURCES = main.cpp
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -10,7 +10,6 @@ CONFIG -= qt app_bundle
CONFIG += console CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -7,7 +7,6 @@ mac {
CONFIG -= app_bundle CONFIG -= app_bundle
} }
# no install rule for application used by test # This app is testdata for tst_qprocess
INSTALLS = target.path = "$$[QT_INSTALL_TESTS]/tst_qprocess/test Space In Name"
INSTALLS += target

View File

@ -73,10 +73,9 @@ class tst_QProcess : public QObject
{ {
Q_OBJECT Q_OBJECT
#ifdef QT_NO_PROCESS
public slots: public slots:
void initTestCase(); void initTestCase();
#else #ifndef QT_NO_PROCESS
private slots: private slots:
void getSetCheck(); void getSetCheck();
void constructing(); void constructing();
@ -166,13 +165,18 @@ private:
#endif #endif
}; };
#ifdef QT_NO_PROCESS
void tst_QProcess::initTestCase() void tst_QProcess::initTestCase()
{ {
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support"); 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 // Testing get/set functions
void tst_QProcess::getSetCheck() void tst_QProcess::getSetCheck()

View File

@ -10,26 +10,14 @@ runtime_resource.commands = $$QMAKE_RCC -root /runtime_resource/ -binary $${runt
QMAKE_EXTRA_TARGETS = runtime_resource QMAKE_EXTRA_TARGETS = runtime_resource
PRE_TARGETDEPS += $${runtime_resource.target} PRE_TARGETDEPS += $${runtime_resource.target}
wince* { TESTDATA += \
deploy.files += runtime_resource.rcc parentdir.txt parentdir.txt \
test.files = testqrc/* testqrc/*
test.path = testqrc
alias.files = testqrc/aliasdir/* # Special case needed for runtime_resource.rcc installation,
alias.path = testqrc/aliasdir # since it does not exist at qmake runtime.
other.files = testqrc/otherdir/* load(testcase) # to get value of target.path
other.path = testqrc/otherdir runtime_resource_install.CONFIG = no_check_exist
search1.files = testqrc/searchpath1/* runtime_resource_install.files = $$OUT_PWD/$${runtime_resource.target}
search1.path = testqrc/searchpath1 runtime_resource_install.path = $${target.path}
search2.files = testqrc/searchpath2/* INSTALLS += runtime_resource_install
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/\\\"
}

View File

@ -59,9 +59,6 @@ private slots:
void searchPath(); void searchPath();
void doubleSlashInRoot(); void doubleSlashInRoot();
void setLocale(); void setLocale();
private:
QString builddir;
}; };
Q_DECLARE_METATYPE(QLocale) Q_DECLARE_METATYPE(QLocale)
@ -69,26 +66,15 @@ Q_DECLARE_METATYPE(qlonglong)
void tst_QResourceEngine::initTestCase() void tst_QResourceEngine::initTestCase()
{ {
QVERIFY(QResource::registerResource("runtime_resource.rcc")); QVERIFY(QResource::registerResource(QFINDTESTDATA("runtime_resource.rcc")));
QVERIFY(QResource::registerResource("runtime_resource.rcc", "/secondary_root/")); QVERIFY(QResource::registerResource(QFINDTESTDATA("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);
}
} }
void tst_QResourceEngine::cleanupTestCase() void tst_QResourceEngine::cleanupTestCase()
{ {
if (!builddir.isEmpty()) {
QDir::setCurrent(builddir);
}
// make sure we don't leak memory // make sure we don't leak memory
QVERIFY(QResource::unregisterResource("runtime_resource.rcc")); QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc")));
QVERIFY(QResource::unregisterResource("runtime_resource.rcc", "/secondary_root/")); QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc"), "/secondary_root/"));
} }
void tst_QResourceEngine::checkStructure_data() void tst_QResourceEngine::checkStructure_data()
@ -182,7 +168,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(0); << 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") QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test1.txt")
<< QString("abc") << QString("abc")
<< QStringList() << QStringList()
@ -190,7 +176,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "text no slashes").toLatin1().constData()) << QString(root + "withoutslashes/blahblah.txt")
<< QString("qwerty") << QString("qwerty")
<< QStringList() << QStringList()
@ -199,7 +185,7 @@ void tst_QResourceEngine::checkStructure_data()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test2.txt")
<< QString("def") << QString("def")
<< QStringList() << QStringList()
@ -207,7 +193,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "currentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir.txt")
<< QString("\"This is the current dir\" ") << QString("\"This is the current dir\" ")
<< QStringList() << QStringList()
@ -215,7 +201,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "currentdir text2").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir2.txt")
<< QString("\"This is also the current dir\" ") << QString("\"This is also the current dir\" ")
<< QStringList() << QStringList()
@ -223,7 +209,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "parentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/parentdir.txt")
<< QString("abcdefgihklmnopqrstuvwxyz ") << QString("abcdefgihklmnopqrstuvwxyz ")
<< QStringList() << QStringList()
@ -231,7 +217,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "subdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/subdir/subdir.txt")
<< QString("\"This is in the sub directory\" ") << QString("\"This is in the sub directory\" ")
<< QStringList() << QStringList()
@ -239,7 +225,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "testdir text").toLatin1().constData()) << QString(root + "test/testdir.txt")
<< QString("\"This is in the test directory\" ") << QString("\"This is in the test directory\" ")
<< QStringList() << QStringList()
@ -247,7 +233,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "otherdir text").toLatin1().constData()) << QString(root + "otherdir/otherdir.txt")
<< QString("\"This is the other dir\" ") << QString("\"This is the other dir\" ")
<< QStringList() << QStringList()
@ -255,7 +241,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "alias text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
<< QString("\"This is another file in this directory\" ") << QString("\"This is another file in this directory\" ")
<< QStringList() << QStringList()
@ -263,7 +249,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale::c() << QLocale::c()
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "korean text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
<< QString("\"This is a korean text file\" ") << QString("\"This is a korean text file\" ")
<< QStringList() << QStringList()
@ -271,7 +257,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale("ko") << QLocale("ko")
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "korean text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
<< QString("\"This is a korean text file\" ") << QString("\"This is a korean text file\" ")
<< QStringList() << QStringList()
@ -279,7 +265,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale("ko_KR") << QLocale("ko_KR")
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "german text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
<< QString("Deutsch") << QString("Deutsch")
<< QStringList() << QStringList()
@ -287,7 +273,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale("de") << QLocale("de")
<< qlonglong(info.size()); << 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") QTest::newRow(QString(root + "german text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
<< QString("Deutsch") << QString("Deutsch")
<< QStringList() << QStringList()
@ -295,9 +281,9 @@ void tst_QResourceEngine::checkStructure_data()
<< QLocale("de_DE") << QLocale("de_DE")
<< qlonglong(info.size()); << qlonglong(info.size());
QFile file("testqrc/aliasdir/compressme.txt"); QFile file(QFINDTESTDATA("testqrc/aliasdir/compressme.txt"));
file.open(QFile::ReadOnly); 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") QTest::newRow(QString(root + "compressed text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
<< QString(file.readAll()) << QString(file.readAll())
<< QStringList() << QStringList()
@ -416,9 +402,9 @@ void tst_QResourceEngine::checkUnregisterResource_data()
QTest::addColumn<QString>("file_check"); QTest::addColumn<QString>("file_check");
QTest::addColumn<int>("size"); 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") << 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() void tst_QResourceEngine::checkUnregisterResource()

View File

@ -2,10 +2,4 @@ CONFIG += testcase parallel_test
TARGET = tst_qstandardpaths TARGET = tst_qstandardpaths
QT = core testlib QT = core testlib
SOURCES = tst_qstandardpaths.cpp SOURCES = tst_qstandardpaths.cpp
TESTDATA += tst_qstandardpaths.cpp qstandardpaths.pro
wince* {
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}

View File

@ -73,8 +73,7 @@ private slots:
private: private:
void setCustomLocations() { void setCustomLocations() {
m_thisDir = QFile::decodeName(SRCDIR); m_thisDir = QFileInfo(QFINDTESTDATA("tst_qstandardpaths.cpp")).absolutePath();
m_thisDir.chop(1); // remove trailing slash!
qputenv("XDG_CONFIG_HOME", QFile::encodeName(m_thisDir)); qputenv("XDG_CONFIG_HOME", QFile::encodeName(m_thisDir));
QDir parent(m_thisDir); QDir parent(m_thisDir);
@ -116,6 +115,8 @@ void tst_qstandardpaths::testCustomLocations()
// test writableLocation() // test writableLocation()
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), m_thisDir); QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), m_thisDir);
QString thisDir_base = QFileInfo(m_thisDir).fileName();
// test locate() // test locate()
const QString thisFileName = QString::fromLatin1("tst_qstandardpaths.cpp"); const QString thisFileName = QString::fromLatin1("tst_qstandardpaths.cpp");
QVERIFY(QFile::exists(m_thisDir + '/' + thisFileName)); QVERIFY(QFile::exists(m_thisDir + '/' + thisFileName));
@ -123,9 +124,9 @@ void tst_qstandardpaths::testCustomLocations()
QVERIFY(!thisFile.isEmpty()); QVERIFY(!thisFile.isEmpty());
QVERIFY(thisFile.endsWith(thisFileName)); 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()); 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 QVERIFY(thisDirAsFile.isEmpty()); // not a file
const QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation); const QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);

View File

@ -2,4 +2,4 @@ CONFIG += testcase parallel_test
TARGET = tst_qtemporaryfile TARGET = tst_qtemporaryfile
QT = core testlib QT = core testlib
SOURCES = tst_qtemporaryfile.cpp SOURCES = tst_qtemporaryfile.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\" TESTDATA += tst_qtemporaryfile.cpp

View File

@ -418,7 +418,7 @@ void tst_QTemporaryFile::renameFdLeak()
static const int count = 10; static const int count = 10;
int bunch_of_files[count]; int bunch_of_files[count];
for (int i = 0; i < count; ++i) { 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); QVERIFY(bunch_of_files[i] != -1);
} }

View File

@ -4,4 +4,6 @@ CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
DESTDIR = ./ DESTDIR = ./
# This app is testdata for tst_qtextstream
target.path = $$[QT_INSTALL_TESTS]/tst_qtextstream/$$TARGET
INSTALLS += target

View File

@ -4,4 +4,6 @@ CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
DESTDIR = ./ DESTDIR = ./
# This app is testdata for tst_qtextstream
target.path = $$[QT_INSTALL_TESTS]/tst_qtextstream/$$TARGET
INSTALLS += target

View File

@ -4,4 +4,6 @@ CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
DESTDIR = ./ DESTDIR = ./
# This app is testdata for tst_qtextstream
target.path = $$[QT_INSTALL_TESTS]/tst_qtextstream/$$TARGET
INSTALLS += target

View File

@ -12,15 +12,12 @@ win32 {
} }
} }
wince* { TESTDATA += \
addFiles.files = ../rfc3261.txt ../shift-jis.txt ../task113817.txt ../qtextstream.qrc ../tst_qtextstream.cpp ../rfc3261.txt \
addFiles.path = . ../shift-jis.txt \
res.files = ../resources ../task113817.txt \
res.path = . ../qtextstream.qrc \
DEPLOYMENT += addFiles ../tst_qtextstream.cpp \
DEFINES += SRCDIR=\\\"\\\" ../resources
} else {
DEFINES += SRCDIR=\\\"$$PWD/../\\\"
}
mac: CONFIG += insignificant_test # QTBUG-22767 mac: CONFIG += insignificant_test # QTBUG-22767

View File

@ -47,7 +47,6 @@
#include <QBuffer> #include <QBuffer>
#include <QByteArray> #include <QByteArray>
#include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QTcpSocket> #include <QTcpSocket>
@ -247,16 +246,16 @@ private:
void tst_QTextStream::initTestCase() void tst_QTextStream::initTestCase()
{ {
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); 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 // Testing get/set functions
void tst_QTextStream::getSetCheck() void tst_QTextStream::getSetCheck()
{ {
// Initialize codecs // Initialize codecs
int argc = 0;
char **argv = 0;
QCoreApplication app(argc, argv);
QTextStream obj1; QTextStream obj1;
// QTextCodec * QTextStream::codec() // QTextCodec * QTextStream::codec()
// void QTextStream::setCodec(QTextCodec *) // void QTextStream::setCodec(QTextCodec *)
@ -753,7 +752,7 @@ void tst_QTextStream::generateAllData(bool for_QString)
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
void tst_QTextStream::readLineUntilNull() void tst_QTextStream::readLineUntilNull()
{ {
QFile file(SRCDIR "rfc3261.txt"); QFile file(QFINDTESTDATA("rfc3261.txt"));
QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(file.open(QFile::ReadOnly));
QTextStream stream(&file); QTextStream stream(&file);
@ -872,7 +871,7 @@ void tst_QTextStream::lineCount_data()
QTest::newRow("buffersize+1 line") << QByteArray(16384, '\n') << 16384; QTest::newRow("buffersize+1 line") << QByteArray(16384, '\n') << 16384;
QTest::newRow("buffersize+2 line") << QByteArray(16385, '\n') << 16385; 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; QTest::newRow("rfc3261") << file.readAll() << 15067;
} }
@ -908,7 +907,7 @@ void tst_QTextStream::performance()
stopWatch.restart(); stopWatch.restart();
int nlines1 = 0; int nlines1 = 0;
QFile file(SRCDIR "rfc3261.txt"); QFile file(QFINDTESTDATA("rfc3261.txt"));
QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(file.open(QFile::ReadOnly));
while (!file.atEnd()) { while (!file.atEnd()) {
@ -920,7 +919,7 @@ void tst_QTextStream::performance()
stopWatch.restart(); stopWatch.restart();
int nlines2 = 0; int nlines2 = 0;
QFile file2(SRCDIR "rfc3261.txt"); QFile file2(QFINDTESTDATA("rfc3261.txt"));
QVERIFY(file2.open(QFile::ReadOnly)); QVERIFY(file2.open(QFile::ReadOnly));
QTextStream stream(&file2); QTextStream stream(&file2);
@ -1089,11 +1088,7 @@ void tst_QTextStream::ws_manipulator()
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
void tst_QTextStream::stillOpenWhenAtEnd() void tst_QTextStream::stillOpenWhenAtEnd()
{ {
int argc = 0; QFile file(QFINDTESTDATA("tst_qtextstream.cpp"));
char **argv = 0;
QCoreApplication app(argc, argv);
QFile file(SRCDIR "tst_qtextstream.cpp");
QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(file.open(QFile::ReadOnly));
QTextStream stream(&file); QTextStream stream(&file);
@ -1141,7 +1136,7 @@ void tst_QTextStream::readNewlines()
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
void tst_QTextStream::seek() void tst_QTextStream::seek()
{ {
QFile file(SRCDIR "rfc3261.txt"); QFile file(QFINDTESTDATA("rfc3261.txt"));
QVERIFY(file.open(QFile::ReadOnly)); QVERIFY(file.open(QFile::ReadOnly));
QTextStream stream(&file); QTextStream stream(&file);
@ -1189,8 +1184,6 @@ void tst_QTextStream::seek()
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
void tst_QTextStream::pos() void tst_QTextStream::pos()
{ {
int argc = 1;
QCoreApplication app(argc, 0);
{ {
// Strings // Strings
QString str("this is a test"); QString str("this is a test");
@ -1236,7 +1229,7 @@ void tst_QTextStream::pos()
} }
{ {
// Latin1 device // Latin1 device
QFile file(SRCDIR "rfc3261.txt"); QFile file(QFINDTESTDATA("rfc3261.txt"));
QVERIFY(file.open(QIODevice::ReadOnly)); QVERIFY(file.open(QIODevice::ReadOnly));
QTextStream stream(&file); QTextStream stream(&file);
@ -1268,7 +1261,7 @@ void tst_QTextStream::pos()
{ {
// Shift-JIS device // Shift-JIS device
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
QFile file(SRCDIR "shift-jis.txt"); QFile file(QFINDTESTDATA("shift-jis.txt"));
if (i == 0) if (i == 0)
QVERIFY(file.open(QIODevice::ReadOnly)); QVERIFY(file.open(QIODevice::ReadOnly));
else else
@ -2870,22 +2863,6 @@ void tst_QTextStream::int_write_with_locale()
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// like QTEST_APPLESS_MAIN, but initialising the locale on Unix QTEST_MAIN(tst_QTextStream)
#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);
}
#include "tst_qtextstream.moc" #include "tst_qtextstream.moc"

View File

@ -2,14 +2,3 @@ CONFIG += testcase
TARGET = tst_qitemmodel TARGET = tst_qitemmodel
QT += widgets sql testlib QT += widgets sql testlib
SOURCES = tst_qitemmodel.cpp SOURCES = tst_qitemmodel.cpp
# NOTE: The deployment of the sqldrivers is disabled on purpose.
# If we deploy the plugins, they are loaded twice when running
# the tests on the autotest system. In that case we run out of
# memory on Windows Mobile 5.
#wince*: {
# plugFiles.files = $$QT_BUILD_TREE/plugins/sqldrivers/*.dll
# plugFiles.path = sqldrivers
# DEPLOYMENT += plugFiles
#}

View File

@ -1,7 +1,3 @@
######################################################################
# Automatically generated by qmake (2.01a) Tue Aug 15 13:45:41 2006
######################################################################
TEMPLATE = app TEMPLATE = app
TARGET = TARGET =
DEPENDPATH += . DEPENDPATH += .
@ -16,4 +12,6 @@ wince*: {
HEADERS += signalbug.h HEADERS += signalbug.h
SOURCES += signalbug.cpp SOURCES += signalbug.cpp
# This app is testdata for tst_qobject
target.path = $$[QT_INSTALL_TESTS]/tst_qobject
INSTALLS += target

View File

@ -2796,7 +2796,8 @@ void tst_QObject::dynamicProperties()
void tst_QObject::recursiveSignalEmission() void tst_QObject::recursiveSignalEmission()
{ {
QProcess proc; QProcess proc;
proc.start("./signalbug"); // signalbug helper app should always be next to this test binary
proc.start(QCoreApplication::applicationDirPath() + "/signalbug");
QVERIFY(proc.waitForFinished()); QVERIFY(proc.waitForFinished());
QVERIFY(proc.exitStatus() == QProcess::NormalExit); QVERIFY(proc.exitStatus() == QProcess::NormalExit);
QCOMPARE(proc.exitCode(), 0); QCOMPARE(proc.exitCode(), 0);

View File

@ -6,9 +6,3 @@ SOURCES = tst_qobject.cpp
# this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by # this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by
# moc from Qt 4.6, and should *not* be generated by the current moc # moc from Qt 4.6, and should *not* be generated by the current moc
SOURCES += moc_oldnormalizeobject.cpp SOURCES += moc_oldnormalizeobject.cpp
wince* {
addFiles.files = signalbug.exe
addFiles.path = .
DEPLOYMENT += addFiles
}

View File

@ -4,8 +4,4 @@ QT += widgets testlib
SOURCES = tst_qtranslator.cpp SOURCES = tst_qtranslator.cpp
RESOURCES += qtranslator.qrc RESOURCES += qtranslator.qrc
wince* { TESTDATA += hellotr_la.qm msgfmt_from_po.qm
addFiles.files = hellotr_la.qm msgfmt_from_po.qm
addFiles.path = .
DEPLOYMENT += addFiles
}

View File

@ -56,6 +56,8 @@ public:
protected: protected:
bool event(QEvent *event); bool event(QEvent *event);
private slots: private slots:
void initTestCase();
void load(); void load();
void load2(); void load2();
void threadLoad(); void threadLoad();
@ -76,6 +78,14 @@ tst_QTranslator::tst_QTranslator()
hide(); hide();
} }
void tst_QTranslator::initTestCase()
{
// chdir into the directory containing our testdata,
// to make the code simpler (load testdata via relative paths)
QString testdata_dir = QFileInfo(QFINDTESTDATA("hellotr_la.qm")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
}
bool tst_QTranslator::event(QEvent *event) bool tst_QTranslator::event(QEvent *event)
{ {
if (event->type() == QEvent::LanguageChange) if (event->type() == QEvent::LanguageChange)
@ -228,10 +238,11 @@ void tst_QTranslator::loadFromResource()
void tst_QTranslator::loadDirectory() void tst_QTranslator::loadDirectory()
{ {
QVERIFY(QFileInfo("../qtranslator").isDir()); QString current_base = QDir::current().dirName();
QVERIFY(QFileInfo("../" + current_base).isDir());
QTranslator tor; QTranslator tor;
tor.load("qtranslator", ".."); tor.load(current_base, "..");
QVERIFY(tor.isEmpty()); QVERIFY(tor.isEmpty());
} }

View File

@ -10,5 +10,6 @@ wince*: DEFINES += WIN32_MSVC
win32-msvc: DEFINES += WIN32_MSVC win32-msvc: DEFINES += WIN32_MSVC
win32-borland: DEFINES += WIN32_BORLAND win32-borland: DEFINES += WIN32_BORLAND
#no special install rule for the library used by test # This project is testdata for tst_qlibrary
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary
INSTALLS += target

View File

@ -26,13 +26,17 @@ win32 {
src = $(DESTDIR)$(TARGET) src = $(DESTDIR)$(TARGET)
files = libmylib.so2 system.trolltech.test.mylib.so files = libmylib.so2 system.trolltech.test.mylib.so
} }
# This project is testdata for tst_qlibrary
target.path = $$[QT_INSTALL_TESTS]$${QMAKE_DIR_SEP}tst_qlibrary
renamed_target.path = $$target.path
for(file, files) { for(file, files) {
QMAKE_POST_LINK += $$QMAKE_COPY $$src ..$$QMAKE_DIR_SEP$$file && QMAKE_POST_LINK += $$QMAKE_COPY $$src ..$$QMAKE_DIR_SEP$$file &&
renamed_target.extra += $$QMAKE_COPY $$src $(INSTALL_ROOT)$${target.path}$$QMAKE_DIR_SEP$$file &&
CLEAN_FILES += ../$$file CLEAN_FILES += ../$$file
} }
renamed_target.extra = $$member(renamed_target.extra, 0, -2)
QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2) QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2)
#no special install rule for the library used by test INSTALLS += target renamed_target
INSTALLS =

View File

@ -11,11 +11,4 @@ win32 {
} }
} }
wince* { TESTDATA += ../library_path/invalid.so
addFiles.files = ../*.dll ../*.dl2 ../mylib_noextension
addFiles.path = .
DEPLOYMENT += addFiles
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/../\\\"
}

View File

@ -115,10 +115,6 @@ class tst_QLibrary : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
tst_QLibrary();
virtual ~tst_QLibrary();
enum QLibraryOperation { enum QLibraryOperation {
Load = 1, Load = 1,
Unload = 2, Unload = 2,
@ -127,6 +123,8 @@ enum QLibraryOperation {
DontSetFileName = 0x100 DontSetFileName = 0x100
}; };
private slots: private slots:
void initTestCase();
void load(); void load();
void load_data(); void load_data();
void library_data(); void library_data();
@ -146,33 +144,17 @@ private slots:
void fileName_data(); void fileName_data();
void fileName(); void fileName();
void multipleInstancesForOneLibrary(); void multipleInstancesForOneLibrary();
#ifdef Q_OS_WINCE
private:
QCoreApplication* app;
#endif
}; };
tst_QLibrary::tst_QLibrary()
{
#ifdef Q_OS_WINCE
char* argv = "app";
int argc = 1;
app = new QCoreApplication(argc,&argv);
#endif
}
tst_QLibrary::~tst_QLibrary()
{
#ifdef Q_OS_WINCE
app->quit();
#endif
}
typedef int (*VersionFunction)(void); typedef int (*VersionFunction)(void);
void tst_QLibrary::initTestCase()
{
// chdir to our testdata directory, and use relative paths in some tests.
QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath();
QVERIFY2(QDir::setCurrent(testdatadir), qPrintable("Could not chdir to " + testdatadir));
}
void tst_QLibrary::version_data() void tst_QLibrary::version_data()
{ {
QTest::addColumn<QString>("lib"); QTest::addColumn<QString>("lib");
@ -376,10 +358,6 @@ void tst_QLibrary::errorString_data()
QString currDir = QDir::currentPath(); QString currDir = QDir::currentPath();
QString srcDir = SRCDIR;
if (srcDir.isEmpty())
srcDir = currDir;
QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*"); QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*");
QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error"); QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error");
#ifdef Q_OS_WINCE #ifdef Q_OS_WINCE
@ -394,7 +372,7 @@ void tst_QLibrary::errorString_data()
// QTest::newRow("bad unload") << (int)Unload << QString("nosuchlib.dll") << false << QString("QLibrary::unload_sys: Cannot unload nosuchlib.dll (The specified module could not be found.)"); // QTest::newRow("bad unload") << (int)Unload << QString("nosuchlib.dll") << false << QString("QLibrary::unload_sys: Cannot unload nosuchlib.dll (The specified module could not be found.)");
#elif defined Q_OS_MAC #elif defined Q_OS_MAC
#else #else
QTest::newRow("load invalid file") << (int)Load << srcDir + "/library_path/invalid.so" << false << QString("Cannot load library.*"); QTest::newRow("load invalid file") << (int)Load << QFINDTESTDATA("library_path/invalid.so") << false << QString("Cannot load library.*");
#endif #endif
} }
@ -569,5 +547,5 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
QCOMPARE(lib2.isLoaded(), true); QCOMPARE(lib2.isLoaded(), true);
} }
QTEST_APPLESS_MAIN(tst_QLibrary) QTEST_MAIN(tst_QLibrary)
#include "tst_qlibrary.moc" #include "tst_qlibrary.moc"

View File

@ -3,8 +3,4 @@ TARGET = tst_qplugin
QT = core testlib QT = core testlib
SOURCES = tst_qplugin.cpp SOURCES = tst_qplugin.cpp
wince* { TESTDATA += plugins/*
plugins.files = plugins/*
plugins.path = plugins
DEPLOYMENT += plugins
}

View File

@ -5,3 +5,7 @@ SOURCES = almostplugin.cpp
TARGET = almostplugin TARGET = almostplugin
DESTDIR = ../bin DESTDIR = ../bin
*-g++*:QMAKE_LFLAGS -= -Wl,--no-undefined *-g++*:QMAKE_LFLAGS -= -Wl,--no-undefined
# This is testdata for the tst_qpluginloader test.
target.path = $$[QT_INSTALL_TESTS]/tst_qpluginloader/bin
INSTALLS += target

View File

@ -9,5 +9,6 @@ QT = core
win32-msvc: DEFINES += WIN32_MSVC win32-msvc: DEFINES += WIN32_MSVC
win32-borland: DEFINES += WIN32_BORLAND win32-borland: DEFINES += WIN32_BORLAND
#no special install rule for the library used by test # This is testdata for the tst_qpluginloader test.
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qpluginloader/bin
INSTALLS += target

View File

@ -4,3 +4,7 @@ HEADERS = theplugin.h
SOURCES = theplugin.cpp SOURCES = theplugin.cpp
TARGET = $$qtLibraryTarget(theplugin) TARGET = $$qtLibraryTarget(theplugin)
DESTDIR = ../bin DESTDIR = ../bin
# This is testdata for the tst_qpluginloader test.
target.path = $$[QT_INSTALL_TESTS]/tst_qpluginloader/bin
INSTALLS += target

View File

@ -3,7 +3,6 @@ TARGET = ../tst_qpluginloader
QT = core testlib QT = core testlib
SOURCES = ../tst_qpluginloader.cpp SOURCES = ../tst_qpluginloader.cpp
HEADERS = ../theplugin/plugininterface.h HEADERS = ../theplugin/plugininterface.h
DEFINES += SRCDIR=\\\"$$PWD/../\\\"
win32 { win32 {
CONFIG(debug, debug|release) { CONFIG(debug, debug|release) {
@ -13,10 +12,6 @@ win32 {
} }
} }
wince* { TESTDATA += ../elftest
addFiles.files = $$OUT_PWD/../bin/*.dll
addFiles.path = bin
DEPLOYMENT += addFiles
}
mac: CONFIG += insignificant_test # QTBUG-22765 mac: CONFIG += insignificant_test # QTBUG-22765

View File

@ -95,8 +95,7 @@
static QString sys_qualifiedLibraryName(const QString &fileName) static QString sys_qualifiedLibraryName(const QString &fileName)
{ {
QString currDir = QDir::currentPath(); return QFINDTESTDATA(QString("bin/%1%2%3").arg(PREFIX).arg(fileName).arg(SUFFIX));
return currDir + "/bin/" + PREFIX + fileName + SUFFIX;
} }
//TESTED_CLASS= //TESTED_CLASS=
@ -249,8 +248,8 @@ void tst_QPluginLoader::deleteinstanceOnUnload()
void tst_QPluginLoader::loadDebugObj() void tst_QPluginLoader::loadDebugObj()
{ {
#if defined (__ELF__) #if defined (__ELF__)
QVERIFY(QFile::exists(SRCDIR "elftest/debugobj.so")); QVERIFY(QFile::exists(QFINDTESTDATA("elftest/debugobj.so")));
QPluginLoader lib1(SRCDIR "elftest/debugobj.so"); QPluginLoader lib1(QFINDTESTDATA("elftest/debugobj.so"));
QCOMPARE(lib1.load(), false); QCOMPARE(lib1.load(), false);
#endif #endif
} }
@ -259,21 +258,21 @@ void tst_QPluginLoader::loadCorruptElf()
{ {
#if defined (__ELF__) #if defined (__ELF__)
if (sizeof(void*) == 8) { if (sizeof(void*) == 8) {
QVERIFY(QFile::exists(SRCDIR "elftest/corrupt1.elf64.so")); QVERIFY(QFile::exists(QFINDTESTDATA("elftest/corrupt1.elf64.so")));
QPluginLoader lib1(SRCDIR "elftest/corrupt1.elf64.so"); QPluginLoader lib1(QFINDTESTDATA("elftest/corrupt1.elf64.so"));
QCOMPARE(lib1.load(), false); QCOMPARE(lib1.load(), false);
QVERIFY2(lib1.errorString().contains("not an ELF object"), qPrintable(lib1.errorString())); QVERIFY2(lib1.errorString().contains("not an ELF object"), qPrintable(lib1.errorString()));
QPluginLoader lib2(SRCDIR "elftest/corrupt2.elf64.so"); QPluginLoader lib2(QFINDTESTDATA("elftest/corrupt2.elf64.so"));
QCOMPARE(lib2.load(), false); QCOMPARE(lib2.load(), false);
QVERIFY2(lib2.errorString().contains("invalid"), qPrintable(lib2.errorString())); QVERIFY2(lib2.errorString().contains("invalid"), qPrintable(lib2.errorString()));
QPluginLoader lib3(SRCDIR "elftest/corrupt3.elf64.so"); QPluginLoader lib3(QFINDTESTDATA("elftest/corrupt3.elf64.so"));
QCOMPARE(lib3.load(), false); QCOMPARE(lib3.load(), false);
QVERIFY2(lib3.errorString().contains("invalid"), qPrintable(lib3.errorString())); QVERIFY2(lib3.errorString().contains("invalid"), qPrintable(lib3.errorString()));
} else if (sizeof(void*) == 4) { } else if (sizeof(void*) == 4) {
QPluginLoader libW(SRCDIR "elftest/corrupt3.elf64.so"); QPluginLoader libW(QFINDTESTDATA("elftest/corrupt3.elf64.so"));
QCOMPARE(libW.load(), false); QCOMPARE(libW.load(), false);
QVERIFY2(libW.errorString().contains("architecture"), qPrintable(libW.errorString())); QVERIFY2(libW.errorString().contains("architecture"), qPrintable(libW.errorString()));
} else { } else {
@ -286,12 +285,12 @@ void tst_QPluginLoader::loadGarbage()
{ {
#if defined (Q_OS_UNIX) #if defined (Q_OS_UNIX)
for (int i=0; i<5; i++) { for (int i=0; i<5; i++) {
QPluginLoader lib(QString(SRCDIR "elftest/garbage%1.so").arg(i)); QPluginLoader lib(QFINDTESTDATA(QString("elftest/garbage%1.so").arg(i)));
QCOMPARE(lib.load(), false); QCOMPARE(lib.load(), false);
QVERIFY(lib.errorString() != QString("Unknown error")); QVERIFY(lib.errorString() != QString("Unknown error"));
} }
#endif #endif
} }
QTEST_APPLESS_MAIN(tst_QPluginLoader) QTEST_MAIN(tst_QPluginLoader)
#include "tst_qpluginloader.moc" #include "tst_qpluginloader.moc"

View File

@ -12,9 +12,3 @@ CONFIG(debug_and_release_target) {
} else { } else {
DESTDIR = .. DESTDIR = ..
} }
wince* {
addFile_processUniqueness.files = $$OUT_PWD/../testProcessUniqueness/testProcessUniqueness.exe
addFile_processUniqueness.path = testProcessUniqueness
DEPLOYMENT += addFile_processUniqueness
}

View File

@ -3,6 +3,6 @@ CONFIG += console
DESTDIR = ./ DESTDIR = ./
# no install rule for application used by test # This app is testdata for tst_quuid
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_quuid/$$TARGET
INSTALLS += target

View File

@ -56,10 +56,9 @@ class tst_QUuid : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
tst_QUuid();
private slots: private slots:
void initTestCase();
void fromChar(); void fromChar();
void toString(); void toString();
void fromString(); void fromString();
@ -90,13 +89,17 @@ public:
QUuid uuidB; QUuid uuidB;
}; };
tst_QUuid::tst_QUuid() void tst_QUuid::initTestCase()
{ {
//"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; //"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}";
uuidA = QUuid(0xfc69b59e, 0xcc34 ,0x4436 ,0xa4 ,0x3c ,0xee ,0x95 ,0xd1 ,0x28 ,0xb8 ,0xc5); uuidA = QUuid(0xfc69b59e, 0xcc34 ,0x4436 ,0xa4 ,0x3c ,0xee ,0x95 ,0xd1 ,0x28 ,0xb8 ,0xc5);
//"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}";
uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b); uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b);
// chdir to the directory containing our testdata, then refer to it with relative paths
QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessUniqueness")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
} }
void tst_QUuid::fromChar() void tst_QUuid::fromChar()

View File

@ -2,3 +2,7 @@ SOURCES += crashOnExit.cpp
QT = core QT = core
CONFIG-=app_bundle CONFIG-=app_bundle
CONFIG+=console CONFIG+=console
# This app is testdata for tst_qthreadstorage
target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage
INSTALLS += target

View File

@ -291,15 +291,9 @@ void tst_QThreadStorage::ensureCleanupOrder()
void tst_QThreadStorage::crashOnExit() void tst_QThreadStorage::crashOnExit()
{ {
QProcess process; QProcess process;
#ifdef Q_OS_WIN // crashOnExit is always expected to be in the same directory
# ifdef QT_NO_DEBUG // as this test binary
process.start("release/crashOnExit"); process.start(QCoreApplication::applicationDirPath() + "/crashOnExit");
# else
process.start("debug/crashOnExit");
# endif
#else
process.start("./crashOnExit");
#endif
QVERIFY(process.waitForFinished()); QVERIFY(process.waitForFinished());
QVERIFY(process.exitStatus() != QProcess::CrashExit); QVERIFY(process.exitStatus() != QProcess::CrashExit);
} }

View File

@ -3,11 +3,4 @@ TARGET = tst_qbytearray
QT = core-private testlib QT = core-private testlib
SOURCES = tst_qbytearray.cpp SOURCES = tst_qbytearray.cpp
wince* { TESTDATA += rfc3252.txt
addFile.files = rfc3252.txt
addFile.path = .
DEPLOYMENT += addFile
DEFINES += SRCDIR=\\\"./\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}

View File

@ -172,7 +172,7 @@ void tst_QByteArray::qCompress_data()
char** tmpArgv = 0; char** tmpArgv = 0;
QCoreApplication app(tmpArgc, tmpArgv); QCoreApplication app(tmpArgc, tmpArgv);
#endif #endif
QFile file( SRCDIR "rfc3252.txt" ); QFile file( QFINDTESTDATA("rfc3252.txt") );
QVERIFY( file.open(QIODevice::ReadOnly) ); QVERIFY( file.open(QIODevice::ReadOnly) );
QTest::newRow( "04" ) << file.readAll(); QTest::newRow( "04" ) << file.readAll();
} }

View File

@ -3,9 +3,4 @@ TARGET = tst_qchar
QT = core-private testlib QT = core-private testlib
SOURCES = tst_qchar.cpp SOURCES = tst_qchar.cpp
wince* { TESTDATA += NormalizationTest.txt
deploy.files += NormalizationTest.txt
DEPLOYMENT += deploy
}
DEFINES += SRCDIR=\\\"$$PWD/\\\"

View File

@ -583,7 +583,7 @@ void tst_QChar::normalization_data()
int linenum = 0; int linenum = 0;
int part = 0; int part = 0;
QFile f(SRCDIR "NormalizationTest.txt"); QFile f(QFINDTESTDATA("NormalizationTest.txt"));
QVERIFY(f.exists()); QVERIFY(f.exists());
f.open(QIODevice::ReadOnly); f.open(QIODevice::ReadOnly);

View File

@ -3,8 +3,3 @@ TARGET = tst_qelapsedtimer
QT = core testlib QT = core testlib
SOURCES = tst_qelapsedtimer.cpp SOURCES = tst_qelapsedtimer.cpp
wince* {
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}

View File

@ -1,8 +1,10 @@
SOURCES += syslocaleapp.cpp SOURCES += syslocaleapp.cpp
DESTDIR = ./ DESTDIR = ./
CONFIG -= app_bundle
QT = core QT = core
# no install rule for application used by test # This app is testdata for tst_qlocale
INSTALLS = target.path = $$[QT_INSTALL_TESTS]/tst_qlocale/$$TARGET
CONFIG -= app_bundle INSTALLS += target

View File

@ -3,20 +3,14 @@ QT = core testlib network
embedded: QT += gui embedded: QT += gui
SOURCES = ../tst_qlocale.cpp SOURCES = ../tst_qlocale.cpp
!wince* { TARGET = ../tst_qlocale
TARGET = ../tst_qlocale win32 {
win32: { CONFIG(debug, debug|release) {
CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qlocale
TARGET = ../../debug/tst_qlocale } else {
} else { TARGET = ../../release/tst_qlocale
TARGET = ../../release/tst_qlocale
}
} }
} else {
TARGET = tst_qlocale
addFiles.files = ../syslocaleapp
addFiles.path = "\\Program Files\\tst_qlocale"
DEPLOYMENT += addFiles
} }
TESTDATA += syslocaleapp
mac: CONFIG += insignificant_test # QTBUG-22769 mac: CONFIG += insignificant_test # QTBUG-22769

View File

@ -372,7 +372,7 @@ void tst_QLocale::emptyCtor()
/* because of caching of the system locale. */ \ /* because of caching of the system locale. */ \
QProcess process; \ QProcess process; \
process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \ process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \
process.start("syslocaleapp/syslocaleapp"); \ process.start(syslocaleapp_dir + "syslocaleapp"); \
process.waitForReadyRead(); \ process.waitForReadyRead(); \
QString ret = QString(process.readAll()); \ QString ret = QString(process.readAll()); \
process.waitForFinished(); \ process.waitForFinished(); \
@ -389,10 +389,12 @@ void tst_QLocale::emptyCtor()
env << entry; env << entry;
} }
QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp/");
// Get default locale. // Get default locale.
QProcess p; QProcess p;
p.setEnvironment(env); p.setEnvironment(env);
p.start("syslocaleapp/syslocaleapp"); p.start(syslocaleapp_dir + "syslocaleapp");
p.waitForReadyRead(); p.waitForReadyRead();
QString defaultLoc = QString(p.readAll()); QString defaultLoc = QString(p.readAll());
p.waitForFinished(); p.waitForFinished();

View File

@ -10,6 +10,6 @@ SOURCES = tst_qsharedpointer.cpp \
HEADERS = forwarddeclared.h \ HEADERS = forwarddeclared.h \
wrapper.h wrapper.h
DEFINES += SRCDIR=\\\"$$PWD/\\\" TESTDATA += forwarddeclared.cpp forwarddeclared.h
include(externaltests.pri) include(externaltests.pri)

View File

@ -1786,7 +1786,7 @@ void tst_QSharedPointer::invalidConstructs()
QTest::QExternalTest test; QTest::QExternalTest test;
test.setQtModules(QTest::QExternalTest::QtCore); test.setQtModules(QTest::QExternalTest::QtCore);
test.setExtraProgramSources(QStringList() << SRCDIR "forwarddeclared.cpp"); test.setExtraProgramSources(QStringList() << QFINDTESTDATA("forwarddeclared.cpp"));
test.setProgramHeader( test.setProgramHeader(
"#define QT_SHAREDPOINTER_TRACK_POINTERS\n" "#define QT_SHAREDPOINTER_TRACK_POINTERS\n"
"#define QT_DEBUG\n" "#define QT_DEBUG\n"

View File

@ -2,10 +2,5 @@ CONFIG += testcase parallel_test
TARGET = tst_qtextboundaryfinder TARGET = tst_qtextboundaryfinder
QT = core testlib QT = core testlib
SOURCES = tst_qtextboundaryfinder.cpp SOURCES = tst_qtextboundaryfinder.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
wince* { TESTDATA += data
addFiles.files = data
addFiles.path = .
DEPLOYMENT += addFiles
}

View File

@ -69,7 +69,9 @@ private slots:
void tst_QTextBoundaryFinder::init() void tst_QTextBoundaryFinder::init()
{ {
#ifndef Q_OS_IRIX #ifndef Q_OS_IRIX
QDir::setCurrent(SRCDIR); // chdir into the top-level data dir, then refer to our testdata using relative paths
QString testdata_dir = QFileInfo(QFINDTESTDATA("data")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
#endif #endif
} }

View File

@ -3,11 +3,4 @@ TARGET = tst_qxmlstream
QT = core xml network testlib QT = core xml network testlib
SOURCES = tst_qxmlstream.cpp SOURCES = tst_qxmlstream.cpp
wince* { TESTDATA += data XML-Test-Suite
addFiles.files = data XML-Test-Suite
addFiles.path = .
DEPLOYMENT += addFiles
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}

View File

@ -57,7 +57,7 @@
Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour) Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour)
static const char *const catalogFile = SRCDIR "XML-Test-Suite/xmlconf/finalCatalog.xml"; static const char *const catalogFile = "XML-Test-Suite/xmlconf/finalCatalog.xml";
static const int expectedRunCount = 1646; static const int expectedRunCount = 1646;
static const int expectedSkipCount = 532; static const int expectedSkipCount = 532;
@ -529,7 +529,7 @@ class tst_QXmlStream: public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
tst_QXmlStream() : m_handler(QUrl::fromLocalFile(QLatin1String(catalogFile))) tst_QXmlStream() : m_handler(QUrl::fromLocalFile(QFINDTESTDATA(catalogFile)))
{ {
} }
@ -581,7 +581,7 @@ private:
void tst_QXmlStream::initTestCase() void tst_QXmlStream::initTestCase()
{ {
QFile file(QString::fromLatin1(catalogFile)); QFile file(QFINDTESTDATA(catalogFile));
QVERIFY2(file.open(QIODevice::ReadOnly), QVERIFY2(file.open(QIODevice::ReadOnly),
qPrintable(QString::fromLatin1("Failed to open the test suite catalog; %1").arg(file.fileName()))); qPrintable(QString::fromLatin1("Failed to open the test suite catalog; %1").arg(file.fileName())));
@ -807,7 +807,7 @@ void tst_QXmlStream::testReader_data() const
QTest::addColumn<QString>("xml"); QTest::addColumn<QString>("xml");
QTest::addColumn<QString>("ref"); QTest::addColumn<QString>("ref");
QDir dir; QDir dir;
dir.cd(SRCDIR "data/"); dir.cd(QFINDTESTDATA("data/"));
foreach(QString filename , dir.entryList(QStringList() << "*.xml")) { foreach(QString filename , dir.entryList(QStringList() << "*.xml")) {
QString reference = QFileInfo(filename).baseName() + ".ref"; QString reference = QFileInfo(filename).baseName() + ".ref";
QTest::newRow(dir.filePath(filename).toLatin1().data()) << dir.filePath(filename) << dir.filePath(reference); QTest::newRow(dir.filePath(filename).toLatin1().data()) << dir.filePath(filename) << dir.filePath(reference);
@ -1120,7 +1120,7 @@ void tst_QXmlStream::crashInUTF16Codec() const
QEventLoop eventLoop; QEventLoop eventLoop;
QNetworkAccessManager networkManager; QNetworkAccessManager networkManager;
QNetworkRequest request(QUrl::fromLocalFile(QLatin1String(SRCDIR "data/051reduced.xml"))); QNetworkRequest request(QUrl::fromLocalFile(QFINDTESTDATA("data/051reduced.xml")));
QNetworkReply *const reply = networkManager.get(request); QNetworkReply *const reply = networkManager.get(request);
eventLoop.connect(reply, SIGNAL(finished()), SLOT(quit())); eventLoop.connect(reply, SIGNAL(finished()), SLOT(quit()));