summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-03-25 13:58:51 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-03-25 13:58:57 +0100
commit8947dc6902bfd2a8acd31b8c894407bf6a12695b (patch)
treeb3d3630d54a27c6c376c39c64aadb5b4589df4bc /tests/auto
parent9522dc8f71e189cf75eabdca4b3fab2d254d1542 (diff)
parent35aa6c30f0e766b8825519e04242b7a4c93b6e0e (diff)
Merge remote-tracking branch 'origin/5.14.2' into 5.14
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index d0453e1e6..94ce92e40 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -226,6 +226,7 @@ private Q_SLOTS:
void customUserAgentInNewTab();
void renderProcessCrashed();
+ void backgroundColor();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -4370,6 +4371,43 @@ void tst_QWebEnginePage::renderProcessCrashed()
status == QWebEnginePage::AbnormalTerminationStatus);
}
+void tst_QWebEnginePage::backgroundColor()
+{
+ QWebEngineProfile profile;
+ QWebEngineView view;
+ QWebEnginePage *page = new QWebEnginePage(&profile, &view);
+
+ view.resize(640, 480);
+ view.show();
+ QPoint center(view.size().width() / 2, view.size().height() / 2);
+
+ QCOMPARE(page->backgroundColor(), Qt::white);
+ QTRY_COMPARE(view.grab().toImage().pixelColor(center), Qt::white);
+
+ page->setBackgroundColor(Qt::red);
+ view.setPage(page);
+
+ QCOMPARE(page->backgroundColor(), Qt::red);
+ QTRY_COMPARE(view.grab().toImage().pixelColor(center), Qt::red);
+
+ page->setHtml(QString("<html>"
+ "<head><style>html, body { margin:0; padding:0; }</style></head>"
+ "<body><div style=\"width:100%; height:10px; background-color:black\"/></body>"
+ "</html>"));
+ QSignalSpy spyFinished(page, &QWebEnginePage::loadFinished);
+ QVERIFY(spyFinished.wait());
+ // Make sure the page is rendered and the test is not grabbing the color of the RenderWidgetHostViewQtDelegateWidget.
+ QTRY_COMPARE(view.grab().toImage().pixelColor(QPoint(5, 5)), Qt::black);
+
+ QCOMPARE(page->backgroundColor(), Qt::red);
+ QCOMPARE(view.grab().toImage().pixelColor(center), Qt::red);
+
+ page->setBackgroundColor(Qt::green);
+
+ QCOMPARE(page->backgroundColor(), Qt::green);
+ QTRY_COMPARE(view.grab().toImage().pixelColor(center), Qt::green);
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)