summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-07-21 17:34:31 +1000
committerabcd <qt_abcd1@ovi.com>2011-07-25 09:08:02 +0200
commit92b852cc98995cd8abbc78fc1b5f8b134c4bd0dc (patch)
treea9b1d97d24a76f12eb8ed6d76089c90f6282c134 /tests/auto
parent323f30661bf08ae12a78756f403e8d6d9af3e7d7 (diff)
downloadqtlocation-92b852cc98995cd8abbc78fc1b5f8b134c4bd0dc.tar.gz
Add in equality operators for abstract bounding area
Also add in implementations for the concrete classes. Also do a deep copy of the search area when copying a place search query. Change-Id: I18bc4f1f18256f810df9ca20846e56fefae67192 Reviewed-on: http://codereview.qt.nokia.com/1922 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com> Reviewed-by: abcd <qt_abcd1@ovi.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp27
-rw-r--r--tests/auto/qgeoboundingcircle/tst_qgeoboundingcircle.cpp20
-rw-r--r--tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp35
3 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp b/tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp
index f0e1736f..1728c9ba 100644
--- a/tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp
+++ b/tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QtTest>
#include <qgeoboundingbox.h>
+#include <qgeoboundingcircle.h>
#include <qgeocoordinate.h>
QT_USE_NAMESPACE
@@ -97,6 +98,7 @@ private slots:
void unite_data();
void clone();
+ void areaComparison();
};
void tst_QGeoBoundingBox::default_constructor()
@@ -2154,6 +2156,31 @@ void tst_QGeoBoundingBox::clone()
"Clone's bottom right coord references the original's");
}
+void tst_QGeoBoundingBox::areaComparison()
+{
+ QGeoBoundingBox b1(QGeoCoordinate(20,20), QGeoCoordinate(10,30));
+ QGeoBoundingBox b2(QGeoCoordinate(20,20), QGeoCoordinate(10,30));
+ QGeoBoundingBox b3(QGeoCoordinate(40,40), QGeoCoordinate(10,30));
+
+ QVERIFY(b1 == b2);
+ QVERIFY(!(b1 != b2));
+
+ QVERIFY(!(b1 == b3));
+ QVERIFY(b1 != b3);
+
+ QGeoBoundingCircle c1(QGeoCoordinate(20,20), 5000);
+ QVERIFY(!(b1 == c1));
+ QVERIFY(b1 != c1);
+
+ QGeoBoundingArea *b2Ptr = &b2;
+ QVERIFY(b1 == *b2Ptr);
+ QVERIFY(!(b1 != *b2Ptr));
+
+ QGeoBoundingArea *b3Ptr = &b3;
+ QVERIFY(!(b1 == *b3Ptr));
+ QVERIFY(b1 != *b3Ptr);
+}
+
QTEST_MAIN(tst_QGeoBoundingBox)
#include "tst_qgeoboundingbox.moc"
diff --git a/tests/auto/qgeoboundingcircle/tst_qgeoboundingcircle.cpp b/tests/auto/qgeoboundingcircle/tst_qgeoboundingcircle.cpp
index 4224ddd6..1d745472 100644
--- a/tests/auto/qgeoboundingcircle/tst_qgeoboundingcircle.cpp
+++ b/tests/auto/qgeoboundingcircle/tst_qgeoboundingcircle.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
#include <qgeoboundingcircle.h>
+#include <qgeoboundingbox.h>
#include <qgeocoordinate.h>
QT_USE_NAMESPACE
@@ -98,9 +99,28 @@ void tst_QGeoBoundingCircle::comparison()
QGeoBoundingCircle c4(QGeoCoordinate(1,2), qreal(50.0));
QVERIFY(c1 == c2);
+ QVERIFY(!(c1 != c2));
+
+ QVERIFY(!(c1 == c3));
QVERIFY(c1 != c3);
+
+ QVERIFY(!(c1 == c4));
QVERIFY(c1 != c4);
+
+ QVERIFY(!(c2 == c3));
QVERIFY(c2 != c3);
+
+ QGeoBoundingBox b1(QGeoCoordinate(20,20),QGeoCoordinate(10,30));
+ QVERIFY(!(c1 == b1));
+ QVERIFY(c1 != b1);
+
+ QGeoBoundingArea *c2Ptr = &c2;
+ QVERIFY(c1 == *c2Ptr);
+ QVERIFY(!(c1 != *c2Ptr));
+
+ QGeoBoundingArea *c3Ptr = &c3;
+ QVERIFY(!(c1 == *c3Ptr));
+ QVERIFY(c1 != *c3Ptr);
}
void tst_QGeoBoundingCircle::type()
diff --git a/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp b/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp
index 929c39a4..2f28b651 100644
--- a/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp
+++ b/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp
@@ -137,6 +137,41 @@ void tst_QPlaceSearchQuery::operatorsTest()
QVERIFY2(testObj == testObj2, "Not copied correctly");
testObj2.setDidYouMeanSuggestionNumber(-5);
QVERIFY2(testObj != testObj2, "Object should be different");
+ testObj2.setDidYouMeanSuggestionNumber(0);
+ QVERIFY(testObj == testObj2);
+
+ QGeoBoundingBox *b1 = new QGeoBoundingBox(QGeoCoordinate(20,20), QGeoCoordinate(10,30));
+ QGeoBoundingBox *b2 = new QGeoBoundingBox(QGeoCoordinate(20,20), QGeoCoordinate(10,30));
+ QGeoBoundingBox *b3 = new QGeoBoundingBox(QGeoCoordinate(40,40), QGeoCoordinate(10,40));
+
+ //testing that identical boxes match
+ testObj.setSearchArea(b1);
+ testObj2.setSearchArea(b2);
+ QVERIFY2(testObj == testObj2, "Identical box areas are not identified as matching");
+
+ //test that different boxes do not match
+ testObj2.setSearchArea(b3);
+ QVERIFY2(testObj != testObj2, "Different box areas identified as matching");
+
+ QGeoBoundingCircle *c1 = new QGeoBoundingCircle(QGeoCoordinate(5,5),500);
+ QGeoBoundingCircle *c2 = new QGeoBoundingCircle(QGeoCoordinate(5,5),500);
+ QGeoBoundingCircle *c3 = new QGeoBoundingCircle(QGeoCoordinate(9,9),600);
+
+ //test that identical cirlces match
+ testObj.setSearchArea(c1);
+ testObj2.setSearchArea(c2);
+ QVERIFY2(testObj == testObj2, "Identical circle areas are not identified as matching");
+
+ //test that different circle don't match
+ testObj2.setSearchArea(c3);
+ QVERIFY2(testObj != testObj2, "Different circle areas identified as matching");
+
+ //test that circles and boxes do not match
+ QGeoBoundingBox *b4 = new QGeoBoundingBox(QGeoCoordinate(20,20),QGeoCoordinate(10,30));
+ QGeoBoundingCircle *c4 = new QGeoBoundingCircle(QGeoCoordinate(20,20),500);
+ testObj.setSearchArea(b4);
+ testObj2.setSearchArea(c4);
+ QVERIFY2(testObj != testObj2, "Circle and box identified as matching");
}
QTEST_APPLESS_MAIN(tst_QPlaceSearchQuery);