summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative_positioning_core
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative_positioning_core')
-rw-r--r--tests/auto/declarative_positioning_core/BLACKLIST6
-rw-r--r--tests/auto/declarative_positioning_core/CMakeLists.txt35
-rw-r--r--tests/auto/declarative_positioning_core/declarative_positioning_core.pro14
-rw-r--r--tests/auto/declarative_positioning_core/factory.cpp50
-rw-r--r--tests/auto/declarative_positioning_core/factory.h55
-rw-r--r--tests/auto/declarative_positioning_core/main.cpp49
-rw-r--r--tests/auto/declarative_positioning_core/tst_address.qml95
-rw-r--r--tests/auto/declarative_positioning_core/tst_coordinate.qml404
-rw-r--r--tests/auto/declarative_positioning_core/tst_geoshape.qml300
-rw-r--r--tests/auto/declarative_positioning_core/tst_position.qml52
-rw-r--r--tests/auto/declarative_positioning_core/tst_positionsource.qml445
11 files changed, 0 insertions, 1505 deletions
diff --git a/tests/auto/declarative_positioning_core/BLACKLIST b/tests/auto/declarative_positioning_core/BLACKLIST
deleted file mode 100644
index f8752ac4..00000000
--- a/tests/auto/declarative_positioning_core/BLACKLIST
+++ /dev/null
@@ -1,6 +0,0 @@
-# QTBUG-59074 and QTBUG-93761: flaky test
-[CoordinateAnimation::test_west_direction_coordinate_animation]
-osx arm
-# QTBUG-59074 and QTBUG-93761: flaky test
-[CoordinateAnimation::test_east_direction_coordinate_animation]
-osx arm
diff --git a/tests/auto/declarative_positioning_core/CMakeLists.txt b/tests/auto/declarative_positioning_core/CMakeLists.txt
deleted file mode 100644
index 0afb3021..00000000
--- a/tests/auto/declarative_positioning_core/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from declarative_positioning_core.pro.
-
-#####################################################################
-## tst_declarative_positioning_core Test:
-#####################################################################
-
-# Collect test data
-file(GLOB_RECURSE test_data_glob
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- *.qml)
-list(APPEND test_data ${test_data_glob})
-
-qt_internal_add_test(tst_declarative_positioning_core
- QMLTEST
- SOURCES
- main.cpp
- factory.cpp
- factory.h
- PUBLIC_LIBRARIES
- Qt::Positioning
- Qt::Quick
- TESTDATA ${test_data}
-)
-
-qt_add_qml_module(tst_declarative_positioning_core
- URI TestFactory
- VERSION 1.0
- QML_FILES
- tst_address.qml
- tst_coordinate.qml
- tst_geoshape.qml
- tst_position.qml
- tst_positionsource.qml
- NO_RESOURCE_TARGET_PATH
-)
diff --git a/tests/auto/declarative_positioning_core/declarative_positioning_core.pro b/tests/auto/declarative_positioning_core/declarative_positioning_core.pro
deleted file mode 100644
index fbf82de0..00000000
--- a/tests/auto/declarative_positioning_core/declarative_positioning_core.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-# QML tests in this directory must not depend on an OpenGL context.
-# QML tests that do require an OpenGL context must go in ../../declarative_ui.
-
-TEMPLATE = app
-TARGET = tst_declarative_positioning_core
-CONFIG += qmltestcase
-SOURCES += main.cpp
-
-CONFIG -= app_bundle
-
-QT += positioning quick
-
-OTHER_FILES = *.qml
-TESTDATA = $$OTHER_FILES
diff --git a/tests/auto/declarative_positioning_core/factory.cpp b/tests/auto/declarative_positioning_core/factory.cpp
deleted file mode 100644
index 92a242c3..00000000
--- a/tests/auto/declarative_positioning_core/factory.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "factory.h"
-#include <QGeoRectangle>
-#include <QGeoCircle>
-
-QT_BEGIN_NAMESPACE
-
-Factory::Factory(QObject *parent) : QObject(parent)
-{
-
-}
-
-QGeoShape Factory::createShape(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight)
-{
- return QGeoRectangle(topLeft, bottomRight);
-}
-
-QGeoShape Factory::createShape(const QGeoCoordinate &center, qreal radius) const
-{
- return QGeoCircle(center, radius);
-}
-
-QT_END_NAMESPACE
diff --git a/tests/auto/declarative_positioning_core/factory.h b/tests/auto/declarative_positioning_core/factory.h
deleted file mode 100644
index 9fcfef53..00000000
--- a/tests/auto/declarative_positioning_core/factory.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef FACTORY_H
-#define FACTORY_H
-
-#include <QObject>
-#include <QGeoShape>
-#include <QGeoCoordinate>
-#include <qqml.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoShape;
-class QGeoCoordinate;
-
-class Factory : public QObject
-{
- Q_OBJECT
- QML_ELEMENT
-
-public:
- explicit Factory(QObject *parent = nullptr);
-
- Q_INVOKABLE QGeoShape createShape(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
- Q_INVOKABLE QGeoShape createShape(const QGeoCoordinate &center, qreal radius) const;
-};
-
-QT_END_NAMESPACE
-
-#endif // FACTORY_H
diff --git a/tests/auto/declarative_positioning_core/main.cpp b/tests/auto/declarative_positioning_core/main.cpp
deleted file mode 100644
index d7cfb648..00000000
--- a/tests/auto/declarative_positioning_core/main.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QCoreApplication>
-#include <QtQuickTest/quicktest.h>
-#include <QtQml/qqml.h>
-
-static void initializeLibraryPath()
-{
-#if QT_CONFIG(library)
- // Set custom path since CI doesn't install test plugins
-#ifdef Q_OS_WIN
- QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() +
- QStringLiteral("/../../../../plugins"));
-#else
- QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() +
- QStringLiteral("/../../../plugins"));
-#endif
-#endif
-}
-
-Q_COREAPP_STARTUP_FUNCTION(initializeLibraryPath)
-
-QUICK_TEST_MAIN(declarative_positioning_core)
diff --git a/tests/auto/declarative_positioning_core/tst_address.qml b/tests/auto/declarative_positioning_core/tst_address.qml
deleted file mode 100644
index bfbe1a63..00000000
--- a/tests/auto/declarative_positioning_core/tst_address.qml
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtTest 1.0
-import QtPositioning 6.2
-
-TestCase {
- id: testCase
-
- name: "Address"
-
- Address {
- id: address
-
- street: "Evergreen Tce"
- streetNumber: "742"
- district: "Pressboard Estates"
- city: "Springfield"
- state: "Oregon"
- postalCode: "8900"
- country: "United States"
- countryCode: "USA"
- }
-
- function test_qmlAddressText() {
- compare(address.isTextGenerated, true);
- compare(address.text, "742 Evergreen Tce<br/>Springfield, Oregon 8900<br/>United States");
- var textChangedSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
- textChangedSpy.target = address;
- textChangedSpy.signalName = "textChanged"
-
- var isTextGeneratedSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
- isTextGeneratedSpy.target = address
- isTextGeneratedSpy.signalName = "isTextGeneratedChanged"
-
- address.countryCode = "FRA";
- compare(address.text, "742 Evergreen Tce<br/>8900 Springfield<br/>United States");
- compare(textChangedSpy.count, 1);
- textChangedSpy.clear();
- compare(isTextGeneratedSpy.count, 0);
-
- address.countryCode = "DEU"; // the street number should go after the street name
- compare(address.text, "Evergreen Tce 742<br/>8900 Springfield<br/>United States");
- compare(textChangedSpy.count, 1);
- textChangedSpy.clear();
- compare(isTextGeneratedSpy.count, 0);
-
- address.text = "address label";
- compare(address.isTextGenerated, false);
- compare(address.text, "address label");
- compare(textChangedSpy.count, 1);
- textChangedSpy.clear();
- compare(isTextGeneratedSpy.count, 1);
- isTextGeneratedSpy.clear();
-
- address.countryCode = "USA";
- compare(address.text, "address label");
- compare(textChangedSpy.count, 0);
- textChangedSpy.clear();
- compare(isTextGeneratedSpy.count, 0);
-
- address.text = "";
- compare(address.isTextGenerated, true);
- compare(address.text, "742 Evergreen Tce<br/>Springfield, Oregon 8900<br/>United States");
- compare(textChangedSpy.count, 1);
- textChangedSpy.clear();
- compare(isTextGeneratedSpy.count, 1);
- isTextGeneratedSpy.clear();
- }
-}
diff --git a/tests/auto/declarative_positioning_core/tst_coordinate.qml b/tests/auto/declarative_positioning_core/tst_coordinate.qml
deleted file mode 100644
index eb5a2573..00000000
--- a/tests/auto/declarative_positioning_core/tst_coordinate.qml
+++ /dev/null
@@ -1,404 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtPositioning 6.2
-
-Item {
- id: item
-
- property var empty: QtPositioning.coordinate()
- property var base: QtPositioning.coordinate(1.0, 1.0, 5.0)
- property var zero: QtPositioning.coordinate(0, 0)
- property var plusone: QtPositioning.coordinate(0, 1)
- property var minusone: QtPositioning.coordinate(0, -1)
- property var north: QtPositioning.coordinate(3, 0)
-
- SignalSpy { id: coordSpy; target: item; signalName: "baseChanged" }
-
- property var inside: QtPositioning.coordinate(0.5, 0.5)
- property var outside: QtPositioning.coordinate(2, 2)
- property var tl: QtPositioning.coordinate(1, 0)
- property var br: QtPositioning.coordinate(0, 1)
- property var box: QtPositioning.rectangle(tl, br)
-
-
- Address {
- id: validTestAddress
- street: "Brandl St"
- streetNumber: "53"
- city: "Eight Mile Plains"
- country: "Australia"
- countryCode: "AUS"
- }
-
- Location {
- id: testLocation
- coordinate: inside
- boundingShape: box
- address: validTestAddress
- }
-
- Location {
- id: invalidLocation
- }
-
-
- Item {
- id: coordinateItem
- property variant coordinate
- property int animationDuration: 100
- property var coordinateList: []
- property int coordinateCount: 0
-
- CoordinateAnimation {
- id: coordinateAnimation
- target: coordinateItem
- property: "coordinate"
- duration: coordinateItem.animationDuration
- }
- onCoordinateChanged: {
- if (!coordinateList) {
- coordinateList = []
- }
- coordinateList[coordinateCount] = QtPositioning.coordinate(coordinate.latitude,coordinate.longitude)
- coordinateCount++
- }
-
- SignalSpy { id: coordinateAnimationStartSpy; target: coordinateAnimation; signalName: "started" }
- SignalSpy { id: coordinateAnimationStopSpy; target: coordinateAnimation; signalName: "stopped" }
- SignalSpy { id: coordinateAnimationDirectionSpy; target: coordinateAnimation; signalName: "directionChanged" }
- }
-
- TestCase {
- name: "GeoLocation"
-
- function test_Location_complete()
- {
- compare (testLocation.coordinate.longitude, inside.longitude)
- compare (testLocation.coordinate.latitude, inside.latitude)
-
- compare (testLocation.boundingShape.contains(inside), true)
- compare (testLocation.boundingShape.contains(outside), false)
- var shapeRectangle = testLocation.boundingShape.boundingGeoRectangle()
- compare (shapeRectangle.bottomRight.longitude, br.longitude)
- compare (shapeRectangle.bottomRight.latitude, br.latitude)
- compare (shapeRectangle.topLeft.longitude, tl.longitude)
- compare (shapeRectangle.topLeft.latitude, tl.latitude)
-
- compare (testLocation.address.country, "Australia")
- compare (testLocation.address.countryCode, "AUS")
- compare (testLocation.address.city, "Eight Mile Plains")
- compare (testLocation.address.street, "Brandl St")
- compare (testLocation.address.streetNumber, "53")
- }
-
- function test_Location_invalid()
- {
- compare(invalidLocation.coordinate.isValid, false)
- compare(invalidLocation.boundingShape.isEmpty, true)
- compare(invalidLocation.boundingShape.isValid, false)
- compare(invalidLocation.address.city, "")
- }
- }
-
- TestCase {
- name: "Coordinate"
-
- function test_validity()
- {
- compare(empty.isValid, false)
-
- empty.longitude = 0.0;
- empty.latitude = 0.0;
-
- compare(empty.isValid, true)
- }
-
- function test_accessors()
- {
- compare(base.longitude, 1.0)
- compare(base.latitude, 1.0)
- compare(base.altitude, 5.0)
-
- coordSpy.clear()
-
- base.longitude = 2.0
- base.latitude = 3.0
- base.altitude = 6.0
-
- compare(base.longitude, 2.0)
- compare(base.latitude, 3.0)
- compare(base.altitude, 6.0)
- // changing individual properties does *not* trigger
- // change notification
- compare(coordSpy.count, 0)
-
- // updating the whole object *does* trigger change notification
- base = QtPositioning.coordinate(3.0, 4.0, 5.0)
- compare(base.latitude, 3.0)
- compare(base.longitude, 4.0)
- compare(base.altitude, 5.0)
- compare(coordSpy.count, 1)
- }
-
- function test_comparison_data()
- {
- return [
- { tag: "empty", coord1: empty, coord2: QtPositioning.coordinate(), result: true },
- { tag: "zero", coord1: zero, coord2: QtPositioning.coordinate(0, 0), result: true },
- { tag: "plusone", coord1: plusone, coord2: QtPositioning.coordinate(0, 1), result: true },
- { tag: "minusone", coord1: minusone, coord2: QtPositioning.coordinate(0, -1), result: true },
- { tag: "north", coord1: north, coord2: QtPositioning.coordinate(3, 0), result: true },
- { tag: "lat,long.alt", coord1: QtPositioning.coordinate(1.1, 2.2, 3.3), coord2: QtPositioning.coordinate(1.1, 2.2, 3.3), result: true },
- { tag: "not equal1", coord1: plusone, coord2: minusone, result: false },
- { tag: "not equal2", coord1: plusone, coord2: north, result: false }
- ]
- }
-
- function test_comparison(data)
- {
- compare(data.coord1 === data.coord2, data.result)
- compare(data.coord1 !== data.coord2, !data.result)
- compare(data.coord1 == data.coord2, data.result)
- compare(data.coord1 != data.coord2, !data.result)
- }
-
- function test_distance()
- {
- compare(zero.distanceTo(plusone), zero.distanceTo(minusone))
- compare(2*plusone.distanceTo(zero), plusone.distanceTo(minusone))
- compare(zero.distanceTo(plusone) > 0, true)
- }
-
- function test_azimuth()
- {
- compare(zero.azimuthTo(north), 0)
- compare(zero.azimuthTo(plusone), 90)
- compare(zero.azimuthTo(minusone), 270)
- compare(minusone.azimuthTo(plusone), 360 - plusone.azimuthTo(minusone))
- }
-
- function test_atDistanceAndAzimuth()
- {
- // 112km is approximately one degree of arc
-
- var coord_0d = zero.atDistanceAndAzimuth(112000, 0)
- compare(coord_0d.latitude > 0.95, true)
- compare(coord_0d.latitude < 1.05, true)
- compare(coord_0d.longitude < 0.05, true)
- compare(coord_0d.longitude > -0.05, true)
- compare(zero.distanceTo(coord_0d), 112000)
- compare(zero.azimuthTo(coord_0d), 0)
-
- var coord_90d = zero.atDistanceAndAzimuth(112000, 90)
- compare(coord_90d.longitude > 0.95, true)
- compare(coord_90d.longitude < 1.05, true)
- compare(coord_90d.latitude < 0.05, true)
- compare(coord_90d.latitude > -0.05, true)
- compare(zero.distanceTo(coord_90d), 112000)
- compare(zero.azimuthTo(coord_90d), 90)
-
- var coord_30d = zero.atDistanceAndAzimuth(20000, 30)
- compare(coord_30d.longitude > 0, true)
- compare(coord_30d.latitude > 0, true)
- compare(zero.distanceTo(coord_30d), 20000)
- compare(zero.azimuthTo(coord_30d), 30)
-
- var coord_30d2 = coord_30d.atDistanceAndAzimuth(200, 30)
- compare(zero.distanceTo(coord_30d2), 20200)
- }
- }
-
- TestCase {
- name: "CoordinateAnimation"
-
- function init()
- {
- coordinateAnimation.stop()
- coordinateAnimationStartSpy.clear()
- coordinateAnimationStopSpy.clear()
- coordinateAnimationDirectionSpy.clear()
- coordinateAnimation.from = QtPositioning.coordinate(50,50)
- coordinateAnimation.to = QtPositioning.coordinate(50,50)
- coordinateAnimation.direction = CoordinateAnimation.Shortest
- coordinateItem.coordinate = QtPositioning.coordinate(50,50)
- coordinateItem.coordinateList = []
- coordinateItem.coordinateCount = 0
- }
-
- function initTestCase()
- {
- compare(coordinateAnimation.direction, CoordinateAnimation.Shortest)
- compare(coordinateAnimationDirectionSpy.count,0)
- coordinateAnimation.direction = CoordinateAnimation.Shortest
- compare(coordinateAnimationDirectionSpy.count,0)
- coordinateAnimation.direction = CoordinateAnimation.West
- compare(coordinateAnimationDirectionSpy.count,1)
- coordinateAnimation.direction = CoordinateAnimation.East
- compare(coordinateAnimationDirectionSpy.count,2)
- }
-
- function toMercator(coord)
- {
- var p = QtPositioning.coordToMercator(coord)
- var lat = p.y
- var lon = p.x
- return {'latitude': lat, 'longitude': lon};
- }
-
- function coordinate_animation(from, to, movingEast)
- {
- var fromMerc = toMercator(from)
- var toMerc = toMercator(to)
- var delta = (toMerc.latitude - fromMerc.latitude) / (toMerc.longitude - fromMerc.longitude)
-
- compare(coordinateItem.coordinateList.length, 0);
- coordinateAnimation.from = from
- coordinateAnimation.to = to
- coordinateAnimation.start()
- tryCompare(coordinateAnimationStartSpy,"count",1)
- tryCompare(coordinateAnimationStopSpy,"count",1)
-
- //check correct start position
- verify(coordinateItem.coordinateList.length != 0)
- compare(coordinateItem.coordinateList[0], from)
- //check correct end position
- compare(coordinateItem.coordinateList[coordinateItem.coordinateList.length - 1],to)
-
- var i
- var lastLongitude
- for (i in coordinateItem.coordinateList) {
- var coordinate = coordinateItem.coordinateList[i]
- var mercCoordinate = toMercator(coordinate)
-
- //check that coordinates from the animation is along a straight line between from and to
- var estimatedLatitude = fromMerc.latitude + (mercCoordinate.longitude - fromMerc.longitude) * delta
- verify(mercCoordinate.latitude - estimatedLatitude < 0.00000000001);
-
- //check that each step has moved in the right direction
-
- if (lastLongitude) {
- var errorMessage = "movingEast: " + movingEast + "; From: " + from + "; To: " + to + "; i: " + i + "; crdList: " + coordinateItem.coordinateList
- if (movingEast) {
- if (coordinate.longitude < 0 && lastLongitude > 0)
- verify(coordinate.longitude + 360 > lastLongitude, errorMessage)
- else
- verify(coordinate.longitude > lastLongitude, errorMessage)
- } else {
- if (coordinate.longitude > 0 && lastLongitude < 0)
- verify(coordinate.longitude < lastLongitude + 360, errorMessage)
- else
- verify(coordinate.longitude < lastLongitude, errorMessage)
- }
- }
- lastLongitude = coordinate.longitude
- }
- }
-
- function test_default_coordinate_animation(data)
- {
- //shortest
- coordinate_animation(data.from, data.to, data.east)
- }
-
- function test_default_coordinate_animation_data()
- {
- return [
- {
- from: QtPositioning.coordinate(58.0, 12.0),
- to: QtPositioning.coordinate(62.0, 24.0),
- east: true
- },
- {
- from: QtPositioning.coordinate(58.0, 24.0),
- to: QtPositioning.coordinate(42.0, 12.0),
- east: false
- },
- // cross 0
- {
- from: QtPositioning.coordinate(30, 10),
- to: QtPositioning.coordinate(20, -10),
- east: false
- },
- {
- from: QtPositioning.coordinate(30, -20),
- to: QtPositioning.coordinate(20, 10),
- east: true
- },
- // cross 180
- {
- from: QtPositioning.coordinate(30, 170),
- to: QtPositioning.coordinate(30, -170),
- east: true
- },
- {
- from: QtPositioning.coordinate(30, -170),
- to: QtPositioning.coordinate(30, 170),
- east: false
- },
- ]
- }
-
- function test_east_direction_coordinate_animation(data)
- {
- coordinateAnimation.direction = CoordinateAnimation.East
- coordinate_animation(data.from,
- data.to,
- true)
- }
-
- function test_east_direction_coordinate_animation_data()
- {
- return [
- { from: QtPositioning.coordinate(58.0,24.0), to: QtPositioning.coordinate(58.0,12.0) },
- { from: QtPositioning.coordinate(58.0,12.0), to: QtPositioning.coordinate(58.0,24.0) },
- ]
- }
-
-
- function test_west_direction_coordinate_animation(data)
- {
- coordinateAnimation.direction = CoordinateAnimation.West
- coordinate_animation(data.from,
- data.to,
- false)
- }
-
- function test_west_direction_coordinate_animation_data()
- {
- return [
- { from: QtPositioning.coordinate(58.0,24.0),to: QtPositioning.coordinate(58.0,12.0) },
- { from: QtPositioning.coordinate(58.0,12.0),to: QtPositioning.coordinate(58.0,24.0) },
- ]
- }
-
-
- }
-}
diff --git a/tests/auto/declarative_positioning_core/tst_geoshape.qml b/tests/auto/declarative_positioning_core/tst_geoshape.qml
deleted file mode 100644
index 6429fb26..00000000
--- a/tests/auto/declarative_positioning_core/tst_geoshape.qml
+++ /dev/null
@@ -1,300 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtPositioning 5.2
-import TestFactory 1.0
-
-Item {
- id: testCase
-
- property var coordinate1: QtPositioning.coordinate(1, 1)
- property var coordinate2: QtPositioning.coordinate(2, 2)
- property var coordinate3: QtPositioning.coordinate(80, 80)
-
- property var emptyCircle: QtPositioning.circle()
- property var circle1: QtPositioning.circle(coordinate1, 200000)
-
- SignalSpy { id: circleChangedSpy; target: testCase; signalName: "emptyCircleChanged" }
-
- TestCase {
- name: "Bounding circle"
- function test_circle_defaults_and_setters() {
- circleChangedSpy.clear();
- compare (emptyCircle.radius, -1)
- compare (circle1.radius, 200000)
-
- emptyCircle.radius = 200
- compare(emptyCircle.radius, 200)
-
- emptyCircle.center = coordinate1
- compare(emptyCircle.center, coordinate1)
-
- emptyCircle.center = coordinate2
- compare(emptyCircle.center, coordinate2)
-
- emptyCircle = QtPositioning.circle(coordinate1, 200000)
- compare(emptyCircle.center, coordinate1)
- compare(emptyCircle.radius, 200000)
- // signal is triggered only when we update the whole object
- compare(circleChangedSpy.count, 1)
-
- compare(emptyCircle.contains(coordinate1), true);
- compare(emptyCircle.contains(coordinate2), true);
- compare(emptyCircle.contains(coordinate3), false);
- }
- }
-
- property var trace1 : [ QtPositioning.coordinate(43.773175, 11.255386),
- QtPositioning.coordinate(43.773546 , 11.255372) ]
- property var trace2 : [ QtPositioning.coordinate(43.773175, 11.255386),
- QtPositioning.coordinate(43.773546 , 11.255372),
- QtPositioning.coordinate(43.77453 , 11.255734) ]
-
-
- // coordinate unit square
- property var bl: QtPositioning.coordinate(0, 0)
- property var tl: QtPositioning.coordinate(1, 0)
- property var tr: QtPositioning.coordinate(1, 1)
- property var br: QtPositioning.coordinate(0, 1)
- property var ntr: QtPositioning.coordinate(3, 3)
-
- property var invalid: QtPositioning.coordinate(100, 190)
- property var inside: QtPositioning.coordinate(0.5, 0.5)
- property var outside: QtPositioning.coordinate(2, 2)
-
- property var box: QtPositioning.rectangle(tl, br)
-
- property var coordinates: [bl, tl, tr, br]
- property var coordinates2: [bl, tl, tr, br, ntr]
- property var coordinates3: [tr]
- property var coordinates4: [invalid]
- property var coordinates5: []
-
- property var listBox: QtPositioning.rectangle(coordinates)
- property var listBox2: QtPositioning.rectangle(coordinates2)
- property var listBox3: QtPositioning.rectangle(coordinates3)
- property var listBox4: QtPositioning.rectangle(coordinates4)
- property var listBox5: QtPositioning.rectangle(coordinates5)
-
- property var widthBox: QtPositioning.rectangle(inside, 1, 1);
-
- // C++ auto test exists for basics of bounding box, testing here
- // only added functionality
- TestCase {
- name: "Bounding box"
- function test_box_defaults_and_setters() {
- compare (box.bottomRight.longitude, br.longitude) // sanity
- compare (box.contains(bl), true)
- compare (box.contains(inside), true)
- compare (box.contains(outside), false)
- box.topRight = ntr
- compare (box.contains(outside), true)
-
- compare (listBox.isValid, true)
- compare (listBox.contains(outside), false)
- compare (listBox2.contains(outside), true)
- compare (listBox3.isValid, true)
- compare (listBox3.isEmpty, true)
- compare (listBox4.isValid, false)
- compare (listBox5.isValid, false)
-
- compare (widthBox.contains(inside), true)
- compare (widthBox.contains(outside), false)
- }
- }
-
- TestCase {
- name: "Shape"
-
- function test_shape_comparison_data() {
- return [
- { tag: "invalid shape", shape1: QtPositioning.shape(), shape2: QtPositioning.shape(), result: true },
- { tag: "box equal", shape1: box, shape2: QtPositioning.rectangle(tl, br), result: true },
- { tag: "box not equal", shape1: box, shape2: QtPositioning.rectangle([inside, outside]), result: false },
- { tag: "box invalid shape", rect1: box, shape2: QtPositioning.shape(), result: false },
- { tag: "invalid rectangle", shape1: QtPositioning.rectangle(), shape2: QtPositioning.rectangle(), result: true },
- { tag: "invalid rectangle2", shape1: QtPositioning.rectangle(), shape2: QtPositioning.shape(), result: false },
- { tag: "circle1 equal", shape1: circle1, shape2: QtPositioning.circle(coordinate1, 200000), result: true },
- { tag: "circle1 not equal", shape1: circle1, shape2: QtPositioning.circle(coordinate2, 2000), result: false },
- { tag: "circle1 invalid shape", shape1: circle1, shape2: QtPositioning.shape(), result: false },
- { tag: "invalid circle", shape1: QtPositioning.circle(), shape2: QtPositioning.circle(), result: true },
- { tag: "invalid circle2", shape1: QtPositioning.circle(), shape2: QtPositioning.shape(), result: false }
- ]
- }
-
- function test_shape_comparison(data) {
- compare(data.shape1 === data.shape2, data.result)
- compare(data.shape1 !== data.shape2, !data.result)
- compare(data.shape1 == data.shape2, data.result)
- compare(data.shape1 != data.shape2, !data.result)
- }
- }
-
- TestCase {
- name: "Conversions"
-
- function test_shape_circle_conversions() {
- var circle = QtPositioning.shapeToCircle(QtPositioning.shape())
- verify(!circle.isValid)
- circle = QtPositioning.shapeToCircle(QtPositioning.circle())
- verify(!circle.isValid)
- circle = QtPositioning.shapeToCircle(QtPositioning.circle(tl, 10000))
- verify(circle.isValid)
- compare(circle.center, tl)
- compare(circle.radius, 10000)
- circle = QtPositioning.shapeToCircle(QtPositioning.rectangle())
- verify(!circle.isValid)
- circle = QtPositioning.shapeToCircle(QtPositioning.rectangle(tl, br))
- verify(!circle.isValid)
- circle = QtPositioning.shapeToCircle(listBox)
- verify(!circle.isValid)
- }
-
- function test_shape_rectangle_conversions() {
- var rectangle = QtPositioning.shapeToRectangle(QtPositioning.shape())
- verify(!rectangle.isValid)
- rectangle = QtPositioning.shapeToRectangle(QtPositioning.circle())
- verify(!rectangle.isValid)
- rectangle = QtPositioning.shapeToRectangle(QtPositioning.circle(tl, 10000))
- verify(!rectangle.isValid)
- rectangle = QtPositioning.shapeToRectangle(QtPositioning.rectangle())
- verify(!rectangle.isValid)
- rectangle = QtPositioning.shapeToRectangle(QtPositioning.rectangle(tl, br))
- verify(rectangle.isValid)
- compare(rectangle.topLeft, tl)
- compare(rectangle.bottomRight, br)
- rectangle = QtPositioning.shapeToRectangle(listBox)
- verify(rectangle.isValid)
- }
-
- function test_shape_path_conversions() {
- var path = QtPositioning.shapeToPath(QtPositioning.shape())
- verify(!path.isValid)
- path = QtPositioning.shapeToPath(QtPositioning.circle())
- verify(!path.isValid)
- path = QtPositioning.shapeToPath(QtPositioning.circle(tl, 10000))
- verify(!path.isValid)
- path = QtPositioning.shapeToPath(QtPositioning.rectangle())
- verify(!path.isValid)
- path = QtPositioning.shapeToPath(QtPositioning.rectangle(tl, br))
- verify(!path.isValid)
-
- path = QtPositioning.shapeToPath(QtPositioning.path())
- verify(!path.isValid)
- path = QtPositioning.shapeToPath(QtPositioning.path(trace1, 1))
- verify(path.isValid)
- path = QtPositioning.shapeToPath(QtPositioning.path(trace2, 2))
- verify(path.isValid)
- verify(path !== QtPositioning.shapeToPath(QtPositioning.path(trace1, 1)))
- compare(path, QtPositioning.shapeToPath(QtPositioning.path(trace2, 2)))
- }
-
- function test_shape_polygon_conversions() {
- var polygon = QtPositioning.shapeToPolygon(QtPositioning.shape())
- verify(!polygon.isValid)
- polygon = QtPositioning.shapeToPolygon(QtPositioning.circle())
- verify(!polygon.isValid)
- polygon = QtPositioning.shapeToPolygon(QtPositioning.circle(tl, 10000))
- verify(polygon.isValid) // fixed, polygon copy constructor can now initialize from a circle.
- polygon = QtPositioning.shapeToPolygon(QtPositioning.rectangle())
- verify(!polygon.isValid)
- polygon = QtPositioning.shapeToPolygon(QtPositioning.rectangle(tl, br))
- verify(polygon.isValid) // fixed, polygon copy constructor can now initialize from a rectangle.
-
- polygon = QtPositioning.shapeToPolygon(QtPositioning.polygon())
- verify(!polygon.isValid)
- polygon = QtPositioning.shapeToPolygon(QtPositioning.polygon(trace1))
- verify(!polygon.isValid) // polygon needs 3 coords at least
- polygon = QtPositioning.shapeToPolygon(QtPositioning.polygon(trace2))
- verify(polygon.isValid)
- verify(polygon !== QtPositioning.shapeToPolygon(QtPositioning.polygon(trace1)))
- compare(polygon, QtPositioning.shapeToPolygon(QtPositioning.polygon(trace2)))
- }
- }
-
- TestCase {
- name: "GeoPath path"
- function test_qgeopath_path_operations() {
- var geopath = QtPositioning.path()
-
- geopath.path = trace2
- compare(geopath.path.length, trace2.length)
-
- geopath.path = trace2
- geopath.path[0].longitude = 11.0
- compare(geopath.path.length, trace2.length)
- compare(geopath.coordinateAt(0).latitude, trace2[0].latitude)
- expectFail("", "Longitude comparison fails")
- compare(geopath.coordinateAt(0).longitude, 11)
- }
- }
-
- TestCase {
- name: "GeoPolygon path"
- function test_qgeopolygon_path_operations() {
- var geopolygon = QtPositioning.polygon()
-
- geopolygon.perimeter = trace2
- compare(geopolygon.perimeter.length, trace2.length)
-
- geopolygon.perimeter = trace2
- compare(geopolygon.perimeter.length, trace2.length)
- compare(geopolygon.coordinateAt(0).latitude, trace2[0].latitude)
- compare(geopolygon.coordinateAt(0).longitude, trace2[0].longitude)
- }
- }
-
- Factory {
- id: factory
- }
-
- TestCase {
- name: "GeoShape factory"
- function test_geoshape_factory_construction() {
- // Both createShape() methods return QGeoShape. We check that
- // invokable methods and properties are called for correct
- // objects
- var c0 = QtPositioning.coordinate(1.0, 1.0)
- var c1 = QtPositioning.coordinate(1.0001, 1.0001)
- var c2 = QtPositioning.coordinate(0.5, 0.5)
- var circle = factory.createShape(c0, 100.0)
- verify(circle.contains(c1))
- verify(!circle.contains(c2))
- compare(circle.center, c0)
-
- var rectangle = factory.createShape(QtPositioning.coordinate(1.0, 0.0), QtPositioning.coordinate(0.0, 1.0))
- verify(rectangle.contains(c2))
- verify(!rectangle.contains(c1))
- compare(rectangle.center, c2)
-
- verify(rectangle.center !== circle.center)
- }
- }
-}
diff --git a/tests/auto/declarative_positioning_core/tst_position.qml b/tests/auto/declarative_positioning_core/tst_position.qml
deleted file mode 100644
index 77e6b90c..00000000
--- a/tests/auto/declarative_positioning_core/tst_position.qml
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtPositioning 5.3
-
-TestCase {
- id: testCase
-
- name: "Position"
-
- Position { id: defaultPosition }
-
- function test_defaults() {
- compare(defaultPosition.latitudeValid, false);
- compare(defaultPosition.longitudeValid, false);
- compare(defaultPosition.altitudeValid, false);
- compare(defaultPosition.speedValid, false);
- compare(defaultPosition.horizontalAccuracyValid, false);
- compare(defaultPosition.verticalAccuracyValid, false);
- verify(!defaultPosition.directionValid);
- verify(isNaN(defaultPosition.direction));
- verify(!defaultPosition.verticalSpeedValid);
- verify(isNaN(defaultPosition.verticalSpeed));
- }
-}
diff --git a/tests/auto/declarative_positioning_core/tst_positionsource.qml b/tests/auto/declarative_positioning_core/tst_positionsource.qml
deleted file mode 100644
index 74233fcd..00000000
--- a/tests/auto/declarative_positioning_core/tst_positionsource.qml
+++ /dev/null
@@ -1,445 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtPositioning 5.14
-
-TestCase {
- id: testCase
-
- name: "PositionSource"
-
- PositionSource { id: defaultSource }
- PositionSource
- {
- id: activeDefaultSource
- active: true
- }
-
- SignalSpy { id: defaultSourceSpy; target: defaultSource; signalName: "positionChanged" }
-
- function test_activeDefaultSource() {
- wait(0);
- verify(activeDefaultSource.name !== "");
- compare(activeDefaultSource.active, true);
- }
-
- function test_invalidSource() {
- activeDefaultSource.name = "invalid_positioning_source";
- verify(!activeDefaultSource.active);
- verify(!activeDefaultSource.valid);
- }
-
- function test_defaults() {
- // at least the test.source plugin should be available
- verify(defaultSource.name != "");
- compare(defaultSource.active, false);
- }
-
- function test_inactive() {
- defaultSourceSpy.clear();
- compare(defaultSourceSpy.count, 0);
- wait(1000);
- compare(defaultSourceSpy.count, 0);
- }
-
- PositionSource { id: testSetSource; name: "nonexistent bogus plugin" }
- SignalSpy { id: testingSourcePluginSpy; target: testSetSource; signalName: "nameChanged" }
-
- function test_setplugin() {
- testingSourcePluginSpy.clear();
-
- // On construction, if the provided source name is invalid, the default source will be
- // used. Test that the source is valid as expected.
- verify(testSetSource.name !== "");
- //we don't really know what the default source is named.
- //It may not be "test.source"
- var defaultSourceName = testSetSource.name;
- verify(testSetSource.valid);
-
- // Test that setting name to "" will still use the default.
- testSetSource.name = "";
- compare(testingSourcePluginSpy.count, 0);
- compare(testSetSource.name, defaultSourceName);
- verify(testSetSource.valid);
-
- testSetSource.name = "test.source";
- if (defaultSourceName === "test.source")
- compare(testingSourcePluginSpy.count, 0);
- compare(testSetSource.name, "test.source");
- verify(testSetSource.valid);
- testingSourcePluginSpy.clear();
-
- testSetSource.name = "bogus";
- compare(testingSourcePluginSpy.count, 1);
- verify(!testSetSource.valid);
- }
-
- PositionSource { id: testingSource; name: "test.source"; updateInterval: 1000 }
-
- PositionSource {
- id: testingSourceWParams
- name: "test.source"
- updateInterval: 200
- PluginParameter {
- id: altitudeParameter
- name: "test.source.altitude"
- value: 42.42
- }
- }
-
- // use property bindings instead of SignalSpy
- property bool directionWParamsValid: testingSourceWParams.position.directionValid
- property int directionWParamsValidChangedCount: 0
- onDirectionWParamsValidChanged: {
- ++directionWParamsValidChangedCount
- }
-
- property real directionWParams: testingSourceWParams.position.direction
- property int directionWParamsChangedCount: 0
- onDirectionWParamsChanged: {
- ++directionWParamsChangedCount
- }
-
- SignalSpy { id: updateSpyWParams; target: testingSourceWParams; signalName: "positionChanged" }
-
- PositionSource { id: testingSourceV1; name: "test.source"; updateInterval: 200 }
-
- // use property bindings instead of SignalSpy
- property bool directionV1Valid: testingSourceV1.position.directionValid
- property int directionV1ValidChangedCount: 0
- onDirectionV1ValidChanged: {
- ++directionV1ValidChangedCount
- }
-
- property real directionV1: testingSourceV1.position.direction
- property int directionV1ChangedCount: 0
- onDirectionV1Changed: {
- ++directionV1ChangedCount
- }
-
- SignalSpy { id: updateSpyV1; target: testingSourceV1; signalName: "positionChanged" }
-
- function test_updateInterval() {
- testingSource.updateInterval = 200;
- compare(testingSource.updateInterval, 200);
- testingSource.updateInterval = 300;
- compare(testingSource.updateInterval, 300);
- testingSource.updateInterval = 100;
- compare(testingSource.updateInterval, 200);
- }
-
- function test_preferredPositioningMethods() {
- testingSource.preferredPositioningMethods = PositionSource.AllPositioningMethods;
- compare(testingSource.preferredPositioningMethods, PositionSource.AllPositioningMethods);
- testingSource.preferredPositioningMethods = PositionSource.SatellitePositioningMethods;
- compare(testingSource.preferredPositioningMethods, PositionSource.SatellitePositioningMethods);
- testingSource.preferredPositioningMethods = PositionSource.NonSatellitePositioningMethods;
- compare(testingSource.preferredPositioningMethods, PositionSource.NonSatellitePositioningMethods);
- }
-
- function test_updates() {
- updateSpyV1.clear();
-
- directionV1ChangedCount = 0
- directionV1ValidChangedCount = 0
-
- testingSourceV1.active = true;
-
- tryCompare(updateSpyV1, "count", 1, 300);
- compare(testingSourceV1.position.coordinate.longitude, 0.1);
- compare(testingSourceV1.position.coordinate.latitude, 0.1);
- compare(directionV1ValidChangedCount, 1)
- compare(directionV1ChangedCount, 1)
- fuzzyCompare(testingSourceV1.position.direction, 45, 0.1)
- verify(!testingSourceV1.position.speedValid)
- verify(isNaN(testingSourceV1.position.speed))
-
- tryCompare(updateSpyV1, "count", 2, 300);
- compare(testingSourceV1.position.coordinate.longitude, 0.2);
- compare(testingSourceV1.position.coordinate.latitude, 0.2);
- compare(directionV1ValidChangedCount, 1)
- compare(directionV1ChangedCount, 2)
- fuzzyCompare(testingSourceV1.position.direction, 45, 0.1)
- verify(testingSourceV1.position.speedValid)
- verify(testingSourceV1.position.speed > 10000)
-
- testingSourceV1.active = false;
- wait(300);
- compare(updateSpyV1.count, 2);
- compare(testingSourceV1.position.coordinate.longitude, 0.2);
- compare(testingSourceV1.position.coordinate.latitude, 0.2);
- compare(directionV1ValidChangedCount, 1)
- compare(directionV1ChangedCount, 2)
- fuzzyCompare(testingSourceV1.position.direction, 45, 0.1)
- verify(testingSourceV1.position.speedValid)
- verify(testingSourceV1.position.speed > 10000)
- }
-
- function test_updates_w_params() {
- updateSpyWParams.clear();
-
- directionWParamsChangedCount = 0
- directionWParamsValidChangedCount = 0
- compare(testingSourceWParams.backendProperty("altitude"), altitudeParameter.value)
- testingSourceWParams.active = true;
-
- tryCompare(updateSpyWParams, "count", 1, 300);
- compare(testingSourceWParams.position.coordinate.longitude, 0.1);
- compare(testingSourceWParams.position.coordinate.latitude, 0.1);
- compare(testingSourceWParams.position.coordinate.altitude, altitudeParameter.value);
- compare(directionWParamsValidChangedCount, 1)
- compare(directionWParamsChangedCount, 1)
- fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1)
- verify(!testingSourceWParams.position.speedValid)
- verify(isNaN(testingSourceWParams.position.speed))
- testingSourceWParams.setBackendProperty("altitude", 24.24)
-
- tryCompare(updateSpyWParams, "count", 2, 300);
- compare(testingSourceWParams.position.coordinate.longitude, 0.2);
- compare(testingSourceWParams.position.coordinate.latitude, 0.2);
- compare(testingSourceWParams.position.coordinate.altitude, 24.24);
- compare(directionWParamsValidChangedCount, 1)
- compare(directionWParamsChangedCount, 2)
- fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1)
- verify(testingSourceWParams.position.speedValid)
- verify(testingSourceWParams.position.speed > 10000)
- compare(testingSourceWParams.backendProperty("altitude"), 24.24)
-
- testingSourceWParams.active = false;
- wait(300);
- compare(updateSpyWParams.count, 2);
- compare(testingSourceWParams.position.coordinate.longitude, 0.2);
- compare(testingSourceWParams.position.coordinate.latitude, 0.2);
- compare(testingSourceWParams.position.coordinate.altitude, 24.24);
- compare(directionWParamsValidChangedCount, 1)
- compare(directionWParamsChangedCount, 2)
- fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1)
- verify(testingSourceWParams.position.speedValid)
- verify(testingSourceWParams.position.speed > 10000)
- }
-
- // tests for bindings
- PositionSource {
- id: testSourceForBindings
- name: "test.source"
- }
-
- property var positionObserver: testSourceForBindings.position
- SignalSpy {
- id: positionObserverSpy; target: testSourceForBindings; signalName: "positionChanged"
- }
-
- property bool activeObserver: testSourceForBindings.active
- SignalSpy {
- id: activeObserverSpy; target: testSourceForBindings; signalName: "activeChanged"
- }
-
- property bool validObserver: testSourceForBindings.valid
- SignalSpy {
- id: validObserverSpy; target: testSourceForBindings; signalName: "validityChanged"
- }
-
- property int updateIntervalObserver: testSourceForBindings.updateInterval
- SignalSpy {
- id: updateIntervalObserverSpy; target: testSourceForBindings; signalName: "updateIntervalChanged"
- }
-
- property int supportedMethodsObserver: testSourceForBindings.supportedPositioningMethods
- SignalSpy {
- id: supportedMethodsObserverSpy; target: testSourceForBindings; signalName: "supportedPositioningMethodsChanged"
- }
-
- property int preferredMethodsObserver: testSourceForBindings.preferredPositioningMethods
- SignalSpy {
- id: preferredMethodsObserverSpy;
- target: testSourceForBindings;
- signalName: "preferredPositioningMethodsChanged"
- }
-
- property int errorObserver: testSourceForBindings.sourceError
- SignalSpy {
- id: errorObserverSpy; target: testSourceForBindings; signalName: "sourceErrorChanged"
- }
-
- property string nameObserver: testSourceForBindings.name
- SignalSpy {
- id: nameObserverSpy; target: testSourceForBindings; signalName: "nameChanged"
- }
-
- function test_bindingsToPositionSource() {
- positionObserverSpy.clear()
- activeObserverSpy.clear()
- validObserverSpy.clear()
- updateIntervalObserverSpy.clear()
- supportedMethodsObserverSpy.clear()
- preferredMethodsObserverSpy.clear()
- errorObserverSpy.clear()
- nameObserverSpy.clear()
-
- verify(testSourceForBindings.valid)
- compare(testSourceForBindings.supportedPositioningMethods, PositionSource.AllPositioningMethods)
-
- testSourceForBindings.preferredPositioningMethods = PositionSource.SatellitePositioningMethods
- compare(preferredMethodsObserver, PositionSource.SatellitePositioningMethods)
- compare(preferredMethodsObserverSpy.count, 1)
-
- testSourceForBindings.updateInterval = 210;
- compare(updateIntervalObserver, 210)
- compare(updateIntervalObserverSpy.count, 1)
-
- testSourceForBindings.start();
- compare(activeObserver, true)
- compare(activeObserverSpy.count, 1)
-
- tryCompare(positionObserverSpy, "count", 1, 300);
- verify(testSourceForBindings.position.coordinate !== QtPositioning.coordinate())
-
- testSourceForBindings.update(50) // small timeout will result in an error
- tryCompare(errorObserverSpy, "count", 1, 200)
- compare(errorObserver, PositionSource.UpdateTimeoutError)
-
- var newSourceName = "some invalid name"
- testSourceForBindings.name = newSourceName
-
- compare(validObserver, false)
- compare(validObserverSpy.count, 1)
-
- compare(nameObserver, newSourceName)
- compare(nameObserverSpy.count, 1)
-
- compare(supportedMethodsObserver, PositionSource.NoPositioningMethods)
- compare(supportedMethodsObserverSpy.count, 1)
- }
-
- property bool activeSetter: false
- property string nameSetter: "test.source"
- property int updateIntervalSetter: 200
- property int preferredMethodsSetter: PositionSource.NonSatellitePositioningMethods
-
- PositionSource {
- id: sourceWithBindings
- name: nameSetter
- active: activeSetter
- updateInterval: updateIntervalSetter
- preferredPositioningMethods: preferredMethodsSetter
- }
-
- function test_bindPositionSourceProperties() {
- compare(sourceWithBindings.name, "test.source")
- compare(sourceWithBindings.active, false)
- compare(sourceWithBindings.updateInterval, 200)
- compare(sourceWithBindings.preferredPositioningMethods, PositionSource.NonSatellitePositioningMethods)
-
- updateIntervalSetter = 210;
- preferredMethodsSetter = PositionSource.AllPositioningMethods
- activeSetter = true
-
- wait(0) // to trigger event processing
-
- compare(sourceWithBindings.active, true)
- compare(sourceWithBindings.updateInterval, 210)
- compare(sourceWithBindings.preferredPositioningMethods, PositionSource.AllPositioningMethods)
-
- activeSetter = false;
-
- compare(sourceWithBindings.active, false)
-
- // check how call to update() effects the binding
- sourceWithBindings.update(updateIntervalSetter)
- compare(sourceWithBindings.active, true)
-
- wait(300)
- compare(sourceWithBindings.active, false)
-
- activeSetter = true;
- wait(0) // to trigger event processing
- // the binding is *not* broken by calling update()
- compare(sourceWithBindings.active, true)
- }
-
- function test_updateIntervalBindings() {
- var updateIntervalSpy = Qt.createQmlObject('import QtTest; SignalSpy { }', testCase)
- updateIntervalSpy.target = sourceWithBindings
- updateIntervalSpy.signalName = "updateIntervalChanged"
- verify(updateIntervalSpy.valid)
-
- nameSetter = "invalid name"
- updateIntervalSetter = 100;
- compare(sourceWithBindings.updateInterval, 100)
- compare(updateIntervalSpy.count, 1)
-
- nameSetter = "test.source"
- // "test.source" has a minimum update interval of 200
- compare(sourceWithBindings.updateInterval, 200)
- compare(updateIntervalSpy.count, 2)
-
- nameSetter = "dummy.source"
- // "dummy.source" has a minimum udpate interval of 100, so we expect
- // the updateInterval to be set to 100
- compare(sourceWithBindings.updateInterval, 100)
- compare(updateIntervalSpy.count, 3)
-
- // The binding still works
- updateIntervalSetter = 110
- compare(sourceWithBindings.updateInterval, 110)
- compare(updateIntervalSpy.count, 4)
- }
-
- function test_preferredPositioningMethodsBindings() {
- var preferredMethodsSpy = Qt.createQmlObject('import QtTest; SignalSpy { }', testCase)
- preferredMethodsSpy.target = sourceWithBindings
- preferredMethodsSpy.signalName = "preferredPositioningMethodsChanged"
- verify(preferredMethodsSpy.valid)
-
- nameSetter = "invalid name"
- preferredMethodsSetter = PositionSource.SatellitePositioningMethods
- compare(sourceWithBindings.preferredPositioningMethods, PositionSource.SatellitePositioningMethods)
- compare(preferredMethodsSpy.count, 1)
-
- nameSetter = "dummy.source"
- // "dummy.source" has only NonSatellitePositioningMethods, so we expect
- // the value to be set to NonSatellitePositioningMethods (see
- // QGeoPositionInfoSource::setPreferredPositioningMethods for details)
- compare(sourceWithBindings.preferredPositioningMethods, PositionSource.NonSatellitePositioningMethods)
- compare(preferredMethodsSpy.count, 2)
-
- nameSetter = "test.source"
- // "test.source" has all positioning methods, so we expect the value to
- // be set to the desired SatellitePositioningMethods
- compare(sourceWithBindings.preferredPositioningMethods, PositionSource.SatellitePositioningMethods)
- compare(preferredMethodsSpy.count, 3)
-
- // The binding still works
- preferredMethodsSetter = PositionSource.AllPositioningMethods
- compare(sourceWithBindings.preferredPositioningMethods, PositionSource.AllPositioningMethods)
- compare(preferredMethodsSpy.count, 4)
- }
-
-}