From 7a760f5ed91055b536219b7beff7a1e5446e1b59 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 13 Jan 2015 16:02:48 +0100 Subject: 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 --- .../auto/widgets/itemviews/qdirmodel/qdirmodel.pro | 6 +++- .../auto/widgets/itemviews/qdirmodel/testdata.qrc | 11 +++++++ .../widgets/itemviews/qdirmodel/tst_qdirmodel.cpp | 34 ++++++++++++++++++++-- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/auto/widgets/itemviews/qdirmodel/testdata.qrc (limited to 'tests') 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()); } -- cgit v1.2.3