diff options
author | Aaron McCarthy <aaron.mccarthy@jollamobile.com> | 2014-02-10 11:22:26 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-11 10:32:44 +0100 |
commit | 2ba9fd5550eb7766c20b3a61679e88ec4a6c8a54 (patch) | |
tree | 6eb0991074302f8d023944c4b4bffb05e9a72591 | |
parent | 63c8b3bca03586994c2b59c262e9cb3a9b12b363 (diff) | |
download | qtlocation-2ba9fd5550eb7766c20b3a61679e88ec4a6c8a54.tar.gz |
Add QML test for comparing QtPositioning base types.old/5.2
Tests added for comparing Coordinate, Shape, Rectangle and Circle.
Task-number: QTBUG-33561
Change-Id: Ie826f670e75b26ac43ad7cea7c9b108b01008f3d
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | tests/auto/declarative_core/tst_coordinate.qml | 22 | ||||
-rw-r--r-- | tests/auto/declarative_core/tst_geoshape.qml | 27 |
2 files changed, 47 insertions, 2 deletions
diff --git a/tests/auto/declarative_core/tst_coordinate.qml b/tests/auto/declarative_core/tst_coordinate.qml index 1541be39..19bdd572 100644 --- a/tests/auto/declarative_core/tst_coordinate.qml +++ b/tests/auto/declarative_core/tst_coordinate.qml @@ -138,6 +138,26 @@ Item { compare(coordSpy.count, 3) } + function test_comparison_data() { + return [ + { tag: "empty", coord1: empty, coord2: QtPositioning.coordinate(), result: true }, + { tag: "zero", coord1: zero, coord2: QtPositioning.coordinate(0, 0), result: true }, + { tag: "plusone", coord1: plusone, coord2: QtPositioning.coordinate(0, 1), result: true }, + { tag: "minusone", coord1: minusone, coord2: QtPositioning.coordinate(0, -1), result: true }, + { tag: "north", coord1: north, coord2: QtPositioning.coordinate(3, 0), result: true }, + { tag: "lat,long.alt", coord1: QtPositioning.coordinate(1.1, 2.2, 3.3), coord2: QtPositioning.coordinate(1.1, 2.2, 3.3), result: true }, + { tag: "not equal1", coord1: plusone, coord2: minusone, result: false }, + { tag: "not equal2", coord1: plusone, coord2: north, result: false } + ] + } + + function test_comparison(data) { + compare(data.coord1 === data.coord2, data.result) + compare(data.coord1 !== data.coord2, !data.result) + compare(data.coord1 == data.coord2, data.result) + compare(data.coord1 != data.coord2, !data.result) + } + function test_distance() { compare(zero.distanceTo(plusone), zero.distanceTo(minusone)) compare(2*plusone.distanceTo(zero), plusone.distanceTo(minusone)) @@ -178,8 +198,6 @@ Item { var coord_30d2 = coord_30d.atDistanceAndAzimuth(200, 30) compare(zero.distanceTo(coord_30d2), 20200) - } - } } diff --git a/tests/auto/declarative_core/tst_geoshape.qml b/tests/auto/declarative_core/tst_geoshape.qml index 72dd788b..fcc2b07c 100644 --- a/tests/auto/declarative_core/tst_geoshape.qml +++ b/tests/auto/declarative_core/tst_geoshape.qml @@ -108,4 +108,31 @@ Item { compare (box.contains(outside), true) } } + + TestCase { + name: "Shape" + + function test_shape_comparison_data() { + return [ + { tag: "invalid shape", shape1: QtPositioning.shape(), shape2: QtPositioning.shape(), result: true }, + { tag: "box equal", shape1: box, shape2: QtPositioning.rectangle(tl, br), result: true }, + { tag: "box not equal", shape1: box, shape2: QtPositioning.rectangle([inside, outside]), result: false }, + { tag: "box invalid shape", rect1: box, shape2: QtPositioning.shape(), result: false }, + { tag: "invalid rectangle", shape1: QtPositioning.rectangle(), shape2: QtPositioning.rectangle(), result: true }, + { tag: "invalid rectangle2", shape1: QtPositioning.rectangle(), shape2: QtPositioning.shape(), result: false }, + { tag: "circle1 equal", shape1: circle1, shape2: QtPositioning.circle(coordinate1, 200000), result: true }, + { tag: "circle1 not equal", shape1: circle1, shape2: QtPositioning.circle(coordinate2, 2000), result: false }, + { tag: "circle1 invalid shape", shape1: circle1, shape2: QtPositioning.shape(), result: false }, + { tag: "invalid circle", shape1: QtPositioning.circle(), shape2: QtPositioning.circle(), result: true }, + { tag: "invalid circle2", shape1: QtPositioning.circle(), shape2: QtPositioning.shape(), result: false } + ] + } + + function test_shape_comparison(data) { + compare(data.shape1 === data.shape2, data.result) + compare(data.shape1 !== data.shape2, !data.result) + compare(data.shape1 == data.shape2, data.result) + compare(data.shape1 != data.shape2, !data.result) + } + } } |