summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/webengine/api/qquickwebengineview.cpp2
-rw-r--r--src/webengine/api/qquickwebengineview_p.h6
-rw-r--r--tests/auto/quick/qmltests/data/tst_linkHovered.qml56
3 files changed, 31 insertions, 33 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 3830a3ea2..547be2246 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -1066,8 +1066,8 @@ void QQuickWebEngineView::setTestSupport(QQuickWebEngineTestSupport *testSupport
{
Q_D(QQuickWebEngineView);
d->m_testSupport = testSupport;
+ Q_EMIT testSupportChanged();
}
-
#endif
bool QQuickWebEngineView::activeFocusOnPress() const
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 16c4799b5..4f9e483bc 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -125,7 +125,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(uint webChannelWorld READ webChannelWorld WRITE setWebChannelWorld NOTIFY webChannelWorldChanged REVISION 3)
#ifdef ENABLE_QML_TESTSUPPORT_API
- Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL)
+ Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL)
#endif
Q_FLAGS(FindFlags);
@@ -513,6 +513,10 @@ Q_SIGNALS:
Q_REVISION(4) void fileDialogRequested(QQuickWebEngineFileDialogRequest *request);
Q_REVISION(4) void formValidationMessageRequested(QQuickWebEngineFormValidationMessageRequest *request);
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ void testSupportChanged();
+#endif
+
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void itemChange(ItemChange, const ItemChangeData &) Q_DECL_OVERRIDE;
diff --git a/tests/auto/quick/qmltests/data/tst_linkHovered.qml b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
index 0b99ffa7f..362130bab 100644
--- a/tests/auto/quick/qmltests/data/tst_linkHovered.qml
+++ b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
@@ -39,22 +39,16 @@ TestWebEngineView {
property string lastUrl
- testSupport: WebEngineTestSupport {
- property bool loadVisuallyCommittedSignalEmitted: false
+ testSupport: WebEngineTestSupport { }
- function waitForLoadVisuallyCommitted() {
- return _waitFor(function() {
- return testSupport.loadVisuallyCommittedSignalEmitted;
- });
- }
-
- onLoadVisuallyCommitted: {
- loadVisuallyCommittedSignalEmitted = true;
- }
+ SignalSpy {
+ id: loadVisuallyCommittedSpy
+ target: webEngineView.testSupport
+ signalName: "loadVisuallyCommitted"
}
SignalSpy {
- id: spy
+ id: linkHoveredSpy
target: webEngineView
signalName: "linkHovered"
}
@@ -76,60 +70,60 @@ TestWebEngineView {
}
function init() {
- webEngineView.testSupport.loadVisuallyCommittedSignalEmitted = false;
- webEngineView.lastUrl = ""
- spy.clear()
+ webEngineView.lastUrl = "";
+ loadVisuallyCommittedSpy.clear();
+ linkHoveredSpy.clear();
}
function test_linkHovered() {
- compare(spy.count, 0)
+ compare(linkHoveredSpy.count, 0);
mouseMove(webEngineView, 100, 300)
webEngineView.url = Qt.resolvedUrl("test2.html")
verify(webEngineView.waitForLoadSucceeded())
// We get a linkHovered signal with empty hoveredUrl after page load
- spy.wait()
- compare(spy.count, 1)
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 1);
compare(webEngineView.lastUrl, "")
// Wait for the page to be rendered before trying to test based on input events
- verify(webEngineView.testSupport.waitForLoadVisuallyCommitted());
+ loadVisuallyCommittedSpy.wait();
mouseMove(webEngineView, 100, 100)
- spy.wait()
- compare(spy.count, 2)
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 2);
compare(webEngineView.lastUrl, Qt.resolvedUrl("test1.html"))
mouseMove(webEngineView, 100, 300)
- spy.wait()
- compare(spy.count, 3)
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 3);
compare(webEngineView.lastUrl, "")
}
function test_linkHoveredDoesntEmitRepeated() {
- compare(spy.count, 0)
+ compare(linkHoveredSpy.count, 0);
webEngineView.url = Qt.resolvedUrl("test2.html")
verify(webEngineView.waitForLoadSucceeded())
// We get a linkHovered signal with empty hoveredUrl after page load
- spy.wait()
- compare(spy.count, 1)
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 1);
compare(webEngineView.lastUrl, "")
// Wait for the page to be rendered before trying to test based on input events
- verify(webEngineView.testSupport.waitForLoadVisuallyCommitted());
+ loadVisuallyCommittedSpy.wait();
for (var i = 0; i < 100; i += 10)
mouseMove(webEngineView, 100, 100 + i)
- spy.wait()
- compare(spy.count, 2)
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 2);
compare(webEngineView.lastUrl, Qt.resolvedUrl("test1.html"))
for (var i = 0; i < 100; i += 10)
mouseMove(webEngineView, 100, 300 + i)
- spy.wait()
- compare(spy.count, 3)
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 3);
compare(webEngineView.lastUrl, "")
}
}