1 #include <QtTest/QtTest>
4 #include "map/mapscene.h"
5 #include "map/maptile.h"
6 #include "map/mapengine.h"
8 class TestMapScene : public QObject
15 void TestMapScene::addMapTile()
20 Zoom level is 18, so no stretching should occure
21 Top-left corner 256, 512
22 Bottom-right corner 511, 767
24 MapTile *mapTile = new MapTile();
25 mapTile->setZoomLevel(18);
26 mapTile->setTileNumber(QPoint(1, 2));
27 mapTile->setPixmap(QPixmap("maptile.png"));
29 mapScene.addMapTile(mapTile);
34 // QList<QGraphicsItem *> items = mapScene.items();
35 // qDebug() << "items.count()" << items.count();
38 Check around top-left and bottom-right corners
40 QCOMPARE(mapScene.itemAt(x-1, y), (QGraphicsItem *)0);
41 QCOMPARE(mapScene.itemAt(x, y-1), (QGraphicsItem *)0);
42 QCOMPARE(mapScene.itemAt(x, y), dynamic_cast<QGraphicsItem *>(mapTile));
43 QCOMPARE(mapScene.itemAt(x+255, y+255), dynamic_cast<QGraphicsItem *>(mapTile));
44 QCOMPARE(mapScene.itemAt(x+256, y+255), (QGraphicsItem *)0);
45 QCOMPARE(mapScene.itemAt(x+255, y+256), (QGraphicsItem *)0);
48 QTEST_MAIN(TestMapScene)
49 #include "testmapscene.moc"