summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs/qfilesystemmodel
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
commit6630937e63ae5797487b86743a7733c8ae5cc42c (patch)
tree3d53dacf6430f9099e1fb20835881205de674961 /tests/auto/widgets/dialogs/qfilesystemmodel
parent37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff)
parentc7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff)
Merge commit 'dev' into 'wip/cmake-merge'
Diffstat (limited to 'tests/auto/widgets/dialogs/qfilesystemmodel')
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST11
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt30
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro5
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp83
4 files changed, 102 insertions, 27 deletions
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST
new file mode 100644
index 0000000000..01679eb6ee
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST
@@ -0,0 +1,11 @@
+winrt
+[sort:QFileDialog usage]
+ubuntu
+b2qt
+[specialFiles]
+ubuntu
+b2qt
+[dirsBeforeFiles]
+ubuntu
+b2qt
+windows
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt b/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt
index bf615c6805..336ce4ca15 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt
@@ -1,5 +1,31 @@
-add_qt_test("tst_qfilesystemmodel" SOURCES tst_qfilesystemmodel.cpp
+# Generated from qfilesystemmodel.pro.
+
+#####################################################################
+## tst_qfilesystemmodel Test:
+#####################################################################
+
+add_qt_test(tst_qfilesystemmodel
+ SOURCES
+ ../../../../shared/emulationdetector.h
+ tst_qfilesystemmodel.cpp
+ INCLUDE_DIRECTORIES
+ ../../../../shared
LIBRARIES
- Qt::WidgetsPrivate
Qt::CorePrivate
+ Qt::WidgetsPrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+ Qt::Widgets
)
+
+#### Keys ignored in scope 1:.:.:qfilesystemmodel.pro:<TRUE>:
+# CONFIG = "testcase"
+
+## Scopes:
+#####################################################################
+
+#### Keys ignored in scope 2:.:.:qfilesystemmodel.pro:WIN32:
+# testcase.timeout = "900"
+
+#### Keys ignored in scope 3:.:.:qfilesystemmodel.pro:APPLE_OSX:
+# testcase.timeout = "900"
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
index bc4671f60c..db8cf7de3f 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
@@ -1,3 +1,6 @@
+INCLUDEPATH += ../../../../shared
+HEADERS += ../../../../shared/emulationdetector.h
+
CONFIG += testcase
# This testcase can be slow on Windows and OS X, and may interfere with other file system tests.
win32:testcase.timeout = 900
@@ -8,5 +11,3 @@ QT += core-private testlib
SOURCES += tst_qfilesystemmodel.cpp
TARGET = tst_qfilesystemmodel
-
-CONFIG += insignificant_test # QTBUG-29403
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index d8a680881a..665a116a3a 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
+#include <emulationdetector.h>
#include <QtTest/QtTest>
#ifdef QT_BUILD_INTERNAL
#include <private/qfilesystemmodel_p.h>
@@ -51,10 +52,15 @@
// Will try to wait for the condition while allowing event processing
// for a maximum of 5 seconds.
-#define TRY_WAIT(expr) \
+#define TRY_WAIT(expr, timedOut) \
do { \
+ *timedOut = true; \
const int step = 50; \
- for (int __i = 0; __i < 5000 && !(expr); __i+=step) { \
+ for (int __i = 0; __i < 5000; __i += step) { \
+ if (expr) { \
+ *timedOut = false; \
+ break; \
+ } \
QTest::qWait(step); \
} \
} while(0)
@@ -123,6 +129,8 @@ private slots:
protected:
bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList());
+ QModelIndex prepareTestModelRoot(const QString &test_path, QSignalSpy **spy2 = nullptr,
+ QSignalSpy **spy3 = nullptr);
private:
QFileSystemModel *model;
@@ -306,7 +314,11 @@ void tst_QFileSystemModel::iconProvider()
bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount, const QStringList &initial_dirs)
{
//qDebug() << (model->rowCount(model->index(test_path))) << existingFileCount << initial_files;
- TRY_WAIT((model->rowCount(model->index(test_path)) == existingFileCount));
+ bool timedOut = false;
+ TRY_WAIT((model->rowCount(model->index(test_path)) == existingFileCount), &timedOut);
+ if (timedOut)
+ return false;
+
for (int i = 0; i < initial_dirs.count(); ++i) {
QDir dir(test_path);
if (!dir.exists()) {
@@ -363,23 +375,45 @@ bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringLi
return true;
}
-void tst_QFileSystemModel::rowCount()
+QModelIndex tst_QFileSystemModel::prepareTestModelRoot(const QString &test_path, QSignalSpy **spy2,
+ QSignalSpy **spy3)
{
- QString tmp = flatDirTestPath;
- QVERIFY(createFiles(tmp, QStringList()));
+ if (model->rowCount(model->index(test_path)) != 0)
+ return QModelIndex();
- QSignalSpy spy2(model, SIGNAL(rowsInserted(QModelIndex,int,int)));
- QSignalSpy spy3(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
+ if (spy2)
+ *spy2 = new QSignalSpy(model, &QFileSystemModel::rowsInserted);
+ if (spy3)
+ *spy3 = new QSignalSpy(model, &QFileSystemModel::rowsAboutToBeInserted);
- QStringList files = QStringList() << "b" << "d" << "f" << "h" << "j" << ".a" << ".c" << ".e" << ".g";
+ QStringList files = { "b", "d", "f", "h", "j", ".a", ".c", ".e", ".g" };
QString l = "b,d,f,h,j,.a,.c,.e,.g";
- QVERIFY(createFiles(tmp, files));
+ if (!createFiles(test_path, files))
+ return QModelIndex();
- QModelIndex root = model->setRootPath(tmp);
- QTRY_COMPARE(model->rowCount(root), 5);
- QVERIFY(spy2.count() > 0);
- QVERIFY(spy3.count() > 0);
+ QModelIndex root = model->setRootPath(test_path);
+ if (!root.isValid())
+ return QModelIndex();
+
+ bool timedOut = false;
+ TRY_WAIT(model->rowCount(root) == 5, &timedOut);
+ if (timedOut)
+ return QModelIndex();
+
+ return root;
+}
+
+void tst_QFileSystemModel::rowCount()
+{
+ const QString tmp = flatDirTestPath;
+ QSignalSpy *spy2 = nullptr;
+ QSignalSpy *spy3 = nullptr;
+ QModelIndex root = prepareTestModelRoot(flatDirTestPath, &spy2, &spy3);
+ QVERIFY(root.isValid());
+
+ QVERIFY(spy2 && spy2->count() > 0);
+ QVERIFY(spy3 && spy3->count() > 0);
}
void tst_QFileSystemModel::rowsInserted_data()
@@ -401,9 +435,9 @@ static inline QString lastEntry(const QModelIndex &root)
void tst_QFileSystemModel::rowsInserted()
{
- QString tmp = flatDirTestPath;
- rowCount();
- QModelIndex root = model->index(model->rootPath());
+ const QString tmp = flatDirTestPath;
+ QModelIndex root = prepareTestModelRoot(tmp);
+ QVERIFY(root.isValid());
QFETCH(int, ascending);
QFETCH(int, count);
@@ -454,9 +488,9 @@ void tst_QFileSystemModel::rowsRemoved_data()
void tst_QFileSystemModel::rowsRemoved()
{
- QString tmp = flatDirTestPath;
- rowCount();
- QModelIndex root = model->index(model->rootPath());
+ const QString tmp = flatDirTestPath;
+ QModelIndex root = prepareTestModelRoot(tmp);
+ QVERIFY(root.isValid());
QFETCH(int, count);
QFETCH(int, ascending);
@@ -509,9 +543,9 @@ void tst_QFileSystemModel::dataChanged()
{
QSKIP("This can't be tested right now since we don't watch files, only directories.");
- QString tmp = flatDirTestPath;
- rowCount();
- QModelIndex root = model->index(model->rootPath());
+ const QString tmp = flatDirTestPath;
+ QModelIndex root = prepareTestModelRoot(tmp);
+ QVERIFY(root.isValid());
QFETCH(int, count);
QFETCH(int, assending);
@@ -755,6 +789,9 @@ void tst_QFileSystemModel::sort()
MyFriendFileSystemModel *myModel = new MyFriendFileSystemModel();
QTreeView *tree = new QTreeView();
+ if (fileDialogMode && EmulationDetector::isRunningArmOnX86())
+ QSKIP("Crashes in QEMU. QTBUG-70572");
+
#ifdef QT_BUILD_INTERNAL
if (fileDialogMode)
myModel->d_func()->disableRecursiveSort = true;