summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/dialogs')
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp28
-rw-r--r--tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp7
2 files changed, 22 insertions, 13 deletions
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 4e31c3e57c..63bf103725 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -1014,30 +1014,38 @@ void tst_QFileSystemModel::drives()
void tst_QFileSystemModel::dirsBeforeFiles()
{
- QDir dir(flatDirTestPath);
+ auto diagnosticMsg = [](int row, const QFileInfo &left, const QFileInfo &right) -> QByteArray {
+ QString message;
+ QDebug(&message).noquote() << "Unexpected sort order at #" << row << ':' << left << right;
+ return message.toLocal8Bit();
+ };
+ QTemporaryDir testDir(flatDirTestPath);
+ QVERIFY2(testDir.isValid(), qPrintable(testDir.errorString()));
+ QDir dir(testDir.path());
const int itemCount = 3;
for (int i = 0; i < itemCount; ++i) {
QLatin1Char c('a' + char(i));
QVERIFY(dir.mkdir(c + QLatin1String("-dir")));
- QFile file(flatDirTestPath + QLatin1Char('/') + c + QLatin1String("-file"));
+ QFile file(dir.filePath(c + QLatin1String("-file")));
QVERIFY(file.open(QIODevice::ReadWrite));
file.close();
}
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = model->setRootPath(flatDirTestPath);
+ QModelIndex root = model->setRootPath(dir.absolutePath());
// Wait for model to be notified by the file system watcher
QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
-
- // Ensure that no file occurs before any directory:
- for (int i = 1; i < model->rowCount(root); ++i) {
+ // sort explicitly - dirs before files (except on macOS), and then by name
+ model->sort(0);
+ // Ensure that no file occurs before any directory (see QFileSystemModelSorter):
+ for (int i = 1, count = model->rowCount(root); i < count; ++i) {
+ const QFileInfo previous = model->fileInfo(model->index(i - 1, 0, root));
+ const QFileInfo current = model->fileInfo(model->index(i, 0, root));
#ifndef Q_OS_MAC
- QVERIFY(!(model->fileInfo(model->index(i - 1, 0, root)).isFile()
- && model->fileInfo(model->index(i, 0, root)).isDir()));
+ QVERIFY2(!(previous.isFile() && current.isDir()), diagnosticMsg(i, previous, current).constData());
#else
- QVERIFY(model->fileInfo(model->index(i - 1, 0, root)).fileName() <
- model->fileInfo(model->index(i, 0, root)).fileName());
+ QVERIFY2(previous.fileName() < current.fileName(), diagnosticMsg(i, previous, current).constData());
#endif
}
}
diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
index 259de49c67..877784041b 100644
--- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
@@ -326,7 +326,7 @@ void tst_QInputDialog::getDouble()
// rounded off to 10.03)
const double value = static_cast<int>(min + (max - min) / 2);
const double result =
- QInputDialog::getDouble(parent, "", "", value, min, max, decimals, &ok);
+ QInputDialog::getDouble(parent, "", "", value, min, max, decimals, &ok, Qt::WindowFlags(), 1);
QVERIFY(ok);
QCOMPARE(result, value);
delete parent;
@@ -395,7 +395,8 @@ void tst_QInputDialog::taskQTBUG_54693_crashWhenParentIsDeletedWhileDialogIsOpen
const double initial = 7;
QAutoPointer<SelfDestructParent> dialog(new SelfDestructParent);
bool ok = true;
- const double result = QInputDialog::getDouble(dialog.get(), "Title", "Label", initial, -10, +10, 2, &ok);
+ const double result = QInputDialog::getDouble(dialog.get(), "Title", "Label", initial, -10, +10, 2, &ok,
+ Qt::WindowFlags(), 1);
QVERIFY(!dialog);
QVERIFY(!ok);
QCOMPARE(result, initial);
@@ -411,7 +412,7 @@ void tst_QInputDialog::task255502getDouble()
bool ok = false;
const double value = 0.001;
const double result =
- QInputDialog::getDouble(parent, "", "", value, -1, 1, 4, &ok);
+ QInputDialog::getDouble(parent, "", "", value, -1, 1, 4, &ok, Qt::WindowFlags(), 1);
QVERIFY(ok);
QCOMPARE(result, value);
delete parent;