diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 4 | ||||
-rw-r--r-- | tests/auto/declarative/declarative.pro (renamed from tests/auto/declarative/qmlmapsandnav.pro) | 0 | ||||
-rw-r--r-- | tests/auto/declarative/tst_map_geocoding.qml | 72 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qgeosearchmanagerengine_test.h | 36 | ||||
-rw-r--r-- | tests/auto/qgeolocation/qgeolocation.pro | 4 | ||||
-rw-r--r-- | tests/auto/qgeolocation/tst_qgeolocation.cpp | 367 | ||||
-rw-r--r-- | tests/auto/qgeolocation/tst_qgeolocation.h (renamed from tests/auto/qgeolocation/tst_qgeoplace.h) | 38 | ||||
-rw-r--r-- | tests/auto/qgeolocation/tst_qgeoplace.cpp | 223 | ||||
-rw-r--r-- | tests/auto/qgeoplace/tst_qgeoplace.cpp | 18 | ||||
-rw-r--r-- | tests/auto/qgeosearchmanagerplugins/qgeosearchmanagerengine_test.h | 6 | ||||
-rw-r--r-- | tests/auto/qgeosearchreply/tst_qgeosearchreply.cpp | 44 | ||||
-rw-r--r-- | tests/auto/qgeosearchreply/tst_qgeosearchreply.h | 10 | ||||
-rw-r--r-- | tests/auto/qplacelocation/qplacelocation.pro | 7 | ||||
-rw-r--r-- | tests/auto/qplacelocation/tst_qplacelocation.cpp | 158 |
14 files changed, 489 insertions, 498 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index f9512df9..0bb331c8 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -20,7 +20,6 @@ SUBDIRS += geotestplugin \ qplacecategory \ qplacecontact \ qplacedescription \ - qplacelocation \ qplacemediaobject \ qplaceperiod \ qplacequery \ @@ -28,4 +27,5 @@ SUBDIRS += geotestplugin \ qplacereview \ qplacesearchquery \ qplacesupplier \ - qplaceweekdayhours + qplaceweekdayhours \ + declarative diff --git a/tests/auto/declarative/qmlmapsandnav.pro b/tests/auto/declarative/declarative.pro index 0df01a8e..0df01a8e 100644 --- a/tests/auto/declarative/qmlmapsandnav.pro +++ b/tests/auto/declarative/declarative.pro diff --git a/tests/auto/declarative/tst_map_geocoding.qml b/tests/auto/declarative/tst_map_geocoding.qml index 87b24a74..939982e0 100644 --- a/tests/auto/declarative/tst_map_geocoding.qml +++ b/tests/auto/declarative/tst_map_geocoding.qml @@ -209,40 +209,40 @@ Item { } GeocodeModel {id: testModel; plugin: testPlugin} - SignalSpy {id: placesSpy; target: testModel; signalName: "placesChanged"} + SignalSpy {id: locationsSpy; target: testModel; signalName: "locationsChanged"} 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: locationsSlackSpy; target: slackModel; signalName: "locationsChanged"} 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: locationsImmediateSpy; target: immediateModel; signalName: "locationsChanged"} 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"} + SignalSpy {id: automaticLocationsSpy; target: automaticModel; signalName: "locationsChanged"} TestCase { name: "Map GeocodeModel basic (reverse) geocoding" function clear_slack_model() { slackModel.clear() - placesSlackSpy.clear() + locationsSlackSpy.clear() countSlackSpy.clear() querySlackSpy.clear() errorSlackSpy.clear() } function clear_immediate_model() { immediateModel.clear() - placesImmediateSpy.clear() + locationsImmediateSpy.clear() countImmediateSpy.clear() queryImmediateSpy.clear() errorImmediateSpy.clear() @@ -266,12 +266,12 @@ Item { slackModel.update() wait (100) compare (countSlackSpy.count, 0) - compare (placesSlackSpy.count, 0) + compare (locationsSlackSpy.count, 0) compare (slackModel.count, 0) slackModel.reset() wait (200) compare (countSlackSpy.count, 0) - compare (placesSlackSpy.count, 0) + compare (locationsSlackSpy.count, 0) compare (slackModel.count, 0) // Check that results are cleared slackModel.update() @@ -362,17 +362,17 @@ Item { } function test_basic_geocode() { testQuerySpy.clear() - placesSpy.clear() + locationsSpy.clear() testStatusSpy.clear() testModel.clear() countSpy.clear() - compare (placesSpy.count, 0) + compare (locationsSpy.count, 0) compare (testModel.error, "") compare (testModel.count, 0) testModel.query = address1 compare (testQuerySpy.count, 1) testModel.update() - tryCompare (placesSpy, "count", 1) // 5 sec + tryCompare (locationsSpy, "count", 1) // 5 sec compare (testModel.error, "") compare (testModel.count, 2) compare (testQuerySpy.count, 1) @@ -384,23 +384,23 @@ Item { function test_geocode_auto_updates() { compare (automaticModel.count, 4) // should be something already - compare (automaticPlacesSpy.count, 1) + compare (automaticLocationsSpy.count, 1) // change query and its contents and verify that autoupdate occurs automaticAddress1.county = 6 wait (300) - compare (automaticPlacesSpy.count, 2) + compare (automaticLocationsSpy.count, 2) compare (automaticModel.count, 6) automaticAddress1.street = "The Avenue" wait (300) - compare (automaticPlacesSpy.count, 3) + compare (automaticLocationsSpy.count, 3) compare (automaticModel.count, 6) automaticModel.query = automaticCoordinate1 wait (300) - compare (automaticPlacesSpy.count, 4) + compare (automaticLocationsSpy.count, 4) compare (automaticModel.count, 3) automaticCoordinate1.longitude = 7 wait (300) - compare (automaticPlacesSpy.count, 5) + compare (automaticLocationsSpy.count, 5) compare (automaticModel.count, 7) } @@ -409,47 +409,47 @@ Item { slackModel.clear() querySlackSpy.clear() countSlackSpy.clear() - placesSlackSpy.clear() + locationsSlackSpy.clear() slackModel.query = slackAddress1 slackAddress1.county = "7" compare (querySlackSpy.count, 1) slackModel.update() wait (100) compare (countSlackSpy.count, 0) - compare (placesSlackSpy.count, 0) + compare (locationsSlackSpy.count, 0) compare (slackModel.count, 0) wait (200) compare (countSlackSpy.count, 1) - compare (placesSlackSpy.count, 1) + compare (locationsSlackSpy.count, 1) compare (slackModel.count, 7) // slackAddress1.county) // Frequent updates, previous requests are aborted slackModel.clear() - placesSlackSpy.clear() + locationsSlackSpy.clear() countSlackSpy.clear() slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) wait (200) - compare (placesSlackSpy.count, 1) + compare (locationsSlackSpy.count, 1) compare(countSlackSpy.count, 1) compare(slackModel.count, 7) // slackAddress1.county } function test_basic_reverse_geocode() { testQuerySpy.clear() - placesSpy.clear() + locationsSpy.clear() testStatusSpy.clear() countSpy.clear() testModel.clear() @@ -459,7 +459,7 @@ Item { testModel.query = rcoordinate1 compare (testQuerySpy.count, 1) testModel.update() - tryCompare (placesSpy, "count", 1) // 5 sec + tryCompare (locationsSpy, "count", 1) // 5 sec tryCompare(countSpy, "count", 1) compare (testModel.error, "") compare (testModel.count, 2) @@ -471,40 +471,40 @@ Item { slackModel.clear() querySlackSpy.clear() countSlackSpy.clear() - placesSlackSpy.clear() + locationsSlackSpy.clear() slackModel.query = slackCoordinate1 compare (querySlackSpy.count, 1) slackModel.update() wait (100) compare (countSlackSpy.count, 0) - compare (placesSlackSpy.count, 0) + compare (locationsSlackSpy.count, 0) compare (slackModel.count, 0) wait (200) compare (countSlackSpy.count, 1) - compare (placesSlackSpy.count, 1) + compare (locationsSlackSpy.count, 1) compare (slackModel.count, 3) // slackCoordinate1.longitude // Frequent updates, previous requests are aborted slackModel.clear() - placesSlackSpy.clear() + locationsSlackSpy.clear() countSlackSpy.clear() slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) slackModel.update() wait (100) - compare(placesSlackSpy.count, 0) + compare(locationsSlackSpy.count, 0) compare(countSlackSpy.count, 0) wait (200) - compare (placesSlackSpy.count, 1) + compare (locationsSlackSpy.count, 1) compare(countSlackSpy.count, 1) compare(slackModel.count, 3) // slackCoordinate1.longitude } diff --git a/tests/auto/geotestplugin/qgeosearchmanagerengine_test.h b/tests/auto/geotestplugin/qgeosearchmanagerengine_test.h index a9705b1c..e5b21757 100644 --- a/tests/auto/geotestplugin/qgeosearchmanagerengine_test.h +++ b/tests/auto/geotestplugin/qgeosearchmanagerengine_test.h @@ -47,7 +47,7 @@ #include <QLocale> #include <qlandmarkmanager.h> #include <qgeoaddress.h> -#include <qgeoplace.h> +#include <qgeolocation.h> #include <qgeosearchreply.h> #include <QTimer> @@ -62,12 +62,12 @@ class SearchReplyTest :public QGeoSearchReply public: SearchReplyTest(QObject *parent=0):QGeoSearchReply (parent) {} - void callAddPlace ( const QGeoPlace & place ) {addPlace(place);} + void callAddLocation ( const QGeoLocation & location ) {addLocation(location);} 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 callSetLocations ( const QList<QGeoLocation> & locations ) {setLocations(locations);} void callSetViewport ( QGeoBoundingArea * viewport ) {setViewport(viewport);} void abort() { emit aborted(); @@ -127,8 +127,8 @@ public: } } - // 2. Set the places into the reply - setPlaces(searchReply_, address); + // 2. Set the locations into the reply + setLocations(searchReply_, address); // 3. Finish the request if (finishRequestImmediately_) { @@ -158,34 +158,34 @@ public Q_SLOTS: } public: - void setPlaces(SearchReplyTest* reply, const QString searchString, int limit ) + void setLocations(SearchReplyTest* reply, const QString searchString, int limit ) { for (int i = 0; i < limit; ++i) { - QGeoPlace place; + QGeoLocation location; QGeoAddress address; address.setStreet(searchString); - place.setAddress(address); - reply->callAddPlace(place); + location.setAddress(address); + reply->callAddLocation(location); } } - void setPlaces(SearchReplyTest* reply, const QGeoAddress& address) + void setLocations(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); + QGeoLocation location; + location.setAddress(address); + reply->callAddLocation(location); } } - void setPlaces(SearchReplyTest* reply, const QGeoCoordinate & coordinate) + void setLocations(SearchReplyTest* reply, const QGeoCoordinate & coordinate) { for (int i = 0; i < coordinate.longitude(); ++i) { - QGeoPlace place; - place.setCoordinate(coordinate); - reply->callAddPlace(place); + QGeoLocation location; + location.setCoordinate(coordinate); + reply->callAddLocation(location); } } @@ -194,7 +194,7 @@ public: searchReply_ = new SearchReplyTest(); connect(searchReply_, SIGNAL(aborted()), this, SLOT(requestAborted())); - setPlaces(searchReply_, coordinate); + setLocations(searchReply_, coordinate); searchReply_->callSetViewport(bounds); if (coordinate.latitude() > 70) { diff --git a/tests/auto/qgeolocation/qgeolocation.pro b/tests/auto/qgeolocation/qgeolocation.pro index 3db543e7..49ef1674 100644 --- a/tests/auto/qgeolocation/qgeolocation.pro +++ b/tests/auto/qgeolocation/qgeolocation.pro @@ -1,8 +1,8 @@ load(qttest_p4) HEADERS += ../qgeocoordinate/qlocationtestutils_p.h \ - tst_qgeoplace.h -SOURCES += tst_qgeoplace.cpp \ + tst_qgeolocation.h +SOURCES += tst_qgeolocation.cpp \ ../qgeocoordinate/qlocationtestutils.cpp QT += location diff --git a/tests/auto/qgeolocation/tst_qgeolocation.cpp b/tests/auto/qgeolocation/tst_qgeolocation.cpp new file mode 100644 index 00000000..dc6f1469 --- /dev/null +++ b/tests/auto/qgeolocation/tst_qgeolocation.cpp @@ -0,0 +1,367 @@ +/**************************************************************************** +** +** 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tst_qgeolocation.h" + +QTM_USE_NAMESPACE + +tst_QGeoLocation::tst_QGeoLocation() + : m_locationScore(0) +{ +} + +void tst_QGeoLocation::initTestCase() +{ + +} + +void tst_QGeoLocation::cleanupTestCase() +{ + +} + +void tst_QGeoLocation::init() +{ +} + +void tst_QGeoLocation::cleanup() +{ +} + +void tst_QGeoLocation::constructor() +{ + QCOMPARE(m_location.address(), m_address); + QCOMPARE(m_location.coordinate(), m_coordinate); + QCOMPARE(m_location.viewport(), m_viewport); + QCOMPARE(m_location.additionalData().count(), 0); + QCOMPARE(m_location.additionalData(), m_additionalData ); + QCOMPARE(m_location.alternativeLabels().count(), 0); + QCOMPARE(m_location.alternativeLabels(), m_alternativeLabels); + QCOMPARE(m_location.label(), m_label); + QCOMPARE(m_location.locationId(), m_locationId); + QCOMPARE(m_location.locationScore(), m_locationScore); +} + +void tst_QGeoLocation::copy_constructor() +{ + QGeoLocation *qgeolocationcopy = new QGeoLocation (m_location); + QCOMPARE(m_location, *qgeolocationcopy); + delete qgeolocationcopy; +} + +void tst_QGeoLocation::destructor() +{ + QGeoLocation *qgeolocationcopy; + + QLocationTestUtils::uheap_mark(); + qgeolocationcopy = new QGeoLocation(); + delete qgeolocationcopy; + QLocationTestUtils::uheap_mark_end(); + + QLocationTestUtils::uheap_mark(); + qgeolocationcopy = new QGeoLocation(m_location); + delete qgeolocationcopy; + QLocationTestUtils::uheap_mark_end(); +} + +void tst_QGeoLocation::address() +{ + m_address.setCity("Berlin"); + m_address.setCountry("Germany"); + m_address.setCountryCode("DEU"); + m_address.setDistrict("Mitte"); + m_address.setPostcode("10115"); + m_address.setStreet("Invalidenstrasse"); + + m_location.setAddress(m_address); + + QCOMPARE(m_location.address(),m_address); + + m_address.setPostcode("10125"); + QVERIFY(m_location.address() != m_address); +} + +void tst_QGeoLocation::coordinate() +{ + m_coordinate.setLatitude(13.3851); + m_coordinate.setLongitude(52.5312); + m_coordinate.setAltitude(134.23); + + m_location.setCoordinate(m_coordinate); + + QCOMPARE(m_location.coordinate(), m_coordinate); + + m_coordinate.setAltitude(0); + QVERIFY(m_location.coordinate() != m_coordinate); +} + +void tst_QGeoLocation::viewport() +{ + m_coordinate.setLatitude(13.3851); + m_coordinate.setLongitude(52.5312); + + QGeoBoundingBox qgeoboundingboxcopy(m_coordinate, 0.4, 0.4); + m_location.setViewport(qgeoboundingboxcopy); + + QCOMPARE(m_location.viewport(),qgeoboundingboxcopy); + + qgeoboundingboxcopy.setHeight(1); + + QVERIFY(m_location.viewport() != qgeoboundingboxcopy); +} + +void tst_QGeoLocation::additionalData() +{ + m_additionalData.insert("key1", "value1"); + m_additionalData.insert("key2", "value2"); + + m_location.setAdditionalData(m_additionalData); + QCOMPARE(m_location.additionalData().count(), 2); + QCOMPARE(m_location.additionalData(), m_additionalData); + + m_additionalData.insert("key3", "value3"); + QVERIFY(m_location.additionalData() != m_additionalData); +} + +void tst_QGeoLocation::alternativeLabels() +{ + QPlaceAlternativeValue altValue; + m_alternativeLabels.append(altValue); + + altValue.setKey("testData"); + altValue.setValue("value"); + m_alternativeLabels.append(altValue); + + m_location.setAlternativeLabels(m_alternativeLabels); + QCOMPARE(m_location.alternativeLabels(), m_alternativeLabels); + + altValue.setKey("newKey"); + m_alternativeLabels.append(altValue); + QVERIFY(m_location.alternativeLabels() != m_alternativeLabels); +} + +void tst_QGeoLocation::navigationPositions() +{ + QGeoCoordinate coordinate1, coordinate2; + coordinate1.setLatitude(10); + coordinate1.setLongitude(10); + coordinate2.setLatitude(2); + coordinate2.setLongitude(2); + m_navigationPositions.append(coordinate1); + m_navigationPositions.append(coordinate2); + + m_location.setNavigationPositions(m_navigationPositions); + QCOMPARE(m_location.navigationPositions(), m_navigationPositions); + + m_navigationPositions.append(coordinate1); + QVERIFY(m_location.navigationPositions() != m_navigationPositions); +} + +void tst_QGeoLocation::label() +{ + m_label = "testText"; + m_location.setLabel(m_label); + QCOMPARE(m_location.label(), m_label); + + m_label = "differentText"; + QVERIFY(m_location.label() != m_label); +} + +void tst_QGeoLocation::locationId() +{ + m_locationId = "id"; + m_location.setLocationId(m_locationId); + + m_locationId = "new id"; + m_location.setLocationId(m_locationId); +} + +void tst_QGeoLocation::locationScore() +{ + m_locationScore = 4.5; + m_location.setLocationScore(m_locationScore); + QCOMPARE(m_location.locationScore(), m_locationScore); + + m_locationScore = 2; + QVERIFY(m_location.locationScore() != m_locationScore); +} + +void tst_QGeoLocation::operators() +{ + QGeoAddress qgeoaddresscopy; + qgeoaddresscopy.setCity("Berlin"); + qgeoaddresscopy.setCountry("Germany"); + qgeoaddresscopy.setCountryCode("DEU"); + + QGeoCoordinate qgeocoordinatecopy (32.324 , 41.324 , 24.55); + + m_address.setCity("Madrid"); + m_address.setCountry("Spain"); + m_address.setCountryCode("SPA"); + + m_coordinate.setLatitude(21.3434); + m_coordinate.setLongitude(38.43443); + m_coordinate.setAltitude(634.21); + + m_location.setAddress(m_address); + m_location.setCoordinate(m_coordinate); + + //Create a copy and see that they are the same + QGeoLocation qgeolocationcopy(m_location); + QVERIFY(m_location == qgeolocationcopy); + QVERIFY(!(m_location != qgeolocationcopy)); + + //Modify one and test if they are different + qgeolocationcopy.setAddress(qgeoaddresscopy); + QVERIFY(!(m_location == qgeolocationcopy)); + QVERIFY(m_location != qgeolocationcopy); + qgeolocationcopy.setCoordinate(qgeocoordinatecopy); + QVERIFY(!(m_location == qgeolocationcopy)); + QVERIFY(m_location != qgeolocationcopy); + + //delete qgeolocationcopy; + //Asign and test that they are the same + qgeolocationcopy = m_location; + QVERIFY(m_location ==qgeolocationcopy); + QVERIFY(!(m_location != qgeolocationcopy)); +} + +void tst_QGeoLocation::comparison() +{ + QFETCH(QString, dataField); + + QGeoLocation location; + + //set address + QGeoAddress address; + address.setStreet("21 jump st"); + address.setCountry("USA"); + location.setAddress(address); + + //set coordinate + location.setCoordinate(QGeoCoordinate(5,10)); + + //set viewport + location.setViewport(QGeoBoundingBox(QGeoCoordinate(5,5),0.4,0.4)); + + //set additionalData + QVariantHash additionalData; + additionalData.insert("key", "value"); + location.setAdditionalData(additionalData); + + //set alternative labels + QPlaceAlternativeValue altValue; + QList<QPlaceAlternativeValue> alternativeLabels; + + altValue.setKey("testData"); + altValue.setValue("value"); + alternativeLabels.append(altValue); + + //set navigation positions + QList<QGeoCoordinate> navPos; + navPos.append(QGeoCoordinate(10,2)); + location.setNavigationPositions(navPos); + + //set label + location.setLabel("label"); + + //set locationId + location.setLocationId("id"); + + //set locationScore + location.setLocationScore(2.5); + + QGeoLocation otherLocation(location); + + if (dataField == "no change") { + QCOMPARE(location, otherLocation); + } else { + if (dataField == "address") { + QGeoAddress otherAddress; + otherAddress.setStreet("42 evergreen tce"); + otherAddress.setCountry("USA"); + otherLocation.setAddress(otherAddress); + } else if (dataField == "coordinate") { + otherLocation.setCoordinate(QGeoCoordinate(12,13)); + } else if (dataField == "viewport"){ + otherLocation.setViewport(QGeoBoundingBox(QGeoCoordinate(1,2), 0.5,0.5)); + } else if (dataField == "additionalData") { + additionalData.insert("key", "otherValue"); + otherLocation.setAdditionalData(additionalData); + } else if (dataField == "alternativeLabels") { + altValue.setKey("otherKey"); + alternativeLabels.clear(); + alternativeLabels.append(altValue); + otherLocation.setAlternativeLabels(alternativeLabels); + } else if (dataField == "navigationPositions") { + navPos.clear(); + navPos.append(QGeoCoordinate(-5, -5)); + otherLocation.setNavigationPositions(navPos); + } else if (dataField == "label") { + otherLocation.setLabel("otherLabel"); + } else if (dataField == "locationId") { + otherLocation.setLocationId("otherId"); + } else if (dataField == "locationScore") { + otherLocation.setLocationScore(1); + }else { + qFatal("Unknown data field to test"); + } + + QVERIFY(location != otherLocation); + } +} + +void tst_QGeoLocation::comparison_data() +{ + QTest::addColumn<QString> ("dataField"); + QTest::newRow("no change") << "no change"; + QTest::newRow("address") << "address"; + QTest::newRow("coordinate") << "coordinate"; + QTest::newRow("additionalData") << "additionalData"; + QTest::newRow("alternativeLabels") << "alternativeLabels"; + QTest::newRow("navigationPositions") << "navigationPositions"; + QTest::newRow("label") << "label"; + QTest::newRow("locationId") << "locationId"; + QTest::newRow("locationScore") << "locationScore"; +} + +QTEST_MAIN(tst_QGeoLocation); + diff --git a/tests/auto/qgeolocation/tst_qgeoplace.h b/tests/auto/qgeolocation/tst_qgeolocation.h index bec1886b..34cfac83 100644 --- a/tests/auto/qgeolocation/tst_qgeoplace.h +++ b/tests/auto/qgeolocation/tst_qgeolocation.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef TST_QGEOPLACE_H -#define TST_QGEOPLACE_H +#ifndef TST_QGEOLOCATION_H +#define TST_QGEOLOCATION_H #include <QtCore/QString> #include <QtTest/QtTest> @@ -50,17 +50,17 @@ #include "../qgeocoordinate/qlocationtestutils_p.h" #include <qgeoaddress.h> #include <qgeocoordinate.h> -#include <qgeoplace.h> +#include <qgeolocation.h> #include <qgeoboundingbox.h> QTM_USE_NAMESPACE -class tst_QGeoPlace : public QObject +class tst_QGeoLocation : public QObject { Q_OBJECT public: - tst_QGeoPlace(); + tst_QGeoLocation(); private Q_SLOTS: void initTestCase(); @@ -68,25 +68,37 @@ private Q_SLOTS: void init(); void cleanup(); - //Start Unit Tests for qgeoplace.h + //Start Unit Tests for qgeolocation.h void constructor(); void copy_constructor(); void destructor(); void address(); void coordinate(); void viewport(); - void isLandmark(); + void additionalData(); + void alternativeLabels(); + void navigationPositions(); + void label(); + void locationId(); + void locationScore(); void operators(); - //End Unit Tests for qgeoplace.h - + void comparison(); + void comparison_data(); + //End Unit Tests for qgeolocation.h private: + QGeoLocation m_location; - QGeoAddress *qgeoaddress; - QGeoCoordinate *qgeocoordinate; - QGeoPlace *qgeoplace; - QGeoBoundingBox *qgeoboundingbox; + QGeoAddress m_address; + QGeoCoordinate m_coordinate; + QGeoBoundingBox m_viewport; + QVariantHash m_additionalData; + QList<QPlaceAlternativeValue> m_alternativeLabels; + QList<QGeoCoordinate> m_navigationPositions; + QString m_label; + QString m_locationId; + qreal m_locationScore; }; Q_DECLARE_METATYPE( QGeoCoordinate::CoordinateFormat); diff --git a/tests/auto/qgeolocation/tst_qgeoplace.cpp b/tests/auto/qgeolocation/tst_qgeoplace.cpp deleted file mode 100644 index 7ca72b84..00000000 --- a/tests/auto/qgeolocation/tst_qgeoplace.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/**************************************************************************** -** -** 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tst_qgeoplace.h" - -QTM_USE_NAMESPACE - -tst_QGeoPlace::tst_QGeoPlace() -{ -} - -void tst_QGeoPlace::initTestCase() -{ - -} - -void tst_QGeoPlace::cleanupTestCase() -{ - -} - -void tst_QGeoPlace::init() -{ - qgeoaddress = new QGeoAddress(); - qgeocoordinate = new QGeoCoordinate(); - qgeoplace = new QGeoPlace(); - qgeoboundingbox = new QGeoBoundingBox(); - -} - -void tst_QGeoPlace::cleanup() -{ - delete qgeoaddress; - delete qgeocoordinate; - delete qgeoplace; - delete qgeoboundingbox; -} - -void tst_QGeoPlace::constructor() -{ - QCOMPARE(qgeoplace->address(), *qgeoaddress); - QCOMPARE(qgeoplace->coordinate(), *qgeocoordinate); - QCOMPARE(qgeoplace->viewport(), *qgeoboundingbox); -} - -void tst_QGeoPlace::copy_constructor() -{ - QGeoPlace *qgeoplacecopy = new QGeoPlace (*qgeoplace); - QCOMPARE(*qgeoplace, *qgeoplacecopy); - delete qgeoplacecopy; -} - -void tst_QGeoPlace::destructor() -{ - QGeoPlace *qgeoplacecopy; - - QLocationTestUtils::uheap_mark(); - qgeoplacecopy = new QGeoPlace(); - delete qgeoplacecopy; - QLocationTestUtils::uheap_mark_end(); - - QLocationTestUtils::uheap_mark(); - qgeoplacecopy = new QGeoPlace(*qgeoplace); - delete qgeoplacecopy; - QLocationTestUtils::uheap_mark_end(); -} - -void tst_QGeoPlace::address() -{ - qgeoaddress->setCity("Berlin"); - qgeoaddress->setCountry("Germany"); - qgeoaddress->setCountryCode("DEU"); - qgeoaddress->setDistrict("Mitte"); - qgeoaddress->setPostcode("10115"); - qgeoaddress->setStreet("Invalidenstrasse"); - - qgeoplace->setAddress(*qgeoaddress); - - QCOMPARE(qgeoplace->address(),*qgeoaddress); - - qgeoaddress->setPostcode("10125"); - QVERIFY(qgeoplace->address() != *qgeoaddress); -} - -void tst_QGeoPlace::coordinate() -{ - qgeocoordinate->setLatitude(13.3851); - qgeocoordinate->setLongitude(52.5312); - qgeocoordinate->setAltitude(134.23); - - qgeoplace->setCoordinate(*qgeocoordinate); - - QCOMPARE(qgeoplace->coordinate(),*qgeocoordinate); - - qgeocoordinate->setAltitude(0); - QVERIFY(qgeoplace->coordinate() != *qgeocoordinate); -} - -void tst_QGeoPlace::viewport() -{ - qgeocoordinate->setLatitude(13.3851); - qgeocoordinate->setLongitude(52.5312); - - QGeoBoundingBox *qgeoboundingboxcopy= new QGeoBoundingBox(*qgeocoordinate,0.4,0.4); - - qgeoplace->setViewport(*qgeoboundingboxcopy); - - QCOMPARE(qgeoplace->viewport(),*qgeoboundingboxcopy); - - qgeoboundingboxcopy->setHeight(1); - - QVERIFY(qgeoplace->viewport() != *qgeoboundingboxcopy); - - delete qgeoboundingboxcopy; -} - -void tst_QGeoPlace::isLandmark() -{ - QVERIFY(!qgeoplace->isLandmark()); - - qgeoplace->setAddress(*qgeoaddress); - QVERIFY(!qgeoplace->isLandmark()); - - qgeoplace->setCoordinate(*qgeocoordinate); - QVERIFY(!qgeoplace->isLandmark()); - - //qgeoaddress->setCity("Berlin"); - qgeoaddress->setCountryCode("DEU"); - qgeocoordinate->setLatitude(13.4109); - qgeocoordinate->setLongitude(52.5221); - - qgeoplace->setAddress(*qgeoaddress); - qgeoplace->setCoordinate(*qgeocoordinate); -// Not passing -// QVERIFY(qgeoplace->isLandmark()); - -} - -void tst_QGeoPlace::operators() -{ - QGeoAddress *qgeoaddresscopy = new QGeoAddress(); - qgeoaddresscopy->setCity("Berlin"); - qgeoaddresscopy->setCountry("Germany"); - qgeoaddresscopy->setCountryCode("DEU"); - - QGeoCoordinate *qgeocoordinatecopy = new QGeoCoordinate (32.324 , 41.324 , 24.55); - - qgeoaddress->setCity("Madrid"); - qgeoaddress->setCountry("Spain"); - qgeoaddress->setCountryCode("SPA"); - - qgeocoordinate->setLatitude(21.3434); - qgeocoordinate->setLongitude(38.43443); - qgeocoordinate->setAltitude(634.21); - - qgeoplace->setAddress(*qgeoaddress); - qgeoplace->setCoordinate(*qgeocoordinate); - - //Create a copy and see that they are the same - QGeoPlace *qgeoplacecopy = new QGeoPlace (*qgeoplace); - QVERIFY(qgeoplace->operator ==(*qgeoplacecopy)); - QVERIFY(!qgeoplace->operator !=(*qgeoplacecopy)); - - //Modify one and test if they are different - qgeoplacecopy->setAddress(*qgeoaddresscopy); - QVERIFY(!qgeoplace->operator ==(*qgeoplacecopy)); - QVERIFY(qgeoplace->operator !=(*qgeoplacecopy)); - qgeoplacecopy->setCoordinate(*qgeocoordinatecopy); - QVERIFY(!qgeoplace->operator ==(*qgeoplacecopy)); - QVERIFY(qgeoplace->operator !=(*qgeoplacecopy)); - - //delete qgeoplacecopy; - //Asign and test that they are the same - *qgeoplacecopy = qgeoplacecopy->operator =(*qgeoplace); - QVERIFY(qgeoplace->operator ==(*qgeoplacecopy)); - QVERIFY(!qgeoplace->operator !=(*qgeoplacecopy)); - - delete qgeocoordinatecopy; - delete qgeoaddresscopy; - delete qgeoplacecopy; - -} - -QTEST_MAIN(tst_QGeoPlace); - diff --git a/tests/auto/qgeoplace/tst_qgeoplace.cpp b/tests/auto/qgeoplace/tst_qgeoplace.cpp index 939e707a..df9b3b2f 100644 --- a/tests/auto/qgeoplace/tst_qgeoplace.cpp +++ b/tests/auto/qgeoplace/tst_qgeoplace.cpp @@ -48,10 +48,10 @@ void tst_QGeoPlace::constructorTest() QPlaceBusinessInformation obj; obj.setOpeningNote("10"); testObj.setBusinessInformation(obj); - QPlaceLocation sup; + QGeoLocation sup; sup.setLabel("testName1"); sup.setLocationId("testId"); - QList<QPlaceLocation> list; + QList<QGeoLocation> list; list.append(sup); sup.setLocationId("testName2"); list.append(sup); @@ -153,8 +153,8 @@ void tst_QGeoPlace::ratingTest() void tst_QGeoPlace::locationTest() { QGeoPlace testObj; - QVERIFY2(testObj.location() == QPlaceLocation(), "Wrong default value"); - QPlaceLocation obj; + QVERIFY2(testObj.location() == QGeoLocation(), "Wrong default value"); + QGeoLocation obj; obj.setLocationScore(10); testObj.setLocation(obj); QVERIFY2(testObj.location() == obj, "Wrong value returned"); @@ -254,10 +254,10 @@ void tst_QGeoPlace::alternativeLocationsTest() { QGeoPlace testObj; QVERIFY2(testObj.alternativeLocations().count() == 0, "Wrong default value"); - QPlaceLocation sup; + QGeoLocation sup; sup.setLabel("testName1"); sup.setLocationId("testId"); - QList<QPlaceLocation> list; + QList<QGeoLocation> list; list.append(sup); sup.setLocationId("testName2"); list.append(sup); @@ -309,10 +309,10 @@ void tst_QGeoPlace::operatorsTest() QPlaceBusinessInformation obj; obj.setOpeningNote("10"); testObj.setBusinessInformation(obj); - QPlaceLocation sup; + QGeoLocation sup; sup.setLabel("testName1"); sup.setLocationId("testId"); - QList<QPlaceLocation> list; + QList<QGeoLocation> list; list.append(sup); sup.setLocationId("testName2"); list.append(sup); @@ -320,7 +320,7 @@ void tst_QGeoPlace::operatorsTest() QStringList tags; tags << "1" << "2" << "3"; testObj.setTags(tags); - QPlaceLocation loc; + QGeoLocation loc; loc.setLocationScore(10); testObj.setLocation(loc); diff --git a/tests/auto/qgeosearchmanagerplugins/qgeosearchmanagerengine_test.h b/tests/auto/qgeosearchmanagerplugins/qgeosearchmanagerengine_test.h index dc0c0d53..82ee6984 100644 --- a/tests/auto/qgeosearchmanagerplugins/qgeosearchmanagerengine_test.h +++ b/tests/auto/qgeosearchmanagerplugins/qgeosearchmanagerengine_test.h @@ -47,7 +47,7 @@ #include <QLocale> #include <qlandmarkmanager.h> #include <qgeoaddress.h> -#include <qgeoplace.h> +#include <qgeolocation.h> #include <qgeosearchreply.h> @@ -60,12 +60,12 @@ class SearchReplyTest :public QGeoSearchReply public: SearchReplyTest(QObject *parent=0):QGeoSearchReply (parent) {} - void callAddPlace ( const QGeoPlace & place ) {addPlace(place);} + void callAddLocation ( const QGeoLocation & location ) {addLocation(location);} 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 callSetLocations ( const QList<QGeoLocation> & locations ) {setLocations(locations);} void callSetViewport ( QGeoBoundingArea * viewport ) {setViewport(viewport);} }; diff --git a/tests/auto/qgeosearchreply/tst_qgeosearchreply.cpp b/tests/auto/qgeosearchreply/tst_qgeosearchreply.cpp index 9224e497..009bd27e 100644 --- a/tests/auto/qgeosearchreply/tst_qgeosearchreply.cpp +++ b/tests/auto/qgeosearchreply/tst_qgeosearchreply.cpp @@ -53,7 +53,7 @@ void tst_QGeoSearchReply::cleanupTestCase() { delete reply; - delete qgeoplace; + delete qgeolocation; } void tst_QGeoSearchReply::init() @@ -231,47 +231,47 @@ void tst_QGeoSearchReply::offset() QCOMPARE(reply->offset(),offset); } -void tst_QGeoSearchReply::places() +void tst_QGeoSearchReply::locations() { - QList <QGeoPlace> geoplaces; - geoplaces = reply->places(); + QList <QGeoLocation> geolocations; + geolocations = reply->locations(); - QCOMPARE(geoplaces.size(),0); + QCOMPARE(geolocations.size(),0); QGeoAddress *qgeoaddress = new QGeoAddress (); qgeoaddress->setCity("Berlin"); QGeoCoordinate *qgeocoordinate = new QGeoCoordinate (12.12 , 54.43); - qgeoplace = new QGeoPlace (); - qgeoplace->setAddress(*qgeoaddress); - qgeoplace->setCoordinate(*qgeocoordinate); + qgeolocation = new QGeoLocation (); + qgeolocation->setAddress(*qgeoaddress); + qgeolocation->setCoordinate(*qgeocoordinate); - reply->callAddPlace(*qgeoplace); + reply->callAddLocation(*qgeolocation); - geoplaces = reply->places(); - QCOMPARE(geoplaces.size(),1); - QCOMPARE(geoplaces.at(0),*qgeoplace); + geolocations = reply->locations(); + QCOMPARE(geolocations.size(),1); + QCOMPARE(geolocations.at(0),*qgeolocation); - QGeoPlace *qgeoplacecopy = new QGeoPlace (*qgeoplace); + QGeoLocation *qgeolocationcopy = new QGeoLocation (*qgeolocation); - QList <QGeoPlace> qgeoplaces; - qgeoplaces.append(*qgeoplace); - qgeoplaces.append(*qgeoplacecopy); + QList <QGeoLocation> qgeolocations; + qgeolocations.append(*qgeolocation); + qgeolocations.append(*qgeolocationcopy); - reply->callSetPlaces(qgeoplaces); + reply->callSetLocations(qgeolocations); - geoplaces = reply->places(); + geolocations = reply->locations(); - QCOMPARE(geoplaces.size(),qgeoplaces.size()); - for (int i = 0 ; i < geoplaces.size(); i++) + QCOMPARE(geolocations.size(),qgeolocations.size()); + for (int i = 0 ; i < geolocations.size(); i++) { - QCOMPARE(geoplaces.at(i),qgeoplaces.at(i)); + QCOMPARE(geolocations.at(i),qgeolocations.at(i)); } delete qgeoaddress; delete qgeocoordinate; - delete qgeoplacecopy; + delete qgeolocationcopy; } void tst_QGeoSearchReply::viewport() diff --git a/tests/auto/qgeosearchreply/tst_qgeosearchreply.h b/tests/auto/qgeosearchreply/tst_qgeosearchreply.h index dfc8cb84..ec411915 100644 --- a/tests/auto/qgeosearchreply/tst_qgeosearchreply.h +++ b/tests/auto/qgeosearchreply/tst_qgeosearchreply.h @@ -51,7 +51,7 @@ #include "../qgeocoordinate/qlocationtestutils_p.h" #include <qgeosearchreply.h> -#include <qgeoplace.h> +#include <qgeolocation.h> #include <qgeoaddress.h> #include <qgeocoordinate.h> #include <qgeoboundingbox.h> @@ -63,12 +63,12 @@ class SubSearchReply : public QGeoSearchReply public: SubSearchReply():QGeoSearchReply() {} - void callAddPlace ( const QGeoPlace & place ) {addPlace(place);} + void callAddLocation ( const QGeoLocation & location ) {addLocation(location);} 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 callSetLocations ( const QList<QGeoLocation> & locations ) {setLocations(locations);} void callSetViewport ( QGeoBoundingArea * viewport ) {setViewport(viewport);} }; @@ -96,7 +96,7 @@ private slots: void finished(); void limit(); void offset(); - void places(); + void locations(); void viewport(); //End Unit Test for QGeoSearchReply @@ -107,7 +107,7 @@ private: QSignalSpy *signalerror; QSignalSpy *signalfinished; SubSearchReply* reply; - QGeoPlace *qgeoplace; + QGeoLocation *qgeolocation; QGeoBoundingBox *qgeoboundingbox; }; diff --git a/tests/auto/qplacelocation/qplacelocation.pro b/tests/auto/qplacelocation/qplacelocation.pro deleted file mode 100644 index c54aeee5..00000000 --- a/tests/auto/qplacelocation/qplacelocation.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = app -CONFIG += testcase -TARGET = tst_qplacelocation - -SOURCES += tst_qplacelocation.cpp - -QT += location testlib diff --git a/tests/auto/qplacelocation/tst_qplacelocation.cpp b/tests/auto/qplacelocation/tst_qplacelocation.cpp deleted file mode 100644 index 887d0f39..00000000 --- a/tests/auto/qplacelocation/tst_qplacelocation.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include <QtCore/QString> -#include <QtTest/QtTest> - -#include <qplacelocation.h> - -QTM_USE_NAMESPACE - -class tst_QPlaceLocation : public QObject -{ - Q_OBJECT - -public: - tst_QPlaceLocation(); - -private Q_SLOTS: - void constructorTest(); - void additionalDataTest(); - void alternativeLabelsTest(); - void addressTest(); - void displayPositionTest(); - void navigationPositionsTest(); - void labelTest(); - void locationIdTest(); - void locationScoreTest(); - void mapViewTest(); - void operatorsTest(); -}; - -tst_QPlaceLocation::tst_QPlaceLocation() -{ -} - -void tst_QPlaceLocation::constructorTest() -{ - QPlaceLocation testObj; - testObj.setLabel("testId"); - QPlaceLocation *testObjPtr = new QPlaceLocation(testObj); - QVERIFY2(testObjPtr != NULL, "Copy constructor - null"); - QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare"); - delete testObjPtr; -} - -void tst_QPlaceLocation::additionalDataTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.additionalData().count() == 0, "Wrong default value"); - QVariantHash list; - list.insert("key1", "value1"); - list.insert("key2", "value2"); - testObj.setAdditionalData(list); - QVERIFY2(testObj.additionalData().count() == 2, "Wrong value returned"); - QVERIFY2(testObj.additionalData()["key1"] == "value1", "Wrong value[1] returned"); -} - -void tst_QPlaceLocation::alternativeLabelsTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.alternativeLabels().count() == 0, "Wrong default value"); - QList<QPlaceAlternativeValue> list; - QPlaceAlternativeValue altValue; - list.append(altValue); - altValue.setKey("testData"); - list.append(altValue); - testObj.setAlternativeLabels(list); - QVERIFY2(testObj.alternativeLabels().count() == 2, "Wrong value returned"); - QVERIFY2(testObj.alternativeLabels()[0].key() == QString(), "Wrong key[0] returned"); - QVERIFY2(testObj.alternativeLabels()[1].key() == "testData", "Wrong key[1] returned"); -} - -void tst_QPlaceLocation::addressTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.address() == QGeoAddress(), "Wrong default value"); - QGeoAddress address; - address.setCountry("testValue"); - testObj.setAddress(address); - QVERIFY2(testObj.address() == address, "Wrong value returned"); -} - -void tst_QPlaceLocation::displayPositionTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.displayPosition() == QGeoCoordinate(), "Wrong default value"); - QGeoCoordinate address; - address.setLatitude(10); - testObj.setDisplayPosition(address); - QVERIFY2(testObj.displayPosition() == address, "Wrong value returned"); -} - -void tst_QPlaceLocation::navigationPositionsTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.navigationPositions().count() == 0, "Wrong default value"); - QGeoCoordinate coordinate1, coordinate2; - coordinate1.setLatitude(10); - coordinate1.setLongitude(10); - coordinate2.setLatitude(2); - coordinate2.setLongitude(2); - QList<QGeoCoordinate> path; - path.append(coordinate1); - path.append(coordinate2); - testObj.setNavigationPositions(path); - QVERIFY2(testObj.navigationPositions() == path, "Wrong value returned"); - QVERIFY2(testObj.navigationPositions().count() == 2, "Wrong value returned"); -} - -void tst_QPlaceLocation::labelTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.label() == QString(), "Wrong default value"); - testObj.setLabel("testText"); - QVERIFY2(testObj.label() == "testText", "Wrong value returned"); -} - -void tst_QPlaceLocation::locationIdTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.locationId() == QString(), "Wrong default value"); - testObj.setLocationId("testText"); - QVERIFY2(testObj.locationId() == "testText", "Wrong value returned"); -} - -void tst_QPlaceLocation::locationScoreTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.locationScore() == 0, "Wrong default value"); - testObj.setLocationScore(5); - QVERIFY2(testObj.locationScore() == 5, "Wrong value returned"); -} - -void tst_QPlaceLocation::mapViewTest() -{ - QPlaceLocation testObj; - QVERIFY2(testObj.mapView().isValid() == false, "Wrong default value"); - QGeoCoordinate coordinate; - coordinate.setLatitude(30); - coordinate.setLongitude(20); - QGeoBoundingBox box; - box.setTopLeft(coordinate); - box.setBottomRight(coordinate); - testObj.setMapView(box); - QVERIFY2(testObj.mapView() == box, "Wrong value returned"); -} - -void tst_QPlaceLocation::operatorsTest() -{ - QPlaceLocation testObj; - testObj.setLabel("testValue"); - QPlaceLocation testObj2; - testObj2 = testObj; - QVERIFY2(testObj == testObj2, "Not copied correctly"); - testObj2.setLocationId("testValue2"); - QVERIFY2(testObj != testObj2, "Object should be different"); -} - -QTEST_APPLESS_MAIN(tst_QPlaceLocation); - -#include "tst_qplacelocation.moc" |