summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-13 16:02:48 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-16 09:27:52 +0100
commit7a760f5ed91055b536219b7beff7a1e5446e1b59 (patch)
tree8530d2bf0f8a30c3057fbfeabf2af30f29efe68f /tests
parenta0c21829eaa2bfc70b4d134c26ac96a63e48a6a5 (diff)
downloadqtbase-7a760f5ed91055b536219b7beff7a1e5446e1b59.tar.gz
qtbase-7a760f5ed91055b536219b7beff7a1e5446e1b59.tar.bz2
qtbase-7a760f5ed91055b536219b7beff7a1e5446e1b59.zip
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro6
-rw-r--r--tests/auto/widgets/itemviews/qdirmodel/testdata.qrc11
-rw-r--r--tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp34
3 files changed, 48 insertions, 3 deletions
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 @@
+<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>
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());
}