From 15752b9ee436f7c0cb49c3ad29a2d81104d64d5d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 15 May 2009 13:06:40 +1000 Subject: Add more resiliant TEST_FILE() method --- .../auto/declarative/qmlbindengine/tst_qmlbindengine.cpp | 15 +++++++++++++-- tests/auto/declarative/qmlparser/tst_qmlparser.cpp | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp index a0554f3..a1efc5f 100644 --- a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp +++ b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp @@ -3,10 +3,21 @@ #include #include #include +#include +#include +#include #include "testtypes.h" -#define TEST_FILE(filename) \ - QUrl::fromLocalFile(QApplication::applicationDirPath() + "/" + filename) +inline QUrl TEST_FILE(const QString &filename) +{ + QFileInfo fileInfo(__FILE__); + return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); +} + +inline QUrl TEST_FILE(const char *filename) +{ + return TEST_FILE(QLatin1String(filename)); +} class tst_qmlbindengine : public QObject { diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp index 65ee5e2..089c116 100644 --- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp +++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "testtypes.h" class tst_qmlparser : public QObject @@ -73,8 +75,16 @@ private: QCOMPARE(expected, actual); \ } -#define TEST_FILE(filename) \ - QUrl::fromLocalFile(QApplication::applicationDirPath() + "/" + filename) +inline QUrl TEST_FILE(const QString &filename) +{ + QFileInfo fileInfo(__FILE__); + return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); +} + +inline QUrl TEST_FILE(const char *filename) +{ + return TEST_FILE(QLatin1String(filename)); +} void tst_qmlparser::errors_data() { -- cgit v0.12