summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2014-03-18 18:32:39 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 09:00:08 +0100
commitca417f2aa2a8264f8818bf8dd2df98981b21867b (patch)
tree6f89cb40d0f573a8bb01dbcf57b654ad9bf5da64 /tests/auto/quick
parente82487177bbfbf5b6c219d40547706f50b3b73ab (diff)
Add Quick's navigationHistory
Add QQuickWebEngineHistory and list models providing API for the quick's navigationHistory. Change-Id: Ia86c94b120cc5d0b4757fc62386fc7a0dcb3e341 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qmltests/data/javascript.html8
-rw-r--r--tests/auto/quick/qmltests/data/test2.html6
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationHistory.qml143
3 files changed, 157 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests/data/javascript.html b/tests/auto/quick/qmltests/data/javascript.html
new file mode 100644
index 000000000..7a3dc0a1c
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/javascript.html
@@ -0,0 +1,8 @@
+<html>
+<head><title>Original Title</title></head>
+<body>
+<script type="text/javascript">
+document.title = "New Title";
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/test2.html b/tests/auto/quick/qmltests/data/test2.html
new file mode 100644
index 000000000..629c2a063
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/test2.html
@@ -0,0 +1,6 @@
+<html>
+<head><title>Test page with huge link area</title></head>
+<body>
+<a title="A title" href="test1.html"><img width=200 height=200></a>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
new file mode 100644
index 000000000..bac87a861
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebEngine 1.0
+import QtWebEngine.experimental 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+
+ ListView {
+ id: backItemsList
+ anchors.fill: parent
+ model: webEngineView.experimental.navigationHistory.backItems
+ delegate:
+ Text {
+ color:"black"
+ text: "title : " + title
+ }
+ }
+
+ ListView {
+ id: forwardItemsList
+ anchors.fill: parent
+ model: webEngineView.experimental.navigationHistory.forwardItems
+ delegate:
+ Text {
+ color:"black"
+ text: "title : " + title
+ }
+ }
+
+ TestCase {
+ name: "WebViewNavigationHistory"
+
+ function test_navigationHistory() {
+ compare(webEngineView.loadProgress, 0)
+
+ webEngineView.url = Qt.resolvedUrl("test1.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.canGoBack, false)
+ compare(webEngineView.canGoForward, false)
+ compare(backItemsList.count, 0)
+ compare(forwardItemsList.count, 0)
+
+ webEngineView.url = Qt.resolvedUrl("test2.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, Qt.resolvedUrl("test2.html"))
+ compare(webEngineView.canGoBack, true)
+ compare(webEngineView.canGoForward, false)
+ compare(backItemsList.count, 1)
+
+ webEngineView.experimental.goBackTo(0)
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, Qt.resolvedUrl("test1.html"))
+ compare(webEngineView.canGoBack, false)
+ compare(webEngineView.canGoForward, true)
+ compare(backItemsList.count, 0)
+ compare(forwardItemsList.count, 1)
+
+ webEngineView.goForward()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, Qt.resolvedUrl("test2.html"))
+ compare(webEngineView.canGoBack, true)
+ compare(webEngineView.canGoForward, false)
+ compare(backItemsList.count, 1)
+ compare(forwardItemsList.count, 0)
+
+ webEngineView.url = Qt.resolvedUrl("javascript.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, Qt.resolvedUrl("javascript.html"))
+ compare(webEngineView.canGoBack, true)
+ compare(webEngineView.canGoForward, false)
+ compare(backItemsList.count, 2)
+ compare(forwardItemsList.count, 0)
+
+ webEngineView.experimental.goBackTo(1)
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, Qt.resolvedUrl("test1.html"))
+ compare(webEngineView.canGoBack, false)
+ compare(webEngineView.canGoForward, true)
+ compare(backItemsList.count, 0)
+ compare(forwardItemsList.count, 2)
+
+ webEngineView.experimental.goForwardTo(1)
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, Qt.resolvedUrl("javascript.html"))
+ compare(webEngineView.canGoBack, true)
+ compare(webEngineView.canGoForward, false)
+ compare(backItemsList.count, 2)
+ compare(forwardItemsList.count, 0)
+
+ webEngineView.goBack()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, Qt.resolvedUrl("test2.html"))
+ compare(webEngineView.canGoBack, true)
+ compare(webEngineView.canGoForward, true)
+ compare(backItemsList.count, 1)
+ compare(forwardItemsList.count, 1)
+ }
+ }
+}