Changed testcase filenames to lowercase
[situare] / tests / testmap / testmapscene / testmapscene.cpp
1 #include <QtTest/QtTest>
2 #include <QDebug>
3
4 #include "map/mapscene.h"
5 #include "map/maptile.h"
6 #include "map/mapengine.h"
7
8 class TestMapScene : public QObject
9 {
10     Q_OBJECT
11 private slots:
12     void addMapTile();
13 };
14
15 void TestMapScene::addMapTile()
16 {
17     MapScene mapScene;
18
19     /*
20        Zoom level is 18, so no stretching should occure
21        Top-left corner 256, 512
22        Bottom-right corner 511, 767
23      */
24     MapTile *mapTile = new MapTile();
25     mapTile->setZoomLevel(18);
26     mapTile->setTileNumber(QPoint(1, 2));
27     mapTile->setPixmap(QPixmap("maptile.png"));
28
29     mapScene.addMapTile(mapTile);
30
31     int x = 256;
32     int y = 512;
33
34 //    QList<QGraphicsItem *> items = mapScene.items();
35 //    qDebug() << "items.count()" << items.count();
36
37     /*
38        Check around top-left and bottom-right corners
39      */
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);
46 }
47
48 QTEST_MAIN(TestMapScene)
49 #include "testmapscene.moc"