summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-01-27 18:18:46 +0100
committerIvan Solovev <ivan.solovev@qt.io>2021-02-09 11:10:26 +0100
commit32f7ffbe7307c02fce1493d43cdaf87bf0f1f1d7 (patch)
treec2a3f110f88f66afac59b278ddbf48da5ec0f556 /tests
parent752f7c79d3bb8c350139d48c9622d426f7ad86d2 (diff)
downloadqtlocation-32f7ffbe7307c02fce1493d43cdaf87bf0f1f1d7.tar.gz
QtPositioning: refactor unit tests
Some of the QtPositioning QML unit tests can be separated from the QtLocation tests, and run with QtPositioning and QtPositioningQuick only. This patch moves such unit tests into separate subdirectory. It also updated the tests to reflect the changes in Qt6: Since Qt6 the variant type behaves as var, so the tests that rely on the obsolete behavior need to be updated. The QGeoShape::center() method is no longer marked Q_INVOKABLE, because with updated Qt6 behavior it overrides the center properties of the child classes (like QGeoCircle or QGeoRectangle). It's marked as a read-only property instread, so that it could still be accessed from QML code. [ChangeLog][QtPositioning][QGeoShape] center is now a read-only property. The center() function is no longer a Q_INVOKABLE. Task-number: QTBUG-90491 Task-number: QTBUG-90836 Change-Id: I3c7993aa8abe1199e825d46ab19ccfb53902018f Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/CMakeLists.txt7
-rw-r--r--tests/auto/auto.pro8
-rw-r--r--tests/auto/declarative_location_core/declarative_location_core.pro (renamed from tests/auto/declarative_core/declarative_core.pro)2
-rw-r--r--tests/auto/declarative_location_core/main.cpp (renamed from tests/auto/declarative_core/main.cpp)2
-rw-r--r--tests/auto/declarative_location_core/tst_category.qml (renamed from tests/auto/declarative_core/tst_category.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_categorymodel.qml (renamed from tests/auto/declarative_core/tst_categorymodel.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_contactdetail.qml (renamed from tests/auto/declarative_core/tst_contactdetail.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_editorialmodel.qml (renamed from tests/auto/declarative_core/tst_editorialmodel.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_geocoding.qml (renamed from tests/auto/declarative_core/tst_geocoding.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_imagemodel.qml (renamed from tests/auto/declarative_core/tst_imagemodel.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_place.qml (renamed from tests/auto/declarative_core/tst_place.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_placeattribute.qml (renamed from tests/auto/declarative_core/tst_placeattribute.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_placeicon.qml (renamed from tests/auto/declarative_core/tst_placeicon.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_placesearchmodel.qml (renamed from tests/auto/declarative_core/tst_placesearchmodel.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_placesearchsuggestionmodel.qml (renamed from tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_plugin.qml (renamed from tests/auto/declarative_core/tst_plugin.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_plugin_error.qml (renamed from tests/auto/declarative_core/tst_plugin_error.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_ratings.qml (renamed from tests/auto/declarative_core/tst_ratings.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_reviewmodel.qml (renamed from tests/auto/declarative_core/tst_reviewmodel.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_routing.qml (renamed from tests/auto/declarative_core/tst_routing.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_supplier.qml (renamed from tests/auto/declarative_core/tst_supplier.qml)0
-rw-r--r--tests/auto/declarative_location_core/tst_user.qml (renamed from tests/auto/declarative_core/tst_user.qml)0
-rw-r--r--tests/auto/declarative_location_core/utils.js (renamed from tests/auto/declarative_core/utils.js)0
-rw-r--r--tests/auto/declarative_mappolyline/declarative_mappolyline.pro (renamed from tests/auto/declarative_geoshape/declarative_geoshape.pro)2
-rw-r--r--tests/auto/declarative_mappolyline/main.cpp (renamed from tests/auto/declarative_geoshape/main.cpp)4
-rw-r--r--tests/auto/declarative_mappolyline/tst_declarative_mappolyline.qml123
-rw-r--r--tests/auto/declarative_positioning_core/BLACKLIST (renamed from tests/auto/declarative_core/BLACKLIST)0
-rw-r--r--tests/auto/declarative_positioning_core/CMakeLists.txt40
-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.qml (renamed from tests/auto/declarative_core/tst_address.qml)0
-rw-r--r--tests/auto/declarative_positioning_core/tst_coordinate.qml (renamed from tests/auto/declarative_core/tst_coordinate.qml)43
-rw-r--r--tests/auto/declarative_positioning_core/tst_geoshape.qml (renamed from tests/auto/declarative_geoshape/tst_locationsingleton.qml)183
-rw-r--r--tests/auto/declarative_positioning_core/tst_position.qml (renamed from tests/auto/declarative_core/tst_position.qml)0
-rw-r--r--tests/auto/declarative_positioning_core/tst_positionsource.qml (renamed from tests/auto/declarative_core/tst_positionsource.qml)0
37 files changed, 441 insertions, 141 deletions
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
index 65412e06..88cbc5ac 100644
--- a/tests/auto/CMakeLists.txt
+++ b/tests/auto/CMakeLists.txt
@@ -66,12 +66,15 @@ add_subdirectory(qgeosatelliteinfo)
# add_subdirectory(qgeotiledmap)
# endif()
# if(TARGET Qt::Location AND TARGET Qt::Quick AND NOT ANDROID)
-# add_subdirectory(declarative_geoshape)
-# add_subdirectory(declarative_core)
+# add_subdirectory(declarative_mappolyline)
+# add_subdirectory(declarative_location_core)
# endif()
# if(TARGET Qt::Location AND TARGET Qt::Quick AND NOT ANDROID AND NOT APPLE)
# add_subdirectory(declarative_ui)
# endif()
+if(TARGET Qt::Quick AND NOT ANDROID)
+ add_subdirectory(declarative_positioning_core)
+endif()
if(NOT ANDROID)
add_subdirectory(positionplugin)
add_subdirectory(positionplugintest)
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 912b6e42..c94ec618 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -70,8 +70,8 @@ qtHaveModule(location) {
qgeotiledmap.depends = geotestplugin
}
qtHaveModule(quick):!android {
- SUBDIRS += declarative_geoshape \
- declarative_core
+ SUBDIRS += declarative_mappolyline \
+ declarative_location_core
declarative_core.depends = geotestplugin
!mac: {
@@ -81,6 +81,10 @@ qtHaveModule(location) {
}
}
+qtHaveModule(quick):!android {
+ SUBDIRS += declarative_positioning_core
+}
+
SUBDIRS += \
doublevectors \
qgeoaddress \
diff --git a/tests/auto/declarative_core/declarative_core.pro b/tests/auto/declarative_location_core/declarative_location_core.pro
index 30c2b7f6..9e1372df 100644
--- a/tests/auto/declarative_core/declarative_core.pro
+++ b/tests/auto/declarative_location_core/declarative_location_core.pro
@@ -2,7 +2,7 @@
# QML tests that do require an OpenGL context must go in ../../declarative_ui.
TEMPLATE = app
-TARGET = tst_declarative_core
+TARGET = tst_declarative_location_core
CONFIG += qmltestcase
SOURCES += main.cpp
diff --git a/tests/auto/declarative_core/main.cpp b/tests/auto/declarative_location_core/main.cpp
index b380a231..80261f14 100644
--- a/tests/auto/declarative_core/main.cpp
+++ b/tests/auto/declarative_location_core/main.cpp
@@ -45,4 +45,4 @@ static void initializeLibraryPath()
Q_COREAPP_STARTUP_FUNCTION(initializeLibraryPath)
-QUICK_TEST_MAIN(declarative_core)
+QUICK_TEST_MAIN(declarative_location_core)
diff --git a/tests/auto/declarative_core/tst_category.qml b/tests/auto/declarative_location_core/tst_category.qml
index f0a14d6f..f0a14d6f 100644
--- a/tests/auto/declarative_core/tst_category.qml
+++ b/tests/auto/declarative_location_core/tst_category.qml
diff --git a/tests/auto/declarative_core/tst_categorymodel.qml b/tests/auto/declarative_location_core/tst_categorymodel.qml
index 59ec3e7c..59ec3e7c 100644
--- a/tests/auto/declarative_core/tst_categorymodel.qml
+++ b/tests/auto/declarative_location_core/tst_categorymodel.qml
diff --git a/tests/auto/declarative_core/tst_contactdetail.qml b/tests/auto/declarative_location_core/tst_contactdetail.qml
index a91c19fa..a91c19fa 100644
--- a/tests/auto/declarative_core/tst_contactdetail.qml
+++ b/tests/auto/declarative_location_core/tst_contactdetail.qml
diff --git a/tests/auto/declarative_core/tst_editorialmodel.qml b/tests/auto/declarative_location_core/tst_editorialmodel.qml
index 4cb38e5e..4cb38e5e 100644
--- a/tests/auto/declarative_core/tst_editorialmodel.qml
+++ b/tests/auto/declarative_location_core/tst_editorialmodel.qml
diff --git a/tests/auto/declarative_core/tst_geocoding.qml b/tests/auto/declarative_location_core/tst_geocoding.qml
index 16843528..16843528 100644
--- a/tests/auto/declarative_core/tst_geocoding.qml
+++ b/tests/auto/declarative_location_core/tst_geocoding.qml
diff --git a/tests/auto/declarative_core/tst_imagemodel.qml b/tests/auto/declarative_location_core/tst_imagemodel.qml
index 2fa5093c..2fa5093c 100644
--- a/tests/auto/declarative_core/tst_imagemodel.qml
+++ b/tests/auto/declarative_location_core/tst_imagemodel.qml
diff --git a/tests/auto/declarative_core/tst_place.qml b/tests/auto/declarative_location_core/tst_place.qml
index bb789b42..bb789b42 100644
--- a/tests/auto/declarative_core/tst_place.qml
+++ b/tests/auto/declarative_location_core/tst_place.qml
diff --git a/tests/auto/declarative_core/tst_placeattribute.qml b/tests/auto/declarative_location_core/tst_placeattribute.qml
index ae61aed4..ae61aed4 100644
--- a/tests/auto/declarative_core/tst_placeattribute.qml
+++ b/tests/auto/declarative_location_core/tst_placeattribute.qml
diff --git a/tests/auto/declarative_core/tst_placeicon.qml b/tests/auto/declarative_location_core/tst_placeicon.qml
index c0f099d7..c0f099d7 100644
--- a/tests/auto/declarative_core/tst_placeicon.qml
+++ b/tests/auto/declarative_location_core/tst_placeicon.qml
diff --git a/tests/auto/declarative_core/tst_placesearchmodel.qml b/tests/auto/declarative_location_core/tst_placesearchmodel.qml
index 4c7897b5..4c7897b5 100644
--- a/tests/auto/declarative_core/tst_placesearchmodel.qml
+++ b/tests/auto/declarative_location_core/tst_placesearchmodel.qml
diff --git a/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml b/tests/auto/declarative_location_core/tst_placesearchsuggestionmodel.qml
index 13347565..13347565 100644
--- a/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml
+++ b/tests/auto/declarative_location_core/tst_placesearchsuggestionmodel.qml
diff --git a/tests/auto/declarative_core/tst_plugin.qml b/tests/auto/declarative_location_core/tst_plugin.qml
index 23c1ff9f..23c1ff9f 100644
--- a/tests/auto/declarative_core/tst_plugin.qml
+++ b/tests/auto/declarative_location_core/tst_plugin.qml
diff --git a/tests/auto/declarative_core/tst_plugin_error.qml b/tests/auto/declarative_location_core/tst_plugin_error.qml
index 50b03590..50b03590 100644
--- a/tests/auto/declarative_core/tst_plugin_error.qml
+++ b/tests/auto/declarative_location_core/tst_plugin_error.qml
diff --git a/tests/auto/declarative_core/tst_ratings.qml b/tests/auto/declarative_location_core/tst_ratings.qml
index 5628432f..5628432f 100644
--- a/tests/auto/declarative_core/tst_ratings.qml
+++ b/tests/auto/declarative_location_core/tst_ratings.qml
diff --git a/tests/auto/declarative_core/tst_reviewmodel.qml b/tests/auto/declarative_location_core/tst_reviewmodel.qml
index 192026fd..192026fd 100644
--- a/tests/auto/declarative_core/tst_reviewmodel.qml
+++ b/tests/auto/declarative_location_core/tst_reviewmodel.qml
diff --git a/tests/auto/declarative_core/tst_routing.qml b/tests/auto/declarative_location_core/tst_routing.qml
index 1d7c1e37..1d7c1e37 100644
--- a/tests/auto/declarative_core/tst_routing.qml
+++ b/tests/auto/declarative_location_core/tst_routing.qml
diff --git a/tests/auto/declarative_core/tst_supplier.qml b/tests/auto/declarative_location_core/tst_supplier.qml
index 3fcb0d1f..3fcb0d1f 100644
--- a/tests/auto/declarative_core/tst_supplier.qml
+++ b/tests/auto/declarative_location_core/tst_supplier.qml
diff --git a/tests/auto/declarative_core/tst_user.qml b/tests/auto/declarative_location_core/tst_user.qml
index 1453c41a..1453c41a 100644
--- a/tests/auto/declarative_core/tst_user.qml
+++ b/tests/auto/declarative_location_core/tst_user.qml
diff --git a/tests/auto/declarative_core/utils.js b/tests/auto/declarative_location_core/utils.js
index 2b7dca32..2b7dca32 100644
--- a/tests/auto/declarative_core/utils.js
+++ b/tests/auto/declarative_location_core/utils.js
diff --git a/tests/auto/declarative_geoshape/declarative_geoshape.pro b/tests/auto/declarative_mappolyline/declarative_mappolyline.pro
index aa6647f5..342fcc42 100644
--- a/tests/auto/declarative_geoshape/declarative_geoshape.pro
+++ b/tests/auto/declarative_mappolyline/declarative_mappolyline.pro
@@ -1,7 +1,7 @@
# QML tests in this directory must not depend on an OpenGL context.
TEMPLATE = app
-TARGET = tst_declarative_geoshape
+TARGET = tst_declarative_mappolyline
CONFIG += qmltestcase
SOURCES += main.cpp
diff --git a/tests/auto/declarative_geoshape/main.cpp b/tests/auto/declarative_mappolyline/main.cpp
index ffc94454..dc8caaaf 100644
--- a/tests/auto/declarative_geoshape/main.cpp
+++ b/tests/auto/declarative_mappolyline/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** 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.
@@ -27,4 +27,4 @@
****************************************************************************/
#include <QtQuickTest/quicktest.h>
-QUICK_TEST_MAIN(declarative_geoshape)
+QUICK_TEST_MAIN(declarative_mappolyline)
diff --git a/tests/auto/declarative_mappolyline/tst_declarative_mappolyline.qml b/tests/auto/declarative_mappolyline/tst_declarative_mappolyline.qml
new file mode 100644
index 00000000..b7ce0c4a
--- /dev/null
+++ b/tests/auto/declarative_mappolyline/tst_declarative_mappolyline.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** 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 QtLocation 5.5
+
+Item {
+ id: testCase
+
+ MapPolyline {
+ id: mapPolyline
+ path: [
+ { latitude: -27, longitude: 153.0 },
+ { latitude: -27, longitude: 154.1 },
+ { latitude: -28, longitude: 153.5 },
+ { latitude: -29, longitude: 153.5 }
+ ]
+ }
+
+ MapPolyline {
+ id: mapPolylineGeopath
+ }
+
+ TestCase {
+ name: "MapPolyline path"
+ function test_path_operations() {
+ compare(mapPolyline.path[1].latitude, -27)
+ compare(mapPolyline.path[1].longitude, 154.1)
+ compare(mapPolyline.coordinateAt(1), QtPositioning.coordinate(-27, 154.1))
+ compare(mapPolyline.path.length, mapPolyline.pathLength())
+
+ mapPolyline.removeCoordinate(1);
+ compare(mapPolyline.path[1].latitude, -28)
+ compare(mapPolyline.path[1].longitude, 153.5)
+ compare(mapPolyline.coordinateAt(1), QtPositioning.coordinate(-28, 153.5))
+ compare(mapPolyline.path.length, mapPolyline.pathLength())
+
+ mapPolyline.addCoordinate(QtPositioning.coordinate(30, 153.1))
+ compare(mapPolyline.path[mapPolyline.path.length-1].latitude, 30)
+ compare(mapPolyline.path[mapPolyline.path.length-1].longitude, 153.1)
+ compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(30, 153.1)), true)
+ compare(mapPolyline.path.length, mapPolyline.pathLength())
+
+ mapPolyline.removeCoordinate(QtPositioning.coordinate(30, 153.1))
+ compare(mapPolyline.path[mapPolyline.path.length-1].latitude, -29)
+ compare(mapPolyline.path[mapPolyline.path.length-1].longitude, 153.5)
+ compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(30, 153.1)), false)
+ compare(mapPolyline.path.length, mapPolyline.pathLength())
+
+ mapPolyline.insertCoordinate(2, QtPositioning.coordinate(35, 153.1))
+ compare(mapPolyline.path[2].latitude, 35)
+ compare(mapPolyline.path[2].longitude, 153.1)
+ compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(35, 153.1)), true)
+ compare(mapPolyline.path.length, mapPolyline.pathLength())
+
+ mapPolyline.replaceCoordinate(2, QtPositioning.coordinate(45, 150.1))
+ compare(mapPolyline.path[2].latitude, 45)
+ compare(mapPolyline.path[2].longitude, 150.1)
+ compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(35, 153.1)), false)
+ compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(45, 150.1)), true)
+ compare(mapPolyline.path.length, mapPolyline.pathLength())
+
+ mapPolyline.insertCoordinate(2, QtPositioning.coordinate(35, 153.1))
+ compare(mapPolyline.coordinateAt(2).latitude, 35)
+ compare(mapPolyline.coordinateAt(2).longitude, 153.1)
+ compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(35, 153.1)), true)
+ compare(mapPolyline.path.length, mapPolyline.pathLength())
+ }
+ }
+
+ TestCase {
+ name: "GeoPath path MapPolyLine"
+ function test_qgeopath_path_operations() {
+ var geopath = QtPositioning.path()
+
+ geopath.path = mapPolyline.path
+ compare(geopath.path.length, mapPolyline.pathLength())
+ compare(geopath.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
+
+ mapPolylineGeopath.geoShape = geopath
+ compare(mapPolylineGeopath.pathLength(), mapPolyline.pathLength())
+ compare(mapPolylineGeopath.geoShape.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
+ }
+ }
+
+ TestCase {
+ name: "GeoPolygon path MapPolyLine"
+ function test_qgeopolygon_path_operations() {
+ var geopolygon = QtPositioning.polygon()
+
+ geopolygon.perimeter = mapPolyline.path
+ compare(geopolygon.perimeter.length, mapPolyline.pathLength())
+ compare(geopolygon.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
+ }
+ }
+}
diff --git a/tests/auto/declarative_core/BLACKLIST b/tests/auto/declarative_positioning_core/BLACKLIST
index 99b4d786..99b4d786 100644
--- a/tests/auto/declarative_core/BLACKLIST
+++ b/tests/auto/declarative_positioning_core/BLACKLIST
diff --git a/tests/auto/declarative_positioning_core/CMakeLists.txt b/tests/auto/declarative_positioning_core/CMakeLists.txt
new file mode 100644
index 00000000..673d2856
--- /dev/null
+++ b/tests/auto/declarative_positioning_core/CMakeLists.txt
@@ -0,0 +1,40 @@
+# 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}
+)
+
+# special case begin
+
+# These properties are required for the qt6_qml_type_registration()
+# to work properly
+set_target_properties(tst_declarative_positioning_core
+ PROPERTIES
+ QT_QML_MODULE_URI TestFactory
+ QT_QML_MODULE_VERSION 1.0
+)
+
+qt6_qml_type_registration(tst_declarative_positioning_core)
+
+# special case end
+
+#### Keys ignored in scope 1:.:.:declarative_positioning_core.pro:<TRUE>:
+# TEMPLATE = "app"
diff --git a/tests/auto/declarative_positioning_core/declarative_positioning_core.pro b/tests/auto/declarative_positioning_core/declarative_positioning_core.pro
new file mode 100644
index 00000000..fbf82de0
--- /dev/null
+++ b/tests/auto/declarative_positioning_core/declarative_positioning_core.pro
@@ -0,0 +1,14 @@
+# 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
new file mode 100644
index 00000000..92a242c3
--- /dev/null
+++ b/tests/auto/declarative_positioning_core/factory.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..9fcfef53
--- /dev/null
+++ b/tests/auto/declarative_positioning_core/factory.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..d7cfb648
--- /dev/null
+++ b/tests/auto/declarative_positioning_core/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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_core/tst_address.qml b/tests/auto/declarative_positioning_core/tst_address.qml
index 94f986c4..94f986c4 100644
--- a/tests/auto/declarative_core/tst_address.qml
+++ b/tests/auto/declarative_positioning_core/tst_address.qml
diff --git a/tests/auto/declarative_core/tst_coordinate.qml b/tests/auto/declarative_positioning_core/tst_coordinate.qml
index 9cb37195..00c8570b 100644
--- a/tests/auto/declarative_core/tst_coordinate.qml
+++ b/tests/auto/declarative_positioning_core/tst_coordinate.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** 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.
@@ -33,20 +33,20 @@ import QtPositioning 5.5
Item {
id: item
- property variant empty: QtPositioning.coordinate()
- property variant base: QtPositioning.coordinate(1.0, 1.0, 5.0)
- property variant zero: QtPositioning.coordinate(0, 0)
- property variant plusone: QtPositioning.coordinate(0, 1)
- property variant minusone: QtPositioning.coordinate(0, -1)
- property variant north: QtPositioning.coordinate(3, 0)
+ 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 variant inside: QtPositioning.coordinate(0.5, 0.5)
- property variant outside: QtPositioning.coordinate(2, 2)
- property variant tl: QtPositioning.coordinate(1, 0)
- property variant br: QtPositioning.coordinate(0, 1)
- property variant box: QtPositioning.rectangle(tl, br)
+ 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 {
@@ -144,16 +144,25 @@ Item {
compare(base.latitude, 1.0)
compare(base.altitude, 5.0)
- coordSpy.clear();
+ coordSpy.clear()
- base.longitude = 2.0;
- base.latitude = 3.0;
- base.altitude = 6.0;
+ 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)
- compare(coordSpy.count, 3)
+ // 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()
diff --git a/tests/auto/declarative_geoshape/tst_locationsingleton.qml b/tests/auto/declarative_positioning_core/tst_geoshape.qml
index b58eedfd..6429fb26 100644
--- a/tests/auto/declarative_geoshape/tst_locationsingleton.qml
+++ b/tests/auto/declarative_positioning_core/tst_geoshape.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** 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.
@@ -29,17 +29,17 @@
import QtQuick 2.0
import QtTest 1.0
import QtPositioning 5.2
-import QtLocation 5.5
+import TestFactory 1.0
Item {
id: testCase
- property variant coordinate1: QtPositioning.coordinate(1, 1)
- property variant coordinate2: QtPositioning.coordinate(2, 2)
- property variant coordinate3: QtPositioning.coordinate(80, 80)
+ property var coordinate1: QtPositioning.coordinate(1, 1)
+ property var coordinate2: QtPositioning.coordinate(2, 2)
+ property var coordinate3: QtPositioning.coordinate(80, 80)
- property variant emptyCircle: QtPositioning.circle()
- property variant circle1: QtPositioning.circle(coordinate1, 200000)
+ property var emptyCircle: QtPositioning.circle()
+ property var circle1: QtPositioning.circle(coordinate1, 200000)
SignalSpy { id: circleChangedSpy; target: testCase; signalName: "emptyCircleChanged" }
@@ -51,19 +51,19 @@ Item {
compare (circle1.radius, 200000)
emptyCircle.radius = 200
- compare(circleChangedSpy.count, 1);
- emptyCircle.radius = 200;
- compare(circleChangedSpy.count, 1);
+ compare(emptyCircle.radius, 200)
- emptyCircle.center = coordinate1;
- compare(circleChangedSpy.count, 2);
emptyCircle.center = coordinate1
- compare(circleChangedSpy.count, 2);
+ compare(emptyCircle.center, coordinate1)
+
emptyCircle.center = coordinate2
- compare(circleChangedSpy.count, 3);
+ compare(emptyCircle.center, coordinate2)
- emptyCircle.center = coordinate1
- emptyCircle.radius = 200000
+ 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);
@@ -71,39 +71,39 @@ Item {
}
}
- property variant trace1 : [ QtPositioning.coordinate(43.773175, 11.255386),
- QtPositioning.coordinate(43.773546 , 11.255372) ]
- property variant trace2 : [ QtPositioning.coordinate(43.773175, 11.255386),
- QtPositioning.coordinate(43.773546 , 11.255372),
- QtPositioning.coordinate(43.77453 , 11.255734)]
+ 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 variant bl: QtPositioning.coordinate(0, 0)
- property variant tl: QtPositioning.coordinate(1, 0)
- property variant tr: QtPositioning.coordinate(1, 1)
- property variant br: QtPositioning.coordinate(0, 1)
- property variant ntr: QtPositioning.coordinate(3, 3)
+ 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 variant invalid: QtPositioning.coordinate(100, 190)
- property variant inside: QtPositioning.coordinate(0.5, 0.5)
- property variant outside: QtPositioning.coordinate(2, 2)
+ property var invalid: QtPositioning.coordinate(100, 190)
+ property var inside: QtPositioning.coordinate(0.5, 0.5)
+ property var outside: QtPositioning.coordinate(2, 2)
- property variant box: QtPositioning.rectangle(tl, br)
+ property var box: QtPositioning.rectangle(tl, br)
- property variant coordinates: [bl, tl, tr, br]
- property variant coordinates2: [bl, tl, tr, br, ntr]
- property variant coordinates3: [tr]
- property variant coordinates4: [invalid]
- property variant coordinates5: []
+ 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 variant listBox: QtPositioning.rectangle(coordinates)
- property variant listBox2: QtPositioning.rectangle(coordinates2)
- property variant listBox3: QtPositioning.rectangle(coordinates3)
- property variant listBox4: QtPositioning.rectangle(coordinates4)
- property variant listBox5: QtPositioning.rectangle(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 variant widthBox: QtPositioning.rectangle(inside, 1, 1);
+ property var widthBox: QtPositioning.rectangle(inside, 1, 1);
// C++ auto test exists for basics of bounding box, testing here
// only added functionality
@@ -239,68 +239,6 @@ Item {
}
}
-
- MapPolyline {
- id: mapPolyline
- path: [
- { latitude: -27, longitude: 153.0 },
- { latitude: -27, longitude: 154.1 },
- { latitude: -28, longitude: 153.5 },
- { latitude: -29, longitude: 153.5 }
- ]
- }
-
- MapPolyline {
- id: mapPolylineGeopath
- }
-
- TestCase {
- name: "MapPolyline path"
- function test_path_operations() {
- compare(mapPolyline.path[1].latitude, -27)
- compare(mapPolyline.path[1].longitude, 154.1)
- compare(mapPolyline.coordinateAt(1), QtPositioning.coordinate(-27, 154.1))
- compare(mapPolyline.path.length, mapPolyline.pathLength())
-
- mapPolyline.removeCoordinate(1);
- compare(mapPolyline.path[1].latitude, -28)
- compare(mapPolyline.path[1].longitude, 153.5)
- compare(mapPolyline.coordinateAt(1), QtPositioning.coordinate(-28, 153.5))
- compare(mapPolyline.path.length, mapPolyline.pathLength())
-
- mapPolyline.addCoordinate(QtPositioning.coordinate(30, 153.1))
- compare(mapPolyline.path[mapPolyline.path.length-1].latitude, 30)
- compare(mapPolyline.path[mapPolyline.path.length-1].longitude, 153.1)
- compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(30, 153.1)), true)
- compare(mapPolyline.path.length, mapPolyline.pathLength())
-
- mapPolyline.removeCoordinate(QtPositioning.coordinate(30, 153.1))
- compare(mapPolyline.path[mapPolyline.path.length-1].latitude, -29)
- compare(mapPolyline.path[mapPolyline.path.length-1].longitude, 153.5)
- compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(30, 153.1)), false)
- compare(mapPolyline.path.length, mapPolyline.pathLength())
-
- mapPolyline.insertCoordinate(2, QtPositioning.coordinate(35, 153.1))
- compare(mapPolyline.path[2].latitude, 35)
- compare(mapPolyline.path[2].longitude, 153.1)
- compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(35, 153.1)), true)
- compare(mapPolyline.path.length, mapPolyline.pathLength())
-
- mapPolyline.replaceCoordinate(2, QtPositioning.coordinate(45, 150.1))
- compare(mapPolyline.path[2].latitude, 45)
- compare(mapPolyline.path[2].longitude, 150.1)
- compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(35, 153.1)), false)
- compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(45, 150.1)), true)
- compare(mapPolyline.path.length, mapPolyline.pathLength())
-
- mapPolyline.insertCoordinate(2, QtPositioning.coordinate(35, 153.1))
- compare(mapPolyline.coordinateAt(2).latitude, 35)
- compare(mapPolyline.coordinateAt(2).longitude, 153.1)
- compare(mapPolyline.containsCoordinate(QtPositioning.coordinate(35, 153.1)), true)
- compare(mapPolyline.path.length, mapPolyline.pathLength())
- }
- }
-
TestCase {
name: "GeoPath path"
function test_qgeopath_path_operations() {
@@ -309,14 +247,6 @@ Item {
geopath.path = trace2
compare(geopath.path.length, trace2.length)
- geopath.path = mapPolyline.path
- compare(geopath.path.length, mapPolyline.pathLength())
- compare(geopath.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
-
- mapPolylineGeopath.geoShape = geopath
- compare(mapPolylineGeopath.pathLength(), mapPolyline.pathLength())
- compare(mapPolylineGeopath.geoShape.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
-
geopath.path = trace2
geopath.path[0].longitude = 11.0
compare(geopath.path.length, trace2.length)
@@ -334,14 +264,37 @@ Item {
geopolygon.perimeter = trace2
compare(geopolygon.perimeter.length, trace2.length)
- geopolygon.perimeter = mapPolyline.path
- compare(geopolygon.perimeter.length, mapPolyline.pathLength())
- compare(geopolygon.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
-
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_core/tst_position.qml b/tests/auto/declarative_positioning_core/tst_position.qml
index 1bde0879..1bde0879 100644
--- a/tests/auto/declarative_core/tst_position.qml
+++ b/tests/auto/declarative_positioning_core/tst_position.qml
diff --git a/tests/auto/declarative_core/tst_positionsource.qml b/tests/auto/declarative_positioning_core/tst_positionsource.qml
index 7b787a0c..7b787a0c 100644
--- a/tests/auto/declarative_core/tst_positionsource.qml
+++ b/tests/auto/declarative_positioning_core/tst_positionsource.qml