Fixing unit tests for MapEngine partly done.
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 14 Apr 2010 07:43:42 +0000 (10:43 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 14 Apr 2010 07:43:42 +0000 (10:43 +0300)
Also fixed convertLanLonToSceneCoordinate comments

src/map/mapengine.h
tests/testmap/testmapengine/testmapengine.cpp
tests/testmap/testmapengine/testmapengine.pro

index 09ceaaf..c6b6b6f 100644 (file)
@@ -99,10 +99,10 @@ public:
     void setViewLocation(QPointF latLonCoordinate);
 
     /**
-    * @brief Converts latitude, longitude and zoom to tile x, y values.
+    * @brief Converts latitude and longitude to scene coordinates.
     *
     * @param latLonCoordinate latitude and longitude values
-    * @return QPoint tile x,y value
+    * @return scene coordinate
     */
     static QPointF convertLatLonToSceneCoordinate(QPointF latLonCoordinate)
     {
index 6ce6ace..36d69c0 100644 (file)
@@ -27,9 +27,9 @@ class TestMapEngine: public QObject
 {
     Q_OBJECT
 private slots:
-    //void convertTileNumberToSceneCoordinate();
+    void convertTileNumberToSceneCoordinate();
 //    void setViewLocation();
-    //void convertLatLonToTile();
+    void convertLatLonToSceneCoordinate();
     void calculateRect();
     void setLocation();
 //    void removeTilesOutOfBounds();
@@ -42,12 +42,12 @@ private slots:
 *
 * Different zoom levels are also tested
 */
-//void TestMapEngine::convertTileNumberToSceneCoordinate()
-//{
-//    QCOMPARE(MapEngine::convertTileNumberToSceneCoordinate(18, QPoint(0,0)), QPoint(0,0));
-//    QCOMPARE(MapEngine::convertTileNumberToSceneCoordinate(18, QPoint(1,2)), QPoint(256,512));
-//    QCOMPARE(MapEngine::convertTileNumberToSceneCoordinate(16, QPoint(3,4)), QPoint(3072,4096));
-//}
+void TestMapEngine::convertTileNumberToSceneCoordinate()
+{
+    QCOMPARE(MapEngine::convertTileNumberToSceneCoordinate(18, QPoint(0,0)), QPoint(0,0));
+    QCOMPARE(MapEngine::convertTileNumberToSceneCoordinate(18, QPoint(1,2)), QPoint(256,512));
+    QCOMPARE(MapEngine::convertTileNumberToSceneCoordinate(16, QPoint(3,4)), QPoint(3072,4096));
+}
 
 /**
 * @brief DUMMY TESTCASE!
@@ -61,16 +61,16 @@ private slots:
 //}
 
 /**
-* @brief Test converting real world cordinates to tile numbers
+* @brief Test converting real world cordinates to scene coordinates
 * @todo Implement
 */
-//void TestMapEngine::convertLatLonToTile()
-//{
-//    QCOMPARE(MapEngine::convertLatLonToTile(7, QPointF(25.5, 65.0)), QPoint(73, 33));
-//    QCOMPARE(MapEngine::convertLatLonToTile(1, QPointF(25.5, 65.0)), QPoint(1, 0));
-//    QCOMPARE(MapEngine::convertLatLonToTile(1, QPointF(-190.0, 65.0)), QPoint(UNDEFINED, UNDEFINED));
-//    QCOMPARE(MapEngine::convertLatLonToTile(100, QPointF(20.0, 65.0)), QPoint(UNDEFINED, UNDEFINED));
-//}
+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));
+}
 
 void TestMapEngine::calculateRect()
 {
@@ -78,7 +78,7 @@ void TestMapEngine::calculateRect()
     engine.viewResized(QSize(800, 480));
     engine.setZoomLevel(14);
 
-    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - engine.getZoomLevel());
+    int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
 
     QRect grid1 = QRect(-1, 0, 6, 4);
     QCOMPARE(engine.calculateGrid(QPointF(550.23*zoomFactor, 550.23*zoomFactor)), grid1);
@@ -101,7 +101,7 @@ void TestMapEngine::setLocation()
     engine.setZoomLevel(14);
     engine.viewResized(QSize(800, 480));
 
-    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - engine.getZoomLevel());
+    int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
 
     QSignalSpy fetchImageSpy(&engine, SIGNAL(fetchImage(QUrl)));
     QTest::qWait(1000);
@@ -121,7 +121,7 @@ void TestMapEngine::setLocation()
 
 void TestMapEngine::convert()
 {
-    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - 14);
+    int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - 14);
 
     QPoint tileNumber = QPoint(1020, 500);
     QPointF sceneCoordinate = QPointF(tileNumber.x()*TILE_SIZE_X*zoomFactor, tileNumber.y()*TILE_SIZE_Y*zoomFactor);
@@ -137,7 +137,7 @@ void TestMapEngine::calculateTileGrid()
     engine.viewResized(QSize(800, 480));
     engine.setZoomLevel(14);
 
-    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - engine.getZoomLevel());
+    int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
 
     engine.calculateTileGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_X*zoomFactor));
 }
index 5b32058..8ec760c 100644 (file)
@@ -24,3 +24,11 @@ HEADERS += ../../../src/map/mapengine.h \
     ../../../src/map/mapfetcher.h \
     ../../../src/common.h
 RESOURCES += 
+
+# use don't use OpenGL when building in scratchbox
+!maemo5 {
+    QT += opengl
+    message(OpenGL built in)
+    message(Make sure you have OpenGL development headers installed)
+    message(install headers with: sudo apt-get install libgl-dev libglu-dev)
+}