From 0655504015c4f1ac9d65fef85c3c0554d7d8fc93 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 19 Dec 2014 10:38:01 +0100 Subject: [PATCH] Also search current directory in QFINDTESTDATA On Android, none of the file system paths used for QFINDTESTDATA currently are suitable. We do have the possibility of putting test data in qrc, but in cases where the test is specifically testing access to the regular file system, we need a way to find files there as well. We add a fifth step when all other fail, which searches the current active directory for the data. Change-Id: I4f02f8530b5843eb282bd112ea03ed6a476593d6 Reviewed-by: BogDan Vatra --- src/testlib/qtestcase.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 24d563045bf..2851f834277 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2722,6 +2722,13 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co found = candidate; } + // 5. Try current directory + if (found.isEmpty()) { + QString candidate = QString::fromLatin1("%1/%2").arg(QDir::currentPath()).arg(base); + if (QFileInfo(candidate).exists()) + found = candidate; + } + if (found.isEmpty()) { QTest::qWarn(qPrintable( QString::fromLatin1("testdata %1 could not be located!").arg(base)),