diff options
author | abcd <amos.choy@nokia.com> | 2012-07-10 18:29:22 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-24 02:42:23 +0200 |
commit | c3b9d42c38f3c21fbcc01e3822127bf9d7d37d06 (patch) | |
tree | 3a408f431168dfea525c40d3e56cff0d1b088f00 /tests/auto/geotestplugin | |
parent | 6075e23f5137f2c54eab99a86f8dabd8b782fb22 (diff) | |
download | qtlocation-c3b9d42c38f3c21fbcc01e3822127bf9d7d37d06.tar.gz |
Expand unit tests for image model
Change-Id: I1039b63a2d0dfb487515697eec5b54565f1e4882
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'tests/auto/geotestplugin')
-rw-r--r-- | tests/auto/geotestplugin/place_data.json | 24 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qplacemanagerengine_test.h | 52 |
2 files changed, 71 insertions, 5 deletions
diff --git a/tests/auto/geotestplugin/place_data.json b/tests/auto/geotestplugin/place_data.json index 1da1d19b..82f97532 100644 --- a/tests/auto/geotestplugin/place_data.json +++ b/tests/auto/geotestplugin/place_data.json @@ -73,6 +73,30 @@ "rating": 2.3, "reviewId": "0005" } + ], + "images": [ + { + "url": "http://somewhere.com/image1.png", + "imageId": "0001", + "mimeType": "image/png" + }, + { + "url": "http://somewhere.com/image2.png", + "imageId": "0002", + "mimeType": "image/png" + }, + { + "url": "http://somewhere.com/image3.png", + "imageId": "0003", + "mimeType": "image/png" + }, + { + }, + { + "url": "http://somewhere.com/image5.png", + "imageId": "0005", + "mimeType": "image/png" + } ] }, { diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h index 5b36c432..a683bb80 100644 --- a/tests/auto/geotestplugin/qplacemanagerengine_test.h +++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h @@ -56,6 +56,7 @@ #include <QtLocation/QPlaceReply> #include <QtLocation/QPlaceDetailsReply> #include <QtLocation/QPlaceIdReply> +#include <QtLocation/QPlaceImage> #include <QtLocation/QPlaceSearchSuggestionReply> #include <QtLocation/QPlaceSearchReply> #include <QtLocation/QPlaceResult> @@ -300,6 +301,25 @@ public: reviews << review; } m_placeReviews.insert(place.placeId(), reviews); + + QJsonArray imgArray = p.value(QStringLiteral("images")).toArray(); + QList<QPlaceImage> images; + for (int j = 0; j < imgArray.count(); ++j) { + QJsonObject imgo = imgArray.at(j).toObject(); + QPlaceImage image; + if (imgo.contains(QStringLiteral("url"))) + image.setUrl(imgo.value(QStringLiteral("url")).toString()); + + if (imgo.contains("imageId")) + image.setImageId(imgo.value(QStringLiteral("imageId")).toString()); + + if (imgo.contains("mimeType")) + image.setMimeType(imgo.value(QStringLiteral("mimeType")).toString()); + + images << image; + } + + m_placeImages.insert(place.placeId(), images); } } } @@ -331,18 +351,39 @@ public: QMetaObject::invokeMethod(reply, "emitError", Qt::QueuedConnection); } else { - if (query.contentType() == QPlaceContent::ReviewType) { QPlaceContent::Collection collection; - int totalCount = m_placeReviews.value(placeId).count(); + int totalCount; + switch (query.contentType()) { + case QPlaceContent::ReviewType: + totalCount = m_placeReviews.value(placeId).count(); + break; + case QPlaceContent::ImageType: + totalCount = m_placeImages.value(placeId).count(); + break; + default: + //do nothing + break; + } + int offset = qMax(query.offset(), 0); int max = (query.limit() == -1) ? totalCount : qMin(offset + query.limit(), totalCount); - for (int i = offset; i < max; ++i) - collection.insert(i, m_placeReviews.value(placeId).at(i)); + for (int i = offset; i < max; ++i) { + switch (query.contentType()) { + case QPlaceContent::ReviewType: + collection.insert(i, m_placeReviews.value(placeId).at(i)); + break; + case QPlaceContent::ImageType: + collection.insert(i, m_placeImages.value(placeId).at(i)); + break; + default: + //do nothing + break; + } + } reply->setContent(collection); reply->setTotalCount(totalCount); - } } QMetaObject::invokeMethod(reply, "emitFinished", Qt::QueuedConnection); @@ -614,6 +655,7 @@ private: QHash<QString, QStringList> m_childCategories; QHash<QString, QStringList> m_placeRecommendations; QHash<QString, QList<QPlaceReview> > m_placeReviews; + QHash<QString, QList<QPlaceImage> > m_placeImages; }; #endif |