diff options
author | Aaron McCarthy <aaron.mccarthy@jollamobile.com> | 2014-02-19 14:52:07 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-14 12:30:09 +0100 |
commit | d2628aeb6ed1ab30d1a825122dc80cfebb5093d2 (patch) | |
tree | 00cec128c5d264346c871ba9bfcdc9a920dfa52b /tests/auto | |
parent | 3f4a3acab163fa6675a1513ab1fccdbda7723dd6 (diff) | |
download | qtlocation-d2628aeb6ed1ab30d1a825122dc80cfebb5093d2.tar.gz |
Parse Nokia route response in helper thread.
Complex and really long routes can take multiple seconds to parse. Use
a helper thread to parse route responses to prevent blocking the main
thread.
Change-Id: I4130510ff15752427f31b429e53d2ab87fa1b84a
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/nokia_services/routing/tst_routing.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp | 29 |
2 files changed, 25 insertions, 7 deletions
diff --git a/tests/auto/nokia_services/routing/tst_routing.cpp b/tests/auto/nokia_services/routing/tst_routing.cpp index 95d034da..dc77ba6c 100644 --- a/tests/auto/nokia_services/routing/tst_routing.cpp +++ b/tests/auto/nokia_services/routing/tst_routing.cpp @@ -521,11 +521,10 @@ void tst_nokia_routing::foobar_data() QTest::newRow("QNetworkReply::UnknownNetworkError") << int(QNetworkReply::UnknownNetworkError); QTest::newRow("QNetworkReply::UnknownProxyError") << int(QNetworkReply::UnknownProxyError); QTest::newRow("QNetworkReply::ProxyAuthenticationRequiredError") << int(QNetworkReply::ProxyAuthenticationRequiredError); - QTest::newRow("QNetworkReply::UnknownContentError") << int(QNetworkReply::UnknownContentError); QTest::newRow("QNetworkReply::ProtocolFailure") << int(QNetworkReply::ProtocolFailure); } -QTEST_APPLESS_MAIN(tst_nokia_routing) +QTEST_MAIN(tst_nokia_routing) #include "tst_routing.moc" diff --git a/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp b/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp index 9fb51cc6..1dde8b33 100644 --- a/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp +++ b/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp @@ -47,6 +47,9 @@ #include <QMetaType> #include <QDebug> #include <QFile> +#include <QSignalSpy> + +Q_DECLARE_METATYPE(QList<QGeoRoute>) QT_USE_NAMESPACE @@ -58,7 +61,9 @@ public: tst_QGeoRouteXmlParser() : start(0.0, 0.0), end(1.0, 1.0) - {} + { + qRegisterMetaType<QList<QGeoRoute> >(); + } private: // dummy values for creating the request object @@ -74,11 +79,18 @@ private slots: QGeoRouteRequest req(start, end); QGeoRouteXmlParser xp(req); + xp.setAutoDelete(false); + + QSignalSpy resultsSpy(&xp, SIGNAL(results(QList<QGeoRoute>))); + + xp.parse(f.readAll()); - QVERIFY(xp.parse(&f)); + QTRY_COMPARE(resultsSpy.count(), 1); + + QVariantList arguments = resultsSpy.first(); // xml contains exactly 1 route - QList<QGeoRoute> results = xp.results(); + QList<QGeoRoute> results = arguments.at(0).value<QList<QGeoRoute> >(); QCOMPARE(results.size(), 1); QGeoRoute route = results.first(); @@ -121,11 +133,18 @@ private slots: QGeoRouteRequest req(start, end); QGeoRouteXmlParser xp(req); + xp.setAutoDelete(false); + + QSignalSpy resultsSpy(&xp, SIGNAL(results(QList<QGeoRoute>))); + + xp.parse(f.readAll()); + + QTRY_COMPARE(resultsSpy.count(), 1); - QVERIFY(xp.parse(&f)); + QVariantList arguments = resultsSpy.first(); // xml contains exactly 1 route - QList<QGeoRoute> results = xp.results(); + QList<QGeoRoute> results = arguments.at(0).value<QList<QGeoRoute> >(); QCOMPARE(results.size(), 1); QGeoRoute route = results.first(); |