diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-05-30 15:28:14 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-06-07 11:12:51 +0000 |
commit | e8dedcd7c621715813b7b954bb7f64c88aa6523d (patch) | |
tree | 087f958ceaa0cb920eb889389afa291454ca09ab /tests | |
parent | f55629245259ba7364e258f92408823024423caa (diff) | |
download | qtlocation-e8dedcd7c621715813b7b954bb7f64c88aa6523d.tar.gz |
Add QGeoPath::size
A way to retrieve the size of the path is missing, as the path property
turns out not to be accessible to QML.
This patch adds a Q_INVOKABLE method to expose it.
[ChangeLog][QtPositioning][QGeoPath] Add ::size() to QGeoPath to
retrieve the number of coordinates in the path.
Change-Id: Ifa7a640113cba71f23e36626a84c8b2fe473a07e
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgeopath/tst_qgeopath.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
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"); |