diff options
author | Frans Englich <frans.englich@nokia.com> | 2009-09-30 13:11:39 (GMT) |
---|---|---|
committer | Frans Englich <frans.englich@nokia.com> | 2009-09-30 13:11:39 (GMT) |
commit | 7c33e0f95789af1f6c091db89581f8a26b10682d (patch) | |
tree | cb8faa2ab6ce19c85a8c0c90dc852db08375868e /tests/auto/qfilesystemmodel | |
parent | da935e9df4c63490a7d2a716236f1e781c2d75a6 (diff) | |
parent | c3ef2d3a6d9a6e35b05cbd8f370630d5dd85415e (diff) | |
download | Qt-7c33e0f95789af1f6c091db89581f8a26b10682d.zip Qt-7c33e0f95789af1f6c091db89581f8a26b10682d.tar.gz Qt-7c33e0f95789af1f6c091db89581f8a26b10682d.tar.bz2 |
Merge commit 'origin/4.6' into mmfphonon
Diffstat (limited to 'tests/auto/qfilesystemmodel')
-rw-r--r-- | tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index a388f0a..ea9304d 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -806,6 +806,16 @@ void tst_QFileSystemModel::sort() QDir dir(QDir::tempPath()); dir.mkdir("sortTemp"); dir.cd("sortTemp"); + QDirIterator it(dir); + while(it.hasNext()) + { + it.next(); + QFileInfo info = it.fileInfo(); + if (info.isDir()) + dir.rmdir(info.fileName()); + else + QFile::remove(info.absoluteFilePath()); + } const QString dirPath = dir.absolutePath(); QVERIFY(dir.exists()); @@ -823,7 +833,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 +856,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; |