summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2022-12-12 17:54:09 +0100
committerSzabolcs David <davidsz@inf.u-szeged.hu>2023-04-05 19:08:06 +0200
commitc3ed0e176ccda503c968626010ca36f1f3961fce (patch)
tree846c865d38066a469b43893ced0931b612b5c2bd /tests
parentfe9d72d931f40eafca97c1012c03e24561c973ff (diff)
downloadqtwebengine-c3ed0e176ccda503c968626010ca36f1f3961fce.tar.gz
Better handling of interrupted PDF printing
- Document the fact Stop WebAction can interrupt the in-progress PDF generation. - Update PrintViewManagerQt::PrintPreviewDone(): Normally IsPrintRenderFrameConnected() implies IsRenderFrameLive(), but we have to check both to avoid crash when render process exits. (Like Chrome does.) - Update PrintViewManagerQt::RequestPrintPreview(): Handle that case when print preview params were sent between processes at the beginning, but it was interrupted before RequestPrintPreview() could start PDF generation. - Add a simple auto test to catch crashes Pick-to: 6.5 Task-number: QTBUG-108154 Change-Id: I8a4f9cc97ddcf9a165d66a5981d93a023858fbc1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/printing/tst_printing.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/widgets/printing/tst_printing.cpp b/tests/auto/widgets/printing/tst_printing.cpp
index 1c1e0615e..1f9b5059c 100644
--- a/tests/auto/widgets/printing/tst_printing.cpp
+++ b/tests/auto/widgets/printing/tst_printing.cpp
@@ -23,6 +23,7 @@ private slots:
#if QT_CONFIG(webengine_system_poppler)
void printToPdfPoppler();
#endif
+ void interruptPrinting();
};
void tst_Printing::printToPdfBasic()
@@ -117,6 +118,19 @@ void tst_Printing::printToPdfPoppler()
}
#endif
+void tst_Printing::interruptPrinting()
+{
+ QWebEngineView view;
+ QSignalSpy spy(&view, &QWebEngineView::loadFinished);
+ view.load(QUrl("qrc:///resources/basic_printing_page.html"));
+ QTRY_VERIFY(spy.size() == 1);
+
+ QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX");
+ QVERIFY(tempDir.isValid());
+ view.page()->printToPdf(tempDir.path() + "/file.pdf");
+ // Navigation stop interrupts print job, preferably do this without crash/assert
+ view.page()->triggerAction(QWebEnginePage::Stop);
+}
QTEST_MAIN(tst_Printing)
#include "tst_printing.moc"