summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2012-01-26 11:50:07 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-26 15:38:33 +0100
commit0818fce01a332450a6046d6a30759362a9fb459f (patch)
tree68580166390d86dc3c8b3965523361bfdcb12aa3 /tests
parentcd7326c16ffee906347d86a74b99eba32f509733 (diff)
Made it possible to run tst_qtjson test from shadow build directory.
Change-Id: I167737c91e01f055a2ce14db54dfcc6b74ad8c28 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/json/json.pro2
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp19
2 files changed, 13 insertions, 8 deletions
diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro
index f7b7a80a2d..5158b7337a 100644
--- a/tests/auto/corelib/json/json.pro
+++ b/tests/auto/corelib/json/json.pro
@@ -3,4 +3,6 @@ QT = core testlib
CONFIG -= app_bundle
CONFIG += testcase
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
SOURCES += tst_qtjson.cpp
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 97504d178a..b30fdc1503 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -1044,7 +1044,7 @@ void TestQtJson::fromJson()
void TestQtJson::fromBinary()
{
- QFile file(QLatin1String("test.json"));
+ QFile file(QLatin1String(SRCDIR "test.json"));
file.open(QFile::ReadOnly);
QByteArray testJson = file.readAll();
@@ -1053,7 +1053,7 @@ void TestQtJson::fromBinary()
QVERIFY(!outdoc.isNull());
QVERIFY(doc == outdoc);
- QFile bfile(QLatin1String("test.bjson"));
+ QFile bfile(QLatin1String(SRCDIR "test.bjson"));
bfile.open(QFile::ReadOnly);
QByteArray binary = bfile.readAll();
@@ -1066,8 +1066,8 @@ void TestQtJson::fromBinary()
void TestQtJson::toAndFromBinary_data()
{
QTest::addColumn<QString>("filename");
- QTest::newRow("test.json") << QString::fromLatin1("test.json");
- QTest::newRow("test2.json") << QString::fromLatin1("test2.json");
+ QTest::newRow("test.json") << QString::fromLatin1(SRCDIR "test.json");
+ QTest::newRow("test2.json") << QString::fromLatin1(SRCDIR "test2.json");
}
void TestQtJson::toAndFromBinary()
@@ -1246,7 +1246,7 @@ void TestQtJson::parseDuplicateKeys()
void TestQtJson::testParser()
{
- QFile file(QLatin1String("test.json"));
+ QFile file(QLatin1String(SRCDIR "test.json"));
file.open(QFile::ReadOnly);
QByteArray testJson = file.readAll();
@@ -1331,9 +1331,10 @@ void TestQtJson::compactObject()
void TestQtJson::validation()
{
// this basically tests that we don't crash on corrupt data
- QFile file(QLatin1String("test.json"));
- file.open(QFile::ReadOnly);
+ QFile file(QLatin1String(SRCDIR "test.json"));
+ QVERIFY(file.open(QFile::ReadOnly));
QByteArray testJson = file.readAll();
+ QVERIFY(!testJson.isEmpty());
QJsonDocument doc = QJsonDocument::fromJson(testJson);
@@ -1350,9 +1351,11 @@ void TestQtJson::validation()
}
- QFile file2(QLatin1String("foo.json"));
+ QFile file2(QLatin1String(SRCDIR "foo.json"));
+// QVERIFY(file2.open(QFile::ReadOnly)); // ### the file is missing o_O
file2.open(QFile::ReadOnly);
testJson = file2.readAll();
+// QVERIFY(!testJson.isEmpty());
doc = QJsonDocument::fromJson(testJson);