diff options
author | abcd <qt-info@nokia.com> | 2011-07-31 21:33:56 +1000 |
---|---|---|
committer | abcd <qt_abcd1@ovi.com> | 2011-08-09 03:48:02 +0200 |
commit | 2904df66e87534ff348f7af13b0d513c8ecc746c (patch) | |
tree | 70fb416d39158f80d9445e1e9f0d1a2c6de20b48 /tests/auto/qgeocodingmanager | |
parent | 38e2574bf27f66100bf9ec16592f938a4b7a02b1 (diff) | |
download | qtlocation-2904df66e87534ff348f7af13b0d513c8ecc746c.tar.gz |
Rename QGeoSearchManager to QGeocodingManager
Also do related renames like QGeoSearchReply to QGeocodeReply
Change-Id: I31cc6da4fda03299e905b4938cdfcff3c20aa8c7
Reviewed-on: http://codereview.qt.nokia.com/2710
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: abcd <qt_abcd1@ovi.com>
Diffstat (limited to 'tests/auto/qgeocodingmanager')
-rw-r--r-- | tests/auto/qgeocodingmanager/qgeocodingmanager.pro | 9 | ||||
-rw-r--r-- | tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp | 192 | ||||
-rw-r--r-- | tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h | 99 |
3 files changed, 300 insertions, 0 deletions
diff --git a/tests/auto/qgeocodingmanager/qgeocodingmanager.pro b/tests/auto/qgeocodingmanager/qgeocodingmanager.pro new file mode 100644 index 00000000..dc65c884 --- /dev/null +++ b/tests/auto/qgeocodingmanager/qgeocodingmanager.pro @@ -0,0 +1,9 @@ +load(qttest_p4) + +HEADERS += ../qgeocoordinate/qlocationtestutils_p.h \ + tst_qgeocodingmanager.h + +SOURCES += tst_qgeocodingmanager.cpp \ + ../qgeocoordinate/qlocationtestutils.cpp + +QT += location diff --git a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp new file mode 100644 index 00000000..a58f1c73 --- /dev/null +++ b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +//TESTED_COMPONENT=src/location + +#include "tst_qgeocodingmanager.h" + +QT_USE_NAMESPACE + + +void tst_QGeocodingManager::initTestCase() +{ + tst_QGeocodingManager::loadGeocodingManager(); +} + +void tst_QGeocodingManager::cleanupTestCase() +{ + delete qgeoserviceprovider; +} + +void tst_QGeocodingManager::init() +{ + qRegisterMetaType<QGeocodeReply::Error>("Error"); + qRegisterMetaType<QGeocodeReply*>(); + + signalerror = new QSignalSpy(qgeocodingmanager, SIGNAL(error(QGeocodeReply*,QGeocodeReply::Error,QString))); + signalfinished = new QSignalSpy(qgeocodingmanager, SIGNAL(finished(QGeocodeReply*))); + QVERIFY( signalerror->isValid() ); + QVERIFY( signalfinished->isValid() ); +} + +void tst_QGeocodingManager::cleanup() +{ + delete signalerror; + delete signalfinished; +} + +void tst_QGeocodingManager::loadGeocodingManager() +{ + QStringList providers = QGeoServiceProvider::availableServiceProviders(); + QVERIFY(providers.contains("static.geocode.test.plugin")); + + qgeoserviceprovider = new QGeoServiceProvider("static.geocode.test.plugin"); + QVERIFY(qgeoserviceprovider); + QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NoError); + + qgeocodingmanager = qgeoserviceprovider->geocodingManager(); + QVERIFY(qgeocodingmanager); +} + +void tst_QGeocodingManager::supports() +{ + QVERIFY(qgeocodingmanager->supportsGeocoding()); + QVERIFY(qgeocodingmanager->supportsReverseGeocoding()); +} + +void tst_QGeocodingManager::locale() +{ + QLocale *german = new QLocale (QLocale::German, QLocale::Germany); + QLocale *english = new QLocale (QLocale::C, QLocale::AnyCountry); + + //Default Locale from the Search Engine + QCOMPARE(qgeocodingmanager->locale(),*german); + + qgeocodingmanager->setLocale(*english); + + QCOMPARE(qgeocodingmanager->locale(),*english); + + QVERIFY(qgeocodingmanager->locale() != *german); + + delete german; + delete english; +} + +void tst_QGeocodingManager::name() +{ + QString name = "static.geocode.test.plugin"; + QCOMPARE(qgeocodingmanager->managerName(),name); +} + +void tst_QGeocodingManager::version() +{ + int version=3; + QCOMPARE(qgeocodingmanager->managerVersion(),version); + +} + +void tst_QGeocodingManager::search() +{ + QCOMPARE(signalerror->count(),0); + QCOMPARE(signalfinished->count(),0); + + QString search = "Berlin. Invaliendenstrasse"; + int limit = 10; + int offset = 2; + QGeoBoundingBox *bounds = new QGeoBoundingBox (); + + QGeocodeReply * reply = qgeocodingmanager->geocode(search, limit,offset,bounds); + + QCOMPARE(reply->errorString(),search); + QCOMPARE(signalfinished->count(),1); + QCOMPARE(signalerror->count(),0); + + delete reply; + delete bounds; + +} + +void tst_QGeocodingManager::geocode() +{ + QCOMPARE(signalerror->count(),0); + QCOMPARE(signalfinished->count(),0); + + QGeoAddress *address = new QGeoAddress (); + QString city = "Berlin"; + address->setCity(city); + + QGeoBoundingBox *bounds = new QGeoBoundingBox (); + + QGeocodeReply *reply = qgeocodingmanager->geocode(*address,bounds); + + QCOMPARE(reply->errorString(),city); + QCOMPARE(signalfinished->count(),1); + QCOMPARE(signalerror->count(),0); + + delete address; + delete bounds; + delete reply; +} + +void tst_QGeocodingManager::reverseGeocode() +{ + QCOMPARE(signalerror->count(),0); + QCOMPARE(signalfinished->count(),0); + + QGeoCoordinate *coordinate = new QGeoCoordinate (34.34 , 56.65); + QGeoBoundingBox *bounds = new QGeoBoundingBox (); + + QGeocodeReply *reply = qgeocodingmanager->reverseGeocode(*coordinate,bounds); + + QCOMPARE(reply->errorString(),coordinate->toString()); + QCOMPARE(signalfinished->count(),1); + QCOMPARE(signalerror->count(),0); + + delete coordinate; + delete bounds; + delete reply; + + +} + + +QTEST_MAIN(tst_QGeocodingManager) + diff --git a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h new file mode 100644 index 00000000..e546a5ab --- /dev/null +++ b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +//TESTED_COMPONENT=src/location + +#ifndef TST_QGEOCODINGMANAGER_H +#define TST_QGEOCODINGMANAGER_H + +#include <QLocale> +#include <QtTest/QtTest> +#include <QSignalSpy> + +#include <qgeoserviceprovider.h> +#include <qgeocodingmanager.h> +#include <qlandmarkmanager.h> +#include <qgeocodereply.h> +#include <qgeoboundingbox.h> +#include <qgeoaddress.h> +#include <qgeocoordinate.h> + + +QT_USE_NAMESPACE + +class SubLandmarkManager :public QLandmarkManager +{ + Q_OBJECT +public: + SubLandmarkManager (QString name):QLandmarkManager(){this->name=name;} + QString name; +}; + +class tst_QGeocodingManager: public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + void supports(); + void locale(); + void name(); + void version(); + void search(); + void geocode(); + void reverseGeocode(); + +private: + QGeoServiceProvider *qgeoserviceprovider; + QGeocodingManager *qgeocodingmanager; + QSignalSpy *signalerror; + QSignalSpy *signalfinished; + void loadGeocodingManager(); + +}; +Q_DECLARE_METATYPE( QGeocodeReply*); +Q_DECLARE_METATYPE( QGeocodeReply::Error); + +#endif + |