From 7ab606e2e4ed3655e9362276f14ede4846308097 Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Thu, 12 Sep 2019 09:41:21 +0200 Subject: Fix Q(Quick)WebEngineDownloadItem::setPath() path conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also extend auto test with path checking Task-number: QTBUG-78213 Change-Id: Icb5d4ec831d8a665894d5890f983752c3af60ce8 Reviewed-by: Florian Bruhin Reviewed-by: Michael BrĂ¼ning --- tests/auto/quick/qmltests/data/tst_download.qml | 35 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'tests/auto/quick/qmltests') 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); + } } } -- cgit v1.2.3