summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-02-24 13:18:52 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-02-25 08:31:57 +0000
commit66e01f2866479fe9f27f663ddcdc32fefb52e193 (patch)
treee65fa99c568dbb82056fb1bc2f0f57eb4c04f7ff /tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
parent26db8c70baa518843ec5ceba04196608f4b82bf0 (diff)
Move printToPDF to page
The API needs nothing from view and view just forwards it to the page anyway. This is an page level API, this also makes it work without being shown. Change-Id: I3b8555ab472ec2c7632db3655bcc31925fcfa001 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.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 207eb019a..685cb9ffc 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -244,6 +244,8 @@ private Q_SLOTS:
void toPlainTextLoadFinishedRace_data();
void toPlainTextLoadFinishedRace();
+ void printToPDF();
+
private:
QWebEngineView* m_view;
QWebEnginePage* m_page;
@@ -5148,5 +5150,20 @@ void tst_QWebEnginePage::toPlainTextLoadFinishedRace()
QVERIFY(spy.count() == 3);
}
+void tst_QWebEnginePage::printToPDF()
+{
+ QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX");
+ QVERIFY(tempDir.isValid());
+ QWebEnginePage page;
+ QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
+ page.load(QUrl("qrc:///resources/basic_printing_page.html"));
+ 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);
+ QTRY_VERIFY(QFile::exists(path));
+}
+
QTEST_MAIN(tst_QWebEnginePage)
#include "tst_qwebenginepage.moc"