Merge branch 'map' of https://vcs.maemo.org/git/situare into map
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 14 Apr 2010 09:15:10 +0000 (12:15 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 14 Apr 2010 09:15:10 +0000 (12:15 +0300)
Conflicts:
tests/testmap/testmapengine/testmapengine.cpp

1  2 
src/map/mapengine.h
src/map/mapfetcher.cpp
tests/testmap/testmapengine/testmapengine.cpp

Simple merge
@@@ -41,7 -41,7 +41,8 @@@ MapFetcher::MapFetcher(QNetworkAccessMa
              QDesktopServices::CacheLocation));
      m_manager->setCache(diskCache);
  
--    connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*)));
++    connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(
++            downloadFinished(QNetworkReply*)));
  }
  
  void MapFetcher::fetchMapImage(const QUrl &url)
@@@ -27,14 -27,14 +27,13 @@@ class TestMapEngine: public QObjec
  {
      Q_OBJECT
  private slots:
-     //void convertTileNumberToSceneCoordinate();
+     void convertTileNumberToSceneCoordinate();
  //    void setViewLocation();
-     //void convertLatLonToTile();
- //    void calculateRect();
-     void moveLocation();
- //    void removeTilesOutOfBounds();
 -    void convertLatLonToSceneCoordinate();
 -    void calculateRect();
 -    void setLocation();
 -//    void removeTilesOutOfBounds();
 -    void calculateTileGrid();
 -    void convert();
++//    void convertLatLonToSceneCoordinate();
++    void setLocationNewTilesCount();
++    void setLocationRemovedTilesCount();
 +//    void calculateTileGrid();
 +//    void convert();
  };
  
  /**
@@@ -61,45 -61,48 +60,22 @@@ void TestMapEngine::convertTileNumberTo
  //}
  
  /**
- * @brief Test converting real world cordinates to tile numbers
+ * @brief Test converting real world cordinates to scene coordinates
  * @todo Implement
  */
- //void TestMapEngine::convertLatLonToTile()
- //{
- //    QCOMPARE(MapEngine::convertLatLonToTile(7, QPointF(25.5, 65.0)), QPoint(73, 33));
- //    QCOMPARE(MapEngine::convertLatLonToTile(1, QPointF(25.5, 65.0)), QPoint(1, 0));
- //    QCOMPARE(MapEngine::convertLatLonToTile(1, QPointF(-190.0, 65.0)), QPoint(UNDEFINED, UNDEFINED));
- //    QCOMPARE(MapEngine::convertLatLonToTile(100, QPointF(20.0, 65.0)), QPoint(UNDEFINED, UNDEFINED));
- //}
- //void TestMapEngine::calculateRect()
 -void TestMapEngine::convertLatLonToSceneCoordinate()
 -{
 -    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(25.5, 65.0)), QPointF(73, 33));
 -    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(25.5, 65.0)), QPointF(1, 0));
 -    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(-190.0, 65.0)), QPointF(UNDEFINED, UNDEFINED));
 -    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(20.0, 65.0)), QPointF(UNDEFINED, UNDEFINED));
 -}
 -
 -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);
 -}
++//void TestMapEngine::convertLatLonToSceneCoordinate()
 +//{
- //    MapEngine engine;
- //    engine.viewResized(QSize(800, 480));
- //    engine.setZoomLevel(14);
- //
- //    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - engine.getZoomLevel());
- //
- //    QRect grid1 = QRect(-1, 0, 6, 4);
- //    QCOMPARE(engine.calculateGrid(QPointF(550.23*16, 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);
++//    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(25.5, 65.0)), QPointF(73, 33));
++//    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(25.5, 65.0)), QPointF(1, 0));
++//    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(-190.0, 65.0)), QPointF(UNDEFINED, UNDEFINED));
++//    QCOMPARE(MapEngine::convertLatLonToSceneCoordinate(QPointF(20.0, 65.0)), QPointF(UNDEFINED, UNDEFINED));
 +//}
  
- void TestMapEngine::moveLocation()
 -void TestMapEngine::setLocation()
++void TestMapEngine::setLocationNewTilesCount()
  {
--    MapEngine engine;
 -    engine.setZoomLevel(14);
++      MapEngine engine;
      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();
      fetchImageSpy.clear();
  }
  
- //void TestMapEngine::convert()
- //{
- //    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - 14);
- //
- //    QPoint tileNumber = QPoint(1020, 500);
- //    QPointF sceneCoordinate = QPointF(tileNumber.x()*TILE_SIZE_X*zoomFactor, tileNumber.y()*TILE_SIZE_Y*zoomFactor);
- //    QPoint tile = MapEngine::convertSceneCoordinateToTileNumber(14, sceneCoordinate);
- //
- //    QCOMPARE(tileNumber, tile);
- //}
 -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 tile = MapEngine::convertSceneCoordinateToTileNumber(14, sceneCoordinate);
 -
 -    QCOMPARE(tileNumber, tile);
 -}
 -
 -void TestMapEngine::calculateTileGrid()
++void TestMapEngine::setLocationRemovedTilesCount()
+ {
+     MapEngine engine;
 -
+     engine.viewResized(QSize(800, 480));
 -    engine.setZoomLevel(14);
  
- //void TestMapEngine::calculateTileGrid()
- //{
- //    MapEngine engine;
- //
- //    engine.viewResized(QSize(800, 480));
- //    engine.setZoomLevel(14);
- //
- //    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - engine.getZoomLevel());
- //
- //    engine.calculateTileGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_X*zoomFactor));
- //}
 -    int zoomFactor = 1 << (MAX_MAP_ZOOM_LEVEL - engine.getZoomLevel());
++    const int maxItemsCount = 30;
  
- //void TestMapEngine::removeTilesOutOfBounds()
- //{
- //    MapEngine engine;
- //    engine.viewResized(QSize(800, 480));
- //    engine.setZoomLevel(14);
- //
- //    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - engine.getZoomLevel());
- //
- //    engine.setLocation(QPointF(1220.23*zoomFactor, 1220.23*zoomFactor));
- //    qDebug() << "Scene items: " << engine.scene()->items().count();
- //    QTest::qWait(1000);
- //    //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);
- //}
 -    engine.calculateTileGrid(QPointF(1020*TILE_SIZE_X*zoomFactor, 500*TILE_SIZE_X*zoomFactor));
 -}
++    engine.setLocation(QPointF(1220.23*16, 1220.23*16));
++    QTest::qWait(1000);
++    engine.setLocation(QPointF(2220.23*16, 2220.23*16));
++    QTest::qWait(1000);
++    QVERIFY(engine.scene()->items().count() <= maxItemsCount);
 -//void TestMapEngine::removeTilesOutOfBounds()
 -//{
 -//    MapEngine engine;
 -//    engine.viewResized(QSize(800, 480));
 -//    engine.setZoomLevel(14);
 -//
 -//    int zoomFactor = 1 << (MAX_ZOOM_LEVEL - engine.getZoomLevel());
 -//
 -//    engine.setLocation(QPointF(1220.23*zoomFactor, 1220.23*zoomFactor));
 -//    qDebug() << "Scene items: " << engine.scene()->items().count();
 -//    QTest::qWait(1000);
 -//    //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);
 -//}
++    engine.setLocation(QPointF(520.23*16, 2220.23*16));
++    QTest::qWait(1000);
++    engine.setLocation(QPointF(2220.23*16, 520.23*16));
++    QTest::qWait(1000);
++
++    QVERIFY(engine.scene()->items().count() <= maxItemsCount);
++}
  
  QTEST_MAIN(TestMapEngine)
  #include "testmapengine.moc"