summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_ui/tst_map.qml53
-rw-r--r--tests/auto/geotestplugin/geotestplugin.pro3
-rw-r--r--tests/auto/geotestplugin/qgeotiledmap_test.cpp88
-rw-r--r--tests/auto/geotestplugin/qgeotiledmap_test.h14
-rw-r--r--tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h3
-rw-r--r--tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro2
-rw-r--r--tests/auto/qgeocameracapabilities/tst_qgeocameracapabilities.cpp4
7 files changed, 158 insertions, 9 deletions
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 5f02962d..a81885fb 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -28,8 +28,8 @@
import QtQuick 2.0
import QtTest 1.0
-import QtLocation 5.6
import QtPositioning 5.5
+import QtLocation 5.9
Item {
width:100
@@ -82,7 +82,11 @@ Item {
Map {id: coordinateMap; plugin: herePlugin; center: coordinate3;
width: 1000; height: 1000; zoomLevel: 15 }
-
+ MapParameter {
+ id: testParameter
+ type: "cameraCenter_test"
+ property var center: QtPositioning.coordinate(-33.0, -47.0)
+ }
TestCase {
@@ -128,6 +132,51 @@ Item {
compare(map.center.latitude, 12)
}
+ function test_map_parameters()
+ {
+ // coordinate is set at map element declaration
+ var center = map.toCoordinate(Qt.point((map.width - 1) / 2.0, (map.height - 1) / 2.0))
+ fuzzyCompare(center.latitude, 10, 0.1)
+ fuzzyCompare(center.longitude, 11, 0.1)
+
+ compare(map.mapParameters.length, 0)
+
+ map.addMapParameter(testParameter)
+
+ compare(map.mapParameters.length, 1)
+
+ center = map.toCoordinate(Qt.point((map.width - 1) / 2.0, (map.height - 1) / 2.0))
+ fuzzyCompare(center.latitude, -33, 0.1)
+ fuzzyCompare(center.longitude, -47, 0.1)
+
+ map.addMapParameter(testParameter)
+ compare(map.mapParameters.length, 1)
+
+ map.removeMapParameter(testParameter)
+ compare(map.mapParameters.length, 0)
+
+ center = map.toCoordinate(Qt.point((map.width - 1) / 2.0, (map.height - 1) / 2.0))
+ fuzzyCompare(center.latitude, -33, 0.1)
+ fuzzyCompare(center.longitude, -47, 0.1)
+
+ testParameter.center = map.center
+ map.addMapParameter(testParameter)
+ compare(map.mapParameters.length, 1)
+
+ var center = map.toCoordinate(Qt.point((map.width - 1) / 2.0, (map.height - 1) / 2.0))
+ fuzzyCompare(center.latitude, 10, 0.1)
+ fuzzyCompare(center.longitude, 11, 0.1)
+
+ testParameter.center = QtPositioning.coordinate(-33.0, -47.0)
+
+ center = map.toCoordinate(Qt.point((map.width - 1) / 2.0, (map.height - 1) / 2.0))
+ fuzzyCompare(center.latitude, -33, 0.1)
+ fuzzyCompare(center.longitude, -47, 0.1)
+
+ map.removeMapParameter(testParameter)
+ compare(map.mapParameters.length, 0)
+ }
+
function test_map_clamp()
{
//valid
diff --git a/tests/auto/geotestplugin/geotestplugin.pro b/tests/auto/geotestplugin/geotestplugin.pro
index fb3f1b39..f4fe25b3 100644
--- a/tests/auto/geotestplugin/geotestplugin.pro
+++ b/tests/auto/geotestplugin/geotestplugin.pro
@@ -14,7 +14,8 @@ HEADERS += qgeocodingmanagerengine_test.h \
qgeotiledmap_test.h \
qgeotilefetcher_test.h
-SOURCES += qgeoserviceproviderplugin_test.cpp
+SOURCES += qgeoserviceproviderplugin_test.cpp \
+ qgeotiledmap_test.cpp
OTHER_FILES += \
geotestplugin.json \
diff --git a/tests/auto/geotestplugin/qgeotiledmap_test.cpp b/tests/auto/geotestplugin/qgeotiledmap_test.cpp
new file mode 100644
index 00000000..ef2af7db
--- /dev/null
+++ b/tests/auto/geotestplugin/qgeotiledmap_test.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmap_test.h"
+#include <QtLocation/private/qgeotiledmap_p_p.h>
+#include <QtLocation/private/qgeomapparameter_p.h>
+
+QT_USE_NAMESPACE
+
+class QGeoTiledMapTestPrivate: public QGeoTiledMapPrivate
+{
+ Q_DECLARE_PUBLIC(QGeoTiledMapTest)
+public:
+ QGeoTiledMapTestPrivate(QGeoTiledMappingManagerEngine *engine)
+ : QGeoTiledMapPrivate(engine)
+ {
+
+ }
+
+ ~QGeoTiledMapTestPrivate()
+ {
+
+ }
+
+ void addParameter(QGeoMapParameter *param) override
+ {
+ Q_Q(QGeoTiledMapTest);
+ if (param->type() == QStringLiteral("cameraCenter_test")) {
+ // We assume that cameraCenter_test parameters have a QGeoCoordinate property named "center"
+ // Handle the parameter
+ QGeoCameraData cameraData = m_cameraData;
+ QGeoCoordinate newCenter = param->property("center").value<QGeoCoordinate>();
+ cameraData.setCenter(newCenter);
+ q->setCameraData(cameraData);
+ // Connect for further changes handling
+ q->connect(param, SIGNAL(propertyUpdated(QGeoMapParameter *, const char *)),
+ q, SLOT(onCameraCenter_testChanged(QGeoMapParameter*, const char*)));
+
+ }
+ }
+ void removeParameter(QGeoMapParameter *param) override
+ {
+ Q_Q(QGeoTiledMapTest);
+ param->disconnect(q);
+ }
+};
+
+QGeoTiledMapTest::QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, QObject *parent)
+: QGeoTiledMap(*new QGeoTiledMapTestPrivate(engine), engine, parent), m_engine(engine)
+{
+}
+
+void QGeoTiledMapTest::onCameraCenter_testChanged(QGeoMapParameter *param, const char *propertyName)
+{
+ Q_D(QGeoTiledMapTest);
+ if (strcmp(propertyName, "center") == 0) {
+ QGeoCameraData cameraData = d->m_cameraData;
+ // Not testing for propertyName as this param has only one allowed property
+ QGeoCoordinate newCenter = param->property(propertyName).value<QGeoCoordinate>();
+ cameraData.setCenter(newCenter);
+ setCameraData(cameraData);
+ }
+}
diff --git a/tests/auto/geotestplugin/qgeotiledmap_test.h b/tests/auto/geotestplugin/qgeotiledmap_test.h
index 27ff7164..19c7620e 100644
--- a/tests/auto/geotestplugin/qgeotiledmap_test.h
+++ b/tests/auto/geotestplugin/qgeotiledmap_test.h
@@ -33,17 +33,25 @@
#include <QtLocation/private/qgeotiledmap_p.h>
QT_USE_NAMESPACE
+
class QGeoTiledMappingManagerEngineTest;
+class QGeoTiledMapTestPrivate;
+
class QGeoTiledMapTest: public QGeoTiledMap
{
Q_OBJECT
+ Q_DECLARE_PRIVATE(QGeoTiledMapTest)
public:
- QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0):
- QGeoTiledMap(engine, parent),
- m_engine(engine){}
+ QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0);
+
+protected slots:
+ void onCameraCenter_testChanged(QGeoMapParameter *param, const char *propertyName);
+
public:
using QGeoTiledMap::setCameraData;
QGeoTiledMappingManagerEngine *m_engine;
};
#endif
+
+
diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
index 2765c268..015a203a 100644
--- a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
@@ -57,6 +57,9 @@ public:
capabilities.setMinimumZoomLevel(0.0);
capabilities.setMaximumZoomLevel(20.0);
capabilities.setSupportsBearing(true);
+ capabilities.setSupportsTilting(true);
+ capabilities.setMinimumTilt(0);
+ capabilities.setMaximumTilt(60);
setTileSize(QSize(256, 256));
QList<QGeoMapType> mapTypes;
diff --git a/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro b/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro
index f629a154..d061f18f 100644
--- a/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro
+++ b/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro
@@ -6,4 +6,4 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeocameracapabilities.cpp
-QT += location positioning-private testlib
+QT += location-private positioning-private testlib
diff --git a/tests/auto/qgeocameracapabilities/tst_qgeocameracapabilities.cpp b/tests/auto/qgeocameracapabilities/tst_qgeocameracapabilities.cpp
index 54755421..09d7293b 100644
--- a/tests/auto/qgeocameracapabilities/tst_qgeocameracapabilities.cpp
+++ b/tests/auto/qgeocameracapabilities/tst_qgeocameracapabilities.cpp
@@ -29,8 +29,8 @@
#include <QtCore/QString>
#include <QtTest/QtTest>
-#include "qgeocameracapabilities_p.h"
-#include "qgeotiledmap_p.h"
+#include <QtLocation/private/qgeocameracapabilities_p.h>
+#include <QtLocation/private/qgeotiledmap_p.h>
QT_USE_NAMESPACE