diff options
author | Jaeyoon Jung <jaeyoon.jung@lge.com> | 2018-02-23 08:56:31 +0900 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-07-02 14:38:50 +0000 |
commit | 73c239c1a402bbfa09f463c28bfbeaf06c7fdaf9 (patch) | |
tree | 6c822c4a13d5133e741286436c47d95e5d5880b6 /tests | |
parent | eb2e53ae81239b561022940db27e65c23506450c (diff) |
Fix baseUrl returning an empty url
Do not append the directory separator if the current path is the root
directory. Otherwise it is treated as a remote path incorrectly and an
empty url is returned as a result.
Change-Id: Icc62114702265e9e1b247624370a78999e564d5f
Task-number: QTBUG-83121
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit bba1b19a18a04060942e5580e36daccf9c830b61)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index cfbbd2a94c..7a93dcbcd0 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -214,6 +214,19 @@ void tst_qqmlengine::baseUrl() engine.setBaseUrl(cwd); QCOMPARE(engine.baseUrl(), cwd); QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml"))); + + + const QString testPath = QDir::currentPath() + QLatin1String("/"); + const QString rootPath = QDir::rootPath(); + engine.setBaseUrl(QUrl()); + + // Check that baseUrl returns a url to a localFile + QCOMPARE(engine.baseUrl().toLocalFile(), testPath); + + QDir::setCurrent(QDir::rootPath()); + + // Make sure this also works when in the rootPath + QCOMPARE(engine.baseUrl().toLocalFile(), rootPath); } void tst_qqmlengine::contextForObject() |