void tst_QPlaceCategory::isEmptyTest()
{
    QPlaceIcon icon;
    QVariantMap parameters;
    parameters.insert(QLatin1String("para"), QLatin1String("meter"));
    icon.setParameters(parameters);
    QVERIFY(!icon.isEmpty());

    QPlaceCategory category;

    QVERIFY(category.isEmpty());

    category.setName(QStringLiteral("name"));
    QVERIFY(!category.isEmpty());
    category.setName(QString());
    QVERIFY(category.isEmpty());

    category.setCategoryId(QStringLiteral("id"));
    QVERIFY(!category.isEmpty());
    category.setCategoryId(QString());
    QVERIFY(category.isEmpty());

    category.setVisibility(QLocation::PublicVisibility);
    QVERIFY(!category.isEmpty());
    category.setVisibility(QLocation::UnspecifiedVisibility);
    QVERIFY(category.isEmpty());

    category.setIcon(icon);
    QVERIFY(!category.isEmpty());
    category.setIcon(QPlaceIcon());
    QVERIFY(category.isEmpty());
}
QDeclarativePlaceIcon::QDeclarativePlaceIcon(const QPlaceIcon &icon, QDeclarativeGeoServiceProvider *plugin, QObject *parent)
:   QObject(parent), m_parameters(new QQmlPropertyMap(this))
{
    if (icon.isEmpty())
        m_plugin = 0;
    else
        m_plugin = plugin;

    initParameters(icon.parameters());
}
void tst_QPlaceProposedSearchResult::constructorTest()
{
    QPlaceProposedSearchResult result;
    QCOMPARE(result.type(), QPlaceSearchResult::ProposedSearchResult);

    result.setTitle(QStringLiteral("title"));

    QPlaceIcon icon;
    QVariantMap parameters;
    parameters.insert(QStringLiteral("paramKey"), QStringLiteral("paramValue"));
    icon.setParameters(parameters);
    result.setIcon(icon);

    QPlaceSearchRequest searchRequest;
    searchRequest.setSearchContext(QUrl(QStringLiteral("http://www.example.com/place-search")));
    result.setSearchRequest(searchRequest);

    //check copy constructor
    QPlaceProposedSearchResult result2(result);
    QCOMPARE(result2.title(), QStringLiteral("title"));
    QCOMPARE(result2.icon(), icon);
    QCOMPARE(result2.searchRequest(), searchRequest);

    QVERIFY(QLocationTestUtils::compareEquality(result, result2));

    //check results are the same after detachment of underlying shared data pointer
    result2.setTitle(QStringLiteral("title"));
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));

    //check construction of SearchResult using a ProposedSearchResult
    QPlaceSearchResult searchResult(result);
    QCOMPARE(searchResult.title(), QStringLiteral("title"));
    QCOMPARE(searchResult.icon(), icon);
    QVERIFY(QLocationTestUtils::compareEquality(searchResult, result));
    QVERIFY(searchResult.type() == QPlaceSearchResult::ProposedSearchResult);
    result2 = searchResult;
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));

    //check construction of a SearchResult using a SearchResult
    //that is actually a PlaceResult underneath
    QPlaceSearchResult searchResult2(searchResult);
    QCOMPARE(searchResult2.title(), QStringLiteral("title"));
    QCOMPARE(searchResult2.icon(), icon);
    QVERIFY(QLocationTestUtils::compareEquality(searchResult2, result));
    QVERIFY(QLocationTestUtils::compareEquality(searchResult, searchResult2));
    QVERIFY(searchResult2.type() == QPlaceSearchResult::ProposedSearchResult);
    result2 = searchResult2;
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));
}
QPlaceProposedSearchResult tst_QPlaceProposedSearchResult::initialSubObject()
{
    QPlaceProposedSearchResult proposedSearchResult;
    proposedSearchResult.setTitle(QStringLiteral("title"));

    QPlaceIcon icon;
    QVariantMap parameters;
    parameters.insert(QPlaceIcon::SingleUrl,
                      QUrl(QStringLiteral("file:///opt/icons/icon.png")));
    icon.setParameters(parameters);
    proposedSearchResult.setIcon(icon);

    QPlaceSearchRequest searchRequest;
    searchRequest.setSearchContext(QUrl(QStringLiteral("http://www.example.com/")));
    proposedSearchResult.setSearchRequest(searchRequest);

    return proposedSearchResult;
}
/*!
    \qmlproperty QPlaceIcon Icon::icon

    For details on how to use this property to interface between C++ and QML see
    "\l {location-cpp-qml.html#placeicon} {Interfaces between C++ and QML Code}".
*/
QPlaceIcon QDeclarativePlaceIcon::icon() const
{
    QPlaceIcon result;

    if (m_plugin)
        result.setManager(manager());
    else
        result.setManager(0);

    QVariantMap params;
    foreach (const QString &key, m_parameters->keys()) {
        const QVariant value = m_parameters->value(key);
        if (value.isValid()) {
            params.insert(key, value);
        }
    }

    result.setParameters(params);

    return result;
}
void tst_QPlaceSearchResult::constructorTest()
{
    QPlaceSearchResult result;

    QCOMPARE(result.type(), QPlaceSearchResult::UnknownSearchResult);
    QVERIFY(result.title().isEmpty());
    QVERIFY(result.icon().isEmpty());

    result.setTitle(QLatin1String("title"));
    QPlaceIcon icon;
    QVariantMap parameters;
    parameters.insert(QLatin1String("paramKey"), QLatin1String("paramValue"));
    icon.setParameters(parameters);
    result.setIcon(icon);

    QPlaceSearchResult result2(result);
    QCOMPARE(result2.title(), QLatin1String("title"));
    QCOMPARE(result2.icon().parameters().value(QLatin1String("paramKey")).toString(),
             QLatin1String("paramValue"));

    QCOMPARE(result2, result);
}
void tst_QPlaceProposedSearchResult::icon()
{
    QPlaceProposedSearchResult result;
    QVERIFY(result.icon().isEmpty());

    QPlaceIcon icon;
    QVariantMap iconParams;
    iconParams.insert(QStringLiteral("paramKey"), QStringLiteral("paramValue"));
    icon.setParameters(iconParams);
    result.setIcon(icon);
    QCOMPARE(result.icon(), icon);

    result.setIcon(QPlaceIcon());
    QVERIFY(result.icon().isEmpty());

    QPlaceProposedSearchResult result2;
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));

    result2.setIcon(icon);
    QVERIFY(QLocationTestUtils::compareInequality(result, result2));

    result.setIcon(icon);
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));
}
void QDeclarativePlaceIcon::setIcon(const QPlaceIcon &src)
{
    initParameters(src.parameters());
}