summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
diff options
context:
space:
mode:
authorMichael Bruning <michael.bruning@theqtcompany.com>2016-02-25 13:40:01 +0100
committerMichael BrĂ¼ning <michael.bruning@theqtcompany.com>2016-03-16 21:21:41 +0000
commitdf222f8ccb2151e519b92d3d2046ee74f221902e (patch)
treede0e9af4a11878399698e383f0162feee48d0aa6 /tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
parentec9a8753a7b17bbbf886c155ed884c581c547913 (diff)
Add callback to printing API
Also corrects and updates the printToPDF docs to reflect recent changes. Change-Id: Iffe276a1046d6d55923939f9d72b97cd533017ff Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 270fd4458..4cfe4e580 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -20,6 +20,7 @@
*/
#include "../util.h"
+#include <QByteArray>
#include <QClipboard>
#include <QDir>
#include <QGraphicsWidget>
@@ -240,7 +241,7 @@ private Q_SLOTS:
void toPlainTextLoadFinishedRace_data();
void toPlainTextLoadFinishedRace();
- void printToPDF();
+ void printToPdf();
private:
QWebEngineView* m_view;
@@ -5045,7 +5046,7 @@ void tst_QWebEnginePage::toPlainTextLoadFinishedRace()
QVERIFY(spy.count() == 3);
}
-void tst_QWebEnginePage::printToPDF()
+void tst_QWebEnginePage::printToPdf()
{
QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX");
QVERIFY(tempDir.isValid());
@@ -5055,9 +5056,25 @@ void tst_QWebEnginePage::printToPDF()
QTRY_VERIFY(spy.count() == 1);
QPageLayout layout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0.0, 0.0, 0.0, 0.0));
- QString path = tempDir.path() + "/print_success.pdf";
- page.printToPDF(path, layout);
+ QString path = tempDir.path() + "/print_1_success.pdf";
+ page.printToPdf(path, layout);
QTRY_VERIFY(QFile::exists(path));
+
+#if !defined(Q_OS_WIN)
+ path = tempDir.path() + "/print_//2_failed.pdf";
+#else
+ path = tempDir.path() + "/print_|2_failed.pdf";
+#endif
+ page.printToPdf(path, QPageLayout());
+ QTRY_VERIFY(!QFile::exists(path));
+
+ CallbackSpy<QByteArray> successfulSpy;
+ page.printToPdf(layout, successfulSpy.ref());
+ QTRY_VERIFY(successfulSpy.waitForResult().length() > 0);
+
+ CallbackSpy<QByteArray> failedInvalidLayoutSpy;
+ page.printToPdf(QPageLayout(), failedInvalidLayoutSpy.ref());
+ QTRY_VERIFY(!failedInvalidLayoutSpy.waitForResult().length() > 0);
}
QTEST_MAIN(tst_QWebEnginePage)