summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-09-29 12:51:06 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-09-29 12:55:24 (GMT)
commit51a556f7e65f3e9c3c011f309f62a819eec07727 (patch)
treee41a8e044f614d64f9dd8514ae5031c9ed94ff8a /tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
parent82ad1edea9fd6d6955ab9e3f661c625f7ba5ed78 (diff)
downloadQt-51a556f7e65f3e9c3c011f309f62a819eec07727.zip
Qt-51a556f7e65f3e9c3c011f309f62a819eec07727.tar.gz
Qt-51a556f7e65f3e9c3c011f309f62a819eec07727.tar.bz2
Fix auto-test failure for QFileSystemModel::sort
This test was failing on the farm because the rootPath for the model was invalid. QDir::rootPath on Windows return C:\ but in the farm the temp directory is in E:\ therefore the sort was only triggered on C:\ and this explain the failure. I also make comparaisons a bit more robust. Reviewed-by:TrustMe
Diffstat (limited to 'tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp')
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index a388f0a..63bc90c 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -823,7 +823,7 @@ void tst_QFileSystemModel::sort()
out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n";
tempFile2.close();
- myModel->setRootPath(QDir::rootPath());
+ myModel->setRootPath("");
myModel->setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
tree->setSortingEnabled(true);
tree->setModel(myModel);
@@ -846,11 +846,22 @@ void tst_QFileSystemModel::sort()
tree->expand(myModel->index(dirPath, 0));
QTest::qWait(500);
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)
- QVERIFY(dirPath + QChar('/') + myModel->index(0, 1, parent).data(QFileSystemModel::FileNameRole).toString() != tempFile2.fileName());
- else
- QCOMPARE(dirPath + QChar('/') + myModel->index(0, 1, parent).data(QFileSystemModel::FileNameRole).toString(), tempFile2.fileName());
+ if (fileDialogMode) {
+ 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);
+ } else {
+ for(int i = 0; i < myModel->rowCount(parent); ++i)
+ {
+ QVERIFY(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString() == expectedOrder.at(i));
+ }
+ }
delete tree;
delete myModel;