Implemented unit test for MapEngine::convertLatLonToSceneCoordinate
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 14 Apr 2010 09:24:28 +0000 (12:24 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 14 Apr 2010 09:24:28 +0000 (12:24 +0300)
...but the test is currently failing because there is something
wrong in the conversion equations or some rounding error.

tests/testmap/testmapengine/testmapengine.cpp

index 36d69c0..eaf9895 100644 (file)
@@ -29,6 +29,7 @@ class TestMapEngine: public QObject
 private slots:
     void convertTileNumberToSceneCoordinate();
 //    void setViewLocation();
+    void convertLatLonToSceneCoordinate_data();
     void convertLatLonToSceneCoordinate();
     void calculateRect();
     void setLocation();
@@ -61,15 +62,27 @@ void TestMapEngine::convertTileNumberToSceneCoordinate()
 //}
 
 /**
+  * @brief Test data for converting latitude and longitude coordinates to scene coordinates
+  */
+void TestMapEngine::convertLatLonToSceneCoordinate_data()
+{
+    QTest::addColumn<QPointF>("coordinate");
+    QTest::addColumn<QPointF>("result");
+
+    QTest::newRow("top left") << QPointF(-180, 85.0511) << QPointF(0, 0);
+    QTest::newRow("bottom right") << QPointF(180, -85.0511) << QPointF(67108863, 67108863);
+}
+
+/**
 * @brief Test converting real world cordinates to scene coordinates
 * @todo Implement
 */
 void TestMapEngine::convertLatLonToSceneCoordinate()
 {
-    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(25.5, 65.0)), QPointF(73, 33));
-    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(25.5, 65.0)), QPointF(1, 0));
-    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(-190.0, 65.0)), QPointF(UNDEFINED, UNDEFINED));
-    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(20.0, 65.0)), QPointF(UNDEFINED, UNDEFINED));
+    QFETCH(QPointF, coordinate);
+    QFETCH(QPointF, result);
+
+    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(coordinate), result);
 }
 
 void TestMapEngine::calculateRect()