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>
bb10
Giuseppe D'Angelo 2015-12-10 19:38:18 +01:00
parent fa9008566c
commit 69efc425b2
1 changed files with 10 additions and 7 deletions

View File

@ -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)
{