From 9da1f08d224bc94f81ae72c4353bf234af6f8592 Mon Sep 17 00:00:00 2001 From: Valentin Fokin Date: Thu, 20 Apr 2017 13:17:45 +0200 Subject: Stabilize tst_download.qml and add check for downloadInterruptReason Change some compares to tryCompares to wait for downloadStateChanged signal before comparing downloadState. Change-Id: If8f7f15a776e60c937f0e006d2ac337f6c1f9ad9 Reviewed-by: Peter Varga Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/qmltests/data/tst_download.qml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml index e4e93b993..019ebd9dc 100644 --- a/tests/auto/quick/qmltests/data/tst_download.qml +++ b/tests/auto/quick/qmltests/data/tst_download.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -28,7 +28,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtWebEngine 1.1 +import QtWebEngine 1.5 TestWebEngineView { id: webEngineView @@ -40,6 +40,7 @@ TestWebEngineView { property int receivedBytes: 0 property bool cancelDownload: false property var downloadState: [] + property var downloadInterruptReason: null SignalSpy { id: downLoadRequestedSpy @@ -55,7 +56,9 @@ TestWebEngineView { Connections { id: downloadItemConnections + ignoreUnknownSignals: true onStateChanged: downloadState.push(target.state) + onInterruptReasonChanged: downloadInterruptReason = target.interruptReason } WebEngineProfile { @@ -88,6 +91,7 @@ TestWebEngineView { cancelDownload = false downloadItemConnections.target = null downloadState = [] + downloadInterruptReason = null } function test_downloadRequest() { @@ -96,6 +100,7 @@ TestWebEngineView { downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) compare(downloadState[0], WebEngineDownloadItem.DownloadRequested) + verify(!downloadInterruptReason) } function test_totalFileLength() { @@ -104,6 +109,7 @@ TestWebEngineView { downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) compare(totalBytes, 325) + verify(!downloadInterruptReason) } function test_downloadSucceeded() { @@ -111,10 +117,12 @@ TestWebEngineView { webEngineView.url = Qt.resolvedUrl("download.zip") downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) - compare(downloadState[1], WebEngineDownloadItem.DownloadInProgress) + compare(downloadState[0], WebEngineDownloadItem.DownloadRequested) + tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress) downloadFinishedSpy.wait() compare(totalBytes, receivedBytes) tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted) + verify(!downloadInterruptReason) } function test_downloadCancelled() { @@ -124,7 +132,8 @@ TestWebEngineView { downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) compare(downloadFinishedSpy.count, 1) - compare(downloadState[1], WebEngineDownloadItem.DownloadCancelled) + tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadCancelled) + tryCompare(webEngineView, "downloadInterruptReason", WebEngineDownloadItem.UserCanceled) } } } -- cgit v1.2.3