From 71916012ea9434247c31e361a3033ae69c4781c6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 31 May 2016 09:51:04 +0200 Subject: Fix QML geolocation test The test had a race condition and never waited for success or failure. In addition it didn't handle the case where there is no location service available. Change-Id: Icac02d0cc6396f31fed83b8b77b691ba872ac2f0 Reviewed-by: Joerg Bornemann --- tests/auto/quick/qmltests/BLACKLIST | 1 - tests/auto/quick/qmltests/data/geolocation.html | 1 + tests/auto/quick/qmltests/data/tst_geopermission.qml | 5 +++-- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST index 3abcd82d0..035e49a83 100644 --- a/tests/auto/quick/qmltests/BLACKLIST +++ b/tests/auto/quick/qmltests/BLACKLIST @@ -6,4 +6,3 @@ osx [WebViewGeopermission::test_geoPermissionRequest] osx -windows diff --git a/tests/auto/quick/qmltests/data/geolocation.html b/tests/auto/quick/qmltests/data/geolocation.html index c095a6b9e..8b116c8ee 100644 --- a/tests/auto/quick/qmltests/data/geolocation.html +++ b/tests/auto/quick/qmltests/data/geolocation.html @@ -8,6 +8,7 @@ function successHandler(location) { message.innerHTML = "Latitude: " + location.coords.latitude + "
Longitude: " + location.coords.longitude; + console.error("Success"); } function errorHandler(error) { diff --git a/tests/auto/quick/qmltests/data/tst_geopermission.qml b/tests/auto/quick/qmltests/data/tst_geopermission.qml index a08ec155c..642cf2016 100644 --- a/tests/auto/quick/qmltests/data/tst_geopermission.qml +++ b/tests/auto/quick/qmltests/data/tst_geopermission.qml @@ -83,8 +83,9 @@ TestWebEngineView { featurePermissionSpy.wait() verify(geoPermissionRequested) compare(featurePermissionSpy.count, 1) - if (consoleErrorMessageSpy.count) // Print the error message if it fails to get user's location - fail(consoleErrorMessageSpy.signalArguments[0][0]) + consoleErrorMessageSpy.wait() + verify(consoleErrorMessageSpy.signalArguments[0][0] === "Success" || + consoleErrorMessageSpy.signalArguments[0][0] === "") } function test_deniedGeolocationByUser() { -- cgit v1.2.3