summaryrefslogtreecommitdiffstats
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-21 14:52:14 +0000
commit856eec783274b51f4d7c9c30805c6ddb41ee7cee (patch)
treef8ab00df7fa5e1315264ac700fccf41311c7a906
parent74e7557409441e8f961f176dfe430d59c51819e1 (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). 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> (cherry picked from commit 9e8964001dcdc4c0dba4501ddcb599b86b5939e9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 7dcdca265f4bf2a979d0ba10c29f5674375d10b7)
-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 f82c58264..bf68fb048 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -3,6 +3,7 @@
#include "testwindow.h"
#include "quickutil.h"
+#include "util.h"
#include <QScopedPointer>
#include <QtCore/qelapsedtimer.h>
@@ -1295,7 +1296,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);
@@ -1320,8 +1324,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");
@@ -1333,7 +1338,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());