From 19444168395424fef4daff76ce64b9813aef0610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 26 Feb 2020 14:27:57 +0100 Subject: Stabilize tst_QQuickWebEngineView::transparentWebEngineViews Change-Id: I847a1750ce5c9533db43fb60f91b9739c544791a Reviewed-by: Allan Sandfeld Jensen --- .../tst_qquickwebengineview.cpp | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp') diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp index 6f9cb9c69..04be25abe 100644 --- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp +++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp @@ -421,32 +421,29 @@ void tst_QQuickWebEngineView::transparentWebEngineViews() webEngineView1->setSize(QSizeF(300, 400)); webEngineView1->loadHtml(""); - QVERIFY(waitForLoadSucceeded(webEngineView1.data())); - webEngineView1->setVisible(true); + QVERIFY(waitForLoadSucceeded(webEngineView1.data(), 30000)); webEngineView2->setSize(QSizeF(300, 400)); webEngineView2->setUrl(urlFromTestPath("/html/basic_page.html")); QVERIFY(waitForLoadSucceeded(webEngineView2.data())); // Result image: black text on red background. - const QImage grabbedWindow = tryToGrabWindowUntil(m_window.data(), [] (const QImage &image) { - return image.pixelColor(0, 0) == QColor(Qt::red); + QSet colors; + tryToGrabWindowUntil(m_window.data(), [&colors] (const QImage &image) { + colors.clear(); + for (int i = 0; i < image.width(); i++) + for (int j = 0; j < image.height(); j++) + colors.insert(image.pixel(i, j)); + return colors.count() > 1; }); - QSet redComponents; - for (int i = 0, width = grabbedWindow.width(); i < width; i++) { - for (int j = 0, height = grabbedWindow.height(); j < height; j++) { - QColor color(grabbedWindow.pixel(i, j)); - redComponents.insert(color.red()); - // There are no green or blue components between red and black. - QVERIFY(color.green() == 0); - QVERIFY(color.blue() == 0); - } + QVERIFY(colors.count() > 1); + QVERIFY(colors.contains(qRgb(0, 0, 0))); // black + QVERIFY(colors.contains(qRgb(255, 0, 0))); // red + for (auto color : colors) { + QCOMPARE(qGreen(color), 0); + QCOMPARE(qBlue(color), 0); } - - QVERIFY(redComponents.count() > 1); - QVERIFY(redComponents.contains(0)); // black - QVERIFY(redComponents.contains(255)); // red } void tst_QQuickWebEngineView::inputMethod() -- cgit v1.2.3