diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-12-10 19:38:18 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-12-12 10:38:53 +0000 |
commit | 69efc425b2cb0ed81a5ec0b6c4c498fdfdefca51 (patch) | |
tree | a08dda5236ecc2de9ff8a42d79585594846bbf79 /tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | |
parent | fa9008566c163f95d99c3551beb4335f28461289 (diff) |
QFileSystemModel autotest: fix a broken sort() test
The test was comparing an "unsorted" file listing read from disk
with a reference listing, checking whether the two were different.
Obviously that's a nonsense test, as there's no stable order
for the entries returned by readdir_r and friends.
Change-Id: I1d781a6513c42bb0b585d02e57a771c5336c7df4
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp')
-rw-r--r-- | tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 996d919591..8c8872e807 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -822,18 +822,21 @@ void tst_QFileSystemModel::sort() QModelIndex parent = myModel->index(dirPath, 0); QList<QString> expectedOrder; expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + "."; - //File dialog Mode means sub trees are not sorted, only the current root + if (fileDialogMode) { - // FIXME: we were only able to disableRecursiveSort in developer builds, so we can only - // stably perform this test for developer builds -#ifdef QT_BUILD_INTERNAL - QList<QString> actualRows; + // File dialog Mode means sub trees are not sorted, only the current root. + // There's no way we can check that the sub tree is "not sorted"; just check if it + // has the same contents of the expected list + QList<QString> actualRows; for(int i = 0; i < myModel->rowCount(parent); ++i) { actualRows << dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString(); } - QVERIFY(actualRows != expectedOrder); -#endif + + std::sort(expectedOrder.begin(), expectedOrder.end()); + std::sort(actualRows.begin(), actualRows.end()); + + QCOMPARE(actualRows, expectedOrder); } else { for(int i = 0; i < myModel->rowCount(parent); ++i) { |