From 885bd1d0e57b9e0e5a7c4945866c2ef00ae30c92 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 16 Nov 2013 22:07:01 +0100 Subject: tst_QFileSystemModel: don't expect ~/Documents to exist For me, this test failed because I don't have a Documents folder in my home directory, even though that's what's returned from QStandardPaths as the first DocumentsLocation. Fix by falling back on the home directory if documentPaths.front() does not exist. Change-Id: I483f62f3b4b43d055c74774a7058a4aa420849b1 Reviewed-by: Friedemann Kleint --- .../widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/auto/widgets/dialogs/qfilesystemmodel') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 61a2abc084..9cb391d5f4 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -212,7 +212,14 @@ void tst_QFileSystemModel::rootPath() QString oldRootPath = model->rootPath(); const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); QVERIFY(!documentPaths.isEmpty()); - const QString documentPath = documentPaths.front(); + QString documentPath = documentPaths.front(); + // In particular on Linux, ~/Documents (the first + // DocumentsLocation) may not exist, so choose ~ in that case: + if (!QFile::exists(documentPath)) { + documentPath = QDir::homePath(); + qWarning("%s: first documentPath \"%s\" does not exist. Using ~ (\"%s\") instead.", + Q_FUNC_INFO, qPrintable(documentPaths.front()), qPrintable(documentPath)); + } root = model->setRootPath(documentPath); QTRY_VERIFY(model->rowCount(root) >= 0); -- cgit v1.2.3