tst_qtranslator: Simplify extraction of test data
This makes it easier to further extend the test. The overhead this causes is negligible. Change-Id: I42941879f55337268bb2914e122a5f573ab7e6f9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 841ce1f938219cb975099a28b720abeb95eea19d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
8df7212325
commit
e90398e3be
@ -11,8 +11,10 @@ qt_internal_add_test(tst_qtranslator
|
|||||||
|
|
||||||
# Resources:
|
# Resources:
|
||||||
set(qtranslator_resource_files
|
set(qtranslator_resource_files
|
||||||
|
"dependencies_la.qm"
|
||||||
"hellotr_empty.qm"
|
"hellotr_empty.qm"
|
||||||
"hellotr_la.qm"
|
"hellotr_la.qm"
|
||||||
|
"msgfmt_from_po.qm"
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_internal_add_resource(tst_qtranslator "qtranslator"
|
qt_internal_add_resource(tst_qtranslator "qtranslator"
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/android_testdata">
|
|
||||||
<file>hellotr_la.qm</file>
|
|
||||||
<file>hellotr_empty.qm</file>
|
|
||||||
<file>msgfmt_from_po.qm</file>
|
|
||||||
<file>dependencies_la.qm</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
@ -1,6 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/tst_qtranslator">
|
|
||||||
<file>hellotr_la.qm</file>
|
|
||||||
<file>hellotr_empty.qm</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
@ -73,38 +73,10 @@ tst_QTranslator::tst_QTranslator()
|
|||||||
|
|
||||||
void tst_QTranslator::initTestCase()
|
void tst_QTranslator::initTestCase()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
|
dataDir = QEXTRACTTESTDATA(QStringLiteral("/tst_qtranslator"));
|
||||||
QString sourceDir(":/android_testdata/");
|
|
||||||
QDirIterator it(sourceDir, QDirIterator::Subdirectories);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
|
|
||||||
QFileInfo sourceFileInfo = it.fileInfo();
|
|
||||||
if (!sourceFileInfo.isDir()) {
|
|
||||||
QFileInfo destinationFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + sourceFileInfo.filePath().mid(sourceDir.length()));
|
|
||||||
|
|
||||||
if (!destinationFileInfo.exists()) {
|
|
||||||
QVERIFY(QDir().mkpath(destinationFileInfo.path()));
|
|
||||||
QVERIFY(QFile::copy(sourceFileInfo.filePath(), destinationFileInfo.filePath()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// chdir into the directory containing our testdata,
|
|
||||||
// to make the code simpler (load testdata via relative paths)
|
|
||||||
#if 0
|
|
||||||
// ### TODO: Use this for all platforms in 5.7
|
|
||||||
dataDir = QEXTRACTTESTDATA(QStringLiteral("/"));
|
|
||||||
QVERIFY2(!dataDir.isNull(), qPrintable("Could not extract test data"));
|
QVERIFY2(!dataDir.isNull(), qPrintable("Could not extract test data"));
|
||||||
QVERIFY2(QDir::setCurrent(dataDir->path()), qPrintable("Could not chdir to " + dataDir->path()));
|
QVERIFY2(QDir::setCurrent(dataDir->path()),
|
||||||
#else
|
qPrintable("Could not chdir to " + dataDir->path()));
|
||||||
QString testdata_dir = QFileInfo(QFINDTESTDATA("hellotr_la.qm")).absolutePath();
|
|
||||||
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tst_QTranslator::eventFilter(QObject *, QEvent *event)
|
bool tst_QTranslator::eventFilter(QObject *, QEvent *event)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user