diff --git a/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro b/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro index 680286d1e4..79848ac22c 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro +++ b/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro @@ -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 +} diff --git a/tests/auto/widgets/itemviews/qdirmodel/testdata.qrc b/tests/auto/widgets/itemviews/qdirmodel/testdata.qrc new file mode 100644 index 0000000000..e0ef4203fe --- /dev/null +++ b/tests/auto/widgets/itemviews/qdirmodel/testdata.qrc @@ -0,0 +1,11 @@ + + + dirtest/test1/dummy + dirtest/test1/test + test/file01.tst + test/file02.tst + test/file03.tst + test/file04.tst + tst_qdirmodel.cpp + + diff --git a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp index 4fee5fb1e5..56a8d1f1f4 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp @@ -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()); }