summaryrefslogtreecommitdiff
path: root/tests/auto/qgeoboundingbox
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-06-27 13:28:00 +1000
committerabcd <qt-info@nokia.com>2011-06-27 13:28:00 +1000
commitd8851dd0f411f0519be72ae0c5ea66f2595ce39f (patch)
tree654d91fafd7119efdf452e0143c7794912993d1a /tests/auto/qgeoboundingbox
parent2de887f688525796c4efc17084968ad5e0b88527 (diff)
downloadqtlocation-d8851dd0f411f0519be72ae0c5ea66f2595ce39f.tar.gz
Add in qgeoboundingbox unit test
This unit test was based off the qt 4 places pre-release, we still need to combine it with the mobility geoboundingbox unit test
Diffstat (limited to 'tests/auto/qgeoboundingbox')
-rw-r--r--tests/auto/qgeoboundingbox/qgeoboundingbox.pro7
-rw-r--r--tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp92
2 files changed, 99 insertions, 0 deletions
diff --git a/tests/auto/qgeoboundingbox/qgeoboundingbox.pro b/tests/auto/qgeoboundingbox/qgeoboundingbox.pro
new file mode 100644
index 00000000..3427c37b
--- /dev/null
+++ b/tests/auto/qgeoboundingbox/qgeoboundingbox.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+CONFIG += testcase
+TARGET = tst_qgeoboundingbox
+
+SOURCES += tst_qgeoboundingbox.cpp
+
+QT += location testlib
diff --git a/tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp b/tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp
new file mode 100644
index 00000000..c6579aa0
--- /dev/null
+++ b/tests/auto/qgeoboundingbox/tst_qgeoboundingbox.cpp
@@ -0,0 +1,92 @@
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+#include <qgeoboundingbox.h>
+
+QTM_USE_NAMESPACE
+
+class tst_QGeoBoundingBox : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QGeoBoundingBox();
+
+private Q_SLOTS:
+ void constructorTest();
+ void topLeftTest();
+ void bottomRightTest();
+ void isValidTest();
+ void operatorsTest();
+};
+
+tst_QGeoBoundingBox::tst_QGeoBoundingBox()
+{
+}
+
+void tst_QGeoBoundingBox::constructorTest()
+{
+ QGeoBoundingBox testObj;
+ Q_UNUSED(testObj);
+
+ QGeoBoundingBox *testObjPtr = new QGeoBoundingBox(testObj);
+ QVERIFY2(testObjPtr != NULL, "Copy constructor - null");
+ QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare");
+ delete testObjPtr;
+}
+
+void tst_QGeoBoundingBox::topLeftTest()
+{
+ QGeoBoundingBox testObj;
+ QVERIFY2(testObj.topLeft().isValid() == false, "Wrong default value");
+ QGeoCoordinate coordinate;
+ coordinate.setLatitude(30);
+ coordinate.setLongitude(20);
+ testObj.setTopLeft(coordinate);
+ QVERIFY2(testObj.topLeft() == coordinate, "Wrong value returned");
+}
+
+void tst_QGeoBoundingBox::bottomRightTest()
+{
+ QGeoBoundingBox testObj;
+ QVERIFY2(testObj.bottomRight().isValid() == false, "Wrong default value");
+ QGeoCoordinate coordinate;
+ coordinate.setLatitude(30);
+ coordinate.setLongitude(20);
+ testObj.setBottomRight(coordinate);
+ QVERIFY2(testObj.bottomRight() == coordinate, "Wrong value returned");
+}
+
+void tst_QGeoBoundingBox::isValidTest()
+{
+ QGeoBoundingBox testObj;
+ QVERIFY2(testObj.isValid() == false, "Wrong default check");
+ QGeoCoordinate coordinate;
+ coordinate.setLatitude(30);
+ coordinate.setLongitude(20);
+ testObj.setBottomRight(coordinate);
+ QVERIFY2(testObj.isValid() == false, "Wrong top/left check");
+ testObj.setTopLeft(coordinate);
+ testObj.setBottomRight(QGeoCoordinate());
+ QVERIFY2(testObj.isValid() == false, "Wrong bottom/right check");
+ testObj.setBottomRight(coordinate);
+ QVERIFY2(testObj.isValid() == true, "Box is valid");
+}
+
+void tst_QGeoBoundingBox::operatorsTest()
+{
+ QGeoBoundingBox testObj;
+ QGeoCoordinate coordinate;
+ coordinate.setLatitude(30);
+ coordinate.setLongitude(20);
+ testObj.setTopLeft(coordinate);
+ QGeoBoundingBox testObj2;
+ testObj2 = testObj;
+ QVERIFY2(testObj == testObj2, "Not copied correctly");
+ testObj2.setBottomRight(coordinate);
+ QVERIFY2(testObj != testObj2, "Object should be different");
+}
+
+QTEST_APPLESS_MAIN(tst_QGeoBoundingBox);
+
+#include "tst_qgeoboundingbox.moc"