summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2021-07-05 14:51:30 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2021-07-05 18:13:38 +0200
commitfa0550312d356519e8ddb614f3419bac31e746c6 (patch)
tree3beacc90efb2b2fd309ed808e9c9fc0f952dd042 /tests/auto/quick/qmltests/data
parent6b9b4b6ec334e47c9bed4fc74a8568481bcd5b7c (diff)
Stabilize WebViewGeoPermission QML auto test
Do not rely on console messages. Empty message doesn't trigger signal nor is shown in terminal (after 90-based). Pick-to: 6.2 Change-Id: I8bb705a2e2ba6c3812902ebd50f993fb9d2fe000 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/quick/qmltests/data')
-rw-r--r--tests/auto/quick/qmltests/data/geolocation.html9
-rw-r--r--tests/auto/quick/qmltests/data/tst_geopermission.qml40
2 files changed, 29 insertions, 20 deletions
diff --git a/tests/auto/quick/qmltests/data/geolocation.html b/tests/auto/quick/qmltests/data/geolocation.html
index 8b116c8ee..e8c54bc58 100644
--- a/tests/auto/quick/qmltests/data/geolocation.html
+++ b/tests/auto/quick/qmltests/data/geolocation.html
@@ -3,16 +3,21 @@
<title>Geolocation Permission API Test</title>
<script>
+var errorMessage;
+var handled = false;
+
function successHandler(location) {
var message = document.getElementById("message");
message.innerHTML = "Latitude: " + location.coords.latitude +
"<br>Longitude: " + location.coords.longitude;
- console.error("Success");
+ errorMessage = "";
+ handled = true;
}
function errorHandler(error) {
- console.error(error.message);
+ errorMessage = error.message;
+ handled = true;
}
<!-- One shot example -->
diff --git a/tests/auto/quick/qmltests/data/tst_geopermission.qml b/tests/auto/quick/qmltests/data/tst_geopermission.qml
index c935ac0b4..9f613abf3 100644
--- a/tests/auto/quick/qmltests/data/tst_geopermission.qml
+++ b/tests/auto/quick/qmltests/data/tst_geopermission.qml
@@ -37,7 +37,6 @@ TestWebEngineView {
property bool deniedGeolocation: false
property bool geoPermissionRequested: false
- signal consoleErrorMessage(string message)
SignalSpy {
id: featurePermissionSpy
@@ -45,12 +44,6 @@ TestWebEngineView {
signalName: "featurePermissionRequested"
}
- SignalSpy {
- id: consoleErrorMessageSpy
- target: webEngineView
- signalName: "consoleErrorMessage"
- }
-
onFeaturePermissionRequested: {
if (feature === WebEngineView.Geolocation) {
geoPermissionRequested = true
@@ -63,19 +56,31 @@ TestWebEngineView {
}
}
- onJavaScriptConsoleMessage: {
- if (level === WebEngineView.ErrorMessageLevel)
- consoleErrorMessage(message)
- }
-
TestCase {
name: "WebViewGeopermission"
when: windowShown
+ function isHandled() {
+ var handled;
+ runJavaScript("handled", function(result) {
+ handled = result;
+ });
+ tryVerify(function() { return handled != undefined; }, 5000);
+ return handled;
+ }
+
+ function getErrorMessage() {
+ var errorMessage;
+ runJavaScript("errorMessage", function(result) {
+ errorMessage = result;
+ });
+ tryVerify(function() { return errorMessage != undefined; }, 5000);
+ return errorMessage;
+ }
+
function init() {
deniedGeolocation = false
featurePermissionSpy.clear()
- consoleErrorMessageSpy.clear()
}
function test_geoPermissionRequest() {
@@ -84,17 +89,16 @@ TestWebEngineView {
featurePermissionSpy.wait()
verify(geoPermissionRequested)
compare(featurePermissionSpy.count, 1)
- consoleErrorMessageSpy.wait()
- verify(consoleErrorMessageSpy.signalArguments[0][0] === "Success" ||
- consoleErrorMessageSpy.signalArguments[0][0] === "")
+ tryVerify(isHandled, 5000)
+ verify(getErrorMessage() === "")
}
function test_deniedGeolocationByUser() {
deniedGeolocation = true
webEngineView.url = Qt.resolvedUrl("geolocation.html")
featurePermissionSpy.wait()
- consoleErrorMessageSpy.wait()
- compare(consoleErrorMessageSpy.signalArguments[0][0], "User denied Geolocation")
+ tryVerify(isHandled, 5000)
+ compare(getErrorMessage(), "User denied Geolocation")
}
}
}