summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2019-04-11 18:47:54 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-04-13 10:00:13 +0000
commit75ae3f8d80955f30f9fee987511149531db2779b (patch)
tree556f0f3b8e70c8acd021422a0e68b19390d97bda
parentbcf38ab56ac6637ea557ea73e39f5cac319e8fbf (diff)
Add unit test for verifying QWebEnginePage::contentsSize correctness
An adaptation to Chromium 70 caused a regression in this. Change-Id: I8928694b9f99cd420afd858d3a1023228276bae0 Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 9ba242e6..19f9b6df 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -200,6 +200,7 @@ private Q_SLOTS:
void notificationRequest_data();
void notificationRequest();
void sendNotification();
+ void contentsSize();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -3357,6 +3358,34 @@ void tst_QWebEnginePage::sendNotification()
QTRY_VERIFY2(page.messages.contains("onclose"), page.messages.join("\n").toLatin1().constData());
}
+void tst_QWebEnginePage::contentsSize()
+{
+ m_view->resize(800, 600);
+ m_view->show();
+
+ QSignalSpy loadSpy(m_page, &QWebEnginePage::loadFinished);
+ QSignalSpy contentsSizeChangedSpy(m_page, &QWebEnginePage::contentsSizeChanged);
+
+ m_view->setHtml(QString("<html><body style=\"width: 1600px; height: 1200px;\"><p>hi</p></body></html>"));
+
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QTRY_COMPARE(contentsSizeChangedSpy.count(), 1);
+
+ // Verify the page's contents size is not limited by the view's size.
+ QCOMPARE(m_page->contentsSize().width(), 1608);
+ QCOMPARE(m_page->contentsSize().height(), 1216);
+
+ // Verify resizing the view does not affect the contents size.
+ m_view->resize(2400, 1800);
+ QCOMPARE(m_page->contentsSize().width(), 1608);
+ QCOMPARE(m_page->contentsSize().height(), 1216);
+
+ // Verify resizing the view does not affect the contents size.
+ m_view->resize(1600, 1200);
+ QCOMPARE(m_page->contentsSize().width(), 1608);
+ QCOMPARE(m_page->contentsSize().height(), 1216);
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)