1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #include <QtCore/QString>
30 #include <QtTest/QtTest>
31 #include <QtLocation/QPlaceSearchResult>
32 #include <QtLocation/QPlaceIcon>
33 
34 QT_USE_NAMESPACE
35 
36 class tst_QPlaceSearchResult : public QObject
37 {
38     Q_OBJECT
39 
40 private Q_SLOTS:
41     void constructorTest();
42     void title();
43     void icon();
44     void operators();
45 };
46 
constructorTest()47 void tst_QPlaceSearchResult::constructorTest()
48 {
49     QPlaceSearchResult result;
50 
51     QCOMPARE(result.type(), QPlaceSearchResult::UnknownSearchResult);
52     QVERIFY(result.title().isEmpty());
53     QVERIFY(result.icon().isEmpty());
54 
55     result.setTitle(QStringLiteral("title"));
56     QPlaceIcon icon;
57     QVariantMap parameters;
58     parameters.insert(QStringLiteral("paramKey"), QStringLiteral("paramValue"));
59     icon.setParameters(parameters);
60     result.setIcon(icon);
61 
62     QPlaceSearchResult result2(result);
63     QCOMPARE(result2.title(), QStringLiteral("title"));
64     QCOMPARE(result2.icon().parameters().value(QStringLiteral("paramKey")).toString(),
65              QStringLiteral("paramValue"));
66 
67     QCOMPARE(result2, result);
68 }
69 
title()70 void tst_QPlaceSearchResult::title()
71 {
72     QPlaceSearchResult result;
73     QVERIFY(result.title().isEmpty());
74     result.setTitle(QStringLiteral("title"));
75     QCOMPARE(result.title(), QStringLiteral("title"));
76     result.setTitle(QString());
77     QVERIFY(result.title().isEmpty());
78 }
79 
icon()80 void tst_QPlaceSearchResult::icon()
81 {
82     QPlaceSearchResult result;
83     QVERIFY(result.icon().isEmpty());
84     QPlaceIcon icon;
85     QVariantMap iconParams;
86     iconParams.insert(QStringLiteral("paramKey"), QStringLiteral("paramValue"));
87     result.setIcon(icon);
88     QCOMPARE(result.icon(), icon);
89     result.setIcon(QPlaceIcon());
90     QVERIFY(result.icon().isEmpty());
91 }
92 
operators()93 void tst_QPlaceSearchResult::operators()
94 {
95     QPlaceSearchResult result1;
96     QPlaceSearchResult result2;
97 
98     QVERIFY(result1 == result2);
99     QVERIFY(!(result1 != result2));
100 
101     result1.setTitle(QStringLiteral("title"));
102     QVERIFY(!(result1 == result2));
103     QVERIFY(result1 != result2);
104 
105     result2.setTitle(QStringLiteral("title"));
106     QVERIFY(result1 == result2);
107     QVERIFY(!(result1 != result2));
108 }
109 
110 QTEST_APPLESS_MAIN(tst_QPlaceSearchResult)
111 
112 #include "tst_qplacesearchresult.moc"
113