From 1c08a41cb9b4a080b2465b1df70941e9c508bf1f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 1 Jul 2014 13:11:03 +0200 Subject: Support getting test data from qrc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If none of the other locations work, we can fall back to bundling the test data in qrc to make it possible to include test data on platforms that do not have any good way of deploying files to the traditional file system, like Android. Change-Id: I7779ce6be2380d551697cecfb9f76652d1fd0a38 Reviewed-by: Tor Arne Vestbø --- src/testlib/qtestcase.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index ffcc7abbfe..5d2014b0c5 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2708,6 +2708,13 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co } } + // 4. Try resources + if (found.isEmpty()) { + QString candidate = QString::fromLatin1(":/%1").arg(base); + if (QFileInfo(candidate).exists()) + found = candidate; + } + if (found.isEmpty()) { QTest::qWarn(qPrintable( QString::fromLatin1("testdata %1 could not be located!").arg(base)), -- cgit v1.2.3