Added unit test for changing drawing order of MapTiles.
authorSami Rämö <sami.ramo@ixonos.com>
Tue, 13 Apr 2010 12:37:02 +0000 (15:37 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Tue, 13 Apr 2010 12:37:02 +0000 (15:37 +0300)
Also added comments to the test class of MapView.

tests/testmap/testmaptile/testmaptile.cpp
tests/testmap/testmapview/testmapview.cpp

index b7e8159..c6676f4 100644 (file)
@@ -32,6 +32,8 @@ private slots:
     void position_data();
     void position();    
     void positionUnsetValues();
+    void sceneLevel_data();
+    void sceneLevel();
 };
 
 /**
@@ -120,5 +122,39 @@ void TestMapTile::positionUnsetValues()
     QCOMPARE(anotherMapTile.pos(), QPointF(-1, -1));
 }
 
+/**
+  * @brief Data for test of setting zValues
+  */
+void TestMapTile::sceneLevel_data()
+{
+    QTest::addColumn<int>("tileZoomLevel");
+    QTest::addColumn<int>("viewZoomLevel");
+    QTest::addColumn<qreal>("result");
+
+    QTest::newRow("tile zoom 15, view zoom 17") << 15 << 17 << 15.0 + 19;
+    QTest::newRow("tile zoom 15, view zoom 16") << 15 << 16 << 15.0 + 19;
+    QTest::newRow("tile zoom 15, view zoom 15") << 15 << 15 << 15.0 + 19;
+    QTest::newRow("tile zoom 15, view zoom 14") << 15 << 14 << 13.5 + 19;
+    QTest::newRow("tile zoom 15, view zoom 13") << 15 << 13 << 11.5 + 19;
+    QTest::newRow("tile zoom 15, view zoom 12") << 15 << 12 << 9.5 + 19;
+    QTest::newRow("tile zoom 18, view zoom 1") << 18 << 1 << -15.5 + 19;
+    QTest::newRow("tile zoom 18, view zoom 0") << 18 << 0 << -17.5 + 19;
+}
+
+/**
+  * @brief Test setting zValues (drawing order)
+  */
+void TestMapTile::sceneLevel()
+{
+    QFETCH(int, tileZoomLevel);
+    QFETCH(int, viewZoomLevel);
+    QFETCH(qreal, result);
+
+    MapTile tile;
+    tile.setZoomLevel(tileZoomLevel);
+    tile.setSceneLevel(viewZoomLevel);
+    QCOMPARE(tile.zValue(), result);
+}
+
 QTEST_MAIN(TestMapTile)
 #include "testmaptile.moc"
index 3641eb4..7179447 100644 (file)
@@ -39,23 +39,35 @@ private:
     MapView *m_mapView;
 };
 
-TestMapView::TestMapView() : m_mapView(0)
+/**
+  * @brief Constructor for setting pointer to MapView to NULL
+  */
+TestMapView::TestMapView() : m_mapView(NULL)
 {
 
 }
 
+/**
+  * @brief Test case initialization
+  */
 void TestMapView::init()
 {
     m_mapView = new MapView();
     QVERIFY(m_mapView);
 }
 
+/**
+  * @brief Test case cleanup
+  */
 void TestMapView::cleanup()
 {
     delete m_mapView;
     m_mapView = 0;
 }
 
+/**
+  * @brief Test data for zoom level change test
+  */
 void TestMapView::zoomLevelChange_data()
 {
     QTest::addColumn<int>("zoomLevel");
@@ -67,6 +79,9 @@ void TestMapView::zoomLevelChange_data()
     QTest::newRow("zoom 15") << 15 << 0.125;
 }
 
+/**
+  * @brief Test view zoom level scaling
+  */
 void TestMapView::zoomLevelChange()
 {
     QFETCH(int, zoomLevel);