summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2023-09-13 10:46:06 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2023-09-14 12:41:35 +0200
commit9e8964001dcdc4c0dba4501ddcb599b86b5939e9 (patch)
tree748df5e7aff1cc1ea3887b40fa22b0eb5df1e578 /tests
parent56fa2aa75ad4d7a1e3386405794c43d23666cfbc (diff)
Improve tst_QQuickWebEngineView::savePage auto test
Use ScopedConnection to avoid "stack-use-after-return" address sanitizer error. Also reduce potential wait time in case of failure by waiting for accepted and finished states individually (same as tst_QWebEngineDownloadRequest tests). Pick-to: 6.6 Fixes: QTBUG-116738 Task-number: QTBUG-56093 Change-Id: I49a60c95a816ae1b4cb6b227501ff81ca9c6f82b Reviewed-by: Anu Aliyas <anu.aliyas@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 17309095a..2eae5bd00 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -5,6 +5,7 @@
#include "testwindow.h"
#include "quickutil.h"
+#include "util.h"
#include <QScopedPointer>
#include <QtCore/qelapsedtimer.h>
@@ -1297,7 +1298,10 @@ void tst_QQuickWebEngineView::savePage()
const QString filePath = tempDir.path() + "/saved_page.html";
QQuickWebEngineView *view = webEngineView();
- connect(view->profile(), &QQuickWebEngineProfile::downloadRequested,
+ int acceptedCount = 0;
+ int finishedCount = 0;
+ ScopedConnection sc1 = connect(
+ view->profile(), &QQuickWebEngineProfile::downloadRequested,
[&](QQuickWebEngineDownloadRequest *downloadRequest) {
QCOMPARE(downloadRequest->state(),
QQuickWebEngineDownloadRequest::DownloadInProgress);
@@ -1322,8 +1326,9 @@ void tst_QQuickWebEngineView::savePage()
.filePath(downloadRequest->downloadFileName()),
filePath);
QCOMPARE(downloadRequest->url(), view->url());
- QTestEventLoop::instance().exitLoop();
+ finishedCount++;
});
+ acceptedCount++;
});
const QString originalData = QStringLiteral("Basic page");
@@ -1335,7 +1340,8 @@ void tst_QQuickWebEngineView::savePage()
// Save the loaded page as HTML.
view->save(filePath, savePageFormat);
- QTestEventLoop::instance().enterLoop(10);
+ QTRY_COMPARE(acceptedCount, 1);
+ QTRY_COMPARE(finishedCount, 1);
QFile file(filePath);
QVERIFY(file.exists());