summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2014-07-25 08:40:54 -0700
committerSzabolcs David <davidsz@inf.u-szeged.hu>2014-08-01 09:59:37 +0200
commit2781345715338669e2573fb0c05efe5656ca37d8 (patch)
treeb55dd9e07f5d868500a3ec3ab1ddb0b69174f784 /tests
parenta2a8ded66e33db0313194bd23c7337f106c2140e (diff)
Add loadVisuallyCommitted signal to the experimental Quick API
This fixes the flaky QQuickWebEngineViewGraphics test and extends it with a new test case. Change-Id: I2d8a0762716cb9232fdea6473760e67ac2e7146d Reviewed-by: Andras Becsi <andras.becsi@digia.com> Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro1
-rw-r--r--tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp29
2 files changed, 28 insertions, 2 deletions
diff --git a/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro b/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
index ff6c4962..cbd11cdc 100644
--- a/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
+++ b/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
@@ -1,2 +1,3 @@
include(../tests.pri)
exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
+QT_PRIVATE += webengine-private
diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
index ad72ea0c..d64ab5d1 100644
--- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
+++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
@@ -45,6 +45,7 @@
#include <QQuickItem>
#include <QPainter>
#include <qtwebengineglobal.h>
+#include <private/qquickwebengineview_p.h>
class TestView : public QQuickView {
Q_OBJECT
@@ -72,6 +73,7 @@ public Q_SLOTS:
private Q_SLOTS:
void simpleGraphics();
+ void renderMultipleTimes();
void renderAfterNodeCleanup();
void showHideShow();
void simpleAcceleratedLayer();
@@ -97,6 +99,21 @@ static QImage get150x150GreenReferenceImage()
return reference;
}
+static inline bool waitForSignal(QObject *obj, const char *signal, int timeout = 10000)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
+
tst_QQuickWebEngineViewGraphics::tst_QQuickWebEngineViewGraphics()
{
}
@@ -127,6 +144,14 @@ void tst_QQuickWebEngineViewGraphics::simpleGraphics()
QCOMPARE(m_view->grabWindow(), get150x150GreenReferenceImage());
}
+void tst_QQuickWebEngineViewGraphics::renderMultipleTimes()
+{
+ // This test is for loadVisuallyCommitted signal.
+ // The setHtml() should not fail after multiple page load.
+ setHtml(greenSquare);
+ setHtml(greenSquare);
+}
+
void tst_QQuickWebEngineViewGraphics::renderAfterNodeCleanup()
{
setHtml(greenSquare);
@@ -177,8 +202,8 @@ void tst_QQuickWebEngineViewGraphics::setHtml(const QString &html)
m_view->setSource(QUrl(QStringLiteral("data:text/plain,%1").arg(qmlData)));
m_view->create();
- // FIXME: Replace with a proper initialLayout signal.
- QTest::qWait(200);
+ QQuickWebEngineView *webEngineView = static_cast<QQuickWebEngineView *>(m_view->rootObject());
+ QVERIFY(waitForSignal(reinterpret_cast<QObject *>(webEngineView->experimental()), SIGNAL(loadVisuallyCommitted())));
QCOMPARE(m_view->rootObject()->property("loading"), QVariant(false));
}