void testUnionFilter() { QLandmarkCategoryId catId; catId.setLocalId("1"); catId.setManagerUri("qtlandmarks:mock:"); QLandmarkCategoryId catId2; catId2.setLocalId("2"); catId2.setManagerUri("qtlandmarks:mock:"); //test a match with the union filter QLandmarkUnionFilter unionFilter; QLandmarkNameFilter nameFilter("beach"); QLandmarkProximityFilter proximityFilter(QGeoCoordinate(30,30)); proximityFilter.setRadius(QGeoCoordinate(30,30).distanceTo(QGeoCoordinate(30,32))); QLandmarkCategoryFilter categoryFilter; categoryFilter.setCategoryId(catId); QLandmark lm; lm.setName("statue"); lm.setCoordinate(QGeoCoordinate(-30,-29)); lm.addCategoryId(catId); unionFilter << nameFilter << categoryFilter << proximityFilter; QVERIFY(MockEngine::testFilter(unionFilter,lm)); //test no match with union filter lm.removeCategoryId(catId); lm.addCategoryId(catId2); QVERIFY(!MockEngine::testFilter(unionFilter,lm)); //test empty union filter unionFilter.clear(); QVERIFY(!MockEngine::testFilter(unionFilter,lm)); }
void testFilterCategory() { //test category matches QLandmarkCategoryFilter categoryFilter; QLandmarkCategoryId catFilterId; catFilterId.setLocalId("1"); catFilterId.setManagerUri("qtlandmarks:mock:"); categoryFilter.setCategoryId(catFilterId); QLandmark lm; QLandmarkCategoryId lmCatId; lmCatId.setLocalId("1"); lmCatId.setManagerUri("qtlandmarks:mock:"); lm.addCategoryId(lmCatId); QVERIFY(MockEngine::testFilter(categoryFilter,lm)); //test category id doesn't match lm.removeCategoryId(lmCatId); QVERIFY(lm.categoryIds().count() == 0); lmCatId.setLocalId("2"); lm.addCategoryId(lmCatId); QVERIFY(!MockEngine::testFilter(categoryFilter,lm)); //test category uri that doesn't match QList<QLandmarkCategoryId> catIdList; lm.setCategoryIds(catIdList); QVERIFY(lm.categoryIds().count() == 0); lmCatId.setLocalId("1"); lmCatId.setManagerUri("qtlandmarks:fake:"); catIdList.append(lmCatId); lm.setCategoryIds(catIdList); QVERIFY(lm.categoryIds().count() == 1); QVERIFY(!MockEngine::testFilter(categoryFilter,lm)); //try match a category when the //landmark has multiple categories QLandmarkCategoryId lmCatId2; QLandmarkCategoryId lmCatId3; lmCatId.setLocalId("1"); lmCatId.setManagerUri("qtlandmarks:mock:"); lmCatId2.setLocalId("2"); lmCatId2.setManagerUri("qtlandmarks:mock:"); lmCatId3.setLocalId("3"); lmCatId3.setManagerUri("qtlandmarks:mock:"); catIdList.clear(); catIdList << lmCatId << lmCatId2 << lmCatId3; lm.setCategoryIds(catIdList); catFilterId.setLocalId("2"); catFilterId.setManagerUri("qtlandmarks:mock:"); categoryFilter.setCategoryId(catFilterId); QVERIFY(MockEngine::testFilter(categoryFilter, lm)); //category id doesn't match when the landmark //has multipl catgories catFilterId.setLocalId("4"); categoryFilter.setCategoryId(catFilterId); }