diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-06-10 09:40:49 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-06-10 10:21:44 +0000 |
commit | c4cfee65f4f2132ef28ace089837149b64b38e52 (patch) | |
tree | 7395e97d3d2c161f4abb505d6acf6ecb9464448f | |
parent | c94226b3ec322726fea7ea42cf631b0bef0769b2 (diff) | |
download | qtlocation-c4cfee65f4f2132ef28ace089837149b64b38e52.tar.gz |
Fix activeMapType handling
* fix map type test to use geo test plugin
* add test types to test plugin
* rewrite map type test so it actually tests something
* fix activeMapTypeChanged signal
* create default map type as NoMap type
Change-Id: I9398815fe42cbdeb392bd226de0c8764d3e0bc19
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r-- | src/imports/location/qdeclarativegeomap.cpp | 12 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map_maptype.qml | 111 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h | 6 |
3 files changed, 64 insertions, 65 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index b00d46b7..53c40a6e 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -192,6 +192,9 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent) // Create internal flickable and pinch area. m_gestureArea = new QDeclarativeGeoMapGestureArea(this, this); + m_activeMapType = new QDeclarativeGeoMapType(QGeoMapType(QGeoMapType::NoMap, + tr("No Map"), + tr("No Map"), false, false, 0), this); } QDeclarativeGeoMap::~QDeclarativeGeoMap() @@ -1123,9 +1126,12 @@ void QDeclarativeGeoMap::clearMapItems() */ void QDeclarativeGeoMap::setActiveMapType(QDeclarativeGeoMapType *mapType) { - m_activeMapType = mapType; - m_map->setActiveMapType(mapType->mapType()); - emit activeMapTypeChanged(); + if (m_activeMapType->mapType() != mapType->mapType()) { + m_activeMapType = mapType; + if (m_map) + m_map->setActiveMapType(mapType->mapType()); + emit activeMapTypeChanged(); + } } QDeclarativeGeoMapType * QDeclarativeGeoMap::activeMapType() const diff --git a/tests/auto/declarative_ui/tst_map_maptype.qml b/tests/auto/declarative_ui/tst_map_maptype.qml index 26290399..a20241fc 100644 --- a/tests/auto/declarative_ui/tst_map_maptype.qml +++ b/tests/auto/declarative_ui/tst_map_maptype.qml @@ -33,78 +33,65 @@ import QtQuick 2.0 import QtTest 1.0 -import QtLocation 5.3 +import QtLocation 5.5 -TestCase { - id: testCase +Item{ + id: page + x: 0; y: 0; + width: 100 + height: 100 - name: "MapType" + Plugin { id: testPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true } + Map { id: map; anchors.fill: parent } + SignalSpy { id: supportedMapTypesSpy; target: map; signalName: "supportedMapTypesChanged" } + SignalSpy { id: activeMapTypeChangedSpy; target: map; signalName: "activeMapTypeChanged" } - Plugin { - id: herePlugin - name: "here" - parameters: [ - PluginParameter { - name: "here.app_id" - value: "stub" - }, - PluginParameter { - name: "here.token" - value: "stub" - } - ] - } + TestCase { + id: testCase + name: "MapType" + when: windowShown - Map { - id: map; - plugin: herePlugin - center { - latitude: 62.240501 - longitude: 25.757014 + function initTestCase() + { + compare(map.supportedMapTypes.length, 0) + compare(map.activeMapType.style, MapType.NoMap) + map.plugin = testPlugin + tryCompare(supportedMapTypesSpy, "count", 1) + compare(map.supportedMapTypes.length,3) + compare(map.supportedMapTypes[0].style, MapType.StreetMap) + compare(map.supportedMapTypes[0].name, "StreetMap") + compare(map.supportedMapTypes[0].description, "StreetMap") + compare(map.supportedMapTypes[1].style, MapType.SatelliteMapDay) + compare(map.supportedMapTypes[1].name, "SatelliteMapDay") + compare(map.supportedMapTypes[1].description, "SatelliteMapDay") + compare(map.supportedMapTypes[2].style, MapType.CycleMap) + compare(map.supportedMapTypes[2].name, "CycleMap") + compare(map.supportedMapTypes[2].description, "CycleMap") + //default + compare(map.activeMapType.style, MapType.StreetMap) } - width: 100 - height: 100 - } - SignalSpy {id: supportedSetSpy; target: map; signalName: "supportedMapTypesChanged"} - SignalSpy {id: activeMapTypeChangedSpy; target: map; signalName: "activeMapTypeChanged"} - - function initTestCase() { - if (map.supportedMapTypes.length == 0 && supportedSetSpy.count == 0) { - wait(1000) - if (supportedSetSpy.count == 0) - wait(2000) - compare(supportedSetSpy.count, 1, - "supportedMapTypesChanged signal didn't arrive") + function init() + { + supportedMapTypesSpy.clear() + activeMapTypeChangedSpy.clear() + map.activeMapType = map.supportedMapTypes[0] } - } - function test_supported_types() { - var count = map.supportedMapTypes.length - console.log('Number of supported map types: ' + count) - - console.log('Supported map types:') - for (var i = 0; i < count; i++) { - console.log('style: ' + map.supportedMapTypes[i].style - + ', name: ' + map.supportedMapTypes[i].name - + ', desc: ' + map.supportedMapTypes[i].description - + ', mobile: ' + map.supportedMapTypes[i].mobile) - } - } + function test_setting_types() + { + map.activeMapType = map.supportedMapTypes[0] + tryCompare(activeMapTypeChangedSpy, "count", 0) - function test_setting_types() { - var count = map.supportedMapTypes.length - console.log('Number of supported map types: ' - + map.supportedMapTypes.length) + map.activeMapType = map.supportedMapTypes[1] + tryCompare(activeMapTypeChangedSpy, "count", 1) + compare(map.supportedMapTypes[1].name, map.activeMapType.name) + compare(map.supportedMapTypes[1].style, map.activeMapType.style) - activeMapTypeChangedSpy.clear(); - for (var i = 0; i < count; i++) { - console.log('setting ' + map.supportedMapTypes[i].name) - map.activeMapType = map.supportedMapTypes[i] - compare(map.supportedMapTypes[i].name, map.activeMapType.name, - "Error setting the active maptype (or getting it after)") + map.activeMapType = map.supportedMapTypes[2] + tryCompare(activeMapTypeChangedSpy, "count", 2) + compare(map.supportedMapTypes[2].name, map.activeMapType.name) + compare(map.supportedMapTypes[2].style, map.activeMapType.style) } - console.log('change count: ' + activeMapTypeChangedSpy.count) - compare(activeMapTypeChangedSpy.count, count) } } diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h index 3751a845..2750dfea 100644 --- a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h +++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h @@ -66,6 +66,12 @@ public: setTileSize(QSize(256, 256)); + QList<QGeoMapType> mapTypes; + mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("StreetMap"), tr("StreetMap"), false, false, 1); + mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("SatelliteMapDay"), tr("SatelliteMapDay"), false, false, 2); + mapTypes << QGeoMapType(QGeoMapType::CycleMap, tr("CycleMap"), tr("CycleMap"), false, false, 3); + setSupportedMapTypes(mapTypes); + QGeoTileFetcherTest *fetcher = new QGeoTileFetcherTest(this); fetcher->setParams(parameters); fetcher->setTileSize(QSize(256, 255)); |