diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-09-08 11:04:31 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-09-08 12:55:06 +0200 |
commit | 22556f899ffd91650c1a1d5a8d71016358291859 (patch) | |
tree | 320dfdcd26a3cd078738da5a0ab9b8ea373fde29 /tests | |
parent | b715310a4fdc2a5e215c99bae042cd820e9a1e27 (diff) | |
parent | dc16cdd60449112343d43852960142db7fd155fd (diff) |
Merge branch '5.5' into 5.6
Change-Id: Idafba4d47393638cfc72fd02be092b67bb8cbd8c
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/publicapi/tst_publicapi.cpp | 1 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/geolocation.html | 26 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_geopermission.qml | 105 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/qmltests.pro | 2 |
4 files changed, 134 insertions, 0 deletions
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index eb925b178..8f0c2f6ec 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -169,6 +169,7 @@ static QStringList expectedAPI = QStringList() << "QQuickWebEngineView.zoomFactor --> double" << "QQuickWebEngineView.zoomFactorChanged(double) --> void" << "QQuickWebEngineView.profile --> QQuickWebEngineProfile*" + << "QQuickWebEngineView.profileChanged() --> void" << "QQuickWebEngineView.navigationHistory --> QQuickWebEngineHistory*" << "QQuickWebEngineView.newViewRequested(QQuickWebEngineNewViewRequest*) --> void" << "QQuickWebEngineView.userScripts --> QQmlListProperty<QQuickWebEngineScript>" diff --git a/tests/auto/quick/qmltests/data/geolocation.html b/tests/auto/quick/qmltests/data/geolocation.html new file mode 100644 index 000000000..c095a6b9e --- /dev/null +++ b/tests/auto/quick/qmltests/data/geolocation.html @@ -0,0 +1,26 @@ +<html> +<head> +<title>Geolocation Permission API Test</title> +<script> + +function successHandler(location) { + var message = document.getElementById("message"); + message.innerHTML = "Latitude: " + location.coords.latitude + + "<br>Longitude: " + location.coords.longitude; + +} + +function errorHandler(error) { + console.error(error.message); +} + +<!-- One shot example --> +navigator.geolocation.getCurrentPosition(successHandler, errorHandler); + +</script> +</head> +<body> +<div id="message">Location unknown</div> +</body> +</html> + diff --git a/tests/auto/quick/qmltests/data/tst_geopermission.qml b/tests/auto/quick/qmltests/data/tst_geopermission.qml new file mode 100644 index 000000000..acb561825 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_geopermission.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company 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.2 +import QtTest 1.0 +import QtWebEngine 1.1 + +TestWebEngineView { + id: webEngineView + width: 200 + height: 200 + + property bool deniedGeolocation: false + property bool geoPermissionRequested: false + property string consoleErrorMessage: "" + + SignalSpy { + id: featurePermissionSpy + target: webEngineView + signalName: "featurePermissionRequested" + } + + onFeaturePermissionRequested: { + if (feature === WebEngineView.Geolocation) { + geoPermissionRequested = true + if (deniedGeolocation) { + webEngineView.grantFeaturePermission(securityOrigin, feature, false) + } + else { + webEngineView.grantFeaturePermission(securityOrigin, feature, true) + } + } + } + + onJavaScriptConsoleMessage: { + if (level === WebEngineView.ErrorMessageLevel) + consoleErrorMessage = message + } + + TestCase { + name: "WebViewGeopermission" + when: windowShown + + function init() { + deniedGeolocation = false + consoleErrorMessage = "" + featurePermissionSpy.clear() + } + + function test_geoPermissionRequest() { + compare(featurePermissionSpy.count, 0) + webEngineView.url = Qt.resolvedUrl("geolocation.html") + featurePermissionSpy.wait() + verify(geoPermissionRequested) + compare(featurePermissionSpy.count, 1) + if (consoleErrorMessage) // Print the error message if it fails to get user's location + fail(consoleErrorMessage) + } + + function test_deniedGeolocationByUser() { + deniedGeolocation = true + webEngineView.url = Qt.resolvedUrl("geolocation.html") + featurePermissionSpy.wait() + compare(consoleErrorMessage, "User denied Geolocation") + } + } +} diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index aac0c449c..01517af47 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -17,6 +17,7 @@ OTHER_FILES += \ $$PWD/data/favicon.png \ $$PWD/data/favicon2.html \ $$PWD/data/forms.html \ + $$PWD/data/geolocation.html \ $$PWD/data/javascript.html \ $$PWD/data/link.html \ $$PWD/data/prompt.html \ @@ -35,6 +36,7 @@ OTHER_FILES += \ $$PWD/data/tst_favIconLoad.qml \ $$PWD/data/tst_filePicker.qml \ $$PWD/data/tst_formValidation.qml \ + $$PWD/data/tst_geopermission.qml \ $$PWD/data/tst_javaScriptDialogs.qml \ $$PWD/data/tst_linkHovered.qml \ $$PWD/data/tst_loadFail.qml \ |