Android: Fix QDirModel tests
This test needs to have a test environment available on the regular file system, so we create this when initializing the test. In addition we QEXPECT_FAIL one of the tests which seems to expose a legitimate bug. A bug report has been created for this. Change-Id: I7c90aea78a067815cb647a51db5d91a652a9fc1c Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
parent
a0c21829ea
commit
7a760f5ed9
@ -13,9 +13,13 @@ wince* {
|
||||
DEPLOYMENT += addit tests sourceFile
|
||||
}
|
||||
|
||||
wince*: {
|
||||
android|wince*: {
|
||||
DEFINES += SRCDIR=\\\"./\\\"
|
||||
} else {
|
||||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
}
|
||||
|
||||
android: !android-no-sdk {
|
||||
RESOURCES += \
|
||||
testdata.qrc
|
||||
}
|
||||
|
11
tests/auto/widgets/itemviews/qdirmodel/testdata.qrc
Normal file
11
tests/auto/widgets/itemviews/qdirmodel/testdata.qrc
Normal file
@ -0,0 +1,11 @@
|
||||
<RCC>
|
||||
<qresource prefix="/android_testdata">
|
||||
<file>dirtest/test1/dummy</file>
|
||||
<file>dirtest/test1/test</file>
|
||||
<file>test/file01.tst</file>
|
||||
<file>test/file02.tst</file>
|
||||
<file>test/file03.tst</file>
|
||||
<file>test/file04.tst</file>
|
||||
<file>tst_qdirmodel.cpp</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -42,6 +42,7 @@ class tst_QDirModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
private slots:
|
||||
@ -113,6 +114,29 @@ void tst_QDirModel::getSetCheck()
|
||||
QCOMPARE(true, obj1.lazyChildCount());
|
||||
}
|
||||
|
||||
void tst_QDirModel::initTestCase()
|
||||
{
|
||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
|
||||
QString dataPath = SRCDIR;
|
||||
QString resourceSourcePath = QStringLiteral(":/android_testdata");
|
||||
QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
||||
QFileInfo fileInfo = it.fileInfo();
|
||||
if (!fileInfo.isDir()) {
|
||||
QString destination = dataPath + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length());
|
||||
QFileInfo destinationFileInfo(destination);
|
||||
if (!destinationFileInfo.exists()) {
|
||||
QDir().mkpath(destinationFileInfo.path());
|
||||
if (!QFile::copy(fileInfo.filePath(), destination))
|
||||
qWarning("Failed to copy %s", qPrintable(fileInfo.filePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QDirModel::cleanupTestCase()
|
||||
{
|
||||
QDir current;
|
||||
@ -556,10 +580,12 @@ void tst_QDirModel::filePath()
|
||||
model.setResolveSymlinks(false);
|
||||
QModelIndex index = model.index(SRCDIR "test.lnk");
|
||||
QVERIFY(index.isValid());
|
||||
#ifndef Q_OS_WINCE
|
||||
#if !defined(Q_OS_WINCE) && !defined(Q_OS_ANDROID)
|
||||
QString path = SRCDIR;
|
||||
#else
|
||||
QString path = QFileInfo(SRCDIR).absoluteFilePath() + "/";
|
||||
QString path = QFileInfo(SRCDIR).absoluteFilePath();
|
||||
if (!path.endsWith("/"))
|
||||
path += "/";
|
||||
#endif
|
||||
QCOMPARE(model.filePath(index), path + QString( "test.lnk"));
|
||||
model.setResolveSymlinks(true);
|
||||
@ -592,6 +618,10 @@ void tst_QDirModel::task196768_sorting()
|
||||
view.setSortingEnabled(true);
|
||||
index2 = model.index(path);
|
||||
|
||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
|
||||
QEXPECT_FAIL("", "QTBUG-43818", Continue);
|
||||
#endif
|
||||
|
||||
QCOMPARE(index.data(), index2.data());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user