summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp2
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp2
-rw-r--r--tests/auto/quick/qmltests/data/tst_download.qml35
3 files changed, 34 insertions, 5 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
index f9b305e88..3ccd27094 100644
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -463,7 +463,7 @@ void QQuickWebEngineDownloadItem::setPath(QString path)
newDirectory = QStringLiteral("");
newFileName = path;
} else {
- newDirectory = QFileInfo(path).filePath();
+ newDirectory = QFileInfo(path).path();
newFileName = QFileInfo(path).fileName();
}
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index 7b0cfe074..e1bfc506f 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
@@ -560,7 +560,7 @@ void QWebEngineDownloadItem::setPath(QString path)
d->downloadDirectory = QStringLiteral("");
d->downloadFileName = path;
} else {
- d->downloadDirectory = QFileInfo(path).filePath();
+ d->downloadDirectory = QFileInfo(path).path();
d->downloadFileName = QFileInfo(path).fileName();
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml
index c38018ffd..e049f3621 100644
--- a/tests/auto/quick/qmltests/data/tst_download.qml
+++ b/tests/auto/quick/qmltests/data/tst_download.qml
@@ -47,6 +47,7 @@ TestWebEngineView {
property string downloadDirectory: ""
property string downloadFileName: ""
property string downloadedPath: ""
+ property string downloadedSetPath: ""
property int downloadDirectoryChanged: 0
property int downloadFileNameChanged: 0
property int downloadPathChanged: 0
@@ -94,14 +95,19 @@ TestWebEngineView {
} else {
totalBytes = download.totalBytes
- download.downloadDirectory = downloadDirectory.length != 0 ? testDownloadProfile.downloadPath + downloadDirectory : testDownloadProfile.downloadPath
- download.downloadFileName = downloadFileName.length != 0 ? downloadFileName : "testfile.zip"
+ if (downloadedSetPath.length != 0) {
+ download.path = testDownloadProfile.downloadPath + downloadedSetPath
+ downloadedPath = download.path
+ } else {
+ download.downloadDirectory = downloadDirectory.length != 0 ? testDownloadProfile.downloadPath + downloadDirectory : testDownloadProfile.downloadPath
+ download.downloadFileName = downloadFileName.length != 0 ? downloadFileName : "testfile.zip"
+ downloadedPath = download.downloadDirectory + download.downloadFileName
+ }
download.accept()
}
downloadUrl = download.url
suggestedFileName = download.suggestedFileName
- downloadedPath = download.downloadDirectory + download.downloadFileName
}
onDownloadFinished: {
receivedBytes = download.receivedBytes;
@@ -126,6 +132,7 @@ TestWebEngineView {
downloadDirectory = ""
downloadFileName = ""
downloadedPath = ""
+ downloadedSetPath = ""
}
function test_downloadRequest() {
@@ -211,5 +218,27 @@ TestWebEngineView {
tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
verify(!downloadInterruptReason);
}
+
+ function test_downloadWithSetPath() {
+ compare(downLoadRequestedSpy.count, 0);
+ compare(downloadDirectoryChanged, 0);
+ compare(downloadFileNameChanged, 0);
+ downloadedSetPath = "/test/test.zip";
+ webEngineView.url = Qt.resolvedUrl("download.zip");
+ downLoadRequestedSpy.wait();
+ compare(downLoadRequestedSpy.count, 1);
+ compare(downloadUrl, webEngineView.url);
+ compare(suggestedFileName, "download.zip");
+ compare(downloadState[0], WebEngineDownloadItem.DownloadRequested);
+ tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress);
+ compare(downloadedPath, testDownloadProfile.downloadPath + downloadedSetPath);
+ compare(downloadDirectoryChanged, 1);
+ compare(downloadFileNameChanged, 1);
+ compare(downloadPathChanged, 2);
+ downloadFinishedSpy.wait();
+ compare(totalBytes, receivedBytes);
+ tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
+ verify(!downloadInterruptReason);
+ }
}
}