From 57140466f277a074b288a515b2bdfd26c8a3cbe3 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 28 May 2021 17:13:27 +0200 Subject: Navigation history test: don't depend on controls 2 needlessly Enables testing without qquickcontrols2 component build Change-Id: I3fc20a75dc836f788a438f15bafeddf81269740b Reviewed-by: Peter Varga --- tests/auto/quick/qmltests/CMakeLists.txt | 7 +--- .../quick/qmltests/data/tst_navigationHistory.qml | 38 +++++++++++++++------- 2 files changed, 27 insertions(+), 18 deletions(-) (limited to 'tests/auto/quick/qmltests') diff --git a/tests/auto/quick/qmltests/CMakeLists.txt b/tests/auto/quick/qmltests/CMakeLists.txt index a67c4d79a..ebcf0434c 100644 --- a/tests/auto/quick/qmltests/CMakeLists.txt +++ b/tests/auto/quick/qmltests/CMakeLists.txt @@ -28,6 +28,7 @@ set(testList tst_loadRecursionCrash.qml tst_loadUrl.qml tst_mouseMove.qml + tst_navigationHistory.qml tst_navigationRequested.qml tst_newViewRequest.qml tst_notification.qml @@ -77,12 +78,6 @@ else() message("\n!!!! QuickControls target is missing, some tests are not executed !!! FIXME \n") endif() -if(TARGET Qt::QuickControls2) - list(APPEND testList tst_navigationHistory.qml) -else() - message("\n!!!! QuickControls2 target is missing, some tests are not executed !!! FIXME \n") -endif() - set(content "") foreach(test ${testList}) set(contents "${contents}${CMAKE_CURRENT_LIST_DIR}/data/${test}\n") diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml index 47be2f47d..26f1fade4 100644 --- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml +++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml @@ -27,7 +27,6 @@ ****************************************************************************/ import QtQuick 2.15 -import QtQuick.Controls 2.15 import QtTest 1.0 import QtWebEngine 1.2 @@ -60,22 +59,20 @@ TestWebEngineView { } } - Button { + Item { // simple button-like interface to not depend on controls id: backButton - text: "Back" enabled: webEngineView.canGoBack - onClicked: webEngineView.goBack() + function clicked() { if (enabled) webEngineView.goBack() } } - Button { + Item { // simple button-like interface to not depend on controls id: forwardButton - text: "Forward" enabled: webEngineView.canGoForward - onClicked: webEngineView.goForward() + function clicked() { if (enabled) webEngineView.goForward() } } TestCase { - name: "WebEngineViewNavigationHistory" + name: "NavigationHistory" function test_navigationHistory() { webEngineView.navigationHistory.clear() @@ -161,17 +158,20 @@ TestWebEngineView { function test_navigationButtons() { webEngineView.navigationHistory.clear() - webEngineView.url = Qt.resolvedUrl("test1.html") + const url1 = Qt.resolvedUrl("test1.html") + webEngineView.url = url1 verify(webEngineView.waitForLoadSucceeded()) compare(backButton.enabled, false) compare(forwardButton.enabled, false) - webEngineView.url = Qt.resolvedUrl("test2.html") + const url2 = Qt.resolvedUrl("test2.html") + webEngineView.url = url2 verify(webEngineView.waitForLoadSucceeded()) compare(backButton.enabled, true) compare(forwardButton.enabled, false) - webEngineView.url = Qt.resolvedUrl("test3.html") + const url3 = Qt.resolvedUrl("test3.html") + webEngineView.url = url3 verify(webEngineView.waitForLoadSucceeded()) compare(backButton.enabled, true) compare(forwardButton.enabled, false) @@ -180,11 +180,25 @@ TestWebEngineView { verify(webEngineView.waitForLoadSucceeded()) compare(backButton.enabled, true) compare(forwardButton.enabled, true) + compare(webEngineView.url, url2) - webEngineView.url = Qt.resolvedUrl("test1.html") + backButton.clicked() + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, false) + compare(forwardButton.enabled, true) + compare(webEngineView.url, url1) + + forwardButton.clicked() + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, true) + compare(webEngineView.url, url2) + + webEngineView.url = url1 verify(webEngineView.waitForLoadSucceeded()) compare(backButton.enabled, true) compare(forwardButton.enabled, false) + compare(webEngineView.url, url1) } } } -- cgit v1.2.3