summaryrefslogtreecommitdiff
path: root/tests/auto/geotestplugin
diff options
context:
space:
mode:
authorBasel Hashisho <basel.hashisho@nokia.com>2012-02-17 12:07:01 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-09 16:04:55 +0100
commit53e5f30e06091f5b05c9283657e454bc45896075 (patch)
treea9a5be51418b008f61165b510f1d87aa748a020e /tests/auto/geotestplugin
parentf61e60ec2d66e181caf9e81b126936075e6fca5d (diff)
downloadqtlocation-53e5f30e06091f5b05c9283657e454bc45896075.tar.gz
Refactoring of QtLocation API
Refactoring QGeoMap, QGeoMappingManager, QGeoMappingManagerEngine Introducing QGeoMapData, QGeoTiledMap, QGeoTiledMappingManagerEngine, QGeoTileFetcher QGeoMap: Container for QGeoMapData QGeoMapData: No tiles data/functionality QGeoTiledMapData: Implements tiles data/functionality. QGeoMappingManager: Looses tiles-related data/functionality. QGeoMappingManagerEngine => QGeoMappingManagerEngine (no tiles data/functionality) QGeoTiledMappingManagerEngine (implements tiles-related data/functionality). QGeoTileFetcher: Implements tile fetching functionality from tiles provider. This commit compiles and runs through mapviewer example. Tests also were adjusted to fit refactored architecture. Change-Id: Id2b62d62d5cd4aaca8295c67e44c009cde636462 Reviewed-by: Alex <alex.blasche@nokia.com>
Diffstat (limited to 'tests/auto/geotestplugin')
-rw-r--r--tests/auto/geotestplugin/geotestplugin.pro4
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp4
-rw-r--r--tests/auto/geotestplugin/qgeotiledmapdata_test.h59
-rw-r--r--tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h94
-rw-r--r--tests/auto/geotestplugin/qgeotilefetcher_test.h177
5 files changed, 335 insertions, 3 deletions
diff --git a/tests/auto/geotestplugin/geotestplugin.pro b/tests/auto/geotestplugin/geotestplugin.pro
index bfed371b..352b1bce 100644
--- a/tests/auto/geotestplugin/geotestplugin.pro
+++ b/tests/auto/geotestplugin/geotestplugin.pro
@@ -11,7 +11,9 @@ HEADERS += qgeocodingmanagerengine_test.h \
qgeoserviceproviderplugin_test.h \
qgeoroutingmanagerengine_test.h \
qplacemanagerengine_test.h \
- qgeomappingmanagerengine_test.h
+ qgeotiledmappingmanagerengine_test.h \
+ qgeotiledmapdata_test.h \
+ qgeotilefetcher_test.h
SOURCES += qgeoserviceproviderplugin_test.cpp
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
index 5b5b095a..371fc359 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
@@ -42,7 +42,7 @@
#include "qgeoserviceproviderplugin_test.h"
#include "qgeocodingmanagerengine_test.h"
#include "qgeoroutingmanagerengine_test.h"
-#include "qgeomappingmanagerengine_test.h"
+#include "qgeotiledmappingmanagerengine_test.h"
#include "qplacemanagerengine_test.h"
#include <QtPlugin>
@@ -74,7 +74,7 @@ QGeoMappingManagerEngine* QGeoServiceProviderFactoryTest::createMappingManagerEn
const QMap<QString, QVariant> & parameters,
QGeoServiceProvider::Error * error, QString * errorString ) const
{
- return new QGeoMappingManagerEngineTest(parameters, error, errorString);
+ return new QGeoTiledMappingManagerEngineTest(parameters, error, errorString);
}
QPlaceManagerEngine* QGeoServiceProviderFactoryTest::createPlaceManagerEngine(
diff --git a/tests/auto/geotestplugin/qgeotiledmapdata_test.h b/tests/auto/geotestplugin/qgeotiledmapdata_test.h
new file mode 100644
index 00000000..94c018c8
--- /dev/null
+++ b/tests/auto/geotestplugin/qgeotiledmapdata_test.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPDATA_TEST_H
+#define QGEOTILEDMAPDATA_TEST_H
+
+#include <qgeotiledmapdata_p.h>
+
+QT_USE_NAMESPACE
+
+
+class QGeoTiledMapDataTest: public QGeoTiledMapData
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapDataTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0)
+ : QGeoTiledMapData(engine, parent) {}
+
+};
+
+#endif
diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
new file mode 100644
index 00000000..559266b8
--- /dev/null
+++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPPINGMANAGERENGINE_TEST_H
+#define QGEOTILEDMAPPINGMANAGERENGINE_TEST_H
+
+#include <qgeoserviceprovider.h>
+#include <qgeotiledmappingmanagerengine.h>
+#include <QLocale>
+#include <qgeotiledmapreply.h>
+#include "qgeomaptype.h"
+#include "qgeocameracapabilities_p.h"
+
+#include "qgeotiledmapdata_test.h"
+#include "qgeotilefetcher_test.h"
+
+#include <QTimer>
+#include <QDebug>
+#include <QTimerEvent>
+
+QT_USE_NAMESPACE
+
+class QGeoTiledMappingManagerEngineTest: public QGeoTiledMappingManagerEngine
+{
+Q_OBJECT
+public:
+ QGeoTiledMappingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error, QString *errorString) :
+ QGeoTiledMappingManagerEngine()
+ {
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ setLocale(QLocale (QLocale::German, QLocale::Germany));
+ QGeoCameraCapabilities capabilities;
+ capabilities.setMinimumZoomLevel(0.0);
+ capabilities.setMaximumZoomLevel(20.0);
+ capabilities.setSupportsBearing(true);
+ setCameraCapabilities(capabilities);
+
+ setTileSize(QSize(256, 256));
+
+ QGeoTileFetcherTest *fetcher = new QGeoTileFetcherTest(this);
+ fetcher->setParams(&parameters);
+ fetcher->setTileSize(QSize(256, 255));
+ setTileFetcher(fetcher);
+ }
+
+ QGeoMapData *createMapData()
+ {
+ return new QGeoTiledMapDataTest(this);;
+ }
+
+};
+
+#endif
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h
new file mode 100644
index 00000000..45788141
--- /dev/null
+++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEFETCHER_TEST_H
+#define QGEOTILEFETCHER_TEST_H
+
+#include <qgeotiledmapreply.h>
+
+#include "qgeotilefetcher.h"
+#include "qgeotilespec.h"
+
+#include <QLocale>
+#include <QPainter>
+#include <QPixmap>
+#include <QByteArray>
+#include <QBuffer>
+#include <QTimer>
+#include <QDebug>
+#include <QTimerEvent>
+
+QT_USE_NAMESPACE
+
+class TiledMapReplyTest :public QGeoTiledMapReply
+{
+ Q_OBJECT
+public:
+ TiledMapReplyTest(const QGeoTileSpec &spec, QObject *parent=0): QGeoTiledMapReply (spec, parent) {}
+ void callSetError ( Error error, const QString & errorString ) {setError(error, errorString);}
+ void callSetFinished ( bool finished ) { setFinished(finished);}
+ void callSetCached(bool cached) { setFinished(cached);}
+ void callSetMapImageData(const QByteArray &data) { setMapImageData(data); }
+ void callSetMapImageFormat(const QString &format) { setMapImageFormat(format); }
+ void abort() { emit aborted(); }
+
+Q_SIGNALS:
+ void aborted();
+};
+
+class QGeoTileFetcherTest: public QGeoTileFetcher
+{
+Q_OBJECT
+public:
+ QGeoTileFetcherTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0)
+ : QGeoTileFetcher(engine, parent) {}
+
+ bool init()
+ {
+ if (m_parameters->contains("finishRequestImmediately"))
+ finishRequestImmediately_ = qvariant_cast<bool>(m_parameters->value("finishRequestImmediately"));
+ return true;
+ }
+
+ QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec)
+ {
+ mappingReply_ = new TiledMapReplyTest(spec, this);
+
+ QImage im(256, 256, QImage::Format_RGB888);
+ im.fill(QColor("lightgray"));
+ QRectF rect;
+ QString text("X: " + QString::number(spec.x()) + "\nY: " + QString::number(spec.y()) + "\nZ: " + QString::number(spec.zoom()));
+ rect.setWidth(250);
+ rect.setHeight(250);
+ rect.setLeft(3);
+ rect.setTop(3);
+ QPainter painter;
+ QPen pen(QColor("firebrick"));
+ painter.begin(&im);
+ painter.setPen(pen);
+ painter.setFont( QFont("Times", 35, 10, false));
+ painter.drawText(rect, text);
+ // different border color for vertically and horizontally adjacent frames
+ if ((spec.x() + spec.y()) % 2 == 0)
+ pen.setColor(QColor("yellow"));
+ pen.setWidth(5);
+ painter.setPen(pen);
+ painter.drawRect(0,0,255,255);
+ painter.end();
+ QPixmap pm = QPixmap::fromImage(im);
+ QByteArray bytes;
+ QBuffer buffer(&bytes);
+ buffer.open(QIODevice::WriteOnly);
+ pm.save(&buffer, "PNG");
+
+ mappingReply_->callSetMapImageData(bytes);
+ mappingReply_->callSetMapImageFormat("png");
+ mappingReply_->callSetFinished(true);
+
+ return static_cast<QGeoTiledMapReply*>(mappingReply_);
+ }
+
+ void setParams(const QMap<QString, QVariant> *parameters)
+ {
+ m_parameters = parameters;
+ }
+
+ void setTileSize(QSize tileSize)
+ {
+ m_tileSize = tileSize;
+ }
+
+public Q_SLOTS:
+ void requestAborted()
+ {
+ if (timerId_) {
+ killTimer(timerId_);
+ timerId_ = 0;
+ }
+ errorString_ = "";
+ errorCode_ = QGeoTiledMapReply::NoError;
+ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ Q_ASSERT(timerId_ == event->timerId());
+ Q_ASSERT(mappingReply_);
+ killTimer(timerId_);
+ timerId_ = 0;
+ if (errorCode_) {
+ mappingReply_->callSetError(errorCode_, errorString_);
+ emit tileError(mappingReply_->tileSpec(), errorString_);
+ } else {
+ mappingReply_->callSetError(QGeoTiledMapReply::NoError, "no error");
+ mappingReply_->callSetFinished(true);
+ }
+ // emit finished(mappingReply_); todo tileFinished
+ }
+
+private:
+ bool finishRequestImmediately_;
+ TiledMapReplyTest* mappingReply_;
+ int timerId_;
+ QGeoTiledMapReply::Error errorCode_;
+ QString errorString_;
+ const QMap<QString, QVariant> *m_parameters;
+ QSize m_tileSize;
+};
+
+#endif