diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-06-19 16:33:44 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-07-26 13:38:02 +0000 |
commit | eca7cc8a260538fcccde97fe59d9580250600bf1 (patch) | |
tree | 6a87cc4391b1e0dbf65ee011d0314cfae4c8b19f /tests/auto | |
parent | d6fc6ba0f84c4cda0ccc2e1250da4a68441dd6ba (diff) | |
download | qtlocation-eca7cc8a260538fcccde97fe59d9580250600bf1.tar.gz |
Introduce Map.visibleArea
This will allow moving the visible map area to a subregion
of the viewport, allowing to maintain the desired visible
region visible when overlaying controls on top of the map.
Task-number: QTBUG-68966
Change-Id: Idf4b30f7c1e4062e5e1c0ddc01a31bc856c0bc0c
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative_ui/tst_map.qml | 41 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qgeotiledmap_test.cpp | 29 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qgeotiledmap_test.h | 8 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h | 10 |
4 files changed, 82 insertions, 6 deletions
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml index f05b2c72..2d35fce0 100644 --- a/tests/auto/declarative_ui/tst_map.qml +++ b/tests/auto/declarative_ui/tst_map.qml @@ -52,6 +52,13 @@ Item { extraTypeName = "SomeString" } } + Plugin { + id: testPluginNoVisibleArea; + name: "qmlgeo.test.plugin"; + allowExperimental: true + PluginParameter { name: "supportVisibleArea"; value: false} + } + Plugin { id: itemsOverlay; name: "itemsoverlay"; } property variant coordinate1: QtPositioning.coordinate(10, 11) property variant coordinate2: QtPositioning.coordinate(12, 13) @@ -127,6 +134,16 @@ Item { property var center: QtPositioning.coordinate(-33.0, -47.0) } + Map { + id: mapVisibleArea + width: 256; height: 256; + } + Map { + id: mapVisibleAreaUnsupported + width: 256; height: 256; + } + SignalSpy { id: visibleAreaSpy; target: mapVisibleArea; signalName: 'visibleAreaChanged'} + SignalSpy { id: visibleAreaUnsupportedSpy; target: mapVisibleAreaUnsupported; signalName: 'visibleAreaChanged'} TestCase { when: windowShown && allMapsReady @@ -684,5 +701,29 @@ Item { verify(isNaN(pos.latitude)) verify(isNaN(pos.longitde)) } + + function test_visible_area() + { + wait(1000) + visibleAreaSpy.clear(); + visibleAreaUnsupportedSpy.clear(); + var defaultRect = Qt.rect(0,0,0,0) + + verify(mapVisibleAreaUnsupported.visibleArea, defaultRect) + mapVisibleAreaUnsupported.visibleArea = Qt.rect(0,0,256,256) + compare(visibleAreaUnsupportedSpy.count, 1) + verify(mapVisibleAreaUnsupported.visibleArea, Qt.rect(0,0,256,256)) + mapVisibleAreaUnsupported.plugin = testPluginNoVisibleArea + tryCompare(visibleAreaUnsupportedSpy, "count", 2) + verify(mapVisibleAreaUnsupported.visibleArea, defaultRect) + + verify(mapVisibleArea.visibleArea, defaultRect) + mapVisibleArea.visibleArea = Qt.rect(0,0,256,256) + compare(visibleAreaSpy.count, 1) + verify(mapVisibleArea.visibleArea, Qt.rect(0,0,256,256)) + mapVisibleArea.plugin = testPlugin + tryCompare(visibleAreaSpy, "count", 1) + verify(mapVisibleAreaUnsupported.visibleArea, Qt.rect(0,0,256,256)) + } } } diff --git a/tests/auto/geotestplugin/qgeotiledmap_test.cpp b/tests/auto/geotestplugin/qgeotiledmap_test.cpp index ef2af7db..62abb313 100644 --- a/tests/auto/geotestplugin/qgeotiledmap_test.cpp +++ b/tests/auto/geotestplugin/qgeotiledmap_test.cpp @@ -36,8 +36,9 @@ class QGeoTiledMapTestPrivate: public QGeoTiledMapPrivate { Q_DECLARE_PUBLIC(QGeoTiledMapTest) public: - QGeoTiledMapTestPrivate(QGeoTiledMappingManagerEngine *engine) - : QGeoTiledMapPrivate(engine) + QGeoTiledMapTestPrivate(QGeoTiledMappingManagerEngine *engine, + const QGeoTiledMapTestOptions &options) + : QGeoTiledMapPrivate(engine), m_options(options) { } @@ -68,10 +69,30 @@ public: Q_Q(QGeoTiledMapTest); param->disconnect(q); } + + virtual void setVisibleArea(const QRectF &visibleArea) override + { + if (m_options.supportVisibleArea) + return QGeoTiledMapPrivate::setVisibleArea(visibleArea); + else + return QGeoMapPrivate::setVisibleArea(visibleArea); + } + + virtual QRectF visibleArea() const override + { + if (m_options.supportVisibleArea) + return QGeoTiledMapPrivate::visibleArea(); + else + return QGeoMapPrivate::visibleArea(); + } + + QGeoTiledMapTestOptions m_options; }; -QGeoTiledMapTest::QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, QObject *parent) -: QGeoTiledMap(*new QGeoTiledMapTestPrivate(engine), engine, parent), m_engine(engine) +QGeoTiledMapTest::QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, + const QGeoTiledMapTestOptions &options, + QObject *parent) +: QGeoTiledMap(*new QGeoTiledMapTestPrivate(engine, options), engine, parent), m_engine(engine) { } diff --git a/tests/auto/geotestplugin/qgeotiledmap_test.h b/tests/auto/geotestplugin/qgeotiledmap_test.h index 19c7620e..a6299efe 100644 --- a/tests/auto/geotestplugin/qgeotiledmap_test.h +++ b/tests/auto/geotestplugin/qgeotiledmap_test.h @@ -37,12 +37,18 @@ QT_USE_NAMESPACE class QGeoTiledMappingManagerEngineTest; class QGeoTiledMapTestPrivate; +struct QGeoTiledMapTestOptions { + bool supportVisibleArea = true; +}; + class QGeoTiledMapTest: public QGeoTiledMap { Q_OBJECT Q_DECLARE_PRIVATE(QGeoTiledMapTest) public: - QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0); + QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, + const QGeoTiledMapTestOptions &options, + QObject *parent = 0); protected slots: void onCameraCenter_testChanged(QGeoMapParameter *param, const char *propertyName); diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h index 297be0d5..0db78336 100644 --- a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h +++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h @@ -100,6 +100,10 @@ public: double maxZoomLevel = parameters.value(QStringLiteral("maxZoomLevel")).toDouble(); capabilities.setMaximumZoomLevel(maxZoomLevel); } + if (parameters.contains(QStringLiteral("supportVisibleArea"))) { + bool supportVisibleArea = parameters.value(QStringLiteral("supportVisibleArea")).toBool(); + m_supportVisibleArea = supportVisibleArea; + } setCameraCapabilities(capabilities); fetcher->setTileSize(tileSize()); @@ -108,8 +112,12 @@ public: QGeoMap *createMap() override { - return new QGeoTiledMapTest(this); + QGeoTiledMapTestOptions opts; + opts.supportVisibleArea = m_supportVisibleArea; + return new QGeoTiledMapTest(this, opts); } + + bool m_supportVisibleArea = true; }; #endif |