diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative_core/tst_placesearchmodel.qml | 18 | ||||
-rw-r--r-- | tests/auto/geotestplugin/place_data.json | 3 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qplacemanagerengine_test.h | 39 |
3 files changed, 59 insertions, 1 deletions
diff --git a/tests/auto/declarative_core/tst_placesearchmodel.qml b/tests/auto/declarative_core/tst_placesearchmodel.qml index 2d3c599c..4c7897b5 100644 --- a/tests/auto/declarative_core/tst_placesearchmodel.qml +++ b/tests/auto/declarative_core/tst_placesearchmodel.qml @@ -129,6 +129,16 @@ TestCase { ] }, { + tag: "searchTerm, multiple results", + property: "searchTerm", + value: "sea", + reset: "", + alternate: true, + places: [ + "8f72057a-54b2-4e95-a7bb-97b4d2b5721e" + ] + }, + { tag: "categories, single result", property: "categories", value: [ park ], @@ -192,6 +202,14 @@ TestCase { verify(data.places.indexOf(place.placeId) >= 0); } + // Test for alternate implementation + if (data.alternate !== undefined && data.alternate === true) { + for (var ii = 0; ii < testModel.count; ++ii) { + var p = testModel.data(ii, "place"); + compare(p.extendedAttributes["x_provider"].text, "QPlacePrivateDefaultAlt") + } + } + testModel.reset(); compare(statusChangedSpy.count, 3); diff --git a/tests/auto/geotestplugin/place_data.json b/tests/auto/geotestplugin/place_data.json index 20062816..3aafcbec 100644 --- a/tests/auto/geotestplugin/place_data.json +++ b/tests/auto/geotestplugin/place_data.json @@ -130,7 +130,8 @@ "location": { "latitude": 0.1002, "longitude": 0.1002 - } + }, + "alternateImplementation": true }, { "name": "Country Gardens", diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h index f8af1edc..30e5422e 100644 --- a/tests/auto/geotestplugin/qplacemanagerengine_test.h +++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h @@ -51,6 +51,7 @@ #include <QtLocation/QPlaceCategory> #include <QtLocation/QPlace> #include <QtLocation/QPlaceReview> +#include <QtLocation/private/qplace_p.h> #include <QtTest/QTest> QT_BEGIN_NAMESPACE @@ -64,6 +65,37 @@ QT_END_NAMESPACE QT_USE_NAMESPACE +class QPlacePrivateDefaultAlt : public QPlacePrivateDefault +{ +public: + QPlacePrivateDefaultAlt() {} + QPlacePrivateDefaultAlt(const QPlacePrivateDefaultAlt &other) + : QPlacePrivateDefault(other) + { + } + ~QPlacePrivateDefaultAlt() {} + + QPlaceAttribute extendedAttribute(const QString &attributeType) const override + { + if (attributeType == QStringLiteral("x_provider")) { + QPlaceAttribute a; + a.setLabel(QStringLiteral("x_provider")); + a.setText(QStringLiteral("QPlacePrivateDefaultAlt")); + return a; + } else { + return QPlacePrivateDefault::extendedAttribute(attributeType); + } + } +}; + +class QPlaceAlt : public QPlace +{ +public: + QPlaceAlt() : QPlace(QSharedDataPointer<QPlacePrivate>(new QPlacePrivateDefaultAlt())) + { + } +}; + class PlaceReply : public QPlaceReply { Q_OBJECT @@ -233,6 +265,13 @@ public: QJsonObject p = places.at(i).toObject(); QPlace place; + if (p.value(QStringLiteral("alternateImplementation")).toBool(false)) { + place = QPlaceAlt(); + QPlaceAttribute att; + att.setLabel(QStringLiteral("x_provider")); + att.setText(QStringLiteral("42")); // Doesn't matter, wont be used. + place.setExtendedAttribute(QStringLiteral("x_provider"), att); + } place.setName(p.value(QStringLiteral("name")).toString()); place.setPlaceId(p.value(QStringLiteral("id")).toString()); |