From a736ef46564ca88a96370f1ac41b7f4b82cb2462 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 8 Dec 2015 18:49:34 +0100 Subject: 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: Allan Sandfeld Jensen --- tests/auto/quick/qmltests/data/tst_download.qml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml index ffd7041e3..415318ed7 100644 --- a/tests/auto/quick/qmltests/data/tst_download.qml +++ b/tests/auto/quick/qmltests/data/tst_download.qml @@ -66,23 +66,26 @@ TestWebEngineView { signalName: "downloadFinished" } + Connections { + id: downloadItemConnections + onStateChanged: downloadState.push(target.state) + } + WebEngineProfile { id: testDownloadProfile onDownloadRequested: { downloadState.push(download.state) + downloadItemConnections.target = download if (cancelDownload) { download.cancel() - downloadState.push(download.state) } else { totalBytes = download.totalBytes download.path = "testfile.zip" download.accept() - downloadState.push(download.state) } } onDownloadFinished: { - downloadState.push(download.state) receivedBytes = download.receivedBytes; } } @@ -96,6 +99,7 @@ TestWebEngineView { totalBytes = 0 receivedBytes = 0 cancelDownload = false + downloadItemConnections.target = null downloadState = [] } @@ -133,7 +137,7 @@ TestWebEngineView { downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) compare(downloadFinishedSpy.count, 1) - compare(downloadState[2], WebEngineDownloadItem.DownloadCancelled) + compare(downloadState[1], WebEngineDownloadItem.DownloadCancelled) } } } -- cgit v1.2.3