Commit a736ef46 authored by Joerg Bornemann's avatar Joerg Bornemann
Browse files

Stabilize tst_download.qml


Connect to WebEngineViewDownloadItem.stateChanged to collect state
changes. This makes sure that state changes from tests that ran before
do not interfere with the current test.

Change-Id: I360ac325711bf041f82375b3714a9cfe7a42398c
Reviewed-by: default avatarAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Showing with 8 additions and 4 deletions
...@@ -66,23 +66,26 @@ TestWebEngineView { ...@@ -66,23 +66,26 @@ TestWebEngineView {
signalName: "downloadFinished" signalName: "downloadFinished"
} }
Connections {
id: downloadItemConnections
onStateChanged: downloadState.push(target.state)
}
WebEngineProfile { WebEngineProfile {
id: testDownloadProfile id: testDownloadProfile
onDownloadRequested: { onDownloadRequested: {
downloadState.push(download.state) downloadState.push(download.state)
downloadItemConnections.target = download
if (cancelDownload) { if (cancelDownload) {
download.cancel() download.cancel()
downloadState.push(download.state)
} else { } else {
totalBytes = download.totalBytes totalBytes = download.totalBytes
download.path = "testfile.zip" download.path = "testfile.zip"
download.accept() download.accept()
downloadState.push(download.state)
} }
} }
onDownloadFinished: { onDownloadFinished: {
downloadState.push(download.state)
receivedBytes = download.receivedBytes; receivedBytes = download.receivedBytes;
} }
} }
...@@ -96,6 +99,7 @@ TestWebEngineView { ...@@ -96,6 +99,7 @@ TestWebEngineView {
totalBytes = 0 totalBytes = 0
receivedBytes = 0 receivedBytes = 0
cancelDownload = false cancelDownload = false
downloadItemConnections.target = null
downloadState = [] downloadState = []
} }
...@@ -133,7 +137,7 @@ TestWebEngineView { ...@@ -133,7 +137,7 @@ TestWebEngineView {
downLoadRequestedSpy.wait() downLoadRequestedSpy.wait()
compare(downLoadRequestedSpy.count, 1) compare(downLoadRequestedSpy.count, 1)
compare(downloadFinishedSpy.count, 1) compare(downloadFinishedSpy.count, 1)
compare(downloadState[2], WebEngineDownloadItem.DownloadCancelled) compare(downloadState[1], WebEngineDownloadItem.DownloadCancelled)
} }
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment