From fc92419c2058b8c3af8fc1c723e9d957118bcb8f Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 2 Feb 2010 15:44:28 +0100 Subject: Expanded tst_QFileSystemModel::rootPath() to check directories ending in "." or ".." Reviewed-by: Jan-Arve --- tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto/qfilesystemmodel') diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 287f472853..9f67a5e425 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -236,6 +236,26 @@ void tst_QFileSystemModel::rootPath() QCOMPARE(model->rootPath(), QString(QDir::homePath())); QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? 0 : 1); QCOMPARE(model->rootDirectory().absolutePath(), QDir::homePath()); + + model->setRootPath(QDir::rootPath()); + int oldCount = rootChanged.count(); + oldRootPath = model->rootPath(); + root = model->setRootPath(QDir::homePath() + QLatin1String("/.")); + QTRY_VERIFY(model->rowCount(root) >= 0); + QCOMPARE(model->rootPath(), QDir::homePath()); + QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1); + QCOMPARE(model->rootDirectory().absolutePath(), QDir::homePath()); + + QDir newdir = QDir::home(); + if (newdir.cdUp()) { + oldCount = rootChanged.count(); + oldRootPath = model->rootPath(); + root = model->setRootPath(QDir::homePath() + QLatin1String("/..")); + QTRY_VERIFY(model->rowCount(root) >= 0); + QCOMPARE(model->rootPath(), newdir.path()); + QCOMPARE(rootChanged.count(), oldCount + 1); + QCOMPARE(model->rootDirectory().absolutePath(), newdir.path()); + } } void tst_QFileSystemModel::naturalCompare_data() -- cgit v1.2.3