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 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
32#include <QtLocation/QPlaceEditorial>
33#include <QtLocation/QPlaceSupplier>
34#include <QtLocation/QPlaceUser>
35
36#include "../utils/qlocationtestutils_p.h"
37
38QT_USE_NAMESPACE
39
40class tst_QPlaceEditorial : public QObject
41{
42 Q_OBJECT
43
44public:
45 tst_QPlaceEditorial();
46
47 //needed for QLocationTestUtils::testConversion
48 QPlaceEditorial initialSubObject();
49 bool checkType(const QPlaceContent &);
50 void detach(QPlaceContent *);
51 void setSubClassProperty(QPlaceEditorial *);
52
53private Q_SLOTS:
54 void constructorTest();
55 void supplierTest();
56 void textTest();
57 void titleTest();
58 void languageTest();
59 void operatorsTest();
60 void conversionTest();
61};
62
63tst_QPlaceEditorial::tst_QPlaceEditorial()
64{
65}
66
67QPlaceEditorial tst_QPlaceEditorial::initialSubObject()
68{
69 QPlaceUser user;
70 user.setName("user 1");
71 user.setUserId("0001");
72
73 QPlaceSupplier supplier;
74 supplier.setName("supplier");
75 supplier.setSupplierId("1");
76
77 QPlaceEditorial editorial;
78 editorial.setTitle("title");
79 editorial.setText("text");
80 editorial.setLanguage("en");
81 editorial.setUser(user);
82 editorial.setSupplier(supplier);
83 editorial.setAttribution("attribution");
84
85 return editorial;
86}
87
88bool tst_QPlaceEditorial::checkType(const QPlaceContent &content)
89{
90 return content.type() == QPlaceContent::EditorialType;
91}
92
93void tst_QPlaceEditorial::detach(QPlaceContent *content)
94{
95 content->setAttribution("attribution");
96}
97
98void tst_QPlaceEditorial::setSubClassProperty(QPlaceEditorial * editorial)
99{
100 editorial->setTitle("new title");
101}
102void tst_QPlaceEditorial::constructorTest()
103{
104 QPlaceEditorial testObj;
105 testObj.setText("testId");
106 QPlaceEditorial *testObjPtr = new QPlaceEditorial(testObj);
107 QVERIFY2(testObjPtr != NULL, "Copy constructor - null");
108 QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare");
109 delete testObjPtr;
110}
111
112void tst_QPlaceEditorial::supplierTest()
113{
114 QPlaceEditorial testObj;
115 QVERIFY2(testObj.supplier().supplierId() == QString(), "Wrong default value");
116 QPlaceSupplier sup;
117 sup.setName("testName1");
118 sup.setSupplierId("testId");
119 testObj.setSupplier(sup);
120 QVERIFY2(testObj.supplier() == sup, "Wrong value returned");
121}
122
123void tst_QPlaceEditorial::textTest()
124{
125 QPlaceEditorial testObj;
126 QVERIFY2(testObj.text() == QString(), "Wrong default value");
127 testObj.setText("testText");
128 QVERIFY2(testObj.text() == "testText", "Wrong value returned");
129}
130
131void tst_QPlaceEditorial::titleTest()
132{
133 QPlaceEditorial testObj;
134 QVERIFY2(testObj.title() == QString(), "Wrong default value");
135 testObj.setTitle("testText");
136 QVERIFY2(testObj.title() == "testText", "Wrong value returned");
137}
138
139void tst_QPlaceEditorial::languageTest()
140{
141 QPlaceEditorial testObj;
142 QVERIFY2(testObj.language() == QString(), "Wrong default value");
143 testObj.setLanguage("testText");
144 QVERIFY2(testObj.language() == "testText", "Wrong value returned");
145}
146
147void tst_QPlaceEditorial::operatorsTest()
148{
149 QPlaceEditorial testObj;
150 testObj.setLanguage("testValue");
151 QPlaceEditorial testObj2;
152 testObj2 = testObj;
153 QVERIFY2(testObj == testObj2, "Not copied correctly");
154 testObj2.setText("testValue2");
155 QVERIFY2(testObj != testObj2, "Object should be different");
156}
157
158void tst_QPlaceEditorial::conversionTest()
159{
160 QLocationTestUtils::testConversion<tst_QPlaceEditorial,
161 QPlaceContent,
162 QPlaceEditorial>(tc: this);
163}
164QTEST_APPLESS_MAIN(tst_QPlaceEditorial);
165
166#include "tst_qplaceeditorial.moc"
167

source code of qtlocation/tests/auto/qplaceeditorial/tst_qplaceeditorial.cpp