summaryrefslogtreecommitdiff
path: root/tests/auto/qgeocodereply/tst_qgeocodereply.cpp
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-07-31 21:33:56 +1000
committerabcd <qt_abcd1@ovi.com>2011-08-09 03:48:02 +0200
commit2904df66e87534ff348f7af13b0d513c8ecc746c (patch)
tree70fb416d39158f80d9445e1e9f0d1a2c6de20b48 /tests/auto/qgeocodereply/tst_qgeocodereply.cpp
parent38e2574bf27f66100bf9ec16592f938a4b7a02b1 (diff)
downloadqtlocation-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/qgeocodereply/tst_qgeocodereply.cpp')
-rw-r--r--tests/auto/qgeocodereply/tst_qgeocodereply.cpp291
1 files changed, 291 insertions, 0 deletions
diff --git a/tests/auto/qgeocodereply/tst_qgeocodereply.cpp b/tests/auto/qgeocodereply/tst_qgeocodereply.cpp
new file mode 100644
index 00000000..1c052fed
--- /dev/null
+++ b/tests/auto/qgeocodereply/tst_qgeocodereply.cpp
@@ -0,0 +1,291 @@
+/****************************************************************************
+**
+** 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_qgeocodereply.h"
+
+QT_USE_NAMESPACE
+
+void tst_QGeocodeReply::initTestCase()
+{
+
+ reply = new SubGeocodeReply();
+}
+
+void tst_QGeocodeReply::cleanupTestCase()
+{
+
+ delete reply;
+ delete qgeolocation;
+}
+
+void tst_QGeocodeReply::init()
+{
+ qRegisterMetaType<QGeocodeReply::Error>("Error");
+ signalerror = new QSignalSpy(reply, SIGNAL(error(QGeocodeReply::Error,const QString)));
+ signalfinished = new QSignalSpy(reply, SIGNAL(finished()));
+}
+
+void tst_QGeocodeReply::cleanup()
+{
+ delete signalerror;
+ delete signalfinished;
+}
+
+void tst_QGeocodeReply::constructor()
+{
+ QVERIFY(!reply->isFinished());
+
+ QCOMPARE(reply->limit(),-1);
+ QCOMPARE(reply->offset(),0);
+ QCOMPARE(reply->error(),QGeocodeReply::NoError);
+
+ QVERIFY( signalerror->isValid() );
+ QVERIFY( signalfinished->isValid() );
+
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE(signalfinished->count(),0);
+}
+
+void tst_QGeocodeReply::constructor_error()
+{
+ QFETCH(QGeocodeReply::Error,error);
+ QFETCH(QString,msg);
+
+ QVERIFY( signalerror->isValid() );
+ QVERIFY( signalfinished->isValid() );
+
+ QGeocodeReply *qgeocodereplycopy = new QGeocodeReply (error,msg,0);
+
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE(signalfinished->count(),0);
+
+ QCOMPARE (qgeocodereplycopy->error(),error);
+ QCOMPARE (qgeocodereplycopy->errorString(),msg);
+
+ delete qgeocodereplycopy;
+}
+
+void tst_QGeocodeReply::constructor_error_data()
+{
+ QTest::addColumn<QGeocodeReply::Error>("error");
+ QTest::addColumn<QString>("msg");
+
+ QTest::newRow("error1") << QGeocodeReply::NoError << "No error.";
+ QTest::newRow("error2") << QGeocodeReply::EngineNotSetError << "Engine Not Set Error.";
+ QTest::newRow("error3") << QGeocodeReply::CommunicationError << "Communication Error.";
+ QTest::newRow("error4") << QGeocodeReply::ParseError << "Parse Error.";
+ QTest::newRow("error5") << QGeocodeReply::UnsupportedOptionError << "Unsupported Option Error.";
+ QTest::newRow("error6") << QGeocodeReply::UnknownError << "Unknown Error.";
+
+}
+
+void tst_QGeocodeReply::destructor()
+{
+ QGeocodeReply *qgeocodereplycopy;
+ QFETCH(QGeocodeReply::Error,error);
+ QFETCH(QString,msg);
+
+ QLocationTestUtils::uheap_mark();
+ qgeocodereplycopy = new QGeocodeReply (error,msg,0);
+ delete qgeocodereplycopy;
+ QLocationTestUtils::uheap_mark_end();
+
+}
+
+void tst_QGeocodeReply::destructor_data()
+{
+ tst_QGeocodeReply::constructor_error_data();
+}
+
+void tst_QGeocodeReply::abort()
+{
+ QVERIFY( signalerror->isValid() );
+ QVERIFY( signalfinished->isValid() );
+
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE (signalfinished->count(),0);
+
+ reply->callSetFinished(true);
+ reply->abort();
+
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE (signalfinished->count(),1);
+
+ reply->abort();
+ reply->callSetFinished(false);
+ reply->abort();
+
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE (signalfinished->count(),2);
+}
+
+void tst_QGeocodeReply::error()
+{
+ QFETCH(QGeocodeReply::Error,error);
+ QFETCH(QString,msg);
+
+ QVERIFY( signalerror->isValid() );
+ QVERIFY( signalfinished->isValid() );
+ QCOMPARE(signalerror->count(),0);
+
+ reply->callSetError(error,msg);
+
+ QCOMPARE(signalerror->count(),1);
+ QCOMPARE(signalfinished->count(),1);
+ QCOMPARE(reply->errorString(),msg);
+ QCOMPARE(reply->error(),error);
+
+
+}
+
+void tst_QGeocodeReply::error_data()
+{
+ QTest::addColumn<QGeocodeReply::Error>("error");
+ QTest::addColumn<QString>("msg");
+
+ QTest::newRow("error1") << QGeocodeReply::NoError << "No error.";
+ QTest::newRow("error2") << QGeocodeReply::EngineNotSetError << "Engine Not Set Error.";
+ QTest::newRow("error3") << QGeocodeReply::CommunicationError << "Communication Error.";
+ QTest::newRow("error4") << QGeocodeReply::ParseError << "Parse Error.";
+ QTest::newRow("error5") << QGeocodeReply::UnsupportedOptionError << "Unsupported Option Error.";
+ QTest::newRow("error6") << QGeocodeReply::UnknownError << "Unknown Error.";
+}
+
+void tst_QGeocodeReply::finished()
+{
+ QVERIFY( signalerror->isValid() );
+ QVERIFY( signalfinished->isValid() );
+
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE (signalfinished->count(),0);
+
+ reply->callSetFinished(true);
+ QVERIFY(reply->isFinished());
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE (signalfinished->count(),1);
+
+ reply->callSetFinished(false);
+
+ QVERIFY(!reply->isFinished());
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE (signalfinished->count(),1);
+
+ reply->callSetFinished(true);
+
+ QVERIFY(reply->isFinished());
+ QCOMPARE(signalerror->count(),0);
+ QCOMPARE (signalfinished->count(),2);
+}
+
+
+
+void tst_QGeocodeReply::limit()
+{
+ int limit =30;
+ reply->callSetLimit(limit);
+ QCOMPARE(reply->limit(),limit);
+}
+
+void tst_QGeocodeReply::offset()
+{
+ int offset = 2;
+ reply->callSetOffset(offset);
+ QCOMPARE(reply->offset(),offset);
+}
+
+void tst_QGeocodeReply::locations()
+{
+ QList <QGeoLocation> geolocations;
+ geolocations = reply->locations();
+
+ QCOMPARE(geolocations.size(),0);
+
+ QGeoAddress *qgeoaddress = new QGeoAddress ();
+ qgeoaddress->setCity("Berlin");
+
+ QGeoCoordinate *qgeocoordinate = new QGeoCoordinate (12.12 , 54.43);
+
+ qgeolocation = new QGeoLocation ();
+ qgeolocation->setAddress(*qgeoaddress);
+ qgeolocation->setCoordinate(*qgeocoordinate);
+
+ reply->callAddLocation(*qgeolocation);
+
+ geolocations = reply->locations();
+ QCOMPARE(geolocations.size(),1);
+ QCOMPARE(geolocations.at(0),*qgeolocation);
+
+ QGeoLocation *qgeolocationcopy = new QGeoLocation (*qgeolocation);
+
+ QList <QGeoLocation> qgeolocations;
+ qgeolocations.append(*qgeolocation);
+ qgeolocations.append(*qgeolocationcopy);
+
+ reply->callSetLocations(qgeolocations);
+
+ geolocations = reply->locations();
+
+ QCOMPARE(geolocations.size(),qgeolocations.size());
+ for (int i = 0 ; i < geolocations.size(); i++)
+ {
+ QCOMPARE(geolocations.at(i),qgeolocations.at(i));
+ }
+
+ delete qgeoaddress;
+ delete qgeocoordinate;
+ delete qgeolocationcopy;
+}
+
+void tst_QGeocodeReply::viewport()
+{
+ QGeoCoordinate *qgeocoordinate = new QGeoCoordinate (12.12 , 54.43);
+
+ qgeoboundingbox = new QGeoBoundingBox (*qgeocoordinate, 0.5 , 0.5);
+
+ reply->callSetViewport(qgeoboundingbox);
+
+ QCOMPARE (reply->viewport(), static_cast<QGeoBoundingArea*>(qgeoboundingbox));
+
+ delete qgeocoordinate;
+ delete qgeoboundingbox;
+}
+
+QTEST_MAIN(tst_QGeocodeReply);