summaryrefslogtreecommitdiffstats
path: root/tests
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
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')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp17
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp19
2 files changed, 17 insertions, 19 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"
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index b09e45646..773550922 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -61,7 +61,6 @@ private Q_SLOTS:
void setPalette_data();
void setPalette();
#endif
- void printToPDF();
};
// This will be called before the first test function is executed.
@@ -531,24 +530,6 @@ void tst_QWebEngineView::setPalette()
}
#endif
-void tst_QWebEngineView::printToPDF()
-{
- QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX");
- QVERIFY(tempDir.isValid());
- QWebEngineView view;
- QUrl url("qrc:///resources/basic_printing_page.html");
- view.page()->load(url);
- QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool))));
- view.show();
-
- QTest::qWaitForWindowExposed(&view);
- QPageLayout layout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0.0, 0.0, 0.0, 0.0));
- QString path = tempDir.path() + "/print_success.pdf";
- view.printToPDF(path, layout);
- QTest::qWait(500);
- QVERIFY(QFile::exists(path));
-}
-
void tst_QWebEngineView::renderingAfterMaxAndBack()
{
#if !defined(QWEBENGINEPAGE_RENDER)