summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-10-05 14:26:06 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-11 06:16:59 +0200
commit3dcb12116420cd29580b28c8e976c17ea605d185 (patch)
treedc803abea29a593f402ec81975e32dc8d31855ed /tests
parentc3b41f8823e9f500bf2fde0213c6302c5ff0d12f (diff)
downloadqtlocation-3dcb12116420cd29580b28c8e976c17ea605d185.tar.gz
Add Icon support to Places
Change-Id: I559c96427db542dd71122f937dff90c900a02241 Reviewed-on: http://codereview.qt-project.org/6041 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com> Reviewed-by: abcd <qt_abcd1@ovi.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/geotestplugin/qplacemanagerengine_test.h8
-rw-r--r--tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp53
-rw-r--r--tests/auto/qplacesupplier/tst_qplacesupplier.cpp28
3 files changed, 80 insertions, 9 deletions
diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h
index 9a0e07ee..deb89a3c 100644
--- a/tests/auto/geotestplugin/qplacemanagerengine_test.h
+++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h
@@ -258,6 +258,14 @@ public:
m_locale = locale;
}
+ QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags) {
+ Q_UNUSED(icon)
+ Q_UNUSED(size)
+ Q_UNUSED(flags)
+
+ return QUrl();
+ }
+
private:
QLocale m_locale;
QMap<QString, QPlace> m_places;
diff --git a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
index c86ec7cf..994fa32c 100644
--- a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
+++ b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
@@ -110,6 +110,7 @@ private Q_SLOTS:
void searchByCircle();
void searchWithLexicalPlaceNameHint();
void searchWithDistanceHint();
+ void icons();
void unsupportedFunctions();
private:
@@ -963,6 +964,58 @@ void tst_QPlaceManagerJsonDb::searchWithDistanceHint()
}
+void tst_QPlaceManagerJsonDb::icons()
+{
+ QPlaceIcon icon;
+ icon.setManager(placeManager);
+ icon.setFullUrl(QUrl(QLatin1String("/icons/placeicon.jpg")));
+
+ //check that we can get the url from the icon
+ QCOMPARE(icon.url(), QUrl(QLatin1String("/icons/placeicon.jpg")));
+
+ //check that we can save and retrieve a place with the icon
+ //intact.
+ QPlace place;
+ place.setIcon(icon);
+ QString placeId;
+ QVERIFY(doSavePlace(place,QPlaceReply::NoError, &placeId));
+
+ QPlace retrievedPlace;
+ QVERIFY(doFetchDetails(placeId, &retrievedPlace));
+ QCOMPARE(retrievedPlace.icon().url(), QUrl(QLatin1String("/icons/placeicon.jpg")));
+
+ QPlaceIcon categoryIcon;
+ categoryIcon.setManager(placeManager);
+ categoryIcon.setFullUrl(QUrl(QLatin1String("/icons/motel.jpg")));
+
+ QPlaceCategory motel;
+ motel.setIcon(categoryIcon);
+ QString categoryId;
+ QVERIFY(doSaveCategory(motel, "", QPlaceReply::NoError, &categoryId));
+ motel.setCategoryId(categoryId);
+
+ QList<QPlaceCategory> categories = placeManager->childCategories();
+ QCOMPARE(categories.count(), 1);
+ QCOMPARE(categories.at(0).icon().url(), QUrl(QLatin1String("/icons/motel.jpg")));
+
+ //test modification of an icon of an existin category
+ categoryIcon.setFullUrl(QUrl(QLatin1String("/icons/motel2.jpg")));
+ motel.setIcon(categoryIcon);
+ QVERIFY(doSaveCategory(motel, "", QPlaceReply::NoError, &categoryId));
+
+ categories = placeManager->childCategories();
+ QCOMPARE(categories.count(), 1);
+ QCOMPARE(categories.at(0).icon().url(), QUrl(QLatin1String("/icons/motel2.jpg")));
+
+ //try saving an empty icon to the category
+ motel.setIcon(QPlaceIcon());
+ QVERIFY(doSaveCategory(motel, "", QPlaceReply::NoError, &categoryId));
+ categories = placeManager->childCategories();
+ QCOMPARE(categories.count(), 1);
+ QCOMPARE(categories.at(0).icon().url(), QUrl());
+ QVERIFY(categories.at(0).icon().isEmpty());
+}
+
void tst_QPlaceManagerJsonDb::unsupportedFunctions()
{
QPlace place;
diff --git a/tests/auto/qplacesupplier/tst_qplacesupplier.cpp b/tests/auto/qplacesupplier/tst_qplacesupplier.cpp
index 296cf6e6..cf759264 100644
--- a/tests/auto/qplacesupplier/tst_qplacesupplier.cpp
+++ b/tests/auto/qplacesupplier/tst_qplacesupplier.cpp
@@ -58,7 +58,7 @@ private Q_SLOTS:
void nameTest();
void supplierIdTest();
void urlTest();
- void supplierIconUrlTest();
+ void iconTest();
void operatorsTest();
};
@@ -102,24 +102,34 @@ void tst_QPlaceSupplier::urlTest()
QVERIFY2(testObj.url() == testUrl, "Wrong value returned");
}
-void tst_QPlaceSupplier::supplierIconUrlTest()
+void tst_QPlaceSupplier::iconTest()
{
QPlaceSupplier testObj;
- const QUrl testUrl = QUrl::fromEncoded("http://example.com/testUrl");
- QVERIFY2(testObj.supplierIconUrl() == QString(), "Wrong default value");
- testObj.setSupplierIconUrl(testUrl);
- QVERIFY2(testObj.supplierIconUrl() == testUrl, "Wrong value returned");
+ QVERIFY(testObj.icon().isEmpty());
+ QPlaceIcon icon;
+ icon.setFullUrl(QUrl::fromEncoded("http://example.com/icon.png"));
+ testObj.setIcon(icon);
+ QCOMPARE(testObj.icon(), icon);
+ QCOMPARE(testObj.icon().fullUrl(), QUrl::fromEncoded("http://example.com/icon.png"));
+
+ testObj.setIcon(QPlaceIcon());
+ QVERIFY(testObj.icon().isEmpty());
+ QCOMPARE(testObj.icon().fullUrl(), QUrl());
}
void tst_QPlaceSupplier::operatorsTest()
{
QPlaceSupplier testObj;
- const QUrl testUrl = QUrl::fromEncoded("http://example.com/testUrl");
- testObj.setSupplierIconUrl(testUrl);
+ testObj.setName(QLatin1String("Acme"));
+ QPlaceIcon icon;
+ icon.setFullUrl(QUrl::fromEncoded("http://example.com/testUrl"));
+ testObj.setIcon(icon);
+ testObj.setSupplierId(QLatin1String("34292"));
+
QPlaceSupplier testObj2;
testObj2 = testObj;
QVERIFY2(testObj == testObj2, "Not copied correctly");
- testObj2.setSupplierId("testValue2");
+ testObj2.setSupplierId(QLatin1String("testValue2"));
QVERIFY2(testObj != testObj2, "Object should be different");
}