summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@digia.com>2015-01-07 16:55:53 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-01-13 16:06:33 +0100
commitecf7772c46db2e5b011cdbb531bc6fd69ba8c76d (patch)
treed208eaece5c7097cca6cd4a1da33d6640ae86bd5 /tests/auto
parentbcdc5cc06bd73b060157936f0b6fa40194cadff8 (diff)
downloadqtlocation-ecf7772c46db2e5b011cdbb531bc6fd69ba8c76d.tar.gz
Adds mapping manager error handling to qml
When map is created, plugins can report errors in case of missing required parameters. Expose error message to qml. Change-Id: I014e55cd4aad5ba15ffd0a15bc1f414c21feacc8 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative_core/tst_plugin_error.qml66
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp24
2 files changed, 87 insertions, 3 deletions
diff --git a/tests/auto/declarative_core/tst_plugin_error.qml b/tests/auto/declarative_core/tst_plugin_error.qml
new file mode 100644
index 00000000..d88ae0fa
--- /dev/null
+++ b/tests/auto/declarative_core/tst_plugin_error.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtLocation 5.3
+
+Item {
+
+ Plugin { id: testPlugin;
+ name: "qmlgeo.test.plugin"
+ allowExperimental: true
+ parameters: [
+ // Parms to guide the test plugin
+ PluginParameter { name: "error"; value: "1"},
+ PluginParameter { name: "errorString"; value: "This error was expected. No worries !"}
+ ]
+ }
+
+ Map {
+ id: map
+ }
+
+ SignalSpy {id: errorSpy; target: map; signalName: "errorChanged"}
+
+ TestCase {
+ name: "MappingManagerError"
+ function test_error() {
+ verify (map.error === Map.NoError);
+ map.plugin = testPlugin;
+ verify (map.error === Map.NotSupportedError);
+ verify (map.errorString == "This error was expected. No worries !");
+ compare(errorSpy.count, 1);
+ }
+ }
+}
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
index 185bf44f..d3e45e41 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
@@ -39,6 +39,24 @@
#include <QtPlugin>
+namespace
+{
+ template<class EngineType>
+ EngineType * createEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
+ {
+ const QString failError = parameters.value(QStringLiteral("error")).toString();
+ const QString failErrorString = parameters.value(QStringLiteral("errorString")).toString();
+
+ if (!failError.isEmpty()) {
+ *error = QGeoServiceProvider::Error(failError.toInt());
+ *errorString = failErrorString;
+ return 0;
+ } else {
+ return new EngineType(parameters, error, errorString);
+ }
+ }
+}
+
QGeoServiceProviderFactoryTest::QGeoServiceProviderFactoryTest()
{
}
@@ -51,7 +69,7 @@ QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEn
const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const
{
- return new QGeoRoutingManagerEngineTest(parameters, error, errorString);
+ return createEngine<QGeoRoutingManagerEngineTest>(parameters, error, errorString);
}
@@ -59,7 +77,7 @@ QGeoCodingManagerEngine* QGeoServiceProviderFactoryTest::createGeocodingManagerE
const QVariantMap &parameters, QGeoServiceProvider::Error *error,
QString *errorString) const
{
- return new QGeoCodingManagerEngineTest(parameters, error, errorString);
+ return createEngine<QGeoCodingManagerEngineTest>(parameters, error, errorString);
}
@@ -67,7 +85,7 @@ QGeoMappingManagerEngine* QGeoServiceProviderFactoryTest::createMappingManagerEn
const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const
{
- return new QGeoTiledMappingManagerEngineTest(parameters, error, errorString);
+ return createEngine<QGeoTiledMappingManagerEngineTest>(parameters, error, errorString);
}
QPlaceManagerEngine* QGeoServiceProviderFactoryTest::createPlaceManagerEngine(