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 <Friedemann.Kleint@digia.com>bb10
parent
6533a736a7
commit
885bd1d0e5
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue