summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests/data/tst_navigationHistory.qml')
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationHistory.qml105
1 files changed, 69 insertions, 36 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
index 6ed232589..2ea76c387 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -38,7 +13,7 @@ TestWebEngineView {
ListView {
id: backItemsList
anchors.fill: parent
- model: webEngineView.navigationHistory.backItems
+ model: webEngineView.history.backItems
currentIndex: count - 1
delegate:
Text {
@@ -50,7 +25,7 @@ TestWebEngineView {
ListView {
id: forwardItemsList
anchors.fill: parent
- model: webEngineView.navigationHistory.forwardItems
+ model: webEngineView.history.forwardItems
currentIndex: 0
delegate:
Text {
@@ -59,11 +34,23 @@ TestWebEngineView {
}
}
+ Item { // simple button-like interface to not depend on controls
+ id: backButton
+ enabled: webEngineView.canGoBack
+ function clicked() { if (enabled) webEngineView.goBack() }
+ }
+
+ Item { // simple button-like interface to not depend on controls
+ id: forwardButton
+ enabled: webEngineView.canGoForward
+ function clicked() { if (enabled) webEngineView.goForward() }
+ }
+
TestCase {
- name: "WebEngineViewNavigationHistory"
+ name: "NavigationHistory"
function test_navigationHistory() {
- compare(webEngineView.loadProgress, 0)
+ webEngineView.history.clear()
webEngineView.url = Qt.resolvedUrl("test1.html")
verify(webEngineView.waitForLoadSucceeded())
@@ -135,12 +122,58 @@ TestWebEngineView {
compare(backItemsList.currentItem.text, Qt.resolvedUrl("test1.html"))
compare(forwardItemsList.currentItem.text, Qt.resolvedUrl("javascript.html"))
- webEngineView.navigationHistory.clear()
+ webEngineView.history.clear()
compare(webEngineView.url, Qt.resolvedUrl("test2.html"))
compare(webEngineView.canGoBack, false)
compare(webEngineView.canGoForward, false)
compare(backItemsList.count, 0)
compare(forwardItemsList.count, 0)
}
+
+ function test_navigationButtons() {
+ webEngineView.history.clear()
+
+ const url1 = Qt.resolvedUrl("test1.html")
+ webEngineView.url = url1
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, false)
+ compare(forwardButton.enabled, false)
+
+ const url2 = Qt.resolvedUrl("test2.html")
+ webEngineView.url = url2
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+
+ const url3 = Qt.resolvedUrl("test3.html")
+ webEngineView.url = url3
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+
+ backButton.clicked()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, true)
+ compare(webEngineView.url, url2)
+
+ 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)
+ }
}
}