summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/declarative_ui/tst_map.qml70
-rw-r--r--tests/auto/declarative_ui/tst_map_flick.qml12
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml38
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml4
-rw-r--r--tests/auto/declarative_ui/tst_map_itemview.qml77
-rw-r--r--tests/auto/declarative_ui/tst_map_maptype.qml39
-rw-r--r--tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h45
-rw-r--r--tests/auto/maptype/tst_maptype.cpp72
-rw-r--r--tests/auto/nokia_services/routing/tst_routing.cpp3
-rw-r--r--tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp6
-rw-r--r--tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp6
-rw-r--r--tests/auto/qgeopath/tst_qgeopath.cpp27
-rw-r--r--tests/auto/qgeopolygon/qgeopolygon.pro8
-rw-r--r--tests/auto/qgeopolygon/tst_qgeopolygon.cpp402
-rw-r--r--tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp7
-rw-r--r--tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp8
17 files changed, 759 insertions, 69 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 5594b8b0..1229874a 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -62,9 +62,6 @@ qtHaveModule(location) {
declarative_geoshape
!mac: SUBDIRS += declarative_ui
-
- # QTBUG-60268
- boot2qt: SUBDIRS -= declarative_ui
}
}
@@ -78,6 +75,7 @@ SUBDIRS += \
qgeorectangle \
qgeocircle \
qgeopath \
+ qgeopolygon \
qgeocoordinate \
qgeolocation \
qgeopositioninfo \
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 8821f55e..f05b2c72 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -29,7 +29,7 @@
import QtQuick 2.0
import QtTest 1.0
import QtPositioning 5.5
-import QtLocation 5.9
+import QtLocation 5.10
import QtLocation.Test 5.6
Item {
@@ -298,6 +298,8 @@ Item {
//initial plugin values
compare(map.minimumZoomLevel, 0)
compare(map.maximumZoomLevel, 20)
+ compare(map.activeMapType.cameraCapabilities.minimumZoomLevel, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumZoomLevel, 20)
//Higher min level than curr zoom, should change curr zoom
map.minimumZoomLevel = 5
@@ -321,6 +323,8 @@ Item {
map.zoomLevel = 18
map.maximumZoomLevel = 16
compare(map.zoomLevel, 16)
+ compare(map.activeMapType.cameraCapabilities.minimumZoomLevel, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumZoomLevel, 20)
//reseting default
map.minimumZoomLevel = 0
@@ -336,6 +340,8 @@ Item {
//initial plugin values
compare(map.minimumTilt, 0)
compare(map.maximumTilt, 60)
+ compare(map.activeMapType.cameraCapabilities.minimumTilt, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumTilt, 60)
//Higher min level than curr tilt, should change curr tilt
map.minimumTilt = 5
@@ -343,6 +349,9 @@ Item {
compare(map.tilt, 5)
compare(map.minimumTilt, 5)
compare(map.maximumTilt, 18)
+ // Capabilities remain the same
+ compare(map.activeMapType.cameraCapabilities.minimumTilt, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumTilt, 60)
//Trying to set higher than max, max should be set.
map.maximumTilt = 61
@@ -376,6 +385,8 @@ Item {
//initial plugin values
compare(map.minimumFieldOfView, 45)
compare(map.maximumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.minimumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 45)
map.minimumFieldOfView = 5
map.maximumFieldOfView = 18
@@ -388,6 +399,8 @@ Item {
// camera caps are [1-179], user previously asked for [5-18]
compare(map.minimumFieldOfView, 5)
compare(map.maximumFieldOfView, 18)
+ compare(map.activeMapType.cameraCapabilities.minimumFieldOfView, 1)
+ compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 179)
map.fieldOfView = 4
compare(map.fieldOfView, 5)
@@ -426,6 +439,8 @@ Item {
compare(map.minimumFieldOfView, 45)
compare(map.maximumFieldOfView, 45)
compare(map.fieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.minimumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 45)
}
function test_zoom()
@@ -561,6 +576,59 @@ Item {
compare(mapTiltBearing.tilt, 25.0)
}
+ function test_map_setbearing()
+ {
+ var zeroCoord = QtPositioning.coordinate(0,0)
+ mapTiltBearing.bearing = 0.0
+ mapTiltBearing.tilt = 0.0
+ mapTiltBearing.zoomLevel = 3
+ mapTiltBearing.center = zeroCoord
+ compare(mapTiltBearing.bearing, 0.0)
+ compare(mapTiltBearing.tilt, 0.0)
+ compare(mapTiltBearing.zoomLevel, 3)
+ compare(mapTiltBearing.center, zeroCoord)
+
+ var fulcrum = QtPositioning.coordinate(20,-20)
+ var fulcrumPos = mapTiltBearing.fromCoordinate(fulcrum)
+ var bearing = 90.0
+ mapTiltBearing.setBearing(bearing, fulcrum)
+ var fulcrumPosAfter = mapTiltBearing.fromCoordinate(fulcrum)
+ compare(mapTiltBearing.bearing, bearing)
+ compare(fulcrumPos, fulcrumPosAfter)
+
+ // resetting
+ mapTiltBearing.center = coordinate1
+ mapTiltBearing.zoomLevel = 4
+ mapTiltBearing.bearing = 45.0
+ mapTiltBearing.tilt = 25.0
+ }
+
+ function test_map_align_coordinate_to_point()
+ {
+ var zeroCoord = QtPositioning.coordinate(0,0)
+ mapTiltBearing.bearing = 0.0
+ mapTiltBearing.tilt = 0.0
+ mapTiltBearing.zoomLevel = 3
+ mapTiltBearing.center = zeroCoord
+ compare(mapTiltBearing.bearing, 0.0)
+ compare(mapTiltBearing.tilt, 0.0)
+ compare(mapTiltBearing.zoomLevel, 3)
+ compare(mapTiltBearing.center, zeroCoord)
+
+ var coord = QtPositioning.coordinate(20,-20)
+ var point = Qt.point(400, 400)
+ mapTiltBearing.alignCoordinateToPoint(coord, point)
+ var coordAfter = mapTiltBearing.toCoordinate(point)
+ compare(coord.latitude, coordAfter.latitude)
+ compare(coord.longitude, coordAfter.longitude)
+
+ // resetting
+ mapTiltBearing.center = coordinate1
+ mapTiltBearing.zoomLevel = 4
+ mapTiltBearing.bearing = 45.0
+ mapTiltBearing.tilt = 25.0
+ }
+
function test_coordinate_conversion()
{
wait(1000)
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index c153411f..ba10d12e 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -170,7 +170,7 @@ Item {
map.center.longitude = 11
mousePress(page, 0, 50)
for (var i = 0; i < 50; i += 5) {
- wait(20)
+ wait(25)
mouseMove(page, 0, (50 + i), 0, Qt.LeftButton);
}
mouseRelease(page, 0, 100)
@@ -207,7 +207,7 @@ Item {
map.center.longitude = 11
mousePress(page, 10, 95)
for (var i = 45; i > 0; i -= 5) {
- wait(20)
+ wait(25)
mouseMove(page, 10, (50 + i), 0, Qt.LeftButton);
}
mouseRelease(page, 10, 50)
@@ -242,7 +242,7 @@ Item {
mousePress(page, pos, pos)
for (var i = pos; i < 50; i += 5) {
pos = i
- wait(20)
+ wait(25)
mouseMove(page, pos, pos, 0, Qt.LeftButton);
}
mouseRelease(page, pos, pos)
@@ -263,7 +263,7 @@ Item {
map.center.longitude = 50
mousePress(page, 0, 0)
for (var i = 0; i < 50; i += 5) {
- wait(20)
+ wait(25)
mouseMove(page, i, i, 0, Qt.LeftButton);
}
mouseRelease(page, 50, 50)
@@ -290,7 +290,7 @@ Item {
map.center.longitude = 50
mousePress(page, 0, 0)
for (var i = 0; i < 50; i += 5) {
- wait(20)
+ wait(25)
mouseMove(page, i, i, 0, Qt.LeftButton);
}
mouseRelease(page, 50, 50)
@@ -324,7 +324,7 @@ Item {
map.center.longitude = 50
mousePress(page, 0, 0)
for (var i = 0; i < 50; i += 5) {
- wait(20)
+ wait(25)
mouseMove(page, i, i, 0, Qt.LeftButton);
}
mouseRelease(page, 50, 50)
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index 80225c16..e7695288 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -157,6 +157,17 @@ Item {
}
MapPolyline {
+ id: polylineForSetpath
+ line.width: 3
+ path: [
+ { latitude: 20, longitude: 175 },
+ { latitude: 20, longitude: -175 },
+ { latitude: 10, longitude: -175 },
+ { latitude: 10, longitude: 175 }
+ ]
+ }
+
+ MapPolyline {
id: extMapPolylineDateline
line.width : 3
path: [
@@ -395,6 +406,33 @@ Item {
verify(extMapPolyline.path.length == 0)
}
+ function test_polyline_setpath()
+ {
+ compare (polylineForSetpath.line.width, 3.0)
+ verify(polylineForSetpath.path.length == 4)
+ compare(polylineForSetpath.path[0], QtPositioning.coordinate(20, 175))
+ compare(polylineForSetpath.path[3], QtPositioning.coordinate(10, 175))
+
+
+ var originalPath = QtPositioning.shapeToPath(polylineForSetpath.geoShape)
+
+ var geoPath = QtPositioning.path([ { latitude: 20, longitude: -15 },
+ { latitude: 20, longitude: -5 },
+ { latitude: 10, longitude: -5 },
+ { latitude: 10, longitude: -15 },
+ { latitude: 10, longitude: -105 } ], 50)
+
+ polylineForSetpath.setPath(geoPath)
+ verify(polylineForSetpath.path.length == 5)
+ compare(polylineForSetpath.path[0], QtPositioning.coordinate(20, -15))
+ compare(polylineForSetpath.path[3], QtPositioning.coordinate(10, -15))
+
+ polylineForSetpath.setPath(originalPath)
+ verify(polylineForSetpath.path.length == 4)
+ compare(polylineForSetpath.path[0], QtPositioning.coordinate(20, 175))
+ compare(polylineForSetpath.path[3], QtPositioning.coordinate(10, 175))
+ }
+
/*
(0,0) ---------------------------------------------------- (600,0)
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index adf9c347..8d1ee42b 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -572,13 +572,13 @@ Item {
}
function calculate_fit_circle_bounds() {
- var circleDiagonal = Math.sqrt(2 * fitCircle.radius * fitCircle.radius)
+ var circleDiagonal = Math.sqrt(2) * fitCircle.radius
fitCircleTopLeft = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,-45)
fitCircleBottomRight = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,135)
}
function calculate_bounds(){
- var circleDiagonal = Math.sqrt(2 * preMapCircle.radius * preMapCircle.radius)
+ var circleDiagonal = Math.sqrt(2) * preMapCircle.radius
var itemTopLeft = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,-45)
var itemBottomRight = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,135)
diff --git a/tests/auto/declarative_ui/tst_map_itemview.qml b/tests/auto/declarative_ui/tst_map_itemview.qml
index bbd70c8e..ff24e7af 100644
--- a/tests/auto/declarative_ui/tst_map_itemview.qml
+++ b/tests/auto/declarative_ui/tst_map_itemview.qml
@@ -46,6 +46,35 @@ Item {
&& mapForTestingListModel.mapReady
&& mapForTestingRouteModel.mapReady
+ MapItemView {
+ id: routeItemViewExtra
+ model: routeModel
+ delegate: Component {
+ MapRoute {
+ route: routeData
+ }
+ }
+ }
+
+ MapItemView {
+ id: listModelItemViewExtra
+ model: ListModel {
+ id: testingListModelExtra
+ ListElement { lat: 11; lon: 31 }
+ ListElement { lat: 12; lon: 32 }
+ ListElement { lat: 13; lon: 33 }
+ }
+ delegate: Component {
+ MapCircle {
+ radius: 1500000
+ center {
+ latitude: lat
+ longitude: lon
+ }
+ }
+ }
+ }
+
Map {
id: map
objectName: 'staticallyDeclaredMap'
@@ -432,6 +461,42 @@ Item {
testingListModel.clear()
compare(mapForTestingListModel.mapItems.length, 0)
+
+ // Repopulating the model with initial data
+ testingListModel.append({ "lat": 11, "lon": 31 })
+ testingListModel.append({ "lat": 12, "lon": 32 })
+ testingListModel.append({ "lat": 13, "lon": 33 })
+ }
+
+ function test_add_extra_listmodel() {
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
+ mapForTestingListModel.addMapItemView(listModelItemViewExtra)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 6)
+ mapForTestingListModel.removeMapItemView(listModelItemViewExtra)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
+ mapForTestingListModel.addMapItemView(listModelItemViewExtra)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 6)
+ mapForTestingListModel.removeMapItemView(listModelItemView)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
+ mapForTestingListModel.removeMapItemView(listModelItemViewExtra)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 0)
+ mapForTestingListModel.addMapItemView(listModelItemViewExtra)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
+ testingListModelExtra.clear()
+ tryCompare(mapForTestingListModel, "mapItemsLength", 0)
+ mapForTestingListModel.removeMapItemView(listModelItemViewExtra)
+
+ mapForTestingListModel.addMapItemView(listModelItemView)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
+
+ testingListModelExtra.append({ "lat": 11, "lon": 31 })
+ testingListModelExtra.append({ "lat": 12, "lon": 32 })
+ testingListModelExtra.append({ "lat": 13, "lon": 33 })
+
+ mapForTestingListModel.addMapItemView(listModelItemViewExtra)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 6)
+ mapForTestingListModel.removeMapItemView(listModelItemViewExtra)
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
}
function test_routemodel() {
@@ -451,6 +516,18 @@ Item {
routeQuery.numberAlternativeRoutes = 3
routeModel.update();
tryCompare(mapForTestingRouteModel, "mapItemsLength", 3)
+
+ // Test adding the extra mapitemview fed from the same route model
+ mapForTestingRouteModel.addMapItemView(routeItemViewExtra)
+ tryCompare(mapForTestingRouteModel, "mapItemsLength", 6)
+ routeQuery.numberAlternativeRoutes = 4
+ routeModel.update();
+ tryCompare(mapForTestingRouteModel, "mapItemsLength", 8)
+ routeQuery.numberAlternativeRoutes = 3
+ routeModel.update();
+ mapForTestingRouteModel.removeMapItemView(routeItemViewExtra)
+ tryCompare(mapForTestingRouteModel, "mapItemsLength", 3)
+
mapForTestingRouteModel.addMapItem(externalCircle2)
compare(mapForTestingRouteModel.mapItems.length, 4)
compare(mapForTestingRouteModel.mapItems[3], externalCircle2)
diff --git a/tests/auto/declarative_ui/tst_map_maptype.qml b/tests/auto/declarative_ui/tst_map_maptype.qml
index 1de30439..f4564ea6 100644
--- a/tests/auto/declarative_ui/tst_map_maptype.qml
+++ b/tests/auto/declarative_ui/tst_map_maptype.qml
@@ -28,7 +28,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtLocation 5.6
+import QtLocation 5.10
Item{
id: page
@@ -122,6 +122,13 @@ Item{
compare(map.minimumFieldOfView, 45)
compare(map.maximumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.minimumZoomLevel, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumZoomLevel, 20)
+ compare(map.activeMapType.cameraCapabilities.minimumTilt, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumTilt, 60)
+ compare(map.activeMapType.cameraCapabilities.minimumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 45)
+
tryCompare(minimumZoomLevelChangedSpy, "count", 0)
tryCompare(maximumZoomLevelChangedSpy, "count", 0)
tryCompare(minimumTiltChangedSpy, "count", 0)
@@ -139,6 +146,13 @@ Item{
compare(map.minimumFieldOfView, 45)
compare(map.maximumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.minimumZoomLevel, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumZoomLevel, 20)
+ compare(map.activeMapType.cameraCapabilities.minimumTilt, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumTilt, 60)
+ compare(map.activeMapType.cameraCapabilities.minimumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 45)
+
tryCompare(minimumZoomLevelChangedSpy, "count", 0)
tryCompare(maximumZoomLevelChangedSpy, "count", 0)
tryCompare(minimumTiltChangedSpy, "count", 0)
@@ -156,6 +170,13 @@ Item{
compare(map.minimumFieldOfView, 1)
compare(map.maximumFieldOfView, 179)
+ compare(map.activeMapType.cameraCapabilities.minimumZoomLevel, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumZoomLevel, 19)
+ compare(map.activeMapType.cameraCapabilities.minimumTilt, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumTilt, 80)
+ compare(map.activeMapType.cameraCapabilities.minimumFieldOfView, 1)
+ compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 179)
+
tryCompare(minimumZoomLevelChangedSpy, "count", 0)
tryCompare(maximumZoomLevelChangedSpy, "count", 1)
tryCompare(minimumTiltChangedSpy, "count", 0)
@@ -173,13 +194,29 @@ Item{
compare(map.minimumFieldOfView, 45)
compare(map.maximumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.minimumZoomLevel, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumZoomLevel, 20)
+ compare(map.activeMapType.cameraCapabilities.minimumTilt, 0)
+ compare(map.activeMapType.cameraCapabilities.maximumTilt, 60)
+ compare(map.activeMapType.cameraCapabilities.minimumFieldOfView, 45)
+ compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 45)
+
tryCompare(minimumZoomLevelChangedSpy, "count", 0)
tryCompare(maximumZoomLevelChangedSpy, "count", 2)
tryCompare(minimumTiltChangedSpy, "count", 0)
tryCompare(maximumTiltChangedSpy, "count", 2)
tryCompare(minimumFieldOfViewChangedSpy, "count", 2)
tryCompare(maximumFieldOfViewChangedSpy, "count", 2)
+ }
+ function test_maptype_metadata()
+ {
+ map.activeMapType = map.supportedMapTypes[0]
+ compare(Object.keys(map.activeMapType.metadata).length, 0)
+
+ map.activeMapType = map.supportedMapTypes[3]
+ compare(Object.keys(map.activeMapType.metadata).length, 1)
+ compare(map.activeMapType.metadata['foo'], 42)
}
}
}
diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
index 2fcf654d..297be0d5 100644
--- a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
@@ -64,14 +64,27 @@ public:
const QByteArray pluginName = "qmlgeo.test.plugin";
QList<QGeoMapType> mapTypes;
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("StreetMap"), tr("StreetMap"), false, false, 1, pluginName);
- mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("SatelliteMapDay"), tr("SatelliteMapDay"), false, false, 2, pluginName);
- mapTypes << QGeoMapType(QGeoMapType::CycleMap, tr("CycleMap"), tr("CycleMap"), false, false, 3, pluginName);
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, tr("AlternateCameraCapabilities"), tr("AlternateCameraCapabilities"), false, false, 4, pluginName);
+
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("StreetMap"), tr("StreetMap"), false, false, 1, pluginName, capabilities);
+ mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("SatelliteMapDay"), tr("SatelliteMapDay"), false, false, 2, pluginName, capabilities);
+ mapTypes << QGeoMapType(QGeoMapType::CycleMap, tr("CycleMap"), tr("CycleMap"), false, false, 3, pluginName, capabilities);
+
+ QGeoCameraCapabilities capabilities4;
+ capabilities4.setMinimumZoomLevel(0.0);
+ capabilities4.setMaximumZoomLevel(19.0);
+ capabilities4.setSupportsBearing(true);
+ capabilities4.setSupportsTilting(true);
+ capabilities4.setMinimumTilt(0);
+ capabilities4.setMaximumTilt(80);
+ capabilities4.setMinimumFieldOfView(1);
+ capabilities4.setMaximumFieldOfView(179);
+ QVariantMap meta;
+ meta["foo"] = 42;
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, tr("AlternateCameraCapabilities"), tr("AlternateCameraCapabilities"), false, false, 4, pluginName, capabilities4, meta);
if (parameters.contains(QStringLiteral("extraMapTypeName"))) {
QString extraMapTypeName = parameters.value(QStringLiteral("extraMapTypeName")).toString();
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, extraMapTypeName, extraMapTypeName, false, false, 5, pluginName);
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, extraMapTypeName, extraMapTypeName, false, false, 5, pluginName, capabilities);
}
setSupportedMapTypes(mapTypes);
@@ -97,28 +110,6 @@ public:
{
return new QGeoTiledMapTest(this);
}
-
- QGeoCameraCapabilities cameraCapabilities(int mapId) const Q_DECL_OVERRIDE
- {
- switch (mapId) {
- case 4:
- {
- QGeoCameraCapabilities capabilities;
- capabilities.setMinimumZoomLevel(0.0);
- capabilities.setMaximumZoomLevel(19.0);
- capabilities.setSupportsBearing(true);
- capabilities.setSupportsTilting(true);
- capabilities.setMinimumTilt(0);
- capabilities.setMaximumTilt(80);
- capabilities.setMinimumFieldOfView(1);
- capabilities.setMaximumFieldOfView(179);
- return capabilities;
- }
- default:
- return QGeoMappingManagerEngine::cameraCapabilities(mapId);
- }
- }
-
};
#endif
diff --git a/tests/auto/maptype/tst_maptype.cpp b/tests/auto/maptype/tst_maptype.cpp
index 43d3175c..f571158e 100644
--- a/tests/auto/maptype/tst_maptype.cpp
+++ b/tests/auto/maptype/tst_maptype.cpp
@@ -28,6 +28,7 @@
#include <QtCore/QString>
#include <QtTest/QtTest>
+#include <QVariantMap>
#include <QtLocation/private/qgeomaptype_p.h>
@@ -52,9 +53,18 @@ tst_MapType::tst_MapType() {}
void tst_MapType::constructorTest()
{
+ QGeoCameraCapabilities capabilities;
+ capabilities.setMinimumZoomLevel(0.0);
+ capabilities.setMaximumZoomLevel(20.0);
+ capabilities.setSupportsBearing(true);
+ capabilities.setSupportsTilting(true);
+ capabilities.setMinimumTilt(0);
+ capabilities.setMaximumTilt(60);
+ capabilities.setMinimumFieldOfView(20);
+ capabilities.setMaximumFieldOfView(90);
const QByteArray pluginName = "tst_MapType";
QGeoMapType *testObjPtr = new QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street map"),
- QStringLiteral("map description"), true, true, 1, pluginName);
+ QStringLiteral("map description"), true, true, 1, pluginName, capabilities);
QVERIFY(testObjPtr);
QCOMPARE(testObjPtr->style(), QGeoMapType::StreetMap);
QCOMPARE(testObjPtr->name(), QStringLiteral("street map"));
@@ -63,6 +73,8 @@ void tst_MapType::constructorTest()
QVERIFY(testObjPtr->night());
QCOMPARE(testObjPtr->mapId(), 1);
QCOMPARE(testObjPtr->pluginName(), pluginName);
+ QCOMPARE(testObjPtr->cameraCapabilities(), capabilities);
+ QCOMPARE(testObjPtr->metadata(), QVariantMap());
delete testObjPtr;
testObjPtr = new QGeoMapType();
@@ -73,6 +85,7 @@ void tst_MapType::constructorTest()
QVERIFY2(!testObjPtr->night(), "Wrong default value");
QCOMPARE(testObjPtr->mapId(), 0);
QCOMPARE(testObjPtr->pluginName(), QByteArrayLiteral(""));
+ QCOMPARE(testObjPtr->cameraCapabilities(), QGeoCameraCapabilities());
delete testObjPtr;
}
@@ -83,57 +96,82 @@ void tst_MapType::comparison_data()
QTest::addColumn<bool>("expected");
const QByteArray pluginName = "tst_MapType";
+ QGeoCameraCapabilities capabilities;
+ capabilities.setMinimumZoomLevel(0.0);
+ capabilities.setMaximumZoomLevel(20.0);
+ capabilities.setSupportsBearing(true);
+ capabilities.setSupportsTilting(true);
+ capabilities.setMinimumTilt(0);
+ capabilities.setMaximumTilt(60);
+ capabilities.setMinimumFieldOfView(20);
+ capabilities.setMaximumFieldOfView(90);
+ QGeoCameraCapabilities capabilities2 = capabilities;
+ capabilities2.setMaximumFieldOfView(80);
QTest::newRow("null") << QGeoMapType() << QGeoMapType() << true;
QTest::newRow("equal") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< true;
QTest::newRow("style") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::TerrainMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< false;
QTest::newRow("name") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("different name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< false;
QTest::newRow("description") << QGeoMapType(QGeoMapType::StreetMap,
QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::StreetMap,
QStringLiteral("street name"),
- QStringLiteral("different desc"), false, false, 42, pluginName)
+ QStringLiteral("different desc"), false, false, 42, pluginName, capabilities)
<< false;
QTest::newRow("mobile") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), true, false, 42, pluginName)
+ QStringLiteral("street desc"), true, false, 42, pluginName, capabilities)
<< false;
QTest::newRow("night") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, true, 42, pluginName)
+ QStringLiteral("street desc"), false, true, 42, pluginName, capabilities)
<< false;
QTest::newRow("id") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 99, pluginName)
+ QStringLiteral("street desc"), false, false, 99, pluginName, capabilities)
<< false;
QTest::newRow("plugin_name") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, pluginName)
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42, QByteArrayLiteral("abc"))
+ QStringLiteral("street desc"), false, false, 42, QByteArrayLiteral("abc"), capabilities)
+ << false;
+
+ QTest::newRow("camera_capabilities") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
+ << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities2)
+ << false;
+
+ QVariantMap metadata;
+ metadata["foo"] = 42;
+ QTest::newRow("metadata") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities)
+ << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
+ QStringLiteral("street desc"), false, false, 42, pluginName, capabilities, metadata)
<< false;
}
diff --git a/tests/auto/nokia_services/routing/tst_routing.cpp b/tests/auto/nokia_services/routing/tst_routing.cpp
index c214556f..833c95af 100644
--- a/tests/auto/nokia_services/routing/tst_routing.cpp
+++ b/tests/auto/nokia_services/routing/tst_routing.cpp
@@ -234,7 +234,8 @@ void tst_nokia_routing::calculateRoute()
m_routingManager->calculateRoute(m_dummyRequest);
m_replyUnowned->complete();
m_replyUnowned = 0;
- QTRY_VERIFY_WITH_TIMEOUT(m_calculationDone, 100);
+ // Timeout of 200ms is required for slow targets (e.g. Qemu)
+ QTRY_VERIFY_WITH_TIMEOUT(m_calculationDone, 200);
}
void tst_nokia_routing::onReply(QGeoRouteReply* reply)
diff --git a/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp b/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp
index 75c1eecb..4cd83446 100644
--- a/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp
+++ b/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp
@@ -720,14 +720,14 @@ private slots:
QGeoAreaMonitorInfo info;
QTest::newRow("uninitialized") << info << 45
<< QString("QGeoAreaMonitorInfo(\"\", QGeoShape(Unknown), "
- "persistent: false, expiry: QDateTime( Qt::TimeSpec(LocalTime))) 45");
+ "persistent: false, expiry: QDateTime(Invalid)) 45");
info.setArea(QGeoRectangle());
info.setPersistent(true);
info.setName("RectangleAreaMonitor");
QTest::newRow("Rectangle Test") << info << 45
<< QString("QGeoAreaMonitorInfo(\"RectangleAreaMonitor\", QGeoShape(Rectangle), "
- "persistent: true, expiry: QDateTime( Qt::TimeSpec(LocalTime))) 45");
+ "persistent: true, expiry: QDateTime(Invalid)) 45");
info = QGeoAreaMonitorInfo();
info.setArea(QGeoCircle());
@@ -738,7 +738,7 @@ private slots:
info.setNotificationParameters(map);
QTest::newRow("Circle Test") << info << 45
<< QString("QGeoAreaMonitorInfo(\"CircleAreaMonitor\", QGeoShape(Circle), "
- "persistent: false, expiry: QDateTime( Qt::TimeSpec(LocalTime))) 45");
+ "persistent: false, expiry: QDateTime(Invalid)) 45");
// we ignore any further QDateTime related changes to avoid depending on QDateTime related
// failures in case its QDebug string changes
diff --git a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
index 0c664ba6..49c4657e 100644
--- a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
+++ b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
@@ -150,7 +150,7 @@ void tst_QGeoCameraTiles::tilesPlugin()
ct.setTileSize(16);
ct.setCameraData(camera);
ct.setScreenSize(QSize(32, 32));
- ct.setMapType(QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1, QByteArrayLiteral("")));
+ ct.setMapType(QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1, QByteArrayLiteral(""), QGeoCameraCapabilities()));
QSet<QGeoTileSpec> tiles1 = ct.createTiles();
@@ -202,7 +202,7 @@ void tst_QGeoCameraTiles::tilesMapType()
QSet<QGeoTileSpec> tiles1 = ct.createTiles();
- QGeoMapType mapType1 = QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1, QByteArrayLiteral(""));
+ QGeoMapType mapType1 = QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1, QByteArrayLiteral(""), QGeoCameraCapabilities());
ct.setMapType(mapType1);
QSet<QGeoTileSpec> tiles2 = ct.createTiles();
@@ -220,7 +220,7 @@ void tst_QGeoCameraTiles::tilesMapType()
QCOMPARE(tiles2, tiles2_check);
- QGeoMapType mapType2 = QGeoMapType(QGeoMapType::StreetMap, "satellite map", "satellite map", false, false, 2, QByteArrayLiteral(""));
+ QGeoMapType mapType2 = QGeoMapType(QGeoMapType::StreetMap, "satellite map", "satellite map", false, false, 2, QByteArrayLiteral(""), QGeoCameraCapabilities());
ct.setMapType(mapType2);
QSet<QGeoTileSpec> tiles3 = ct.createTiles();
diff --git a/tests/auto/qgeopath/tst_qgeopath.cpp b/tests/auto/qgeopath/tst_qgeopath.cpp
index 9244394a..86ff137d 100644
--- a/tests/auto/qgeopath/tst_qgeopath.cpp
+++ b/tests/auto/qgeopath/tst_qgeopath.cpp
@@ -47,6 +47,7 @@ private slots:
void path();
void width();
+ void size();
void translate_data();
void translate();
@@ -188,6 +189,32 @@ void tst_QGeoPath::width()
QCOMPARE(p.width(), qreal(10.0));
}
+void tst_QGeoPath::size()
+{
+ QList<QGeoCoordinate> coords;
+
+ QGeoPath p1(coords, 3);
+ QCOMPARE(p1.size(), coords.size());
+
+ coords.append(QGeoCoordinate(1,1));
+ QGeoPath p2(coords, 3);
+ QCOMPARE(p2.size(), coords.size());
+
+ coords.append(QGeoCoordinate(2,2));
+ QGeoPath p3(coords, 3);
+ QCOMPARE(p3.size(), coords.size());
+
+ coords.append(QGeoCoordinate(3,0));
+ QGeoPath p4(coords, 3);
+ QCOMPARE(p4.size(), coords.size());
+
+ p4.removeCoordinate(2);
+ QCOMPARE(p4.size(), coords.size() - 1);
+
+ p4.removeCoordinate(coords.first());
+ QCOMPARE(p4.size(), coords.size() - 2);
+}
+
void tst_QGeoPath::translate_data()
{
QTest::addColumn<QGeoCoordinate>("c1");
diff --git a/tests/auto/qgeopolygon/qgeopolygon.pro b/tests/auto/qgeopolygon/qgeopolygon.pro
new file mode 100644
index 00000000..f6314ca4
--- /dev/null
+++ b/tests/auto/qgeopolygon/qgeopolygon.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+CONFIG += testcase
+TARGET = tst_qgeopolygon
+
+SOURCES += \
+ tst_qgeopolygon.cpp
+
+QT += positioning testlib
diff --git a/tests/auto/qgeopolygon/tst_qgeopolygon.cpp b/tests/auto/qgeopolygon/tst_qgeopolygon.cpp
new file mode 100644
index 00000000..12e39f0f
--- /dev/null
+++ b/tests/auto/qgeopolygon/tst_qgeopolygon.cpp
@@ -0,0 +1,402 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtPositioning/QGeoCoordinate>
+#include <QtPositioning/QGeoRectangle>
+#include <QtPositioning/QGeoPolygon>
+
+QT_USE_NAMESPACE
+
+class tst_QGeoPolygon : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void defaultConstructor();
+ void listConstructor();
+ void assignment();
+
+ void comparison();
+ void type();
+
+ void path();
+ void size();
+
+ void translate_data();
+ void translate();
+
+ void valid_data();
+ void valid();
+
+ void contains_data();
+ void contains();
+
+ void boundingGeoRectangle_data();
+ void boundingGeoRectangle();
+
+ void extendShape();
+ void extendShape_data();
+};
+
+void tst_QGeoPolygon::defaultConstructor()
+{
+ QGeoPolygon p;
+ QVERIFY(!p.path().size());
+ QVERIFY(!p.size());
+ QVERIFY(!p.isValid());
+ QVERIFY(p.isEmpty());
+}
+
+void tst_QGeoPolygon::listConstructor()
+{
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ QGeoPolygon p2(coords);
+ QCOMPARE(p2.path().size(), 2);
+ QCOMPARE(p2.size(), 2);
+ QVERIFY(!p2.isValid()); // a polygon can't have only 2 coords
+ QVERIFY(!p2.isEmpty());
+
+ coords.append(QGeoCoordinate(3,0));
+
+ QGeoPolygon p(coords);
+ QCOMPARE(p.path().size(), 3);
+ QCOMPARE(p.size(), 3);
+ QVERIFY(p.isValid());
+ QVERIFY(!p.isEmpty());
+
+
+ for (const QGeoCoordinate &c : coords) {
+ QCOMPARE(p.path().contains(c), true);
+ QCOMPARE(p.containsCoordinate(c), true);
+ }
+}
+
+void tst_QGeoPolygon::assignment()
+{
+ QGeoPolygon p1;
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ coords.append(QGeoCoordinate(3,0));
+ QGeoPolygon p2(coords);
+
+ QVERIFY(p1 != p2);
+
+ p1 = p2;
+ QCOMPARE(p1.path(), coords);
+ QCOMPARE(p1, p2);
+
+ // Assign c1 to an area
+ QGeoShape area = p1;
+ QCOMPARE(area.type(), p1.type());
+ QVERIFY(area == p1);
+
+ // Assign the area back to a polygon
+ QGeoPolygon p3 = area;
+ QCOMPARE(p3.path(), coords);
+ QVERIFY(p3 == p1);
+
+ // Check that the copy is not modified when modifying the original.
+ p1.addCoordinate(QGeoCoordinate(4,0));
+ QVERIFY(p3 != p1);
+}
+
+void tst_QGeoPolygon::comparison()
+{
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ coords.append(QGeoCoordinate(3,0));
+ QList<QGeoCoordinate> coords2;
+ coords2.append(QGeoCoordinate(3,1));
+ coords2.append(QGeoCoordinate(4,2));
+ coords2.append(QGeoCoordinate(3,0));
+ QGeoPolygon c1(coords);
+ QGeoPolygon c2(coords);
+ QGeoPolygon c3(coords2);
+
+ QVERIFY(c1 == c2);
+ QVERIFY(!(c1 != c2));
+
+ QVERIFY(!(c1 == c3));
+ QVERIFY(c1 != c3);
+
+ QVERIFY(!(c2 == c3));
+ QVERIFY(c2 != c3);
+
+ QGeoRectangle b1(QGeoCoordinate(20,20),QGeoCoordinate(10,30));
+ QVERIFY(!(c1 == b1));
+ QVERIFY(c1 != b1);
+
+ QGeoShape *c2Ptr = &c2;
+ QVERIFY(c1 == *c2Ptr);
+ QVERIFY(!(c1 != *c2Ptr));
+
+ QGeoShape *c3Ptr = &c3;
+ QVERIFY(!(c1 == *c3Ptr));
+ QVERIFY(c1 != *c3Ptr);
+}
+
+void tst_QGeoPolygon::type()
+{
+ QGeoPolygon c;
+ QCOMPARE(c.type(), QGeoShape::PolygonType);
+}
+
+void tst_QGeoPolygon::path()
+{
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ coords.append(QGeoCoordinate(3,0));
+
+ QGeoPolygon p;
+ p.setPath(coords);
+ QCOMPARE(p.path().size(), 3);
+ QCOMPARE(p.size(), 3);
+
+ for (const QGeoCoordinate &c : coords) {
+ QCOMPARE(p.path().contains(c), true);
+ QCOMPARE(p.containsCoordinate(c), true);
+ }
+}
+
+void tst_QGeoPolygon::size()
+{
+ QList<QGeoCoordinate> coords;
+
+ QGeoPolygon p1(coords);
+ QCOMPARE(p1.size(), coords.size());
+
+ coords.append(QGeoCoordinate(1,1));
+ QGeoPolygon p2(coords);
+ QCOMPARE(p2.size(), coords.size());
+
+ coords.append(QGeoCoordinate(2,2));
+ QGeoPolygon p3(coords);
+ QCOMPARE(p3.size(), coords.size());
+
+ coords.append(QGeoCoordinate(3,0));
+ QGeoPolygon p4(coords);
+ QCOMPARE(p4.size(), coords.size());
+
+ p4.removeCoordinate(2);
+ QCOMPARE(p4.size(), coords.size() - 1);
+
+ p4.removeCoordinate(coords.first());
+ QCOMPARE(p4.size(), coords.size() - 2);
+}
+
+void tst_QGeoPolygon::translate_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<double>("lat");
+ QTest::addColumn<double>("lon");
+
+ QTest::newRow("Simple") << QGeoCoordinate(1,1) << QGeoCoordinate(2,2) <<
+ QGeoCoordinate(3,0) << 5.0 << 4.0;
+ QTest::newRow("Backward") << QGeoCoordinate(1,1) << QGeoCoordinate(2,2) <<
+ QGeoCoordinate(3,0) << -5.0 << -4.0;
+}
+
+void tst_QGeoPolygon::translate()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(double, lat);
+ QFETCH(double, lon);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPolygon p(coords);
+
+ p.translate(lat, lon);
+
+ for (int i = 0; i < p.path().size(); i++) {
+ QCOMPARE(coords[i].latitude(), p.path()[i].latitude() - lat );
+ QCOMPARE(coords[i].longitude(), p.path()[i].longitude() - lon );
+ }
+}
+
+void tst_QGeoPolygon::valid_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("empty coords") << QGeoCoordinate() << QGeoCoordinate() << QGeoCoordinate() << false;
+ QTest::newRow("invalid coord") << QGeoCoordinate(50, 50) << QGeoCoordinate(60, 60) << QGeoCoordinate(700, 700) << false;
+ QTest::newRow("good") << QGeoCoordinate(10, 10) << QGeoCoordinate(11, 11) << QGeoCoordinate(10, 12) << true;
+}
+
+void tst_QGeoPolygon::valid()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(bool, valid);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPolygon p(coords);
+
+ QCOMPARE(p.isValid(), valid);
+
+ QGeoShape area = p;
+ QCOMPARE(area.isValid(), valid);
+}
+
+void tst_QGeoPolygon::contains_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<QGeoCoordinate>("probe");
+ QTest::addColumn<bool>("result");
+
+ QList<QGeoCoordinate> c;
+ c.append(QGeoCoordinate(1,1));
+ c.append(QGeoCoordinate(2,2));
+ c.append(QGeoCoordinate(3,0));
+
+ QTest::newRow("One of the points") << c[0] << c[1] << c[2] << QGeoCoordinate(2, 2) << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << QGeoCoordinate(0.8, 0.8) << false;
+ QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << QGeoCoordinate(0.8, 0.8) << false;
+ QTest::newRow("Inside") << c[0] << c[1] << c[2] << QGeoCoordinate(2.0, 1.0) << true;
+}
+
+void tst_QGeoPolygon::contains()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(QGeoCoordinate, probe);
+ QFETCH(bool, result);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPolygon p(coords);
+
+ QCOMPARE(p.contains(probe), result);
+
+ QGeoShape area = p;
+ QCOMPARE(area.contains(probe), result);
+}
+
+void tst_QGeoPolygon::boundingGeoRectangle_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<QGeoCoordinate>("probe");
+ QTest::addColumn<bool>("result");
+
+ QList<QGeoCoordinate> c;
+ c.append(QGeoCoordinate(1,1));
+ c.append(QGeoCoordinate(2,2));
+ c.append(QGeoCoordinate(3,0));
+
+ QTest::newRow("One of the points") << c[0] << c[1] << c[2] << QGeoCoordinate(2, 2) << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << QGeoCoordinate(0, 0) << false;
+ QTest::newRow("Inside the bounds") << c[0] << c[1] << c[2] << QGeoCoordinate(1, 0) << true;
+ QTest::newRow("Inside the bounds") << c[0] << c[1] << c[2] << QGeoCoordinate(1.1, 0.1) << true;
+}
+
+void tst_QGeoPolygon::boundingGeoRectangle()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(QGeoCoordinate, probe);
+ QFETCH(bool, result);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPolygon p(coords);
+
+ QGeoRectangle box = p.boundingGeoRectangle();
+ QCOMPARE(box.contains(probe), result);
+}
+
+void tst_QGeoPolygon::extendShape()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(QGeoCoordinate, probe);
+ QFETCH(bool, before);
+ QFETCH(bool, after);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPolygon p(coords);
+
+
+ QCOMPARE(p.contains(probe), before);
+ p.extendShape(probe);
+ QCOMPARE(p.contains(probe), after);
+}
+
+void tst_QGeoPolygon::extendShape_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<QGeoCoordinate>("probe");
+ QTest::addColumn<bool>("before");
+ QTest::addColumn<bool>("after");
+
+ QList<QGeoCoordinate> c;
+ c.append(QGeoCoordinate(1,1));
+ c.append(QGeoCoordinate(2,2));
+ c.append(QGeoCoordinate(3,0));
+
+ QTest::newRow("One of the points") << c[0] << c[1] << c[2] << QGeoCoordinate(2, 2) << true << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << QGeoCoordinate(0, 0) << false << true;
+ QTest::newRow("Contained point") << c[0] << c[1] << c[2] << QGeoCoordinate(2.0, 1.0) << true << true;
+}
+
+QTEST_MAIN(tst_QGeoPolygon)
+#include "tst_qgeopolygon.moc"
diff --git a/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp b/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp
index ae0083ba..14b40eb6 100644
--- a/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp
+++ b/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp
@@ -113,6 +113,7 @@ void tst_QGeoTiledMap::initTestCase()
m_map.reset(static_cast<QGeoTiledMapTest*>(mappingManager->createMap(this)));
QVERIFY(m_map);
m_map->setViewportSize(QSize(256, 256));
+ m_map->setActiveMapType(m_map->m_engine->supportedMapTypes().first());
m_fetcher = static_cast<QGeoTileFetcherTest*>(m_map->m_engine->tileFetcher());
m_tilesCounter.reset(new FetchTileCounter());
connect(m_fetcher, SIGNAL(tileFetched(const QGeoTileSpec&)), m_tilesCounter.data(), SLOT(tileFetched(const QGeoTileSpec&)));
@@ -133,6 +134,8 @@ void tst_QGeoTiledMap::fetchTiles()
//prev_visible
camera.setZoomLevel(zoomLevel-1);
+ // Delay needed on slow targets (e.g. Qemu)
+ QTest::qWait(10);
m_map->clearData();
m_tilesCounter->m_tiles.clear();
m_map->setCameraData(camera);
@@ -141,6 +144,8 @@ void tst_QGeoTiledMap::fetchTiles()
//visible + prefetch
camera.setZoomLevel(zoomLevel);
+ // Delay needed on slow targets (e.g. Qemu)
+ QTest::qWait(10);
m_map->clearData();
m_tilesCounter->m_tiles.clear();
m_map->setCameraData(camera);
@@ -154,6 +159,8 @@ void tst_QGeoTiledMap::fetchTiles()
//next visible
camera.setZoomLevel(zoomLevel + 1);
+ // Delay needed on slow targets (e.g. Qemu)
+ QTest::qWait(10);
m_map->clearData();
m_tilesCounter->m_tiles.clear();
m_map->setCameraData(camera);
diff --git a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
index e0004596..e4bb755d 100644
--- a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
+++ b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
@@ -41,8 +41,6 @@ QDeclarativeLocationTestModel::QDeclarativeLocationTestModel(QObject *parent):
crazyLevel_(0),
crazyMode_(false)
{
- // seed crazy random generator
- qsrand(QTime(0,0,0).secsTo(QTime::currentTime()) + QCoreApplication::applicationPid());
timer_.setSingleShot(true);
connect(&timer_, SIGNAL(timeout()), this, SLOT(timerFired()));
}
@@ -63,7 +61,7 @@ void QDeclarativeLocationTestModel::timerFired()
repopulate();
if (crazyMode_) {
//qDebug() << "raw randomw value: " << qrand();
- int delay = (qAbs(qrand()) % crazyLevel_); // writing software is exact science
+ int delay = (QRandomGenerator::bounded(uint(INT_MAX) + 1) % crazyLevel_); // writing software is exact science
delay = qMax(1000, delay); // 3 ms at minimum
qDebug() << "starting timer with : " << delay;
timer_.start(delay);
@@ -164,7 +162,7 @@ void QDeclarativeLocationTestModel::repopulate()
}
int datacount = datacount_;
if (crazyMode_)
- datacount = (qAbs(qrand()) % datacount_);
+ datacount = QRandomGenerator::bounded(datacount_);
for (int i = 0; i < datacount; ++i) {
DataObject* dataobject = new DataObject;
@@ -206,7 +204,7 @@ void QDeclarativeLocationTestModel::scheduleRepopulation()
if (crazyMode_) {
// start generating arbitrary amount of data at arbitrary intervals
- int delay = (qAbs(qrand()) % crazyLevel_); // writing software is exact science
+ int delay = QRandomGenerator::bounded(crazyLevel_); // writing software is exact science
delay = qMax(3, delay); // 3 ms at minimum
qDebug() << "starting timer with : " << delay;
timer_.start(delay);