summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-09-15 16:51:38 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-04-12 14:49:10 +0000
commitb21c33a3278260df469175a3ce08447b7a3dc47c (patch)
treedd8d0592cf388d8f71063b400d5013d3d68a761f
parent5779661ba629eff1ffaf3a38c842b74250100bb1 (diff)
Improve QGeoPath::path documentation and add autotestsv5.11.0-beta4
Change-Id: I8359c79f114abd0006012098cc154695013e0512 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/positioning/qgeopath.cpp10
-rw-r--r--tests/auto/declarative_geoshape/tst_locationsingleton.qml39
2 files changed, 46 insertions, 3 deletions
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index 592933a9..94a14ad1 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -73,15 +73,19 @@ QT_BEGIN_NAMESPACE
This class is a \l Q_GADGET.
It can be \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.
+
+ A QGeoPath is both invalid and empty if it contains no coordinate.
+
+ \note A default constructed QGeoPath is both invalid and empty as it does not contain any coordinates.
*/
/*!
\property QGeoPath::path
\brief This property holds the list of coordinates for the geo path.
- The path is both invalid and empty if it contains no coordinate.
-
- A default constructed QGeoPath is therefore invalid.
+ \note The coordinates cannot be processed in place. To change the value
+ of this property, retrieve the complete list of coordinates, process them,
+ and assign the new value to the property.
*/
inline QGeoPathPrivate *QGeoPath::d_func()
diff --git a/tests/auto/declarative_geoshape/tst_locationsingleton.qml b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
index 6ebee62a..645aedb6 100644
--- a/tests/auto/declarative_geoshape/tst_locationsingleton.qml
+++ b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
@@ -228,6 +228,10 @@ Item {
]
}
+ MapPolyline {
+ id: mapPolylineGeopath
+ }
+
TestCase {
name: "MapPolyline path"
function test_path_operations() {
@@ -274,4 +278,39 @@ Item {
compare(mapPolyline.path.length, mapPolyline.pathLength())
}
}
+
+ TestCase {
+ name: "GeoPath path"
+ function test_qgeopath_path_operations() {
+ var geopath = QtPositioning.path()
+
+ 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.path = mapPolyline.path
+ compare(mapPolylineGeopath.pathLength(), mapPolyline.pathLength())
+ compare(mapPolylineGeopath.geoShape.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
+
+ try {
+ var err = false;
+ mapPolylineGeopath.geoShape = geopath
+ } catch (e) {
+ if (e.message != 'Cannot assign to read-only property "geoShape"')
+ fail('Expected Cannot assign to read-only property "geoShape", got: ' + e.message);
+ err = true;
+ } finally {
+ verify(err, 'should throw Cannot assign to read-only property "geoShape"');
+ }
+
+ geopath.path = trace2
+ geopath.path[0].longitude = 11.0
+ compare(geopath.path.length, trace2.length)
+ compare(geopath.coordinateAt(0).latitude, trace2[0].latitude)
+ compare(geopath.coordinateAt(0).longitude, 11) // This fails
+ }
+ }
}