*/
void centerToSceneCoordinates(QPointF sceneCoordinate);
+ /**
+ * @brief Set zoom level of the view
+ *
+ * @param zoomLevel Zoom level
+ */
+ void setZoomLevel(int zoomLevel);
+
protected:
void resizeEvent(QResizeEvent *event);
void mousePressEvent(QMouseEvent *event);
/**
- * @brief Set zoom level of the view
- *
- * @param zoomLevel Zoom level
- */
- void setZoomLevel(int zoomLevel);
-
- /**
* @brief Timer events for smooth zoom effect
*
* @param event
class TestMapView: public QObject
{
Q_OBJECT
+public:
+ TestMapView();
+
private slots:
-// void dummyTestCase();
+ void init();
+ void cleanup();
+ void zoomLevelChange_data();
+ void zoomLevelChange();
+
+private:
+ MapView *m_mapView;
};
-/**
-* @brief DUMMY TESTCASE!
-* @todo Implement test(s) when there is something to be tested
-*/
-//void TestMapView::dummyTestCase()
-//{
-// QVERIFY(true);
-//}
+TestMapView::TestMapView() : m_mapView(0)
+{
+
+}
+
+void TestMapView::init()
+{
+ m_mapView = new MapView();
+ QVERIFY(m_mapView);
+}
+
+void TestMapView::cleanup()
+{
+ delete m_mapView;
+ m_mapView = 0;
+}
+
+void TestMapView::zoomLevelChange_data()
+{
+ QTest::addColumn<int>("zoomLevel");
+ QTest::addColumn<qreal>("result");
+
+ QTest::newRow("zoom 18") << 18 << 1.0;
+ QTest::newRow("zoom 17") << 17 << 0.5;
+ QTest::newRow("zoom 16") << 16 << 0.25;
+ QTest::newRow("zoom 15") << 15 << 0.125;
+}
+
+void TestMapView::zoomLevelChange()
+{
+ QFETCH(int, zoomLevel);
+ QFETCH(qreal, result);
+
+ m_mapView->setZoomLevel(zoomLevel);
+ QTest::qWait(300);
+ QCOMPARE(m_mapView->transform().m11(), result);
+ QCOMPARE(m_mapView->transform().m22(), result);
+}
QTEST_MAIN(TestMapView)
#include "testmapview.moc"