summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjuhvu <qt-info@nokia.com>2011-06-03 15:05:42 +1000
committerjuhvu <qt-info@nokia.com>2011-06-03 15:05:42 +1000
commit1712fff1eab0c9ac467618059971276e28d73d05 (patch)
tree2b166545460a6c31adf2cefed612bca150fdf03b
parent7f812b12ac0002a543d2ab8edcbad74b4694bd5b (diff)
downloadqtlocation-1712fff1eab0c9ac467618059971276e28d73d05.tar.gz
Added declarative tests to qtlocation.
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/declarative/landmarks.dbbin0 -> 26624 bytes
-rw-r--r--tests/auto/declarative/qmlmapsandnav.pro12
-rw-r--r--tests/auto/declarative/tst_bounding_area.qml113
-rw-r--r--tests/auto/declarative/tst_map_geocoding.qml512
-rw-r--r--tests/auto/declarative/tst_map_mouse.qml110
-rw-r--r--tests/auto/declarative/tst_map_objectview_qml1164
-rw-r--r--tests/auto/declarative/tst_map_qml1161
-rw-r--r--tests/auto/declarative/tst_map_routing.qml698
-rw-r--r--tests/auto/declarative/tst_plugin.qml119
-rw-r--r--tests/auto/declarative/tst_qmlmapsandnav.cpp52
-rw-r--r--tests/auto/testplugin/qgeoroutingmanagerengine_test.h196
-rw-r--r--tests/auto/testplugin/qgeosearchmanagerengine_test.h250
-rw-r--r--tests/auto/testplugin/qgeosearchmanagerplugins.pro25
-rw-r--r--tests/auto/testplugin/qgeoserviceproviderplugin_test.cpp91
-rw-r--r--tests/auto/testplugin/qgeoserviceproviderplugin_test.h76
16 files changed, 2583 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
new file mode 100644
index 00000000..5a81c123
--- /dev/null
+++ b/tests/auto/auto.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += testplugin
+SUBDIRS += declarative
diff --git a/tests/auto/declarative/landmarks.db b/tests/auto/declarative/landmarks.db
new file mode 100644
index 00000000..e3fb33ac
--- /dev/null
+++ b/tests/auto/declarative/landmarks.db
Binary files differ
diff --git a/tests/auto/declarative/qmlmapsandnav.pro b/tests/auto/declarative/qmlmapsandnav.pro
new file mode 100644
index 00000000..0df01a8e
--- /dev/null
+++ b/tests/auto/declarative/qmlmapsandnav.pro
@@ -0,0 +1,12 @@
+TEMPLATE=app
+TARGET=tst_qmlmapsandnavtest
+CONFIG += warn_on qmltestcase
+SOURCES += tst_qmlmapsandnav.cpp
+
+QT += declarative location
+
+OTHERFILES += *.qml
+
+#qml.path = $$DESTDIR
+#qml.files = *.qml
+#INSTALLS += qml
diff --git a/tests/auto/declarative/tst_bounding_area.qml b/tests/auto/declarative/tst_bounding_area.qml
new file mode 100644
index 00000000..e71cb9cd
--- /dev/null
+++ b/tests/auto/declarative/tst_bounding_area.qml
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtTest 1.0
+import Qt.location 5.0
+
+Item {
+ Coordinate{ id: coordinate1; latitude: 1; longitude: 1}
+ Coordinate{ id: coordinate2; latitude: 2; longitude: 2}
+ Coordinate{ id: coordinate3; latitude: 80; longitude: 80}
+
+ BoundingCircle{ id: emptyCircle}
+ BoundingCircle{ id: circle1; center: coordinate1; radius: 200000}
+
+ SignalSpy {id: radiusSpy; target: emptyCircle; signalName: "radiusChanged"}
+ SignalSpy {id: centerSpy; target: emptyCircle; signalName: "centerChanged"}
+
+ TestCase {
+ name: "Bounding circle"
+ function test_circle_defaults_and_setters() {
+ compare (emptyCircle.radius, -1)
+ compare (circle1.radius, 200000)
+
+ emptyCircle.radius = 200
+ compare (radiusSpy.count, 1)
+ emptyCircle.radius = 200
+ compare (radiusSpy.count, 1)
+
+ emptyCircle.center = coordinate1
+ compare (centerSpy.count, 1)
+ emptyCircle.center = coordinate1
+ compare (centerSpy.count, 1)
+ emptyCircle.center = coordinate2
+ compare (centerSpy.count, 2)
+
+ emptyCircle.center = coordinate1
+ emptyCircle.radius = 200000
+ compare(emptyCircle.contains(coordinate1), true)
+ compare(emptyCircle.contains(coordinate2), true)
+ compare(emptyCircle.contains(coordinate3), false)
+ }
+ }
+
+ // coordinate unit square
+ Coordinate{ id: bottomLeft; latitude: 0; longitude: 0}
+ Coordinate{ id: topLeft; latitude: 1; longitude: 0}
+ Coordinate{ id: topRight; latitude: 1; longitude: 1}
+ Coordinate{ id: bottomRight; latitude: 0; longitude: 1}
+ Coordinate{ id: newTopRight; latitude: 3; longitude: 3}
+
+ Coordinate{ id: inside; latitude: 0.5; longitude: 0.5}
+ Coordinate{ id: outside; latitude: 2; longitude: 2}
+
+ BoundingBox {
+ id: box;
+ bottomLeft: bottomLeft;
+ topLeft: topLeft;
+ topRight: topRight;
+ bottomRight: bottomRight}
+
+ // C++ auto test exists for basics of bounding box, testing here
+ // only added functionality
+ TestCase {
+ name: "Bounding box"
+ function test_box_defaults_and_setters() {
+ compare (box.bottomRight.longitude, bottomRight.longitude) // sanity
+ compare (box.contains(bottomLeft), true)
+ compare (box.contains(inside), true)
+ compare (box.contains(outside), false)
+ box.topRight = newTopRight
+ compare (box.contains(outside), true)
+ }
+ }
+}
diff --git a/tests/auto/declarative/tst_map_geocoding.qml b/tests/auto/declarative/tst_map_geocoding.qml
new file mode 100644
index 00000000..87b24a74
--- /dev/null
+++ b/tests/auto/declarative/tst_map_geocoding.qml
@@ -0,0 +1,512 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtTest 1.0
+import Qt.location 5.0
+
+Item {
+ Plugin { id: nokiaPlugin; name: "nokia"}
+ Plugin { id: invalidPlugin; name: "invalid"}
+
+ Coordinate{ id: coordinate1; latitude: 51; longitude: 41}
+ Coordinate{ id: coordinate2; latitude: 52; longitude: 42}
+ BoundingBox{ id: boundingBox1; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000}
+ BoundingBox{ id: boundingBox2; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000}
+ BoundingCircle { id: boundingCircle1; center: coordinate1; radius: 100}
+ BoundingCircle { id: boundingCircle2; center: coordinate2; radius: 100}
+
+ BoundingBox {id: emptyBox}
+ Coordinate {id: emptyCoordinate}
+ GeocodeModel {id: emptyModel}
+
+ Address {id: emptyAddress}
+ SignalSpy {id: querySpy; target: emptyModel; signalName: "queryChanged"}
+ SignalSpy {id: autoUpdateSpy; target: emptyModel; signalName: "autoUpdateChanged"}
+ SignalSpy {id: pluginSpy; target: emptyModel ; signalName: "pluginChanged"}
+ SignalSpy {id: boundsSpy; target: emptyModel; signalName: "boundsChanged"}
+
+ TestCase {
+ id: testCase1
+ name: "Map GeocodeModel basic API"
+ function test_model_defaults_and_setters() {
+ // Query: address
+ compare (querySpy.count, 0)
+ emptyModel.query = address1
+ compare (querySpy.count, 1)
+ compare (emptyModel.query.street, address1.street)
+ emptyModel.query = address1
+ compare (querySpy.count, 1)
+ compare (emptyModel.query.street, address1.street)
+ // Query:: coordinate
+ emptyModel.query = coordinate1
+ compare (querySpy.count, 2)
+ compare (emptyModel.query.latitude, coordinate1.latitude)
+ emptyModel.query = coordinate1
+ compare (querySpy.count, 2)
+ compare (emptyModel.query.latitude, coordinate1.latitude)
+
+ // bounding box
+ compare(boundsSpy.count, 0)
+ emptyModel.bounds = boundingBox1
+ compare(boundsSpy.count, 1)
+ compare(emptyModel.bounds.topLeft.latitude, boundingBox1.topLeft.latitude)
+ compare(emptyModel.bounds.bottomRight.longitude, boundingBox1.bottomRight.longitude)
+ emptyModel.bounds = boundingBox1
+ compare(boundsSpy.count, 1)
+ compare(emptyModel.bounds.topLeft.latitude, boundingBox1.topLeft.latitude)
+ compare(emptyModel.bounds.bottomRight.longitude, boundingBox1.bottomRight.longitude)
+ emptyModel.bounds = boundingBox2
+ compare(boundsSpy.count, 2)
+ compare(emptyModel.bounds.topLeft.latitude, boundingBox2.topLeft.latitude)
+ compare(emptyModel.bounds.bottomRight.longitude, boundingBox2.bottomRight.longitude)
+ var dynamicBox = Qt.createQmlObject("import QtQuick 1.0; import Qt.location 5.0; BoundingBox { id: dynBox}", testCase1)
+ emptyModel.bounds = dynamicBox
+ compare(boundsSpy.count, 3)
+
+
+ // bounding circle
+ boundsSpy.clear()
+ emptyModel.bounds = boundingCircle1
+ compare(boundsSpy.count, 1)
+ compare(emptyModel.bounds.center.latitude, coordinate1.latitude)
+ emptyModel.bounds = boundingCircle1
+ compare(boundsSpy.count, 1)
+ compare(emptyModel.bounds.center.latitude, coordinate1.latitude)
+ emptyModel.bounds = boundingCircle2
+ compare(boundsSpy.count, 2)
+ compare(emptyModel.bounds.center.latitude, coordinate2.latitude)
+ var dynamicCircle = Qt.createQmlObject("import QtQuick 1.0; import Qt.location 5.0; BoundingCircle { id: dynCircle; center: Coordinate {id: dynCoord; latitude: 8; longitude: 9}}", testCase1)
+ emptyModel.bounds = dynamicCircle
+ compare(boundsSpy.count, 3)
+ compare(emptyModel.bounds.center.latitude, dynamicCircle.center.latitude)
+
+ // status
+ compare (emptyModel.status, RouteModel.Null)
+
+ // error
+ compare (emptyModel.error, "")
+
+ // count
+ compare( emptyModel.count, 0)
+
+ // auto update
+ compare (autoUpdateSpy.count, 0)
+ compare (emptyModel.autoUpdate, false)
+ emptyModel.autoUpdate = true
+ compare (emptyModel.autoUpdate, true)
+ compare (autoUpdateSpy.count, 1)
+ emptyModel.autoUpdate = true
+ compare (emptyModel.autoUpdate, true)
+ compare (autoUpdateSpy.count, 1)
+
+ // mustn't crash even we don't have plugin
+ emptyModel.update()
+
+ // Plugin
+ compare(pluginSpy.count, 0)
+ emptyModel.plugin = nokiaPlugin
+ compare(pluginSpy.count, 1)
+ compare(emptyModel.plugin, nokiaPlugin)
+ emptyModel.plugin = nokiaPlugin
+ compare(pluginSpy.count, 1)
+ emptyModel.plugin = invalidPlugin
+ compare(pluginSpy.count, 2)
+ }
+ // Test that model acts gracefully when plugin is not set or is invalid
+ // (does not support routing)
+ GeocodeModel {id: invalidModel; plugin: invalidPlugin}
+ SignalSpy {id: countInvalidSpy; target: invalidModel; signalName: "countChanged"}
+ function test_invalid_plugin() {
+ invalidModel.update()
+ invalidModel.clear()
+ invalidModel.reset()
+ invalidModel.update()
+ invalidModel.get(-1)
+ invalidModel.get(1)
+ }
+
+ }
+ Address {id: address1; street: "wellknown street"; city: "expected city"; county: "2"}
+ Address {id: errorAddress1; street: "error"; county: "2"} // street is the error reason
+ Coordinate{ id: rcoordinate1; latitude: 51; longitude: 2}
+ Coordinate{ id: errorCoordinate1; latitude: 73; longitude: 2} // (latiude mod 70) is the error code
+ Coordinate{ id: slackCoordinate1; latitude: 60; longitude: 3}
+ Address {id: slackAddress1; street: "Slacker st"; city: "Lazy town"; county: "4"}
+
+ Coordinate{ id: automaticCoordinate1; latitude: 60; longitude: 3}
+ Address {id: automaticAddress1; street: "Auto st"; city: "Detroit"; county: "4"}
+
+ Plugin {
+ id: testPlugin;
+ name: "qmlgeo.test.plugin"
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "supported"; value: true},
+ PluginParameter { name: "finishRequestImmediately"; value: true},
+ PluginParameter { name: "validateWellKnownValues"; value: true}
+ ]
+ }
+
+ Plugin {
+ id: immediatePlugin;
+ name: "qmlgeo.test.plugin"
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "supported"; value: true},
+ PluginParameter { name: "finishRequestImmediately"; value: true},
+ PluginParameter { name: "validateWellKnownValues"; value: false}
+ ]
+ }
+
+ Plugin {
+ id: slackPlugin;
+ name: "qmlgeo.test.plugin"
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "supported"; value: true},
+ PluginParameter { name: "finishRequestImmediately"; value: false},
+ PluginParameter { name: "validateWellKnownValues"; value: false}
+ ]
+ }
+
+ GeocodeModel {id: testModel; plugin: testPlugin}
+ SignalSpy {id: placesSpy; target: testModel; signalName: "placesChanged"}
+ SignalSpy {id: countSpy; target: testModel; signalName: "countChanged"}
+ SignalSpy {id: testQuerySpy; target: testModel; signalName: "queryChanged"}
+ SignalSpy {id: testStatusSpy; target: testModel; signalName: "statusChanged"}
+
+ GeocodeModel {id: slackModel; plugin: slackPlugin; }
+ SignalSpy {id: placesSlackSpy; target: slackModel; signalName: "placesChanged"}
+ SignalSpy {id: countSlackSpy; target: slackModel; signalName: "countChanged"}
+ SignalSpy {id: querySlackSpy; target: slackModel; signalName: "queryChanged"}
+ SignalSpy {id: errorSlackSpy; target: slackModel; signalName: "errorChanged"}
+ SignalSpy {id: pluginSlackSpy; target: slackModel; signalName: "pluginChanged"}
+
+ GeocodeModel {id: immediateModel; plugin: immediatePlugin}
+ SignalSpy {id: placesImmediateSpy; target: immediateModel; signalName: "placesChanged"}
+ SignalSpy {id: countImmediateSpy; target: immediateModel; signalName: "countChanged"}
+ SignalSpy {id: queryImmediateSpy; target: immediateModel; signalName: "queryChanged"}
+ SignalSpy {id: statusImmediateSpy; target: immediateModel; signalName: "statusChanged"}
+ SignalSpy {id: errorImmediateSpy; target: immediateModel; signalName: "errorChanged"}
+
+ GeocodeModel {id: automaticModel; plugin: slackPlugin; query: automaticAddress1; autoUpdate: true}
+ SignalSpy {id: automaticPlacesSpy; target: automaticModel; signalName: "placesChanged"}
+
+ TestCase {
+ name: "Map GeocodeModel basic (reverse) geocoding"
+ function clear_slack_model() {
+ slackModel.clear()
+ placesSlackSpy.clear()
+ countSlackSpy.clear()
+ querySlackSpy.clear()
+ errorSlackSpy.clear()
+ }
+ function clear_immediate_model() {
+ immediateModel.clear()
+ placesImmediateSpy.clear()
+ countImmediateSpy.clear()
+ queryImmediateSpy.clear()
+ errorImmediateSpy.clear()
+ statusImmediateSpy.clear()
+ }
+ function test_reset() {
+ clear_immediate_model();
+ immediateModel.query = errorAddress1
+ immediateModel.update()
+ compare (immediateModel.error, errorAddress1.street)
+ compare (immediateModel.count, 0)
+ compare (statusImmediateSpy.count, 2)
+ compare (immediateModel.status, GeocodeModel.Error)
+ immediateModel.reset()
+ compare (immediateModel.error, "")
+ compare (immediateModel.status, GeocodeModel.Null)
+ // Check that ongoing req is aborted
+ clear_slack_model()
+ slackModel.query = slackAddress1
+ slackAddress1.county = "5"
+ slackModel.update()
+ wait (100)
+ compare (countSlackSpy.count, 0)
+ compare (placesSlackSpy.count, 0)
+ compare (slackModel.count, 0)
+ slackModel.reset()
+ wait (200)
+ compare (countSlackSpy.count, 0)
+ compare (placesSlackSpy.count, 0)
+ compare (slackModel.count, 0)
+ // Check that results are cleared
+ slackModel.update()
+ wait (300)
+ compare (slackModel.count, 5) // slackAddress1.county)
+ slackModel.reset()
+ compare (slackModel.count, 0)
+ // Check that changing plugin resets any ongoing requests
+ clear_slack_model()
+ slackModel.query = slackAddress1
+ slackAddress1.county = "7"
+ compare (pluginSlackSpy.count, 0)
+ slackModel.update()
+ wait (100)
+ compare (countSlackSpy.count, 0)
+ slackModel.plugin = invalidPlugin
+ wait (200)
+ compare (countSlackSpy.count, 0)
+ compare (pluginSlackSpy.count, 1)
+ // switch back and check that works
+ slackModel.plugin = slackPlugin
+ compare (pluginSlackSpy.count, 2)
+ slackModel.update()
+ wait (100)
+ compare (countSlackSpy.count, 0)
+ wait (200)
+ compare (countSlackSpy.count, 1)
+ }
+ function test_error_geocode() {
+ // basic immediate geocode error
+ clear_immediate_model()
+ immediateModel.query = errorAddress1
+ immediateModel.update()
+ compare (errorImmediateSpy.count, 1)
+ compare (immediateModel.error, errorAddress1.street)
+ compare (immediateModel.count, 0)
+ compare (statusImmediateSpy.count, 2)
+ compare (immediateModel.status, GeocodeModel.Error)
+ // basic delayed geocode error
+ clear_slack_model()
+ slackModel.query = errorAddress1
+ errorAddress1.street = "error code 2"
+ slackModel.update()
+ compare (errorSlackSpy.count, 0)
+ tryCompare (errorSlackSpy, "count", 1)
+ compare (slackModel.error, errorAddress1.street)
+ compare (slackModel.count, 0)
+ // Check that we recover
+ slackModel.query = address1
+ slackModel.update()
+ tryCompare(countSlackSpy, "count", 1)
+ compare (slackModel.count, 2)
+ compare (errorSlackSpy.count, 2)
+ compare (slackModel.error, "")
+ }
+
+ function test_error_reverse_geocode() {
+ // basic immediate geocode error
+ clear_immediate_model()
+ immediateModel.query = errorCoordinate1
+ immediateModel.update()
+ if (immediateModel.error != "")
+ compare (errorImmediateSpy.count, 2) // the previous error is cleared upon update()
+ else
+ compare (errorImmediateSpy.count, 1)
+ compare (immediateModel.error, "error")
+ compare (immediateModel.count, 0)
+ compare (statusImmediateSpy.count, 2)
+ compare (immediateModel.status, GeocodeModel.Error)
+ // basic delayed geocode error
+ clear_slack_model()
+ slackModel.query = errorCoordinate1
+ slackModel.update()
+ compare (errorSlackSpy.count, 0)
+ if (slackModel.error != "")
+ tryCompare (errorSlackSpy, "count", 2)
+ else
+ tryCompare (errorSlackSpy, "count", 1)
+ compare (slackModel.error, "error")
+ compare (slackModel.count, 0)
+ // Check that we recover
+ slackModel.query = rcoordinate1
+ slackModel.update()
+ tryCompare(countSlackSpy, "count", 1)
+ compare (slackModel.count, 2)
+ compare (errorSlackSpy.count, 2)
+ compare (slackModel.error, "")
+ }
+ function test_basic_geocode() {
+ testQuerySpy.clear()
+ placesSpy.clear()
+ testStatusSpy.clear()
+ testModel.clear()
+ countSpy.clear()
+ compare (placesSpy.count, 0)
+ compare (testModel.error, "")
+ compare (testModel.count, 0)
+ testModel.query = address1
+ compare (testQuerySpy.count, 1)
+ testModel.update()
+ tryCompare (placesSpy, "count", 1) // 5 sec
+ compare (testModel.error, "")
+ compare (testModel.count, 2)
+ compare (testQuerySpy.count, 1)
+ compare (testStatusSpy.count, 2)
+ compare (testModel.status, GeocodeModel.Ready)
+ compare (testModel.get(0).address.street, "wellknown street")
+ compare (testModel.get(0).address.city, "expected city")
+ }
+
+ function test_geocode_auto_updates() {
+ compare (automaticModel.count, 4) // should be something already
+ compare (automaticPlacesSpy.count, 1)
+ // change query and its contents and verify that autoupdate occurs
+ automaticAddress1.county = 6
+ wait (300)
+ compare (automaticPlacesSpy.count, 2)
+ compare (automaticModel.count, 6)
+ automaticAddress1.street = "The Avenue"
+ wait (300)
+ compare (automaticPlacesSpy.count, 3)
+ compare (automaticModel.count, 6)
+ automaticModel.query = automaticCoordinate1
+ wait (300)
+ compare (automaticPlacesSpy.count, 4)
+ compare (automaticModel.count, 3)
+ automaticCoordinate1.longitude = 7
+ wait (300)
+ compare (automaticPlacesSpy.count, 5)
+ compare (automaticModel.count, 7)
+ }
+
+ function test_delayed_geocode() {
+ // basic delayed response
+ slackModel.clear()
+ querySlackSpy.clear()
+ countSlackSpy.clear()
+ placesSlackSpy.clear()
+ slackModel.query = slackAddress1
+ slackAddress1.county = "7"
+ compare (querySlackSpy.count, 1)
+ slackModel.update()
+ wait (100)
+ compare (countSlackSpy.count, 0)
+ compare (placesSlackSpy.count, 0)
+ compare (slackModel.count, 0)
+ wait (200)
+ compare (countSlackSpy.count, 1)
+ compare (placesSlackSpy.count, 1)
+ compare (slackModel.count, 7) // slackAddress1.county)
+ // Frequent updates, previous requests are aborted
+ slackModel.clear()
+ placesSlackSpy.clear()
+ countSlackSpy.clear()
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ wait (200)
+ compare (placesSlackSpy.count, 1)
+ compare(countSlackSpy.count, 1)
+ compare(slackModel.count, 7) // slackAddress1.county
+ }
+ function test_basic_reverse_geocode() {
+ testQuerySpy.clear()
+ placesSpy.clear()
+ testStatusSpy.clear()
+ countSpy.clear()
+ testModel.clear()
+ compare (testModel.error, "")
+ compare (testModel.count, 0)
+ compare (testQuerySpy.count, 0)
+ testModel.query = rcoordinate1
+ compare (testQuerySpy.count, 1)
+ testModel.update()
+ tryCompare (placesSpy, "count", 1) // 5 sec
+ tryCompare(countSpy, "count", 1)
+ compare (testModel.error, "")
+ compare (testModel.count, 2)
+ testModel.clear()
+ tryCompare(countSpy, "count", 1)
+ compare (testModel.count, 0)
+ }
+ function test_delayed_reverse_geocode() {
+ slackModel.clear()
+ querySlackSpy.clear()
+ countSlackSpy.clear()
+ placesSlackSpy.clear()
+ slackModel.query = slackCoordinate1
+ compare (querySlackSpy.count, 1)
+ slackModel.update()
+ wait (100)
+ compare (countSlackSpy.count, 0)
+ compare (placesSlackSpy.count, 0)
+ compare (slackModel.count, 0)
+ wait (200)
+ compare (countSlackSpy.count, 1)
+ compare (placesSlackSpy.count, 1)
+ compare (slackModel.count, 3) // slackCoordinate1.longitude
+ // Frequent updates, previous requests are aborted
+ slackModel.clear()
+ placesSlackSpy.clear()
+ countSlackSpy.clear()
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ slackModel.update()
+ wait (100)
+ compare(placesSlackSpy.count, 0)
+ compare(countSlackSpy.count, 0)
+ wait (200)
+ compare (placesSlackSpy.count, 1)
+ compare(countSlackSpy.count, 1)
+ compare(slackModel.count, 3) // slackCoordinate1.longitude
+ }
+ }
+}
diff --git a/tests/auto/declarative/tst_map_mouse.qml b/tests/auto/declarative/tst_map_mouse.qml
new file mode 100644
index 00000000..d0b4aa55
--- /dev/null
+++ b/tests/auto/declarative/tst_map_mouse.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtTest 1.0
+import Qt.location 5.0
+
+Item {
+ id: masterItem
+ // General-purpose elements for the test:
+ Plugin { id: testPlugin; name : "nokia"; PluginParameter {name: "mapping.host"; value: "for.nonexistent"}}
+ //Coordinate{ id: mapDefaultCenter; latitude: 10; longitude: 10}
+ Coordinate{ id: mapDefaultCenter; latitude: 0; longitude: 0}
+ Coordinate{ id: topLeftCoord; latitude: 10; longitude: 11}
+ Coordinate{ id: bottomRightCoord; latitude: 12; longitude: 13}
+ MapMouseEvent{ id: dummyMouseEvent;}
+ Rectangle {id: rektankeli; anchors.top: parent.top; width: parent.width; height: 20}
+ Map {
+ id: mouseMap;
+ anchors.top: rektankeli.bottom
+ center: mapDefaultCenter
+ plugin: testPlugin;
+ MapMouseArea {
+ id: mapMouse
+ enabled: true
+ //onClicked: console.log('mouse area clicked mapMouse')
+ }
+ MapCircle {
+ MapMouseArea {
+ id: circleMouse
+ //onClicked: console.log('mouse area clicked circleMouse')
+ }
+ }
+ MapRectangle {
+ topLeft: topLeftCoord
+ bottomRight: bottomRightCoord
+ MapMouseArea {
+ id: rectangleMouse
+ enabled: false
+ //onClicked: console.log('mouse area clicked rectanglemouse')
+ }
+ }
+ }
+ TestCase {
+ name: "MapMouse"
+ when: windowShown
+ SignalSpy {id: rectangleClickedSpy; target: rectangleMouse; signalName: "clicked"}
+ SignalSpy {id: rectangleEnabledSpy; target: rectangleMouse; signalName: "enabledChanged"}
+ SignalSpy {id: rectangleAcceptedButtonsSpy; target: rectangleMouse; signalName: "acceptedButtonsChanged"}
+ function test_signals() {
+ // 1. Default values
+ compare (circleMouse.mouseX, 0)
+ compare (circleMouse.mouseY, 0)
+ compare (circleMouse.pressed, false)
+ compare (circleMouse.enabled, true)
+ // 2. Basic changes
+ compare (rectangleEnabledSpy.count, 0)
+ compare (rectangleAcceptedButtonsSpy.count, 0)
+ rectangleMouse.enabled = true
+ rectangleMouse.acceptedButtons = Qt.MiddleButton
+ compare (rectangleEnabledSpy.count, 1)
+ compare (rectangleAcceptedButtonsSpy.count, 1)
+ // 3. Clicking
+ // MousePress does not work for some reason. It propagates all the way
+ // to the QDeclarativeView but never reaches the graphics geo map.
+ // That should be solved to really be able to test the mouse.
+ //mousePress(masterItem, 5, 5)
+ //mousePress(mouseMap, 20, 20)
+ //compare(rectangleClickedSpy.count, 1)
+ }
+ }
+}
diff --git a/tests/auto/declarative/tst_map_objectview_qml1 b/tests/auto/declarative/tst_map_objectview_qml1
new file mode 100644
index 00000000..370a72b7
--- /dev/null
+++ b/tests/auto/declarative/tst_map_objectview_qml1
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtTest 1.0
+import Qt.location 5.0
+
+Item {
+ id: masterItem
+ width: 200
+ height: 350
+ // General-purpose elements for the test:
+ Plugin { id: testPlugin; name : "nokia"; PluginParameter {name: "mapping.host"; value: "for.nonexistent"}}
+ Coordinate{ id: mapDefaultCenter; latitude: 10; longitude: 30}
+
+ // This model results in 7 landmarks
+ LandmarkModel {
+ id: landmarkModelAll
+ autoUpdate: true
+ //onLandmarksChanged: console.log('all landmarks changed, count: ' + count)
+ }
+ // This model results in 2 landmarks
+ LandmarkModel {
+ id: landmarkModelNearMe
+ autoUpdate: true
+ //onLandmarksChanged: console.log('nearme landmarks changed, count: ' + count)
+ filter: proximityFilter
+ }
+ LandmarkProximityFilter {
+ id: proximityFilter
+ center: mapDefaultCenter
+ radius: 6000000
+ }
+
+ MapCircle {
+ id: externalCircle
+ radius: 2000000
+ center: mapDefaultCenter
+ }
+
+ Map {
+ id: mapWithPlugin; center: mapDefaultCenter; plugin: testPlugin;
+ anchors.fill: parent; size.width: parent.width; size.height: parent.height; zoomLevel: 2
+ MapCircle {
+ id: internalCircle
+ radius: 2000000
+ center: mapDefaultCenter
+ }
+ MapObjectView {
+ id: theObjectView
+ model: landmarkModelAll
+ delegate: Component {
+ MapCircle {
+ radius: 1500000
+ center: landmark.coordinate
+ }
+ }
+ }
+ }
+ Map {
+ id: mapWithoutPlugin; center: mapDefaultCenter;
+ anchors.fill: parent; size.width: parent.width; size.height: parent.height; zoomLevel: 2
+ MapCircle {
+ id: internalCircle2
+ radius: 2000000
+ center: mapDefaultCenter
+ }
+ MapObjectView {
+ id: theObjectView2
+ model: landmarkModelAll
+ delegate: Component {
+ MapCircle {
+ radius: 1500000
+ center: landmark.coordinate
+ }
+ }
+ }
+ }
+
+ TestCase {
+ name: "MapObjectView"
+ function test_a_add_and_remove() {
+ // Basic adding and removing of static object
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 1)
+ mapWithPlugin.addMapObject(internalCircle)
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 1)
+ mapWithPlugin.removeMapObject(internalCircle)
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 0)
+ mapWithPlugin.removeMapObject(internalCircle)
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 0)
+ // Basic adding and removing of dynamic object
+ var dynamicCircle = Qt.createQmlObject( "import QtQuick 1.0; import Qt.location 5.0; MapCircle {radius: 4000; center: mapDefaultCenter}", mapWithPlugin, "");
+ mapWithPlugin.addMapObject(dynamicCircle)
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 1)
+ mapWithPlugin.removeMapObject(dynamicCircle)
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 0)
+ mapWithPlugin.removeMapObject(dynamicCircle)
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 0)
+ }
+ SignalSpy {id: allCountSpy; target: landmarkModelAll; signalName: "countChanged"}
+ SignalSpy {id: nearMeCountSpy; target: landmarkModelNearMe; signalName: "countChanged"}
+ function test_b_model_change() {
+ // Change the model of an MapObjectView on the fly
+ // and verify that object counts change accordingly.
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 0)
+ landmarkModelAll.setDbFileName("landmarks.db")
+ landmarkModelNearMe.setDbFileName("landmarks.db")
+ tryCompare(allCountSpy, "count", 1, 1000)
+ tryCompare(nearMeCountSpy, "count", 1, 1000)
+ compare(landmarkModelAll.count, 7)
+ compare(landmarkModelNearMe.count, 2)
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 7)
+ theObjectView.model = landmarkModelNearMe
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 2)
+ theObjectView.model = landmarkModelAll
+ compare(mapWithPlugin.testGetDeclarativeMapObjectCount(), 7)
+ }
+ SignalSpy {id: pluginChangedSpy; target: mapWithoutPlugin; signalName: "pluginChanged"}
+ function test_c_plugin_set_later() {
+ compare(mapWithoutPlugin.testGetDeclarativeMapObjectCount(), 0)
+ mapWithoutPlugin.plugin = testPlugin
+ tryCompare(pluginChangedSpy, "count", 1, 1000)
+ compare(mapWithoutPlugin.testGetDeclarativeMapObjectCount(), 8) // 7 + 1
+ }
+ }
+}
diff --git a/tests/auto/declarative/tst_map_qml1 b/tests/auto/declarative/tst_map_qml1
new file mode 100644
index 00000000..599e921e
--- /dev/null
+++ b/tests/auto/declarative/tst_map_qml1
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtTest 1.0
+import Qt.location 5.0
+
+Item {
+ // General-purpose elements for the test:
+ Plugin { id: nokiaPlugin; name: "nokia"; PluginParameter {name: "mapping.host"; value: "for.nonexistent"} }
+ Coordinate{ id: coordinate1; latitude: 10; longitude: 11}
+ Coordinate{ id: coordinate2; latitude: 12; longitude: 13}
+ TestCase {
+ name: "MapProperties"
+ Map {id: emptyMap}
+ SignalSpy {id: emptyMapPluginSpy; target: emptyMap; signalName: "pluginChanged" }
+ function test_a_map_properties_without_plugin() {
+ compare (emptyMap.minimumZoomLevel, -1, "Minimum zoom level.")
+ compare (emptyMap.maximumZoomLevel, -1, "Maximum zoom level.")
+ compare (emptyMap.zoomLevel, 8, "Zoom level.")
+ compare (emptyMap.mapType, Map.NoMap, "Map type")
+ compare (emptyMap.connectivityMode, Map.NoConnectivity, "Connectivity mode.")
+ }
+ function test_b_map_properties_with_plugin() {
+ // Set plugin and check that appropriate changes are reflected
+ emptyMap.plugin = nokiaPlugin
+ compare(emptyMapPluginSpy.count, 1, "Plugin changed signal received.")
+ compare (emptyMap.plugin, nokiaPlugin, "Plugin set correctly.")
+ verify(emptyMap.maximumZoomLevel != -1, "Maximum zoom level.")
+ verify(emptyMap.minimumZoomLevel != -1, "Minimum zoom level.")
+ verify(emptyMap.zoomLevel != -1, "Zoom level")
+ // Should not change:
+ compare (emptyMap.mapType, Map.NoMap, "Default map type.")
+ compare (emptyMap.connectivityMode, Map.NoConnectivity, "Connectivity mode.")
+ }
+ }
+ TestCase {
+ name: "MapPolyObjects"
+ Map {
+ id: polygonMap;
+ plugin: nokiaPlugin;
+ MapPolygon {id: polygon1}
+ MapPolygon {id: polygon2; Coordinate{latitude: 0;longitude:1} Coordinate{latitude: 2;longitude:3} }
+ MapPolyline {id:polyline1}
+ MapPolyline {id: polyline2; Coordinate{latitude: 0;longitude:1} Coordinate{latitude: 2;longitude:3} }
+ }
+ SignalSpy {id: polygon2PathSpy; target: polygon2; signalName: "pathChanged"}
+ function test_polygons() {
+ compare(polygon1.path.length, 0)
+ compare(polygon2.path.length, 2)
+ compare(polygon2PathSpy.count, 0)
+ polygon2.addCoordinate(coordinate1)
+ polygon2.addCoordinate(coordinate2)
+ compare(polygon2PathSpy.count, 2)
+ // Check the values are correct
+ compare(polygon2.path[0].latitude, 0)
+ compare(polygon2.path[1].latitude, 2)
+ compare(polygon2.path[2].latitude, 10)
+ compare(polygon2.path[3].latitude, 12)
+ // Remove a coordinate from the middle
+ polygon2.removeCoordinate(coordinate1)
+ compare(polygon2PathSpy.count, 3)
+ compare(polygon2.path[0].latitude, 0)
+ compare(polygon2.path[1].latitude, 2)
+ compare(polygon2.path[2].latitude, 12)
+ // Add same coordinate twice and remove it, latest should be removed
+ polygon2.addCoordinate(coordinate1)
+ polygon2.addCoordinate(coordinate2)
+ compare(polygon2PathSpy.count, 5)
+ compare(polygon2.path[2].latitude, 12)
+ compare(polygon2.path[3].latitude, 10)
+ compare(polygon2.path[4].latitude, 12)
+ polygon2.removeCoordinate(coordinate2)
+ compare(polygon2.path[2].latitude, 12)
+ compare(polygon2.path[3].latitude, 10)
+ compare(polygon2.path.length, 4)
+ // Clear coordinates
+ compare(polygon2PathSpy.count, 6)
+ polygon2.clearCoordinates()
+ compare(polygon2.path.length, 0)
+ compare(polygon2PathSpy.count, 7)
+ }
+ SignalSpy {id: polyline2PathSpy; target: polyline2; signalName: "pathChanged"}
+ function test_polylines() {
+ compare(polyline1.path.length, 0)
+ compare(polyline2.path.length, 2)
+ compare(polyline2PathSpy.count, 0)
+ polyline2.addCoordinate(coordinate1)
+ polyline2.addCoordinate(coordinate2)
+ compare(polyline2PathSpy.count, 2)
+ // Check the values are correct
+ compare(polyline2.path[0].latitude, 0)
+ compare(polyline2.path[1].latitude, 2)
+ compare(polyline2.path[2].latitude, 10)
+ compare(polyline2.path[3].latitude, 12)
+ // Remove a coordinate from the middle
+ polyline2.removeCoordinate(coordinate1)
+ compare(polyline2PathSpy.count, 3)
+ compare(polyline2.path[0].latitude, 0)
+ compare(polyline2.path[1].latitude, 2)
+ compare(polyline2.path[2].latitude, 12)
+ // Add same coordinate twice and remove it, latest should be removed
+ polyline2.addCoordinate(coordinate1)
+ polyline2.addCoordinate(coordinate2)
+ compare(polyline2PathSpy.count, 5)
+ compare(polyline2.path[2].latitude, 12)
+ compare(polyline2.path[3].latitude, 10)
+ compare(polyline2.path[4].latitude, 12)
+ polyline2.removeCoordinate(coordinate2)
+ compare(polyline2.path[2].latitude, 12)
+ compare(polyline2.path[3].latitude, 10)
+ compare(polyline2.path.length, 4)
+ // Clear coordinates
+ compare(polyline2PathSpy.count, 6)
+ polyline2.clearCoordinates()
+ compare(polyline2.path.length, 0)
+ compare(polyline2PathSpy.count, 7)
+ }
+ }
+}
+
+
+
diff --git a/tests/auto/declarative/tst_map_routing.qml b/tests/auto/declarative/tst_map_routing.qml
new file mode 100644
index 00000000..7435349b
--- /dev/null
+++ b/tests/auto/declarative/tst_map_routing.qml
@@ -0,0 +1,698 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtTest 1.0
+import Qt.location 5.0
+
+Item {
+ Plugin { id: nokiaPlugin; name: "nokia"}
+ Plugin { id: invalidPlugin; name: "invalid"}
+ Coordinate{ id: coordinate1; latitude: 51; longitude: 0}
+ Coordinate{ id: coordinate2; latitude: 52; longitude: 0}
+ BoundingBox{ id: boundingBox1; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000}
+ BoundingBox{ id: boundingBox2; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000}
+
+ Coordinate{ id: bottomLeft; latitude: 0; longitude: 0}
+ Coordinate{ id: topLeft; latitude: 1; longitude: 0}
+ Coordinate{ id: topRight; latitude: 1; longitude: 1}
+ Coordinate{ id: bottomRight; latitude: 0; longitude: 1}
+ Coordinate{ id: newTopRight; latitude: 3; longitude: 3}
+ BoundingBox {
+ id: unitBox;
+ bottomLeft: bottomLeft;
+ topLeft: topLeft;
+ topRight: topRight;
+ bottomRight: bottomRight}
+
+ Route {id: emptyRoute}
+ TestCase {
+ name: "RouteManeuver RouteSegment and MapRoute"
+ RouteSegment {id: emptySegment}
+ RouteManeuver {id: emptyManeuver}
+ MapRoute {id: emptyMapRoute}
+
+ BoundingBox {id: emptyBox}
+ Coordinate {id: emptyCoordinate}
+
+ SignalSpy {id: mapRouteDetailLevelSpy; target: emptyMapRoute; signalName: "detailLevelChanged"}
+ SignalSpy {id: mapRouteColorSpy; target: emptyMapRoute; signalName: "colorChanged"}
+ SignalSpy {id: mapRouteRouteSpy; target: emptyMapRoute; signalName: "routeChanged"}
+ function test_maproute_defaults() {
+ compare(mapRouteRouteSpy.count, 0)
+ compare(mapRouteColorSpy.count, 0)
+ compare(mapRouteDetailLevelSpy.count, 0)
+ compare (emptyMapRoute.detailLevel, 6)
+ emptyMapRoute.color = 'green'
+ emptyMapRoute.detailLevel = 3
+ compare(mapRouteRouteSpy.count, 0)
+ compare(mapRouteColorSpy.count, 1)
+ compare(mapRouteDetailLevelSpy.count, 1)
+ emptyMapRoute.color = 'green'
+ emptyMapRoute.detailLevel = 3
+ compare(mapRouteColorSpy.count, 1)
+ compare(mapRouteDetailLevelSpy.count, 1)
+ emptyMapRoute.route = emptyRoute
+ compare(mapRouteRouteSpy.count, 1)
+ compare(emptyMapRoute.route, emptyRoute)
+ }
+
+ function test_route_defaults() {
+ compare(emptyRoute.travelTime, 0)
+ compare(emptyRoute.distance,0)
+ compare(emptyRoute.path.length,0)
+ compare(emptyRoute.segments.length,0)
+ compare(emptyRoute.bounds.topLeft.latitude, emptyBox.topLeft.latitude)
+ compare(emptyRoute.bounds.bottomRight.longitude, emptyBox.bottomRight.longitude)
+ }
+
+ function test_routesegment_defaults() {
+ compare(emptySegment.travelTime, 0)
+ compare(emptySegment.distance, 0)
+ compare(emptySegment.path.length, 0)
+ compare(emptySegment.maneuver.valid, emptyManeuver.valid)
+ compare(emptySegment.maneuver.instructionText, emptyManeuver.instructionText)
+ }
+ function test_maneuver_defaults() {
+ compare(emptyManeuver.valid, false)
+ compare(emptyManeuver.instructionText, "")
+ compare(emptyManeuver.direction, RouteManeuver.NoDirection)
+ compare(emptyManeuver.timeToNextInstruction,0)
+ compare(emptyManeuver.distanceToNextInstruction,0)
+ compare(emptyManeuver.waypoint.latitude, emptyCoordinate.latitude)
+ compare(emptyManeuver.waypoint.longitude, emptyCoordinate.longitude)
+ compare(emptyManeuver.position.latitude, emptyCoordinate.latitude)
+ compare(emptyManeuver.position.longitude, emptyCoordinate.longitude)
+ }
+ }
+
+ TestCase {
+ name: "MapRouteModel and MapRouteQuery"
+ RouteModel {id: emptyModel}
+ RouteQuery {id: emptyQuery}
+
+ function test_model_default_properties() {
+ compare (emptyModel.autoUpdate, false, "Automatic update")
+ compare (emptyModel.status, RouteModel.Null, "Model status")
+ compare (emptyModel.error, "", "Model error")
+ compare (emptyModel.count, 0, "Model count")
+ emptyModel.get(192) // don't do stupid
+
+ compare (emptyQuery.numberAlternativeRoutes, 0, "Number of alternative routes")
+ compare (emptyQuery.travelModes, RouteQuery.CarTravel, "Travel mode")
+ compare (emptyQuery.routeOptimizations, RouteQuery.FastestRoute, "Route optimization")
+ compare (emptyQuery.segmentDetail, RouteQuery.BasicSegmentData)
+ compare (emptyQuery.maneuverDetail, RouteQuery.BasicManeuvers)
+ compare (emptyQuery.waypoints.length, 0, "Waypoints")
+ compare (emptyQuery.excludedAreas.length, 0, "excluded areas")
+ compare (emptyQuery.featureTypes.length, 0, "Feature types")
+ }
+
+ SignalSpy {id: autoUpdateSpy; target: emptyModel; signalName: "autoUpdateChanged"}
+ SignalSpy {id: pluginSpy; target: emptyModel ; signalName: "pluginChanged"}
+
+ SignalSpy {id: travelModesSpy; target: emptyQuery; signalName: "travelModesChanged"}
+ SignalSpy {id: waypointsSpy; target: emptyQuery; signalName: "waypointsChanged"}
+ SignalSpy {id: exclusionSpy; target: emptyQuery; signalName: "excludedAreasChanged"}
+ SignalSpy {id: featureTypesSpy; target: emptyQuery; signalName: "featureTypesChanged"}
+ SignalSpy {id: segmentDetailSpy; target: emptyQuery; signalName: "segmentDetailChanged"}
+ SignalSpy {id: maneuverDetailSpy; target: emptyQuery; signalName: "maneuverDetailChanged"}
+ SignalSpy {id: numberAlterNativeRoutesSpy; target: emptyQuery; signalName: "numberAlternativeRoutesChanged"}
+ SignalSpy {id: routeOptimizationsSpy; target: emptyQuery; signalName: "routeOptimizationsChanged"}
+ SignalSpy {id: queryDetailsChangedSpy; target: emptyQuery; signalName: "queryDetailsChanged"}
+ function test_model_setters() {
+ // Autoupdate
+ compare(autoUpdateSpy.count, 0)
+ emptyModel.autoUpdate = true
+ compare(autoUpdateSpy.count, 1)
+ compare(emptyModel.autoUpdate, true)
+ emptyModel.autoUpdate = true // mustn't retrigger 'changed' -signal
+ compare(autoUpdateSpy.count, 1)
+ emptyModel.autoUpdate = false
+ compare(autoUpdateSpy.count, 2)
+
+ // Travelmodes
+ compare(travelModesSpy.count, 0)
+ emptyQuery.travelModes = RouteQuery.BicycleTravel
+ compare(travelModesSpy.count, 1)
+ compare(emptyQuery.travelModes, RouteQuery.BicycleTravel)
+ emptyQuery.travelModes = RouteQuery.BicycleTravel | RouteQuery.PedestrianTravel
+ compare(emptyQuery.travelModes, RouteQuery.BicycleTravel | RouteQuery.PedestrianTravel)
+ compare(travelModesSpy.count, 2)
+ compare(queryDetailsChangedSpy.count, 2)
+
+ // Basic adding and removing of waypoint
+ queryDetailsChangedSpy.clear()
+ compare(waypointsSpy.count, 0)
+ emptyQuery.addWaypoint(coordinate1)
+ compare(waypointsSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ emptyQuery.addWaypoint(coordinate1)
+ compare(waypointsSpy.count, 2)
+ compare(queryDetailsChangedSpy.count, 2)
+ compare(emptyQuery.waypoints.length, 2)
+ emptyQuery.removeWaypoint(coordinate1)
+ compare(waypointsSpy.count, 3)
+ compare(queryDetailsChangedSpy.count, 3)
+ compare(emptyQuery.waypoints.length, 1)
+ emptyQuery.removeWaypoint(coordinate2) // coordinate2 isn't in the list, must not impact
+ compare(waypointsSpy.count, 3)
+ compare(queryDetailsChangedSpy.count, 3)
+ emptyQuery.removeWaypoint(coordinate1)
+ compare(waypointsSpy.count, 4)
+ emptyQuery.removeWaypoint(coordinate1) // doesn't exist anymore, must not impact
+ compare(waypointsSpy.count, 4)
+ compare(emptyQuery.waypoints.length, 0)
+ // Check correct ordering of waypoints
+ waypointsSpy.clear()
+ emptyQuery.addWaypoint(coordinate1)
+ emptyQuery.addWaypoint(coordinate2)
+ emptyQuery.addWaypoint(coordinate1)
+ emptyQuery.addWaypoint(coordinate2)
+ compare(waypointsSpy.count, 4)
+ compare(emptyQuery.waypoints[0], coordinate1)
+ compare(emptyQuery.waypoints[1], coordinate2)
+ compare(emptyQuery.waypoints[2], coordinate1)
+ compare(emptyQuery.waypoints[3], coordinate2)
+ emptyQuery.removeWaypoint(coordinate1) // remove one from the middle, check that one added last is removed
+ compare(emptyQuery.waypoints[0], coordinate1)
+ compare(emptyQuery.waypoints[1], coordinate2)
+ compare(emptyQuery.waypoints[2], coordinate2)
+ waypointsSpy.clear()
+ emptyQuery.clearWaypoints()
+ compare(emptyQuery.waypoints.length, 0)
+ compare(waypointsSpy.count, 1)
+
+ // Altering the waypoint contents should trigger signal
+ emptyQuery.clearWaypoints()
+ emptyQuery.addWaypoint(coordinate1)
+ queryDetailsChangedSpy.clear()
+ coordinate1.latitude = 41
+ compare (queryDetailsChangedSpy.count, 1)
+ coordinate1.longitude = 1
+ compare (queryDetailsChangedSpy.count, 2)
+ coordinate1.altitude = 1
+ compare (queryDetailsChangedSpy.count, 3)
+ // verify coordinate is disconnected
+ emptyQuery.removeWaypoint(coordinate1)
+ compare (queryDetailsChangedSpy.count, 4)
+ coordinate1.latitude = 46
+ compare (queryDetailsChangedSpy.count, 4)
+ // verify that same coordinate instance only produces one set of changes
+ emptyQuery.addWaypoint(coordinate1)
+ emptyQuery.addWaypoint(coordinate1)
+ compare (emptyQuery.waypoints.length, 2)
+ queryDetailsChangedSpy.clear()
+ coordinate1.latitude = 61
+ compare (queryDetailsChangedSpy.count, 1)
+ // verify that removing duplicat coordinate leaves remaining ones correctly connected
+ emptyQuery.removeWaypoint(coordinate1)
+ compare (queryDetailsChangedSpy.count, 2)
+ compare (emptyQuery.waypoints.length, 1)
+ coordinate1.latitude = 69
+ compare (queryDetailsChangedSpy.count, 3)
+ // verify that clearing works
+ emptyQuery.clearWaypoints()
+ compare (queryDetailsChangedSpy.count, 4)
+ compare (emptyQuery.waypoints.length, 0)
+ coordinate1.latitude = 62
+ compare (queryDetailsChangedSpy.count, 4)
+
+ // Excluded areas
+ queryDetailsChangedSpy.clear()
+ compare(exclusionSpy.count, 0)
+ emptyQuery.addExcludedArea(boundingBox1)
+ compare(exclusionSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ emptyQuery.addExcludedArea(boundingBox1)
+ compare(exclusionSpy.count, 2)
+ compare(queryDetailsChangedSpy.count, 2)
+ compare(emptyQuery.excludedAreas.length, 2)
+ emptyQuery.removeExcludedArea(boundingBox1)
+ compare(exclusionSpy.count, 3)
+ compare(queryDetailsChangedSpy.count, 3)
+ compare(emptyQuery.excludedAreas.length, 1)
+ emptyQuery.removeExcludedArea(boundingBox2) // boundingBox2 isn't in the list, must not impact
+ compare(exclusionSpy.count, 3)
+ compare(queryDetailsChangedSpy.count, 3)
+ emptyQuery.removeExcludedArea(boundingBox1)
+ compare(exclusionSpy.count, 4)
+ compare(queryDetailsChangedSpy.count, 4)
+ emptyQuery.removeExcludedArea(boundingBox1) // doesn't exist anymore, must not impact
+ compare(exclusionSpy.count, 4)
+ compare(emptyQuery.excludedAreas.length, 0)
+ // Check correct ordering of exclusion
+ exclusionSpy.clear()
+ emptyQuery.addExcludedArea(boundingBox1)
+ emptyQuery.addExcludedArea(boundingBox2)
+ emptyQuery.addExcludedArea(boundingBox1)
+ emptyQuery.addExcludedArea(boundingBox2)
+ compare(exclusionSpy.count, 4)
+ compare(emptyQuery.excludedAreas[0], boundingBox1)
+ compare(emptyQuery.excludedAreas[1], boundingBox2)
+ compare(emptyQuery.excludedAreas[2], boundingBox1)
+ compare(emptyQuery.excludedAreas[3], boundingBox2)
+ emptyQuery.removeExcludedArea(boundingBox1) // remove one from the middle, check that one added last is removed
+ compare(emptyQuery.excludedAreas[0], boundingBox1)
+ compare(emptyQuery.excludedAreas[1], boundingBox2)
+ compare(emptyQuery.excludedAreas[2], boundingBox2)
+ exclusionSpy.clear()
+ emptyQuery.clearExcludedAreas()
+ compare(emptyQuery.excludedAreas.length, 0)
+ compare(exclusionSpy.count, 1)
+
+ // Altering exclusion area details should trigger signals
+ emptyQuery.clearExcludedAreas()
+ emptyQuery.addExcludedArea(unitBox)
+ queryDetailsChangedSpy.clear()
+ compare (emptyQuery.excludedAreas.length, 1)
+ unitBox.width = 200
+ compare(queryDetailsChangedSpy.count, 1)
+ unitBox.height = 200
+ compare(queryDetailsChangedSpy.count, 2)
+ unitBox.topRight = newTopRight
+ compare(queryDetailsChangedSpy.count, 5)
+ // verify box is disconnected
+ emptyQuery.removeExcludedArea(unitBox)
+ compare (queryDetailsChangedSpy.count, 6)
+ unitBox.height = 400
+ compare (queryDetailsChangedSpy.count, 6)
+ // verify that same box instance only produces one set of changes
+ compare (emptyQuery.excludedAreas.length, 0)
+ emptyQuery.addExcludedArea(unitBox)
+ emptyQuery.addExcludedArea(unitBox)
+ compare (emptyQuery.excludedAreas.length, 2)
+ queryDetailsChangedSpy.clear()
+ unitBox.width = 777
+ compare (queryDetailsChangedSpy.count, 1)
+ // verify that removing duplicat coordinate leaves remaining ones correctly connected
+ emptyQuery.removeExcludedArea(unitBox)
+ compare (queryDetailsChangedSpy.count, 2)
+ compare (emptyQuery.excludedAreas.length, 1)
+ unitBox.width = 200
+ compare (queryDetailsChangedSpy.count, 3)
+ // verify that clearing works
+ emptyQuery.clearExcludedAreas()
+ compare (queryDetailsChangedSpy.count, 4)
+ compare (emptyQuery.excludedAreas.length, 0)
+ unitBox.width = 777
+ compare (queryDetailsChangedSpy.count, 4)
+
+ // Feature types and weights
+ queryDetailsChangedSpy.clear()
+ compare(emptyQuery.featureTypes.length, 0)
+ compare(featureTypesSpy.count, 0)
+ emptyQuery.setFeatureWeight(RouteQuery.TollFeature, RouteQuery.AvoidFeatureWeight);
+ compare(featureTypesSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ emptyQuery.setFeatureWeight(RouteQuery.HighwayFeature, RouteQuery.PreferFeatureWeight);
+ compare(featureTypesSpy.count, 2)
+ compare(queryDetailsChangedSpy.count, 2)
+ compare(emptyQuery.featureTypes.length, 2)
+ compare(emptyQuery.featureTypes[0], RouteQuery.TollFeature)
+ compare(emptyQuery.featureTypes[1], RouteQuery.HighwayFeature)
+ // Verify feature weights are as set
+ compare(emptyQuery.featureWeight(RouteQuery.TollFeature), RouteQuery.AvoidFeatureWeight);
+ compare(emptyQuery.featureWeight(RouteQuery.HighwayFeature), RouteQuery.PreferFeatureWeight);
+ // Neutralize a weight, feature should disappear
+ emptyQuery.setFeatureWeight(RouteQuery.TollFeature, RouteQuery.NeutralFeatureWeight);
+ compare(featureTypesSpy.count, 3)
+ compare(queryDetailsChangedSpy.count, 3)
+ compare(emptyQuery.featureTypes.length, 1)
+ compare(emptyQuery.featureWeight(RouteQuery.TollFeature), RouteQuery.NeutralFeatureWeight);
+ compare(emptyQuery.featureWeight(RouteQuery.HighwayFeature), RouteQuery.PreferFeatureWeight);
+ compare(emptyQuery.featureTypes[0], RouteQuery.HighwayFeature)
+ compare(emptyQuery.featureWeight(emptyQuery.featureTypes[0]), RouteQuery.PreferFeatureWeight)
+
+ // Segment details
+ queryDetailsChangedSpy.clear()
+ compare(segmentDetailSpy.count, 0)
+ compare(emptyQuery.segmentDetail, RouteQuery.BasicSegmentData)
+ emptyQuery.segmentDetail = RouteQuery.NoSegmentData
+ compare(segmentDetailSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ compare(emptyQuery.segmentDetail, RouteQuery.NoSegmentData)
+ emptyQuery.segmentDetail = RouteQuery.NoSegmentData
+ compare(segmentDetailSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ compare(emptyQuery.segmentDetail, RouteQuery.NoSegmentData)
+
+ // Maneuver details
+ queryDetailsChangedSpy.clear()
+ compare(maneuverDetailSpy.count, 0)
+ compare(emptyQuery.maneuverDetail, RouteQuery.BasicManeuvers)
+ emptyQuery.maneuverDetail = RouteQuery.NoManeuvers
+ compare(maneuverDetailSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ compare(emptyQuery.maneuverDetail, RouteQuery.NoManeuvers)
+ emptyQuery.maneuverDetail = RouteQuery.NoManeuvers
+ compare(maneuverDetailSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ compare(emptyQuery.maneuverDetail, RouteQuery.NoManeuvers)
+
+ // NumberAlternativeRoutes
+ queryDetailsChangedSpy.clear()
+ compare(numberAlterNativeRoutesSpy.count, 0)
+ compare(emptyQuery.numberAlternativeRoutes, 0)
+ emptyQuery.numberAlternativeRoutes = 2
+ compare(numberAlterNativeRoutesSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ compare(emptyQuery.numberAlternativeRoutes, 2)
+ emptyQuery.numberAlternativeRoutes = 2
+ compare(numberAlterNativeRoutesSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ compare(emptyQuery.numberAlternativeRoutes, 2)
+
+ // Route optimization
+ queryDetailsChangedSpy.clear()
+ compare(routeOptimizationsSpy.count, 0)
+ compare(emptyQuery.routeOptimizations, RouteQuery.FastestRoute)
+ emptyQuery.routeOptimizations = RouteQuery.ShortestRoute
+ compare(routeOptimizationsSpy.count, 1)
+ compare(queryDetailsChangedSpy.count, 1)
+ compare(emptyQuery.routeOptimizations, RouteQuery.ShortestRoute)
+ emptyQuery.routeOptimizations = RouteQuery.ShortestRoute | RouteQuery.MostScenicRoute
+ compare(routeOptimizationsSpy.count, 2)
+ compare(queryDetailsChangedSpy.count, 2)
+ compare(emptyQuery.routeOptimizations, RouteQuery.ShortestRoute | RouteQuery.MostScenicRoute)
+
+ // Must act gracefully
+ emptyModel.clear()
+ emptyModel.update()
+
+ // Plugin
+ compare(pluginSpy.count, 0)
+ emptyModel.plugin = nokiaPlugin
+ compare(pluginSpy.count, 1)
+ compare(emptyModel.plugin, nokiaPlugin)
+ emptyModel.plugin = nokiaPlugin
+ compare(pluginSpy.count, 1)
+ emptyModel.plugin = invalidPlugin
+ compare(pluginSpy.count, 2)
+
+ // Must act gracefully
+ emptyModel.clear()
+ emptyModel.update()
+ }
+ // Test that model acts gracefully when plugin is not set or is invalid
+ // (does not support routing)
+ RouteModel {id: invalidModel; plugin: invalidPlugin}
+ SignalSpy {id: countInvalidSpy; target: invalidModel; signalName: "countChanged"}
+ function test_invalid_plugin() {
+ invalidModel.update()
+ invalidModel.clear()
+ invalidModel.reset()
+ invalidModel.update()
+ invalidModel.get(-1)
+ invalidModel.get(1)
+ }
+ }
+
+ Plugin {
+ id: testPlugin_immediate;
+ name: "qmlgeo.test.plugin"
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "gc_supported"; value: true},
+ PluginParameter { name: "gc_finishRequestImmediately"; value: true},
+ PluginParameter { name: "gc_validateWellKnownValues"; value: true}
+ ]
+ }
+
+ Plugin {
+ id: testPlugin_slacker;
+ name: "qmlgeo.test.plugin"
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "gc_finishRequestImmediately"; value: false}
+ ]
+ }
+
+ Coordinate {id: rcoordinate1; latitude: 50; longitude: 50}
+ Coordinate {id: rcoordinate2; latitude: 51; longitude: 52}
+ Coordinate {id: rcoordinate3; latitude: 53; longitude: 54}
+ Coordinate {id: rcoordinate4; latitude: 55; longitude: 56}
+ Coordinate {id: rcoordinate5; latitude: 57; longitude: 58}
+
+ RouteQuery {id: routeQuery}
+ RouteQuery {id: filledRouteQuery;
+ waypoints: [
+ Coordinate {id: fcoordinate1; latitude: 60; longitude: 60},
+ Coordinate {id: fcoordinate2; latitude: 61; longitude: 62},
+ Coordinate {id: fcoordinate3; latitude: 63; longitude: 64},
+ Coordinate {id: fcoordinate4; latitude: 65; longitude: 66},
+ Coordinate {id: fcoordinate5; latitude: 67; longitude: 68}
+ ]
+ }
+ RouteQuery {id: filledRouteQuery2;
+ waypoints: [
+ Coordinate {id: f2coordinate1; latitude: 60; longitude: 60},
+ Coordinate {id: f2coordinate2; latitude: 61; longitude: 62},
+ Coordinate {id: f2coordinate3; latitude: 63; longitude: 64}
+ ]
+ }
+
+ RouteModel {id: routeModelAutomatic; plugin: testPlugin_slacker; query: filledRouteQuery; autoUpdate: true}
+ SignalSpy {id: automaticRoutesSpy; target: routeModelAutomatic; signalName: "routesChanged" }
+
+ RouteModel {id: routeModel; plugin: testPlugin_immediate; query: routeQuery }
+ SignalSpy {id: testRoutesSpy; target: routeModel; signalName: "routesChanged"}
+ SignalSpy {id: testCountSpy; target: routeModel; signalName: "countChanged" }
+ SignalSpy {id: testStatusSpy; target: routeModel; signalName: "statusChanged"}
+ SignalSpy {id: testErrorSpy; target: routeModel; signalName: "errorChanged"}
+ SignalSpy {id: testWaypointsSpy; target: routeQuery; signalName: "waypointsChanged"}
+
+ RouteModel {id: routeModelSlack; plugin: testPlugin_slacker; query: routeQuery }
+ SignalSpy {id: testRoutesSlackSpy; target: routeModelSlack; signalName: "routesChanged"}
+ SignalSpy {id: testCountSlackSpy; target: routeModelSlack; signalName: "countChanged" }
+ SignalSpy {id: testStatusSlackSpy; target: routeModelSlack; signalName: "statusChanged"}
+ SignalSpy {id: testErrorSlackSpy; target: routeModelSlack; signalName: "errorChanged"}
+ SignalSpy {id: testPluginSlackSpy; target: routeModelSlack; signalName: "pluginChanged"}
+
+ TestCase {
+ name: "Routing"
+ function clear_immediate_model() {
+ routeModel.clear()
+ testRoutesSpy.clear()
+ testCountSpy.clear()
+ testStatusSpy.clear()
+ testErrorSpy.clear()
+ }
+ function clear_slacker_model() {
+ routeModelSlack.clear()
+ testRoutesSlackSpy.clear()
+ testCountSlackSpy.clear()
+ testStatusSlackSpy.clear()
+ testErrorSlackSpy.clear()
+ }
+
+ function test_reset() {
+ clear_immediate_model();
+ routeQuery.numberAlternativeRoutes = 72 // 'altroutes - 70' is the echoed errorcode
+ routeModel.update()
+ verify (testErrorSpy.count > 0)
+ compare (routeModel.error, "error")
+ compare (routeModel.count, 0)
+ compare (testStatusSpy.count, 2)
+ compare (routeModel.status, RouteModel.Error)
+ routeModel.reset()
+ compare (routeModel.status, RouteModel.Null)
+ compare (routeModel.error, "")
+ // Check that ongoing req is aborted
+ clear_slacker_model()
+ routeQuery.numberAlternativeRoutes = 3
+ routeModelSlack.update()
+ wait (100)
+ routeModelSlack.reset()
+ wait (200)
+ compare (routeModelSlack.count, 0)
+ // Check that results are cleared
+ routeModelSlack.update()
+ wait (300)
+ compare (routeModelSlack.count, 1)
+ routeModelSlack.reset()
+ compare (routeModelSlack.count, 0)
+ // Check that changing plugin resets any ongoing requests
+ clear_slacker_model()
+ routeQuery.numberAlternativeRoutes = 3
+ compare (testPluginSlackSpy.count, 0)
+ routeModelSlack.update()
+ wait (100)
+ routeModelSlack.plugin = testPlugin_immediate
+ wait (200)
+ compare (routeModelSlack.count, 0) // should be no updates
+ compare (testPluginSlackSpy.count, 1)
+ // test that works
+ routeModelSlack.update()
+ compare (routeModelSlack.count, 1)
+ // return back
+ routeModelSlack.plugin = testPlugin_slacker
+ }
+
+ function test_error_routing() {
+ // Basic immediate error
+ clear_immediate_model();
+ routeQuery.numberAlternativeRoutes = 72 // 'altroutes - 70' is the echoed errorcode
+ routeModel.update()
+ compare (testErrorSpy.count, 1)
+ compare (routeModel.error, "error")
+ compare (routeModel.count, 0)
+ compare (testStatusSpy.count, 2)
+ compare (routeModel.status, RouteModel.Error)
+ // Basic delayed error
+ clear_slacker_model()
+ routeQuery.numberAlternativeRoutes = 73
+ routeModelSlack.update()
+ compare (testErrorSlackSpy.count, 0)
+ if (routeModelSlack.error == "")
+ tryCompare(testErrorSlackSpy, "count", 1)
+ else
+ tryCompare(testErrorSlackSpy, "count", 2)
+ compare (routeModelSlack.error, "error")
+ compare (routeModelSlack.count, 0)
+ // check that we recover
+ routeQuery.numberAlternativeRoutes = 1
+ routeModelSlack.update()
+ tryCompare(routeModelSlack, "count", 1)
+ compare (testCountSlackSpy.count, 1)
+ compare (routeModelSlack.error, "")
+ }
+ function test_basic_routing() {
+ compare (testRoutesSpy.count, 0)
+ compare (routeModel.error, "")
+ compare (testCountSpy.count, 0)
+ compare (routeModel.count, 0)
+ compare (routeQuery.waypoints.length, 0)
+ compare (testWaypointsSpy.count, 0)
+ routeQuery.addWaypoint(rcoordinate1)
+ routeQuery.addWaypoint(rcoordinate2)
+ routeQuery.addWaypoint(rcoordinate3)
+ routeQuery.addWaypoint(rcoordinate4)
+ routeQuery.addWaypoint(rcoordinate5)
+ compare (testWaypointsSpy.count, 5)
+ compare (routeQuery.waypoints.length, 5)
+ routeModel.update()
+ tryCompare (testRoutesSpy, "count", 1) // 5 sec
+ tryCompare (testCountSpy, "count", 1)
+ compare (routeModel.count, 1)
+ // the test plugin echoes waypoints back as the path of the route:
+ compare (routeQuery.waypoints.length, 5)
+ compare (routeModel.get(0).path.length, 5)
+ compare (routeModel.get(0).path[0].latitude, routeQuery.waypoints[0].latitude)
+ // check clear() functionality
+ routeModel.clear()
+ tryCompare (testRoutesSpy, "count", 2) // 5 sec
+ tryCompare (testCountSpy, "count", 2)
+ compare (routeModel.count, 0)
+
+ // delayed responses
+ compare (testRoutesSlackSpy.count, 0)
+ compare (routeModelSlack.error, "")
+ compare (testCountSlackSpy.count, 0)
+ compare (routeModelSlack.count, 0)
+ routeModelSlack.update()
+ wait (100)
+ compare (testRoutesSlackSpy.count, 0)
+ compare (testCountSlackSpy.count, 0)
+ wait (200)
+ compare (testRoutesSlackSpy.count, 1)
+ compare (testCountSlackSpy.count, 1)
+ compare(routeModelSlack.count, 1)
+ compare (routeModelSlack.get(0).path.length, 5)
+ compare (routeModelSlack.get(0).path[0].latitude, routeQuery.waypoints[0].latitude)
+
+ // Frequent updates, previous requests are aborted
+ routeModelSlack.clear()
+ testRoutesSlackSpy.clear()
+ testCountSlackSpy.clear()
+ routeModelSlack.update()
+ wait (100)
+ compare(testRoutesSlackSpy.count, 0)
+ compare(testCountSlackSpy.count, 0)
+ routeModelSlack.update()
+ wait (100)
+ compare(testRoutesSlackSpy.count, 0)
+ compare(testCountSlackSpy.count, 0)
+ routeModelSlack.update()
+ wait (100)
+ compare(testRoutesSlackSpy.count, 0)
+ compare(testCountSlackSpy.count, 0)
+ routeModelSlack.update()
+ wait (100)
+ compare(testRoutesSlackSpy.count, 0)
+ compare(testCountSlackSpy.count, 0)
+ wait (200)
+ compare (testRoutesSlackSpy.count, 1)
+ compare(testCountSlackSpy.count, 1)
+ compare(routeModelSlack.count, 1)
+
+ // Autoupdate
+ automaticRoutesSpy.clear()
+ compare(routeModelAutomatic.count, 1) // There should be a route already
+ compare (routeModelAutomatic.get(0).path.length, 5)
+ compare (routeModelAutomatic.get(0).path[0].latitude, filledRouteQuery.waypoints[0].latitude)
+ // Remove a waypoint and check that autoupdate works
+ filledRouteQuery.removeWaypoint(fcoordinate2)
+ wait(300)
+ compare (routeModelAutomatic.get(0).path.length, 4)
+ compare (routeModelAutomatic.get(0).path[0].latitude, fcoordinate1.latitude)
+ compare (automaticRoutesSpy.count, 1)
+ // Change contents of a coordinate and check that autoupdate works
+ fcoordinate1.latitude++
+ wait(300)
+ compare (routeModelAutomatic.get(0).path[0].latitude, fcoordinate1.latitude) // new value should be echoed
+ compare (automaticRoutesSpy.count, 2)
+ // Change query
+ routeModelAutomatic.query = filledRouteQuery2
+ wait(300)
+ compare (routeModelAutomatic.get(0).path.length, 3)
+ compare (automaticRoutesSpy.count, 3)
+ // Verify that the old query is disconnected internally ie. does not trigger update
+ fcoordinate1.latitude++
+ wait(300)
+ compare (automaticRoutesSpy.count, 3)
+ }
+ }
+}
+
+
+
+
diff --git a/tests/auto/declarative/tst_plugin.qml b/tests/auto/declarative/tst_plugin.qml
new file mode 100644
index 00000000..7a37b273
--- /dev/null
+++ b/tests/auto/declarative/tst_plugin.qml
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtTest 1.0
+import Qt.location 5.0
+
+Item {
+
+ Plugin { id: nokiaPlugin; name: "nokia"}
+ Plugin { id: invalidPlugin; name: "invalid"}
+ Plugin { id: testPlugin;
+ name: "qmlgeo.test.plugin"
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "supported"; value: true},
+ PluginParameter { name: "finishRequestImmediately"; value: true},
+ PluginParameter { name: "validateWellKnownValues"; value: true}
+ ]
+ }
+ SignalSpy {id: invalidGeocodeSpy; target: invalidPlugin; signalName: "supportsGeocodingChanged"}
+ SignalSpy {id: invalidReverseGeocodeSpy; target: invalidPlugin; signalName: "supportsReverseGeocodingChanged"}
+ SignalSpy {id: invalidRoutingSpy; target: invalidPlugin; signalName: "supportsRoutingChanged"}
+ SignalSpy {id: invalidMappingSpy; target: invalidPlugin; signalName: "supportsMappingChanged"}
+
+ TestCase {
+ name: "Plugin properties"
+ function test_plugin() {
+ verify (invalidPlugin.availableServiceProviders.length > 0)
+ verify (invalidPlugin.availableServiceProviders.indexOf('qmlgeo.test.plugin') > -1) // at least test plugin must be present
+ // invalid plugin
+ compare (invalidPlugin.supportsGeocoding, false )
+ compare (invalidPlugin.supportsReverseGeocoding, false )
+ compare (invalidPlugin.supportsRouting, false )
+ compare (invalidPlugin.supportsMapping, false )
+ // if nokia plugin present
+ if (invalidPlugin.availableServiceProviders.indexOf('qmlgeo.test.plugin') > -1) {
+ compare (nokiaPlugin.supportsGeocoding, true )
+ compare (nokiaPlugin.supportsReverseGeocoding, true )
+ compare (nokiaPlugin.supportsRouting, true )
+ compare (nokiaPlugin.supportsMapping, true )
+ }
+ // test plugin does not do mapping
+ compare (testPlugin.supportsGeocoding, true )
+ compare (testPlugin.supportsReverseGeocoding, true )
+ compare (testPlugin.supportsRouting, true )
+ compare (testPlugin.supportsMapping, false )
+ // test changing name of plugin
+ compare (invalidGeocodeSpy.count, 0)
+ compare (invalidReverseGeocodeSpy.count, 0)
+ compare (invalidRoutingSpy.count, 0)
+ compare (invalidMappingSpy.count, 0)
+ invalidPlugin.name = 'qmlgeo.test.plugin'
+ compare (invalidGeocodeSpy.count, 1)
+ compare (invalidReverseGeocodeSpy.count, 1)
+ compare (invalidRoutingSpy.count, 1)
+ compare (invalidMappingSpy.count, 0)
+ compare (invalidPlugin.supportsGeocoding, true )
+ compare (invalidPlugin.supportsReverseGeocoding, true )
+ compare (invalidPlugin.supportsRouting, true )
+ compare (invalidPlugin.supportsMapping, false )
+ invalidPlugin.name = ''
+ compare (invalidGeocodeSpy.count, 2)
+ compare (invalidReverseGeocodeSpy.count, 2)
+ compare (invalidRoutingSpy.count, 2)
+ compare (invalidMappingSpy.count, 0)
+ compare (invalidPlugin.supportsGeocoding, false )
+ compare (invalidPlugin.supportsReverseGeocoding, false )
+ compare (invalidPlugin.supportsRouting, false )
+ compare (invalidPlugin.supportsMapping, false )
+ }
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/tests/auto/declarative/tst_qmlmapsandnav.cpp b/tests/auto/declarative/tst_qmlmapsandnav.cpp
new file mode 100644
index 00000000..cd5e2b2f
--- /dev/null
+++ b/tests/auto/declarative/tst_qmlmapsandnav.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(qmlmapsandnav)
+//QTQUICK1_TEST_MAIN(qmlmapsandnav)
+
+// temproray hack: put '-qtuick1' into argument vector
+// to enforce QML1 testing until location QML elements are QML2
+// compatible. TODO
+//int main(int argc, char **argv)
+// {
+// return quick_test_main(argc, argv, #name, 0, QUICK_TEST_SOURCE_DIR);
+ // }
diff --git a/tests/auto/testplugin/qgeoroutingmanagerengine_test.h b/tests/auto/testplugin/qgeoroutingmanagerengine_test.h
new file mode 100644
index 00000000..93383adf
--- /dev/null
+++ b/tests/auto/testplugin/qgeoroutingmanagerengine_test.h
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTINGMANAGERENGINE_TEST_H
+#define QGEOROUTINGMANAGERENGINE_TEST_H
+
+#include <qgeoserviceprovider.h>
+#include <qgeoroutingmanagerengine.h>
+#include <QLocale>
+#include <qlandmarkmanager.h>
+#include <qgeoaddress.h>
+#include <qgeoplace.h>
+#include <qgeoroutereply.h>
+
+#include <QDebug>
+#include <QTimer>
+#include <QTimerEvent>
+
+QTM_USE_NAMESPACE
+
+
+class RouteReplyTest :public QGeoRouteReply
+{
+ Q_OBJECT
+
+public:
+ RouteReplyTest(QObject *parent=0) :QGeoRouteReply (QGeoRouteRequest(), parent)
+ {}
+ 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
+{
+ Q_OBJECT
+ RouteReplyTest* routeReply_;
+ bool finishRequestImmediately_;
+ int timerId_;
+ QGeoRouteReply::Error errorCode_;
+ QString errorString_;
+
+public:
+ QGeoRoutingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error, QString *errorString) :
+ QGeoRoutingManagerEngine(parameters),
+ routeReply_(0),
+ finishRequestImmediately_(true),
+ timerId_(0),
+ errorCode_(QGeoRouteReply::NoError)
+ {
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ if (parameters.contains("gc_finishRequestImmediately")) {
+ finishRequestImmediately_ = qvariant_cast<bool>(parameters.value("gc_finishRequestImmediately"));
+ }
+
+ setLocale(*(new QLocale (QLocale::German, QLocale::Germany)));
+ setSupportedFeatureTypes (
+ QGeoRouteRequest::NoFeature | QGeoRouteRequest::TollFeature |
+ QGeoRouteRequest::HighwayFeature | QGeoRouteRequest::PublicTransitFeature |
+ QGeoRouteRequest::FerryFeature | QGeoRouteRequest::TunnelFeature |
+ QGeoRouteRequest::DirtRoadFeature | QGeoRouteRequest::ParksFeature |
+ QGeoRouteRequest::MotorPoolLaneFeature );
+ setSupportedFeatureWeights (
+ QGeoRouteRequest::NeutralFeatureWeight | QGeoRouteRequest::PreferFeatureWeight |
+ QGeoRouteRequest::RequireFeatureWeight | QGeoRouteRequest::AvoidFeatureWeight |
+ QGeoRouteRequest::DisallowFeatureWeight );
+ setSupportedManeuverDetails (
+ QGeoRouteRequest::NoManeuvers | QGeoRouteRequest::BasicManeuvers);
+ setSupportedRouteOptimizations (
+ QGeoRouteRequest::ShortestRoute | QGeoRouteRequest::FastestRoute |
+ QGeoRouteRequest::MostEconomicRoute | QGeoRouteRequest::MostScenicRoute);
+ setSupportedSegmentDetails (
+ QGeoRouteRequest::NoSegmentData | QGeoRouteRequest::BasicSegmentData );
+ setSupportedTravelModes (
+ QGeoRouteRequest::CarTravel | QGeoRouteRequest::PedestrianTravel |
+ QGeoRouteRequest::BicycleTravel | QGeoRouteRequest::PublicTransitTravel |
+ QGeoRouteRequest::TruckTravel );
+ setSupportsAlternativeRoutes ( true );
+ setSupportsExcludeAreas ( true );
+ setSupportsRouteUpdates ( true );
+ }
+
+ virtual QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request)
+ {
+ routeReply_ = new RouteReplyTest();
+ connect(routeReply_, SIGNAL(aborted()), this, SLOT(requestAborted()));
+
+ if (request.numberAlternativeRoutes() > 70) {
+ errorCode_ = (QGeoRouteReply::Error)(request.numberAlternativeRoutes() - 70);
+ errorString_ = "error";
+ } else {
+ errorCode_ = QGeoRouteReply::NoError;
+ errorString_ = "";
+ }
+ setRoutes(request, routeReply_);
+ if (finishRequestImmediately_) {
+ if (errorCode_) {
+ routeReply_->callSetError(errorCode_, errorString_);
+ } else {
+ routeReply_->callSetError(QGeoRouteReply::NoError, "no error");
+ routeReply_->callSetFinished(true);
+ }
+ } else {
+ // we only allow serialized requests in QML - previous must have been aborted or finished
+ Q_ASSERT(timerId_ == 0);
+ timerId_ = startTimer(200);
+ }
+ return static_cast<QGeoRouteReply*>(routeReply_);
+ }
+
+ void setRoutes(const QGeoRouteRequest& request, RouteReplyTest* reply)
+ {
+ QList<QGeoRoute> routes;
+ QGeoRoute route;
+ route.setPath(request.waypoints());
+ routes.append(route);
+ reply->callSetRoutes(routes);
+ }
+
+public Q_SLOTS:
+ void requestAborted()
+ {
+ if (timerId_) {
+ killTimer(timerId_);
+ timerId_ = 0;
+ }
+ errorCode_ = QGeoRouteReply::NoError;
+ errorString_ = "";
+ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ Q_ASSERT(timerId_ == event->timerId());
+ Q_ASSERT(routeReply_);
+ killTimer(timerId_);
+ timerId_ = 0;
+ if (errorCode_) {
+ routeReply_->callSetError(errorCode_, errorString_);
+ emit error(routeReply_, errorCode_, errorString_);
+ } else {
+ routeReply_->callSetError(QGeoRouteReply::NoError, "no error");
+ routeReply_->callSetFinished(true);
+ emit finished(routeReply_);
+ }
+ }
+};
+
+#endif
diff --git a/tests/auto/testplugin/qgeosearchmanagerengine_test.h b/tests/auto/testplugin/qgeosearchmanagerengine_test.h
new file mode 100644
index 00000000..c3532521
--- /dev/null
+++ b/tests/auto/testplugin/qgeosearchmanagerengine_test.h
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHMANAGERENGINE_TEST_H
+#define QGEOSEARCHMANAGERENGINE_TEST_H
+
+#include <qgeoserviceprovider.h>
+#include <qgeosearchmanagerengine.h>
+#include <QLocale>
+#include <qlandmarkmanager.h>
+#include <qgeoaddress.h>
+#include <qgeoplace.h>
+#include <qgeosearchreply.h>
+
+#include <QTimer>
+#include <QTimerEvent>
+
+QTM_USE_NAMESPACE
+
+
+class SearchReplyTest :public QGeoSearchReply
+{
+ Q_OBJECT
+public:
+ SearchReplyTest(QObject *parent=0):QGeoSearchReply (parent) {}
+
+ void callAddPlace ( const QGeoPlace & place ) {addPlace(place);}
+ void callSetError ( Error error, const QString & errorString ) {setError(error, errorString);}
+ void callSetFinished ( bool finished ) {setFinished(finished);}
+ void callSetLimit ( int limit ) {setLimit(limit);}
+ void callSetOffset ( int offset ) {setOffset(offset);}
+ void callSetPlaces ( const QList<QGeoPlace> & places ) {setPlaces(places);}
+ void callSetViewport ( QGeoBoundingArea * viewport ) {setViewport(viewport);}
+ void abort() {
+ emit aborted();
+ }
+Q_SIGNALS:
+ void aborted();
+};
+
+class QGeoSearchManagerEngineTest: public QGeoSearchManagerEngine
+
+{
+Q_OBJECT
+public:
+ QGeoSearchManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error, QString *errorString) :
+ QGeoSearchManagerEngine(parameters),
+ validateWellKnownValues_(false),
+ finishRequestImmediately_(true),
+ supported_(true),
+ searchReply_(0),
+ timerId_(0),
+ errorCode_(QGeoSearchReply::NoError)
+ {
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+ if (parameters.contains("supported"))
+ supported_ = qvariant_cast<bool>(parameters.value("supported"));
+ if (parameters.contains("finishRequestImmediately"))
+ finishRequestImmediately_ = qvariant_cast<bool>(parameters.value("finishRequestImmediately"));
+ if (parameters.contains("validateWellKnownValues"))
+ validateWellKnownValues_ = qvariant_cast<bool>(parameters.value("validateWellKnownValues"));
+
+ setSupportedSearchTypes(QGeoSearchManager::SearchGeocode);
+ setSupportsGeocoding(supported_);
+ setSupportsReverseGeocoding(supported_);
+ setLocale(*(new QLocale (QLocale::German, QLocale::Germany)));
+ }
+
+ QGeoSearchReply* geocode ( const QGeoAddress & address, QGeoBoundingArea * bounds )
+ {
+ searchReply_ = new SearchReplyTest();
+ connect(searchReply_, SIGNAL(aborted()), this, SLOT(requestAborted()));
+ searchReply_->callSetViewport(bounds);
+
+ if (address.street().startsWith("error")) {
+ errorString_ = address.street();
+ errorCode_ = (QGeoSearchReply::Error)address.county().toInt();
+ } else {
+ errorString_ = "";
+ errorCode_ = QGeoSearchReply::NoError;
+ }
+ // 1. Check if we are to validate values
+ if (validateWellKnownValues_) {
+ if (address.street() != "wellknown street") {
+ searchReply_->callSetError(QGeoSearchReply::EngineNotSetError, address.street());
+ } else {
+ searchReply_->callSetError(QGeoSearchReply::NoError,address.street());
+ }
+ }
+
+ // 2. Set the places into the reply
+ setPlaces(searchReply_, address);
+
+ // 3. Finish the request
+ if (finishRequestImmediately_) {
+ // check if we should finish with error
+ if (errorCode_) {
+ searchReply_->callSetError(errorCode_, errorString_);
+ } else {
+ searchReply_->callSetFinished(true);
+ }
+ } else {
+ // we only allow serialized requests in QML - previous must have been aborted
+ Q_ASSERT(timerId_ == 0);
+ timerId_ = startTimer(200);
+ }
+ return static_cast<QGeoSearchReply*>(searchReply_);
+ }
+
+public Q_SLOTS:
+ void requestAborted()
+ {
+ if (timerId_) {
+ killTimer(timerId_);
+ timerId_ = 0;
+ }
+ errorString_ = "";
+ errorCode_ = QGeoSearchReply::NoError;
+ }
+
+public:
+ void setPlaces(SearchReplyTest* reply, const QString searchString, int limit )
+ {
+ for (int i = 0; i < limit; ++i) {
+ QGeoPlace place;
+ QGeoAddress address;
+ address.setStreet(searchString);
+ place.setAddress(address);
+ reply->callAddPlace(place);
+ }
+ }
+
+ void setPlaces(SearchReplyTest* reply, const QGeoAddress& address)
+ {
+ int count = address.county().toInt();
+
+ for (int i = 0; i < count; ++i) {
+ QGeoPlace place;
+ place.setAddress(address);
+ reply->callAddPlace(place);
+ }
+ }
+
+ void setPlaces(SearchReplyTest* reply, const QGeoCoordinate & coordinate)
+ {
+ for (int i = 0; i < coordinate.longitude(); ++i) {
+ QGeoPlace place;
+ place.setCoordinate(coordinate);
+ reply->callAddPlace(place);
+ }
+ }
+
+ QGeoSearchReply* reverseGeocode ( const QGeoCoordinate & coordinate, QGeoBoundingArea * bounds )
+ {
+ searchReply_ = new SearchReplyTest();
+ connect(searchReply_, SIGNAL(aborted()), this, SLOT(requestAborted()));
+
+ setPlaces(searchReply_, coordinate);
+ searchReply_->callSetViewport(bounds);
+
+ if (coordinate.latitude() > 70) {
+ errorString_ = "error";
+ errorCode_ = (QGeoSearchReply::Error) (coordinate.latitude() - 70);
+ } else {
+ errorString_ = "";
+ errorCode_ = QGeoSearchReply::NoError;
+ }
+ if (finishRequestImmediately_) {
+ if (errorCode_) {
+ searchReply_->callSetError(errorCode_, errorString_);
+ } else {
+ searchReply_->callSetError(QGeoSearchReply::NoError,coordinate.toString());
+ searchReply_->callSetFinished(true);
+ }
+ } else {
+ // we only allow serialized requests in QML - previous must have been aborted or finished
+ Q_ASSERT(timerId_ == 0);
+ timerId_ = startTimer(200);
+ }
+ return static_cast<QGeoSearchReply*>(searchReply_);
+ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ Q_ASSERT(timerId_ == event->timerId());
+ Q_ASSERT(searchReply_);
+ killTimer(timerId_);
+ timerId_ = 0;
+ if (errorCode_) {
+ searchReply_->callSetError(errorCode_, errorString_);
+ emit error(searchReply_, errorCode_, errorString_);
+ } else {
+ searchReply_->callSetError(QGeoSearchReply::NoError, "no error");
+ searchReply_->callSetFinished(true);
+ }
+ emit finished(searchReply_);
+ }
+
+private:
+ bool validateWellKnownValues_;
+ bool finishRequestImmediately_;
+ bool supported_;
+ SearchReplyTest* searchReply_;
+ int timerId_;
+ QGeoSearchReply::Error errorCode_;
+ QString errorString_;
+};
+
+#endif
diff --git a/tests/auto/testplugin/qgeosearchmanagerplugins.pro b/tests/auto/testplugin/qgeosearchmanagerplugins.pro
new file mode 100644
index 00000000..62febab2
--- /dev/null
+++ b/tests/auto/testplugin/qgeosearchmanagerplugins.pro
@@ -0,0 +1,25 @@
+load(qt_module)
+
+TEMPLATE = lib
+CONFIG += plugin testplugin
+TARGET = qtgeoservices_qmltestplugin
+PLUGIN_TYPE=geoservices
+QT += location
+
+include($$QT_SOURCE_TREE/src/plugins/qpluginbase.pri)
+# TODO not sure where to put test plugins in Qt 5
+DESTDIR = $$QT.location.plugins/geoservices
+
+HEADERS += qgeosearchmanagerengine_test.h \
+ qgeoserviceproviderplugin_test.h \
+ qgeoroutingmanagerengine_test.h
+
+SOURCES += qgeoserviceproviderplugin_test.cpp
+
+
+INCLUDEPATH += ../../../src/location \
+ ../../../src/location/maps \
+ ../../../src/location/landmarks
+
+target.path += $$[QT_INSTALL_PLUGINS]/geoservices
+INSTALLS += target
diff --git a/tests/auto/testplugin/qgeoserviceproviderplugin_test.cpp b/tests/auto/testplugin/qgeoserviceproviderplugin_test.cpp
new file mode 100644
index 00000000..e31bc8f6
--- /dev/null
+++ b/tests/auto/testplugin/qgeoserviceproviderplugin_test.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoserviceproviderplugin_test.h"
+#include "qgeosearchmanagerengine_test.h"
+#include "qgeoroutingmanagerengine_test.h"
+
+#include <QtPlugin>
+
+QGeoServiceProviderFactoryTest::QGeoServiceProviderFactoryTest()
+{
+}
+
+QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
+{
+}
+
+QString QGeoServiceProviderFactoryTest::providerName() const
+{
+ return "qmlgeo.test.plugin";
+}
+
+int QGeoServiceProviderFactoryTest::providerVersion() const
+{
+ return 3;
+}
+
+QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine (
+ const QMap<QString, QVariant> & parameters,
+ QGeoServiceProvider::Error * error, QString * errorString ) const
+{
+ return new QGeoRoutingManagerEngineTest(parameters, error, errorString);
+}
+
+
+QGeoSearchManagerEngine* QGeoServiceProviderFactoryTest::createSearchManagerEngine(const QMap<
+ QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
+{
+ return new QGeoSearchManagerEngineTest(parameters, error, errorString);
+}
+
+
+QGeoMappingManagerEngine* QGeoServiceProviderFactoryTest::createMappingManagerEngine (
+ const QMap<QString, QVariant> & parameters,
+ QGeoServiceProvider::Error * error, QString * errorString ) const
+{
+ Q_UNUSED(parameters);
+ Q_UNUSED(error);
+ Q_UNUSED(errorString);
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(qtgeoservices_qmltestplugin, QGeoServiceProviderFactoryTest)
diff --git a/tests/auto/testplugin/qgeoserviceproviderplugin_test.h b/tests/auto/testplugin/qgeoserviceproviderplugin_test.h
new file mode 100644
index 00000000..f747f38d
--- /dev/null
+++ b/tests/auto/testplugin/qgeoserviceproviderplugin_test.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSERVICEPROVIDER_TEST_H
+#define QGEOSERVICEPROVIDER_TEST_H
+
+#include <qgeoserviceproviderfactory.h>
+#include <QObject>
+
+QTM_USE_NAMESPACE
+
+class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QGeoServiceProviderFactory)
+public:
+ QGeoServiceProviderFactoryTest();
+ ~QGeoServiceProviderFactoryTest();
+
+ QString providerName() const;
+ int providerVersion() const;
+
+
+ QGeoMappingManagerEngine* createMappingManagerEngine (
+ const QMap<QString, QVariant> & parameters,
+ QGeoServiceProvider::Error * error, QString * errorString ) const;
+ QGeoRoutingManagerEngine* createRoutingManagerEngine (
+ const QMap<QString, QVariant> & parameters,
+ QGeoServiceProvider::Error * error, QString * errorString ) const;
+ QGeoSearchManagerEngine* createSearchManagerEngine(
+ const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error, QString *errorString) const;
+
+};
+
+#endif
+
+