aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-07-26 14:40:09 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-29 13:49:48 +0200
commitc71c7dadda2b15d7dbde6591172a1d7e85b7fbe6 (patch)
tree1a496afbbf9abc2b7b51aacce7656a38aa3692d9 /tests
parent646503bfcd53897a630a1844860e139157d65640 (diff)
FolderListModel: Do not return invalid URLs like "file:" when navigating up.
Task-number: QTBUG-32139 Change-Id: I715b97eb85bc4235de6a2bb696131efae56477fd Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index 9230608622..ef24e0a2d2 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -73,6 +73,7 @@ private slots:
void basicProperties();
void resetFiltering();
void refresh();
+ void cdUp();
#if defined (Q_OS_WIN) && !defined (Q_OS_WINCE)
// WinCE does not have drive concept, so lets execute this test only on desktop Windows.
void changeDrive();
@@ -182,6 +183,33 @@ void tst_qquickfolderlistmodel::refresh()
QTRY_COMPARE(removeEnd, count-1); // wait for refresh
}
+void tst_qquickfolderlistmodel::cdUp()
+{
+ enum { maxIterations = 50 };
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+ const QUrl startFolder = flm->property("folder").toUrl();
+ QVERIFY(startFolder.isValid());
+
+ // QTBUG-32139: Ensure navigating upwards terminates cleanly and does not
+ // return invalid Urls like "file:".
+ for (int i = 0; ; ++i) {
+ const QVariant folderV = flm->property("parentFolder");
+ const QUrl folder = folderV.toUrl();
+ if (!folder.isValid())
+ break;
+ QVERIFY(folder.toString() != QLatin1String("file:"));
+ QVERIFY2(i < maxIterations,
+ qPrintable(QString::fromLatin1("Unable to reach root after %1 iterations starting from %2, stuck at %3")
+ .arg(maxIterations).arg(QDir::toNativeSeparators(startFolder.toLocalFile()),
+ QDir::toNativeSeparators(folder.toLocalFile()))));
+ flm->setProperty("folder", folderV);
+ }
+}
+
#if defined (Q_OS_WIN) && !defined (Q_OS_WINCE)
void tst_qquickfolderlistmodel::changeDrive()
{