Android: Fix tests in gui/text requiring test data

Several tests require test data to be deployed with the
application. The easiest way to achieve this on Android
is to add them to a qrc file and use the QFINDTESTDATA macro
to look up the files. This fixes several test failures
in the gui/text subdirectory for Android.

Change-Id: If944bb1fc93434a1b2d6487da829d21bd6b84e87
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2014-07-10 12:04:49 +02:00
parent 8b8eebd8a4
commit e746e2a11a
11 changed files with 66 additions and 11 deletions

View File

@ -15,3 +15,8 @@ wince* {
DEPLOYMENT += addFiles timesFont
}
android {
RESOURCES += \
testdata.qrc
}

View File

@ -0,0 +1,18 @@
<RCC>
<qresource prefix="/">
<file>testdata/scanner/comments/input</file>
<file>testdata/scanner/comments/output</file>
<file>testdata/scanner/comments2/input</file>
<file>testdata/scanner/comments2/output</file>
<file>testdata/scanner/comments3/input</file>
<file>testdata/scanner/comments3/output</file>
<file>testdata/scanner/comments4/input</file>
<file>testdata/scanner/comments4/output</file>
<file>testdata/scanner/quotedstring/input</file>
<file>testdata/scanner/quotedstring/output</file>
<file>testdata/scanner/simple/input</file>
<file>testdata/scanner/simple/output</file>
<file>testdata/scanner/unicode/input</file>
<file>testdata/scanner/unicode/output</file>
</qresource>
</RCC>

View File

@ -130,7 +130,9 @@ void tst_QCssParser::scanner_data()
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("output");
#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE)
#if defined(Q_OS_ANDROID)
QDir d(":/");
#elif !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE)
QDir d(SRCDIR);
#else
QDir d(QDir::current());

View File

@ -8,8 +8,14 @@ linux: CONFIG += insignificant_test
SOURCES += \
tst_qglyphrun.cpp
wince* {
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
android {
RESOURCES += \
testdata.qrc
}
wince* {
additionalFiles.files = test.ttf
additionalFiles.path = .
DEPLOYMENT += additionalFiles
}

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>test.ttf</file>
</qresource>
</RCC>

View File

@ -94,7 +94,7 @@ void tst_QGlyphRun::initTestCase()
{
m_testFont_ok = false;
m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf");
m_testFontId = QFontDatabase::addApplicationFont(QFINDTESTDATA("test.ttf"));
QVERIFY(m_testFontId >= 0);
m_testFont = QFont("QtsSpecialTestFont");

View File

@ -8,3 +8,8 @@ SOURCES += \
tst_qrawfont.cpp
TESTDATA += testfont_bold_italic.ttf testfont.ttf
android {
RESOURCES += \
testdata.qrc
}

View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>testfont_bold_italic.ttf</file>
<file>testfont.ttf</file>
</qresource>
</RCC>

View File

@ -7,7 +7,9 @@ wince* {
addFiles.files = testdata
addFiles.path = .
DEPLOYMENT += addFiles
DEFINES += SRCDIR=\\\".\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
android {
RESOURCES += \
testdata.qrc
}

View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>testdata/symlink.zip</file>
<file>testdata/test.zip</file>
</qresource>
</RCC>

View File

@ -68,7 +68,7 @@ void tst_QZip::cleanup()
void tst_QZip::basicUnpack()
{
QZipReader zip(QString(SRCDIR) + "/testdata/test.zip", QIODevice::ReadOnly);
QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly);
QList<QZipReader::FileInfo> files = zip.fileInfoList();
QCOMPARE(files.count(), 2);
@ -104,7 +104,7 @@ void tst_QZip::basicUnpack()
void tst_QZip::symlinks()
{
QZipReader zip(QString(SRCDIR) + "/testdata/symlink.zip", QIODevice::ReadOnly);
QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly);
QList<QZipReader::FileInfo> files = zip.fileInfoList();
QCOMPARE(files.count(), 2);