aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativelanguage
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-12-14 16:24:46 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-15 02:35:31 +0100
commit89892191761db53b2094315362be695f054a8700 (patch)
tree27f47fce3f61e622608cbd4cd96102379651721a /tests/auto/declarative/qdeclarativelanguage
parent293a2e9641b44743e8f355286bed47371418bbf3 (diff)
qdeclarativelanguage-test: Fix location.
Introduce the standard method of locating test data (QFINDTESTDATA). Change-Id: I4074396a7631cf68060c02b716fa7e1b95d6e22d Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage')
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index abd8a3744c..31b2666460 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -61,27 +61,15 @@ DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
*/
QString testdata(QString const& name = QString())
{
- /*
- Try to find it relative to the binary.
- Note we are looking for a _directory_ which exists, but the _file_ itself need not exist,
- to support the case of finding a path to a testdata file which doesn't exist yet (i.e.
- a file we are about to create).
- */
- QFileInfo relative = QDir(QCoreApplication::applicationDirPath()).filePath(QLatin1String("data/") + name);
- if (relative.dir().exists()) {
- return relative.absoluteFilePath();
+ static const QString dataDirectory = QDir::currentPath() + QLatin1String("/data");
+ QString result = dataDirectory;
+ if (!name.isEmpty()) {
+ result += QLatin1Char('/');
+ result += name;
}
-
- qWarning("requested testdata %s could not be found (looked at %s)",
- qPrintable(name),
- qPrintable(relative.filePath())
- );
-
- // Chances are the calling test will now fail.
- return QString();
+ return result;
}
-
/*
This test case covers QML language issues. This covers everything that does not
involve evaluating ECMAScript expressions and bindings.
@@ -2048,6 +2036,9 @@ void tst_qdeclarativelanguage::revisionOverloads()
void tst_qdeclarativelanguage::initTestCase()
{
+ QString testdataDir = QFileInfo(QFINDTESTDATA("data")).absolutePath();
+ QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
+
registerTypes();
// Registering the TestType class in other modules should have no adverse effects
@@ -2068,9 +2059,9 @@ void tst_qdeclarativelanguage::initTestCase()
// For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
// For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
- QVERIFY(in.open(QIODevice::ReadOnly));
+ QVERIFY2(in.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(in.fileName(), in.errorString())));
QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
- QVERIFY(out.open(QIODevice::WriteOnly));
+ QVERIFY2(out.open(QIODevice::WriteOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(out.fileName(), out.errorString())));
out.write(in.readAll());
}