summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAaron McCarthy <mccarthy.aaron@gmail.com>2014-07-28 09:57:04 +1000
committerAaron McCarthy <mccarthy.aaron@gmail.com>2014-12-04 05:31:54 +0100
commitb8681cdb51cc5d7040ecbe08b014bace2444c6f1 (patch)
treeebfe6a4e4cbbf178b1df2339abf91f7b4c84a2cf /tests
parentfddb7c51231e1649081de3a1d5f2ad191e9cd7dc (diff)
downloadqtlocation-b8681cdb51cc5d7040ecbe08b014bace2444c6f1.tar.gz
Add center() function to QGeoShape.
It is frequently useful to calculate the geometric center of a shape. Both QGeoCircle and QGeoRectangle already define center() functions, however, the application developer must cast each QGeoShape into either a QGeoCirlce or QGeoRectangle before calling. Providing QGeoShape::center() allows application code to be simplified. Existing QGeoCircle::center() and QGeoRectangle::center() functions are kept for compatibility. Change-Id: I92b727ab5e713f70174588a27040446c992ae14e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgeocircle/tst_qgeocircle.cpp4
-rw-r--r--tests/auto/qgeorectangle/tst_qgeorectangle.cpp2
2 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/qgeocircle/tst_qgeocircle.cpp b/tests/auto/qgeocircle/tst_qgeocircle.cpp
index e821db3d..695b1cfb 100644
--- a/tests/auto/qgeocircle/tst_qgeocircle.cpp
+++ b/tests/auto/qgeocircle/tst_qgeocircle.cpp
@@ -174,6 +174,10 @@ void tst_QGeoCircle::center()
QGeoCircle c;
c.setCenter(QGeoCoordinate(1,1));
QCOMPARE(c.center(), QGeoCoordinate(1,1));
+
+ QGeoShape shape = c;
+ QCOMPARE(shape.center(), c.center());
+
c.setCenter(QGeoCoordinate(5,10));
QCOMPARE(c.center(), QGeoCoordinate(5,10));
}
diff --git a/tests/auto/qgeorectangle/tst_qgeorectangle.cpp b/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
index 2e6d274b..0a358c35 100644
--- a/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
+++ b/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
@@ -829,7 +829,9 @@ void tst_QGeoRectangle::center()
QFETCH(QGeoCoordinate, newCenter);
QFETCH(QGeoRectangle, newBox);
+ QGeoShape shape = box;
QCOMPARE(box.center(), oldCenter);
+ QCOMPARE(shape.center(), oldCenter);
box.setCenter(newCenter);
QCOMPARE(box, newBox);
}