summaryrefslogtreecommitdiff
path: root/tests/auto/geotestplugin
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-07-03 15:20:46 +0200
committerMichal Klocek <michal.klocek@theqtcompany.com>2016-02-09 13:58:43 +0000
commit5fd9681a3563e2346c722bcd779e2b16cd4ac9fd (patch)
tree0d85e40638232803e25c0b42f0715e7d363a07ad /tests/auto/geotestplugin
parentf5f23c4279b454e2465e7f9835b04cc80332f3a0 (diff)
downloadqtlocation-5fd9681a3563e2346c722bcd779e2b16cd4ac9fd.tar.gz
Refactor prefetching tiles
Current implementation uses same QGeoCameraTiles object to calculate visible tiles and tiles which should be prefetched. This is semi optimal since frustum intersection algorithm uses bunch of different parameters. Simplify the logic and use separate objects, this way values in both cases are cached and calculation is done when required. This is important since prefetchData can be called anytime from map's API. Remove textured tiles from scene when clearCache called, this will force redownload of all the tiles. Add new unit test qgeotiledmap and move prefetch test due to refactoring. Change-Id: I6a906df405f212436cdd35ac76f95b559e6b7aae Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto/geotestplugin')
-rw-r--r--tests/auto/geotestplugin/qgeotiledmap_test.h13
-rw-r--r--tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h19
-rw-r--r--tests/auto/geotestplugin/qgeotilefetcher_test.h11
3 files changed, 28 insertions, 15 deletions
diff --git a/tests/auto/geotestplugin/qgeotiledmap_test.h b/tests/auto/geotestplugin/qgeotiledmap_test.h
index 6cb99806..27ff7164 100644
--- a/tests/auto/geotestplugin/qgeotiledmap_test.h
+++ b/tests/auto/geotestplugin/qgeotiledmap_test.h
@@ -29,20 +29,21 @@
#ifndef QGEOTILEDMAP_TEST_H
#define QGEOTILEDMAP_TEST_H
+#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
#include <QtLocation/private/qgeotiledmap_p.h>
QT_USE_NAMESPACE
-
-
+class QGeoTiledMappingManagerEngineTest;
class QGeoTiledMapTest: public QGeoTiledMap
{
Q_OBJECT
public:
- QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0)
- : QGeoTiledMap(engine, parent) {}
+ QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0):
+ QGeoTiledMap(engine, parent),
+ m_engine(engine){}
public:
- using QGeoTiledMap::setCameraData;
-
+ using QGeoTiledMap::setCameraData;
+ QGeoTiledMappingManagerEngine *m_engine;
};
#endif
diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
index 608edaea..2765c268 100644
--- a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
@@ -57,8 +57,6 @@ public:
capabilities.setMinimumZoomLevel(0.0);
capabilities.setMaximumZoomLevel(20.0);
capabilities.setSupportsBearing(true);
- setCameraCapabilities(capabilities);
-
setTileSize(QSize(256, 256));
QList<QGeoMapType> mapTypes;
@@ -68,14 +66,25 @@ public:
setSupportedMapTypes(mapTypes);
QGeoTileFetcherTest *fetcher = new QGeoTileFetcherTest(this);
- fetcher->setParams(parameters);
- fetcher->setTileSize(QSize(256, 255));
+ if (parameters.contains(QStringLiteral("finishRequestImmediately")))
+ fetcher->setFinishRequestImmediately(parameters.value(QStringLiteral("finishRequestImmediately")).toBool());
+ if (parameters.contains(QStringLiteral("tileSize"))) {
+ int tileSize = parameters.value(QStringLiteral("tileSize")).toInt();
+ setTileSize(QSize(tileSize, tileSize));
+ }
+ if (parameters.contains(QStringLiteral("maxZoomLevel"))) {
+ double maxZoomLevel = parameters.value(QStringLiteral("maxZoomLevel")).toDouble();
+ capabilities.setMaximumZoomLevel(maxZoomLevel);
+ }
+
+ setCameraCapabilities(capabilities);
+ fetcher->setTileSize(tileSize());
setTileFetcher(fetcher);
}
QGeoMap *createMap()
{
- return new QGeoTiledMapTest(this);;
+ return new QGeoTiledMapTest(this);
}
};
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h
index 29a18cf4..a25b0119 100644
--- a/tests/auto/geotestplugin/qgeotilefetcher_test.h
+++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h
@@ -121,10 +121,9 @@ public:
return mappingReply;
}
- void setParams(const QVariantMap &parameters)
+ void setFinishRequestImmediately(bool enabled)
{
- if (parameters.contains(QStringLiteral("finishRequestImmediately")))
- finishRequestImmediately_ = parameters.value(QStringLiteral("finishRequestImmediately")).toBool();
+ finishRequestImmediately_ = enabled;
}
void setTileSize(QSize tileSize)
@@ -139,6 +138,8 @@ public Q_SLOTS:
errorString_.clear();
errorCode_ = QGeoTiledMapReply::NoError;
}
+Q_SIGNALS:
+ void tileFetched(const QGeoTileSpec&);
protected:
void updateRequest(TiledMapReplyTest* mappingReply)
@@ -149,6 +150,7 @@ protected:
} else {
mappingReply->callSetError(QGeoTiledMapReply::NoError, "no error");
mappingReply->callSetFinished(true);
+ emit tileFetched(mappingReply->tileSpec());
}
}
@@ -159,8 +161,9 @@ protected:
return;
}
updateRequest(m_queue.takeFirst());
- if (m_queue.isEmpty())
+ if (m_queue.isEmpty()) {
timer_.stop();
+ }
}
private: