summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@nokia.com>2011-12-14 14:53:33 +0200
committerQt by Nokia <qt-info@nokia.com>2011-12-15 01:59:01 +0100
commitd6e91077ee259e26b4574a2bde8f5990eddf272c (patch)
tree391f927025d5ae707f49bb6d26881598f752c5ed
parent7ec81b7be1b71c8ab359412e980e45fc98838519 (diff)
downloadqtlocation-d6e91077ee259e26b4574a2bde8f5990eddf272c.tar.gz
Rough version of the mapping test plugin.
Change-Id: I5ed2ab21ea0bfbecd599fe006d2f8a61abc9e50c Reviewed-by: David Laing <david.laing@nokia.com>
-rw-r--r--tests/applications/declarative_map/map3d.qml14
-rw-r--r--tests/auto/declarative_core/tst_plugin.qml8
-rw-r--r--tests/auto/geotestplugin/geotestplugin.pro3
-rw-r--r--tests/auto/geotestplugin/qgeomappingmanagerengine_test.h172
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp6
5 files changed, 193 insertions, 10 deletions
diff --git a/tests/applications/declarative_map/map3d.qml b/tests/applications/declarative_map/map3d.qml
index c05e37f3..a9d98054 100644
--- a/tests/applications/declarative_map/map3d.qml
+++ b/tests/applications/declarative_map/map3d.qml
@@ -796,7 +796,19 @@ Rectangle {
Text {text: "Flick deceleration: " + map.flick.deceleration; color: firstText.color; font.bold: true}
Text {text: "Weather: Sunny, mild, late showers."; color: firstText.color; font.bold: true}
}
- plugin : Plugin {name : "nokia"}
+
+
+ //plugin : Plugin {name : "nokia"}
+
+ plugin: Plugin {
+ id: testPlugin;
+ name: "qmlgeo.test.plugin"
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "finishRequestImmediately"; value: true}
+ ]
+ }
+
// commented features are checked to work at least somehow
//anchors.left: parent.left
//anchors.bottom: parent.bottom
diff --git a/tests/auto/declarative_core/tst_plugin.qml b/tests/auto/declarative_core/tst_plugin.qml
index c357b9fb..fb33f24e 100644
--- a/tests/auto/declarative_core/tst_plugin.qml
+++ b/tests/auto/declarative_core/tst_plugin.qml
@@ -85,7 +85,7 @@ Item {
compare (testPlugin.supportsGeocoding, true )
compare (testPlugin.supportsReverseGeocoding, true )
compare (testPlugin.supportsRouting, true )
- compare (testPlugin.supportsMapping, false )
+ compare (testPlugin.supportsMapping, true )
compare (testPlugin.supportsPlaces, true )
// test changing name of plugin
compare (invalidGeocodeSpy.count, 0)
@@ -96,17 +96,17 @@ Item {
compare (invalidGeocodeSpy.count, 1)
compare (invalidReverseGeocodeSpy.count, 1)
compare (invalidRoutingSpy.count, 1)
- compare (invalidMappingSpy.count, 0)
+ compare (invalidMappingSpy.count, 1)
compare (invalidPlugin.supportsGeocoding, true )
compare (invalidPlugin.supportsReverseGeocoding, true )
compare (invalidPlugin.supportsRouting, true )
- compare (invalidPlugin.supportsMapping, false )
+ compare (invalidPlugin.supportsMapping, true )
compare (invalidPlugin.supportsPlaces, true )
invalidPlugin.name = ''
compare (invalidGeocodeSpy.count, 2)
compare (invalidReverseGeocodeSpy.count, 2)
compare (invalidRoutingSpy.count, 2)
- compare (invalidMappingSpy.count, 0)
+ compare (invalidMappingSpy.count, 2)
compare (invalidPlugin.supportsGeocoding, false )
compare (invalidPlugin.supportsReverseGeocoding, false )
compare (invalidPlugin.supportsRouting, false )
diff --git a/tests/auto/geotestplugin/geotestplugin.pro b/tests/auto/geotestplugin/geotestplugin.pro
index 2e8af6fd..f84f2d95 100644
--- a/tests/auto/geotestplugin/geotestplugin.pro
+++ b/tests/auto/geotestplugin/geotestplugin.pro
@@ -8,7 +8,8 @@ DESTDIR = $$QT.location.plugins/geoservices
HEADERS += qgeocodingmanagerengine_test.h \
qgeoserviceproviderplugin_test.h \
qgeoroutingmanagerengine_test.h \
- qplacemanagerengine_test.h
+ qplacemanagerengine_test.h \
+ qgeomappingmanagerengine_test.h
SOURCES += qgeoserviceproviderplugin_test.cpp
diff --git a/tests/auto/geotestplugin/qgeomappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeomappingmanagerengine_test.h
new file mode 100644
index 00000000..7d4ebd10
--- /dev/null
+++ b/tests/auto/geotestplugin/qgeomappingmanagerengine_test.h
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 QGEOMAPPINGMANAGERENGINE_TEST_H
+#define QGEOMAPPINGMANAGERENGINE_TEST_H
+
+#include <qgeoserviceprovider.h>
+#include <qgeomappingmanagerengine.h>
+#include <QLocale>
+#include <QPixmap>
+#include <QByteArray>
+#include <QBuffer>
+#include <qgeotiledmapreply.h>
+#include "maptype.h"
+#include "tilespec.h"
+
+#include <QTimer>
+#include <QDebug>
+#include <QTimerEvent>
+
+QT_USE_NAMESPACE
+
+
+class TiledMapReplyTest :public QGeoTiledMapReply
+{
+ Q_OBJECT
+public:
+ TiledMapReplyTest(const TileSpec &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 QGeoMappingManagerEngineTest: public QGeoMappingManagerEngine
+
+{
+Q_OBJECT
+public:
+ QGeoMappingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error, QString *errorString) :
+ QGeoMappingManagerEngine(parameters),
+ finishRequestImmediately_(true),
+ mappingReply_(0),
+ timerId_(0),
+ errorCode_(QGeoTiledMapReply::NoError)
+ {
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+ if (parameters.contains("finishRequestImmediately"))
+ finishRequestImmediately_ = qvariant_cast<bool>(parameters.value("finishRequestImmediately"));
+ setLocale(QLocale (QLocale::German, QLocale::Germany));
+ setMinimumZoomLevel(0.0);
+ setMaximumZoomLevel(20.0);
+ }
+
+ void init()
+ {
+ setTileSize(QSize(256, 256));
+ QList<MapType> types;
+ types << MapType(MapType::StreetMap,tr("Street Map"),tr("Test Street Map"), false, 1);
+ setSupportedMapTypes(types);
+ QGeoMappingManagerEngine::init();
+ }
+
+ QGeoTiledMapReply* getTileImage(const TileSpec &spec)
+ {
+ //qDebug() << __FUNCTION__ << "in test plugin for spec: " << spec.x() << spec.y() << spec.zoom();
+ mappingReply_ = new TiledMapReplyTest(spec, this);
+
+ QImage im(256, 256, QImage::Format_RGB888);
+ im.fill(0);
+
+ for (int y = 0; y < im.height(); y++) {
+ for (int x = 0; x < im.width(); x++) {
+ im.setPixel(x, y, (x + y) % 255);
+ }
+ }
+ 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_);
+ }
+
+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_;
+};
+
+#endif
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
index 36b1688b..8e4d7c54 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
@@ -42,6 +42,7 @@
#include "qgeoserviceproviderplugin_test.h"
#include "qgeocodingmanagerengine_test.h"
#include "qgeoroutingmanagerengine_test.h"
+#include "qgeomappingmanagerengine_test.h"
#include "qplacemanagerengine_test.h"
#include <QtPlugin>
@@ -88,10 +89,7 @@ QGeoMappingManagerEngine* QGeoServiceProviderFactoryTest::createMappingManagerEn
const QMap<QString, QVariant> & parameters,
QGeoServiceProvider::Error * error, QString * errorString ) const
{
- Q_UNUSED(parameters);
- Q_UNUSED(error);
- Q_UNUSED(errorString);
- return 0;
+ return new QGeoMappingManagerEngineTest(parameters, error, errorString);
}
QPlaceManagerEngine* QGeoServiceProviderFactoryTest::createPlaceManagerEngine(