summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/declarative_ui/tst_map.qml53
-rw-r--r--tests/auto/geotestplugin/geotestplugin.pro3
-rw-r--r--tests/auto/geotestplugin/qgeocodingmanagerengine_test.h5
-rw-r--r--tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h6
-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/tst_qgeocameracapabilities.cpp4
-rw-r--r--tests/auto/qgeocircle/tst_qgeocircle.cpp40
-rw-r--r--tests/auto/qgeopath/qgeopath.pro8
-rw-r--r--tests/auto/qgeopath/tst_qgeopath.cpp385
-rw-r--r--tests/auto/qgeorectangle/tst_qgeorectangle.cpp33
-rw-r--r--tests/auto/qgeoroutereply/tst_qgeoroutereply.cpp2
14 files changed, 619 insertions, 26 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index e3236deb..ba7dc523 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -74,6 +74,7 @@ SUBDIRS += \
qgeoshape \
qgeorectangle \
qgeocircle \
+ qgeopath \
qgeocoordinate \
qgeolocation \
qgeopositioninfo \
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/qgeocodingmanagerengine_test.h b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
index 1d9f0792..ecbb60d1 100644
--- a/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
@@ -57,11 +57,6 @@ public:
void callSetOffset ( int offset ) {setOffset(offset);}
void callSetLocations ( const QList<QGeoLocation> & locations ) {setLocations(locations);}
void callSetViewport ( const QGeoShape &viewport ) {setViewport(viewport);}
- void abort() {
- emit aborted();
- }
-Q_SIGNALS:
- void aborted();
};
class QGeoCodingManagerEngineTest: public QGeoCodingManagerEngine
diff --git a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
index 8ae58042..0a1e7ce6 100644
--- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
@@ -52,12 +52,6 @@ public:
void callSetError ( Error error, const QString & errorString ) {setError(error, errorString);}
void callSetFinished ( bool finished ) {setFinished(finished);}
void callSetRoutes(const QList<QGeoRoute> &routes) {setRoutes(routes);}
-
- void abort() {
- emit aborted();
- }
-Q_SIGNALS:
- void aborted();
};
class QGeoRoutingManagerEngineTest: public QGeoRoutingManagerEngine
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/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
diff --git a/tests/auto/qgeocircle/tst_qgeocircle.cpp b/tests/auto/qgeocircle/tst_qgeocircle.cpp
index 01fbed6b..fb2f248b 100644
--- a/tests/auto/qgeocircle/tst_qgeocircle.cpp
+++ b/tests/auto/qgeocircle/tst_qgeocircle.cpp
@@ -60,6 +60,9 @@ private slots:
void contains_data();
void contains();
+ void boundingGeoRectangle_data();
+ void boundingGeoRectangle();
+
void extendShape();
void extendShape_data();
@@ -243,7 +246,7 @@ void tst_QGeoCircle::valid()
QCOMPARE(c.isValid(), valid);
QGeoShape area = c;
- QCOMPARE(c.isValid(), valid);
+ QCOMPARE(area.isValid(), valid);
}
void tst_QGeoCircle::empty_data()
@@ -281,7 +284,7 @@ void tst_QGeoCircle::contains_data()
QTest::addColumn<QGeoCoordinate>("probe");
QTest::addColumn<bool>("result");
- QTest::newRow("own centre") << QGeoCoordinate(1,1) << qreal(100.0) <<
+ QTest::newRow("own center") << QGeoCoordinate(1,1) << qreal(100.0) <<
QGeoCoordinate(1,1) << true;
QTest::newRow("over the hills") << QGeoCoordinate(1,1) << qreal(100.0) <<
QGeoCoordinate(30, 40) << false;
@@ -291,6 +294,7 @@ void tst_QGeoCircle::contains_data()
QGeoCoordinate(1.00077538, 0.99955527) << true;
QTest::newRow("at 1.01*radius") << QGeoCoordinate(1,1) << qreal(100.0) <<
QGeoCoordinate(1.00071413, 0.99943423) << false;
+ // TODO: add tests for edge circle cases: cross 1 pole, cross both poles
}
void tst_QGeoCircle::contains()
@@ -307,6 +311,38 @@ void tst_QGeoCircle::contains()
QCOMPARE(area.contains(probe), result);
}
+void tst_QGeoCircle::boundingGeoRectangle_data()
+{
+ QTest::addColumn<QGeoCoordinate>("center");
+ QTest::addColumn<qreal>("radius");
+ QTest::addColumn<QGeoCoordinate>("probe");
+ QTest::addColumn<bool>("result");
+
+ QTest::newRow("own center") << QGeoCoordinate(1,1) << qreal(100.0) <<
+ QGeoCoordinate(1,1) << true;
+ QTest::newRow("over the hills") << QGeoCoordinate(1,1) << qreal(100.0) <<
+ QGeoCoordinate(30, 40) << false;
+ QTest::newRow("at 0.5*radius") << QGeoCoordinate(1,1) << qreal(100.0) <<
+ QGeoCoordinate(1.00015374,1.00015274) << true;
+ QTest::newRow("at 0.99*radius") << QGeoCoordinate(1,1) << qreal(100.0) <<
+ QGeoCoordinate(1.00077538, 0.99955527) << true;
+ QTest::newRow("Outside the box") << QGeoCoordinate(1,1) << qreal(100.0) <<
+ QGeoCoordinate(1.00071413, 0.99903423) << false;
+ // TODO: add tests for edge circle cases: cross 1 pole, cross both poles
+}
+
+void tst_QGeoCircle::boundingGeoRectangle()
+{
+ QFETCH(QGeoCoordinate, center);
+ QFETCH(qreal, radius);
+ QFETCH(QGeoCoordinate, probe);
+ QFETCH(bool, result);
+
+ QGeoCircle c(center, radius);
+ QGeoRectangle box = c.boundingGeoRectangle();
+ QCOMPARE(box.contains(probe), result);
+}
+
void tst_QGeoCircle::extendShape()
{
QFETCH(QGeoCircle, circle);
diff --git a/tests/auto/qgeopath/qgeopath.pro b/tests/auto/qgeopath/qgeopath.pro
new file mode 100644
index 00000000..eec05974
--- /dev/null
+++ b/tests/auto/qgeopath/qgeopath.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+CONFIG += testcase
+TARGET = tst_qgeopath
+
+SOURCES += \
+ tst_qgeopath.cpp
+
+QT += positioning testlib
diff --git a/tests/auto/qgeopath/tst_qgeopath.cpp b/tests/auto/qgeopath/tst_qgeopath.cpp
new file mode 100644
index 00000000..8c4ac767
--- /dev/null
+++ b/tests/auto/qgeopath/tst_qgeopath.cpp
@@ -0,0 +1,385 @@
+/****************************************************************************
+**
+** 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 <QtTest/QtTest>
+#include <QtPositioning/QGeoCoordinate>
+#include <QtPositioning/QGeoRectangle>
+#include <QtPositioning/QGeoPath>
+
+QT_USE_NAMESPACE
+
+class tst_QGeoPath : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void defaultConstructor();
+ void listConstructor();
+ void assignment();
+
+ void comparison();
+ void type();
+
+ void path();
+ void width();
+
+ void translate_data();
+ void translate();
+
+ void valid_data();
+ void valid();
+
+ void contains_data();
+ void contains();
+
+ void boundingGeoRectangle_data();
+ void boundingGeoRectangle();
+
+ void extendShape();
+ void extendShape_data();
+};
+
+void tst_QGeoPath::defaultConstructor()
+{
+ QGeoPath p;
+ QVERIFY(!p.path().size());
+ QCOMPARE(p.width(), qreal(0.0));
+}
+
+void tst_QGeoPath::listConstructor()
+{
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ coords.append(QGeoCoordinate(3,0));
+
+ QGeoPath p(coords, 1.0);
+ QCOMPARE(p.width(), qreal(1.0));
+ QCOMPARE(p.path().size(), 3);
+
+ for (const QGeoCoordinate &c : coords) {
+ QCOMPARE(p.path().contains(c), true);
+ }
+}
+
+void tst_QGeoPath::assignment()
+{
+ QGeoPath p1;
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ coords.append(QGeoCoordinate(3,0));
+ QGeoPath p2(coords, 1.0);
+
+ QVERIFY(p1 != p2);
+
+ p1 = p2;
+ QCOMPARE(p1.path(), coords);
+ QCOMPARE(p1.width(), 1.0);
+ QCOMPARE(p1, p2);
+
+ // Assign c1 to an area
+ QGeoShape area = p1;
+ QCOMPARE(area.type(), p1.type());
+ QVERIFY(area == p1);
+
+ // Assign the area back to a bounding circle
+ QGeoPath p3 = area;
+ QCOMPARE(p3.path(), coords);
+ QCOMPARE(p3.width(), 1.0);
+
+ // Check that the copy is not modified when modifying the original.
+ p1.setWidth(2.0);
+ QVERIFY(p3.width() != p1.width());
+ QVERIFY(p3 != p1);
+}
+
+void tst_QGeoPath::comparison()
+{
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ coords.append(QGeoCoordinate(3,0));
+ QList<QGeoCoordinate> coords2;
+ coords2.append(QGeoCoordinate(3,1));
+ coords2.append(QGeoCoordinate(4,2));
+ coords2.append(QGeoCoordinate(3,0));
+ QGeoPath c1(coords, qreal(50.0));
+ QGeoPath c2(coords, qreal(50.0));
+ QGeoPath c3(coords, qreal(35.0));
+ QGeoPath c4(coords2, qreal(50.0));
+
+ QVERIFY(c1 == c2);
+ QVERIFY(!(c1 != c2));
+
+ QVERIFY(!(c1 == c3));
+ QVERIFY(c1 != c3);
+
+ QVERIFY(!(c1 == c4));
+ QVERIFY(c1 != c4);
+
+ QVERIFY(!(c2 == c3));
+ QVERIFY(c2 != c3);
+
+ QGeoRectangle b1(QGeoCoordinate(20,20),QGeoCoordinate(10,30));
+ QVERIFY(!(c1 == b1));
+ QVERIFY(c1 != b1);
+
+ QGeoShape *c2Ptr = &c2;
+ QVERIFY(c1 == *c2Ptr);
+ QVERIFY(!(c1 != *c2Ptr));
+
+ QGeoShape *c3Ptr = &c3;
+ QVERIFY(!(c1 == *c3Ptr));
+ QVERIFY(c1 != *c3Ptr);
+}
+
+void tst_QGeoPath::type()
+{
+ QGeoPath c;
+ QCOMPARE(c.type(), QGeoShape::PathType);
+}
+
+void tst_QGeoPath::path()
+{
+ QList<QGeoCoordinate> coords;
+ coords.append(QGeoCoordinate(1,1));
+ coords.append(QGeoCoordinate(2,2));
+ coords.append(QGeoCoordinate(3,0));
+
+ QGeoPath p;
+ p.setPath(coords);
+ QCOMPARE(p.path().size(), 3);
+
+ for (const QGeoCoordinate &c : coords) {
+ QCOMPARE(p.path().contains(c), true);
+ }
+}
+
+void tst_QGeoPath::width()
+{
+ QGeoPath p;
+ p.setWidth(10.0);
+ QCOMPARE(p.width(), qreal(10.0));
+}
+
+void tst_QGeoPath::translate_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<double>("lat");
+ QTest::addColumn<double>("lon");
+
+ QTest::newRow("Simple") << QGeoCoordinate(1,1) << QGeoCoordinate(2,2) <<
+ QGeoCoordinate(3,0) << 5.0 << 4.0;
+ QTest::newRow("Backward") << QGeoCoordinate(1,1) << QGeoCoordinate(2,2) <<
+ QGeoCoordinate(3,0) << -5.0 << -4.0;
+}
+
+void tst_QGeoPath::translate()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(double, lat);
+ QFETCH(double, lon);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPath p(coords);
+
+ p.translate(lat, lon);
+
+ for (int i = 0; i < p.path().size(); i++) {
+ QCOMPARE(coords[i].latitude(), p.path()[i].latitude() - lat );
+ QCOMPARE(coords[i].longitude(), p.path()[i].longitude() - lon );
+ }
+}
+
+void tst_QGeoPath::valid_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<qreal>("width");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("empty coords") << QGeoCoordinate() << QGeoCoordinate() << QGeoCoordinate() << qreal(5.0) << false;
+ QTest::newRow("invalid coord") << QGeoCoordinate(50, 50) << QGeoCoordinate(60, 60) << QGeoCoordinate(700, 700) << qreal(5.0) << false;
+ QTest::newRow("bad width") << QGeoCoordinate(10, 10) << QGeoCoordinate(11, 11) << QGeoCoordinate(10, 12) << qreal(-5.0) << true;
+ QTest::newRow("NaN width") << QGeoCoordinate(10, 10) << QGeoCoordinate(11, 11) << QGeoCoordinate(10, 12) << qreal(qQNaN()) << true;
+ QTest::newRow("zero width") << QGeoCoordinate(10, 10) << QGeoCoordinate(11, 11) << QGeoCoordinate(10, 12) << qreal(0) << true;
+ QTest::newRow("good") << QGeoCoordinate(10, 10) << QGeoCoordinate(11, 11) << QGeoCoordinate(10, 12) << qreal(5) << true;
+}
+
+void tst_QGeoPath::valid()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(qreal, width);
+ QFETCH(bool, valid);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPath p(coords, width);
+
+ QCOMPARE(p.isValid(), valid);
+
+ QGeoShape area = p;
+ QCOMPARE(area.isValid(), valid);
+}
+
+void tst_QGeoPath::contains_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<qreal>("width");
+ QTest::addColumn<QGeoCoordinate>("probe");
+ QTest::addColumn<bool>("result");
+
+ QList<QGeoCoordinate> c;
+ c.append(QGeoCoordinate(1,1));
+ c.append(QGeoCoordinate(2,2));
+ c.append(QGeoCoordinate(3,0));
+
+ QTest::newRow("One of the points") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(2, 2) << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0, 0) << false;
+ QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0, 0) << true;
+}
+
+void tst_QGeoPath::contains()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(qreal, width);
+ QFETCH(QGeoCoordinate, probe);
+ QFETCH(bool, result);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPath p(coords, width);
+
+ QCOMPARE(p.contains(probe), result);
+
+ QGeoShape area = p;
+ QCOMPARE(area.contains(probe), result);
+}
+
+void tst_QGeoPath::boundingGeoRectangle_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<qreal>("width");
+ QTest::addColumn<QGeoCoordinate>("probe");
+ QTest::addColumn<bool>("result");
+
+ QList<QGeoCoordinate> c;
+ c.append(QGeoCoordinate(1,1));
+ c.append(QGeoCoordinate(2,2));
+ c.append(QGeoCoordinate(3,0));
+
+ QTest::newRow("One of the points") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(2, 2) << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0, 0) << false;
+ QTest::newRow("Inside the bounds") << c[0] << c[1] << c[2] << 100.0 << QGeoCoordinate(1, 0) << true;
+ QTest::newRow("Inside the bounds") << c[0] << c[1] << c[2] << 100.0 << QGeoCoordinate(1.1, 0.1) << true;
+}
+
+void tst_QGeoPath::boundingGeoRectangle()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(qreal, width);
+ QFETCH(QGeoCoordinate, probe);
+ QFETCH(bool, result);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPath p(coords, width);
+
+ QGeoRectangle box = p.boundingGeoRectangle();
+ QCOMPARE(box.contains(probe), result);
+}
+
+void tst_QGeoPath::extendShape()
+{
+ QFETCH(QGeoCoordinate, c1);
+ QFETCH(QGeoCoordinate, c2);
+ QFETCH(QGeoCoordinate, c3);
+ QFETCH(qreal, width);
+ QFETCH(QGeoCoordinate, probe);
+ QFETCH(bool, before);
+ QFETCH(bool, after);
+
+ QList<QGeoCoordinate> coords;
+ coords.append(c1);
+ coords.append(c2);
+ coords.append(c3);
+ QGeoPath p(coords, width);
+
+
+ QCOMPARE(p.contains(probe), before);
+ p.extendShape(probe);
+ QCOMPARE(p.contains(probe), after);
+}
+
+void tst_QGeoPath::extendShape_data()
+{
+ QTest::addColumn<QGeoCoordinate>("c1");
+ QTest::addColumn<QGeoCoordinate>("c2");
+ QTest::addColumn<QGeoCoordinate>("c3");
+ QTest::addColumn<qreal>("width");
+ QTest::addColumn<QGeoCoordinate>("probe");
+ QTest::addColumn<bool>("before");
+ QTest::addColumn<bool>("after");
+
+ QList<QGeoCoordinate> c;
+ c.append(QGeoCoordinate(1,1));
+ c.append(QGeoCoordinate(2,2));
+ c.append(QGeoCoordinate(3,0));
+
+ QTest::newRow("One of the points") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(2, 2) << true << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0, 0) << false << true;
+ QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0, 0) << true << true;
+}
+
+QTEST_MAIN(tst_QGeoPath)
+#include "tst_qgeopath.moc"
diff --git a/tests/auto/qgeorectangle/tst_qgeorectangle.cpp b/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
index 71a3765a..06b65e86 100644
--- a/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
+++ b/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
@@ -71,6 +71,9 @@ private slots:
void center();
void center_data();
+ void boundingGeoRectangle();
+ void boundingGeoRectangle_data();
+
void containsCoord();
void containsCoord_data();
@@ -957,6 +960,28 @@ void tst_QGeoRectangle::center_data()
QGeoCoordinate(-90.0, -170.0));
}
+void tst_QGeoRectangle::boundingGeoRectangle_data()
+{
+ QTest::addColumn<QGeoRectangle>("rectangle");
+
+ QGeoRectangle b1(QGeoCoordinate(70, 30), QGeoCoordinate(30, 70));
+ QGeoRectangle b2(QGeoCoordinate(70, 150), QGeoCoordinate(30, -170));
+ QGeoRectangle b3(QGeoCoordinate(90, 30), QGeoCoordinate(50, 70));
+ QGeoRectangle b4(QGeoCoordinate(-50, 30), QGeoCoordinate(-90, 70));
+
+ QTest::newRow("Box 1") << b1;
+ QTest::newRow("Box 2") << b2;
+ QTest::newRow("Box 3") << b3;
+ QTest::newRow("Box 4") << b4;
+}
+
+void tst_QGeoRectangle::boundingGeoRectangle()
+{
+ QFETCH(QGeoRectangle, rectangle);
+
+ QGeoRectangle box = rectangle.boundingGeoRectangle();
+ QCOMPARE(box, rectangle);
+}
void tst_QGeoRectangle::containsCoord()
{
@@ -1769,14 +1794,14 @@ void tst_QGeoRectangle::translate_data()
<< 20.0
<< 20.0
<< QGeoRectangle(QGeoCoordinate(90.0, -10.0),
- QGeoCoordinate(40.0, 50.0));
+ QGeoCoordinate(30.0, 50.0));
QTest::newRow("non wrapping -> south clip")
<< QGeoRectangle(QGeoCoordinate(-20.0, -30.0),
QGeoCoordinate(-80.0, 30.0))
<< -20.0
<< 20.0
- << QGeoRectangle(QGeoCoordinate(-40.0, -10.0),
+ << QGeoRectangle(QGeoCoordinate(-30.0, -10.0),
QGeoCoordinate(-90.0, 50.0));
QTest::newRow("wrapping -> non wrapping")
@@ -1801,14 +1826,14 @@ void tst_QGeoRectangle::translate_data()
<< 20.0
<< 20.0
<< QGeoRectangle(QGeoCoordinate(90.0, 150.0),
- QGeoCoordinate(40.0, -150.0));
+ QGeoCoordinate(30.0, -150.0));
QTest::newRow("wrapping -> south clip")
<< QGeoRectangle(QGeoCoordinate(-20.0, 130.0),
QGeoCoordinate(-80.0, -170.0))
<< -20.0
<< 20.0
- << QGeoRectangle(QGeoCoordinate(-40.0, 150.0),
+ << QGeoRectangle(QGeoCoordinate(-30.0, 150.0),
QGeoCoordinate(-90.0, -150.0));
}
diff --git a/tests/auto/qgeoroutereply/tst_qgeoroutereply.cpp b/tests/auto/qgeoroutereply/tst_qgeoroutereply.cpp
index 447181f2..de406b40 100644
--- a/tests/auto/qgeoroutereply/tst_qgeoroutereply.cpp
+++ b/tests/auto/qgeoroutereply/tst_qgeoroutereply.cpp
@@ -197,7 +197,7 @@ void tst_QGeoRouteReply::abort()
reply->abort();
QCOMPARE(signalerror->count(), 0);
- QCOMPARE(signalfinished->count(), 1);
+ QCOMPARE(signalfinished->count(), 0);
}
void tst_QGeoRouteReply::error()