1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the test suite of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 21 ** included in the packaging of this file. Please review the following 22 ** information to ensure the GNU General Public License requirements will 23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 24 ** 25 ** $QT_END_LICENSE$ 26 ** 27 ****************************************************************************/ 28 29 #ifndef QGEOCODINGMANAGERENGINE_TEST_H 30 #define QGEOCODINGMANAGERENGINE_TEST_H 31 32 #include <qgeoserviceprovider.h> 33 #include <qgeocodingmanagerengine.h> 34 #include <QLocale> 35 #include <qgeoaddress.h> 36 #include <qgeolocation.h> 37 #include <qgeocodereply.h> 38 #include <QtPositioning/QGeoCoordinate> 39 40 QT_USE_NAMESPACE 41 42 class GeocodeReplyTest : public QGeoCodeReply 43 { 44 Q_OBJECT 45 public: QGeoCodeReply(parent)46 GeocodeReplyTest(QObject *parent = 0) : QGeoCodeReply(parent) {} 47 callAddLocation(const QGeoLocation & location)48 void callAddLocation ( const QGeoLocation & location ) {addLocation(location);} callSetError(Error error,const QString & errorString)49 void callSetError ( Error error, const QString & errorString ) {setError(error, errorString);} callSetFinished(bool finished)50 void callSetFinished ( bool finished ) {setFinished(finished);} callSetLimit(int limit)51 void callSetLimit ( int limit ) {setLimit(limit);} callSetOffset(int offset)52 void callSetOffset ( int offset ) {setOffset(offset);} callSetLocations(const QList<QGeoLocation> & locations)53 void callSetLocations ( const QList<QGeoLocation> & locations ) {setLocations(locations);} callSetViewport(const QGeoShape & viewport)54 void callSetViewport ( const QGeoShape &viewport ) {setViewport(viewport);} 55 56 }; 57 58 class QGeoCodingManagerEngineTest: public QGeoCodingManagerEngine 59 60 { 61 Q_OBJECT 62 public: QGeoCodingManagerEngineTest(const QVariantMap & parameters,QGeoServiceProvider::Error * error,QString * errorString)63 QGeoCodingManagerEngineTest(const QVariantMap ¶meters, 64 QGeoServiceProvider::Error *error, QString *errorString) : 65 QGeoCodingManagerEngine(parameters) 66 { 67 Q_UNUSED(error); 68 Q_UNUSED(errorString); 69 setLocale(QLocale(QLocale::German, QLocale::Germany)); 70 } 71 geocode(const QString & searchString,int limit,int offset,const QGeoShape & bounds)72 QGeoCodeReply* geocode(const QString &searchString, int limit, int offset, const QGeoShape &bounds) 73 { 74 GeocodeReplyTest *geocodereply = new GeocodeReplyTest(); 75 geocodereply->callSetLimit(limit); 76 geocodereply->callSetOffset(offset); 77 geocodereply->callSetViewport(bounds); 78 geocodereply->callSetError(QGeoCodeReply::NoError,searchString); 79 geocodereply->callSetFinished(true); 80 emit(this->finished(geocodereply)); 81 82 return static_cast<QGeoCodeReply*>(geocodereply); 83 } 84 geocode(const QGeoAddress & address,const QGeoShape & bounds)85 QGeoCodeReply* geocode (const QGeoAddress &address, const QGeoShape &bounds) 86 { 87 GeocodeReplyTest *geocodereply = new GeocodeReplyTest(); 88 geocodereply->callSetViewport(bounds); 89 geocodereply->callSetError(QGeoCodeReply::NoError,address.city()); 90 geocodereply->callSetFinished(true); 91 emit(this->finished(geocodereply)); 92 93 return static_cast<QGeoCodeReply*>(geocodereply); 94 } 95 reverseGeocode(const QGeoCoordinate & coordinate,const QGeoShape & bounds)96 QGeoCodeReply* reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds) 97 { 98 GeocodeReplyTest *geocodereply = new GeocodeReplyTest(); 99 geocodereply->callSetViewport(bounds); 100 geocodereply->callSetError(QGeoCodeReply::NoError,coordinate.toString()); 101 geocodereply->callSetFinished(true); 102 emit(this->finished(geocodereply)); 103 return static_cast<QGeoCodeReply*>(geocodereply); 104 } 105 }; 106 107 #endif 108