diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2021-03-22 13:27:33 +0100 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2021-03-22 14:35:50 +0100 |
commit | c1ba8bdae978ffbdf55d95ce3b342b09bf6fb738 (patch) | |
tree | 5ca5d0e225ba32dfea9513cb8cd3ffe0c4ea062c /tests | |
parent | 93a6cc9df0f012bc1e0ed96b6016e1ad1ad07f9d (diff) |
Notify canGoBack/canGoForward changes based on web actions
Before, QQuickWebEngineView's canGoBack/canGoForward change signals
are based on urlChanged. But the urlChanged signal may be emitted
slightly before the value of canGoBack/canGoForwad actually changes,
resulting in a missed change notification.
After, they get their own signals, which are forwarded from the
QQuickWebEngineAction::enabledChanged signal of the respective web
actions.
Fixes: QTBUG-91565
Change-Id: Id411eb146c776e2824fd2447660e8857974da32e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/publicapi/tst_publicapi.cpp | 2 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_navigationHistory.qml | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index dad962576..950c7375a 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -687,7 +687,9 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.backgroundColor --> QColor" << "QQuickWebEngineView.backgroundColorChanged() --> void" << "QQuickWebEngineView.canGoBack --> bool" + << "QQuickWebEngineView.canGoBackChanged() --> void" << "QQuickWebEngineView.canGoForward --> bool" + << "QQuickWebEngineView.canGoForwardChanged() --> void" << "QQuickWebEngineView.certificateError(QQuickWebEngineCertificateError*) --> void" << "QQuickWebEngineView.colorDialogRequested(QQuickWebEngineColorDialogRequest*) --> void" << "QQuickWebEngineView.contentsSize --> QSizeF" diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml index 6ed232589..f32af2106 100644 --- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml +++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml @@ -26,7 +26,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.15 +import QtQuick.Controls 2.15 import QtTest 1.0 import QtWebEngine 1.2 @@ -59,6 +60,20 @@ TestWebEngineView { } } + Button { + id: backButton + text: "Back" + enabled: webEngineView.canGoBack + onClicked: webEngineView.goBack() + } + + Button { + id: forwardButton + text: "Forward" + enabled: webEngineView.canGoForward + onClicked: webEngineView.goForward() + } + TestCase { name: "WebEngineViewNavigationHistory" @@ -142,5 +157,34 @@ TestWebEngineView { compare(backItemsList.count, 0) compare(forwardItemsList.count, 0) } + + function test_navigationButtons() { + compare(webEngineView.loadProgress, 0) + + webEngineView.url = Qt.resolvedUrl("test1.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, false) + compare(forwardButton.enabled, false) + + webEngineView.url = Qt.resolvedUrl("test2.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, false) + + webEngineView.url = Qt.resolvedUrl("test3.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, false) + + backButton.clicked() + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, true) + + webEngineView.url = Qt.resolvedUrl("test1.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, false) + } } } |