From ca417f2aa2a8264f8818bf8dd2df98981b21867b Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Tue, 18 Mar 2014 18:32:39 +0100 Subject: Add Quick's navigationHistory Add QQuickWebEngineHistory and list models providing API for the quick's navigationHistory. Change-Id: Ia86c94b120cc5d0b4757fc62386fc7a0dcb3e341 Reviewed-by: Jocelyn Turcotte --- tests/auto/quick/qmltests/data/javascript.html | 8 ++ tests/auto/quick/qmltests/data/test2.html | 6 + .../quick/qmltests/data/tst_navigationHistory.qml | 143 +++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 tests/auto/quick/qmltests/data/javascript.html create mode 100644 tests/auto/quick/qmltests/data/test2.html create mode 100644 tests/auto/quick/qmltests/data/tst_navigationHistory.qml (limited to 'tests/auto/quick') 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 @@ + +Original Title + + + + 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 @@ + +Test page with huge link area + + + + 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) + } + } +} -- cgit v1.2.3