Q_OBJECT
private slots:
void convertTileNumberToSceneCoordinate();
-// void setViewLocation();
void convertLatLonToSceneCoordinate_data();
void convertLatLonToSceneCoordinate();
void calculateRect();
void setLocation();
-// void removeTilesOutOfBounds();
+ void removeTilesOutOfBounds();
void calculateTileGrid();
void convert();
};
}
/**
-* @brief DUMMY TESTCASE!
-*
-* @todo Actual test should be added when there is something to be tested
-*/
-//void TestMapEngine::setViewLocation()
-//{
-// MapEngine mapEngine;
-// mapEngine.setViewLocation(QPointF(25.0000, 65.0000));
-//}
-
-/**
* @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::addColumn<QPoint>("result");
+
+ QTest::newRow("top left") << QPointF(MIN_LONGITUDE, MAX_LATITUDE) << QPoint(0, 0);
- QTest::newRow("top left") << QPointF(-180, 85.0511) << QPointF(0, 0);
- QTest::newRow("bottom right") << QPointF(180, -85.0511) << QPointF(67108863, 67108863);
+ int x = (1 << MAX_MAP_ZOOM_LEVEL) * TILE_SIZE_X;
+ int y = (1 << MAX_MAP_ZOOM_LEVEL) * TILE_SIZE_Y;
+ QTest::newRow("bottom right") << QPointF(MAX_LONGITUDE, MIN_LATITUDE) << QPoint(x, y);
}
/**
void TestMapEngine::convertLatLonToSceneCoordinate()
{
QFETCH(QPointF, coordinate);
- QFETCH(QPointF, result);
+ QFETCH(QPoint, result);
QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(coordinate), result);
}
void TestMapEngine::calculateRect()
{
- MapEngine engine;
- engine.viewResized(QSize(800, 480));
- engine.setZoomLevel(14);
-
- 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);
-
- QRect grid2 = QRect(-3, -2, 6, 4);
- QCOMPARE(engine.calculateGrid(QPointF(0.23*zoomFactor, 0.23*zoomFactor)), grid2);
-
- QRect grid3 = QRect(1017, 498, 6, 4);
- QCOMPARE(engine.calculateGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_Y*zoomFactor)), grid3);
-
- engine.viewResized(QSize(1280, 1024));
-
- QRect grid4 = QRect(1016, 497, 8, 7);
- QCOMPARE(engine.calculateGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_Y*zoomFactor)), grid4);
+ QVERIFY(false);
+// MapEngine engine;
+// engine.viewResized(QSize(800, 480));
+// engine.setZoomLevel(14);
+//
+// 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);
+//
+// QRect grid2 = QRect(-3, -2, 6, 4);
+// QCOMPARE(engine.calculateGrid(QPointF(0.23*zoomFactor, 0.23*zoomFactor)), grid2);
+//
+// QRect grid3 = QRect(1017, 498, 6, 4);
+// QCOMPARE(engine.calculateGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_Y*zoomFactor)), grid3);
+//
+// engine.viewResized(QSize(1280, 1024));
+//
+// QRect grid4 = QRect(1016, 497, 8, 7);
+// QCOMPARE(engine.calculateGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_Y*zoomFactor)), grid4);
}
void TestMapEngine::setLocation()
{
- MapEngine engine;
- engine.setZoomLevel(14);
- engine.viewResized(QSize(800, 480));
-
- int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
-
- QSignalSpy fetchImageSpy(&engine, SIGNAL(fetchImage(QUrl)));
- QTest::qWait(1000);
- fetchImageSpy.clear();
-
- engine.setLocation(QPointF(1220.23*zoomFactor, 1220.23*zoomFactor));
- QTest::qWait(1000);
- QCOMPARE(fetchImageSpy.count(), 6*4);
- fetchImageSpy.clear();
-
- //Move one tile right and one down = 9 new tiles
- engine.setLocation(QPointF((1220.23+TILE_SIZE_X)*zoomFactor, (1220.23+TILE_SIZE_Y)*zoomFactor));
- QTest::qWait(1000);
- QCOMPARE(fetchImageSpy.count(), 9);
- fetchImageSpy.clear();
+ QVERIFY(false);
+// MapEngine engine;
+// engine.setZoomLevel(14);
+// engine.viewResized(QSize(800, 480));
+//
+// int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
+//
+// QSignalSpy fetchImageSpy(&engine, SIGNAL(fetchImage(QUrl)));
+// QTest::qWait(1000);
+// fetchImageSpy.clear();
+//
+// engine.setLocation(QPointF(1220.23*zoomFactor, 1220.23*zoomFactor));
+// QTest::qWait(1000);
+// QCOMPARE(fetchImageSpy.count(), 6*4);
+// fetchImageSpy.clear();
+//
+// //Move one tile right and one down = 9 new tiles
+// engine.setLocation(QPointF((1220.23+TILE_SIZE_X)*zoomFactor, (1220.23+TILE_SIZE_Y)*zoomFactor));
+// QTest::qWait(1000);
+// QCOMPARE(fetchImageSpy.count(), 9);
+// fetchImageSpy.clear();
}
void TestMapEngine::convert()
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);
+ QPoint sceneCoordinate = QPoint(tileNumber.x()*TILE_SIZE_X*zoomFactor, tileNumber.y()*TILE_SIZE_Y*zoomFactor);
QPoint tile = MapEngine::convertSceneCoordinateToTileNumber(14, sceneCoordinate);
QCOMPARE(tileNumber, tile);
void TestMapEngine::calculateTileGrid()
{
- MapEngine engine;
-
- engine.viewResized(QSize(800, 480));
- engine.setZoomLevel(14);
-
- int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
-
- engine.calculateTileGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_X*zoomFactor));
+ QVERIFY(false);
+// MapEngine engine;
+//
+// engine.viewResized(QSize(800, 480));
+// engine.setZoomLevel(14);
+//
+// int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
+//
+// engine.calculateTileGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_X*zoomFactor));
}
-//void TestMapEngine::removeTilesOutOfBounds()
-//{
+void TestMapEngine::removeTilesOutOfBounds()
+{
+ QVERIFY(false);
// MapEngine engine;
// engine.viewResized(QSize(800, 480));
// engine.setZoomLevel(14);
// //Move one tile right and one tile down
// engine.setLocation(QPointF((1220.23+TILE_SIZE_X)*zoomFactor, (1220.23+TILE_SIZE_Y)*zoomFactor));
// QCOMPARE(engine.scene()->items().count(), 15);
-//}
+}
QTEST_MAIN(TestMapEngine)
#include "testmapengine.moc"