Changeset View
Changeset View
Standalone View
Standalone View
autotests/testattendee.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 120 | { | |||
---|---|---|---|---|---|
126 | QVERIFY(!(attendee1 == attendee2)); | 126 | QVERIFY(!(attendee1 == attendee2)); | ||
127 | 127 | | |||
128 | Attendee attendee3(attendee1); | 128 | Attendee attendee3(attendee1); | ||
129 | QVERIFY(attendee3 == attendee1); | 129 | QVERIFY(attendee3 == attendee1); | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | void AttendeeTest::testDataStreamOut() | 132 | void AttendeeTest::testDataStreamOut() | ||
133 | { | 133 | { | ||
134 | Attendee::Ptr attendee1(new Attendee(QStringLiteral("fred"), QStringLiteral("fred@flintstone.com"))); | 134 | Attendee attendee1(QStringLiteral("fred"), QStringLiteral("fred@flintstone.com")); | ||
135 | attendee1->setRSVP(true); | 135 | attendee1.setRSVP(true); | ||
136 | attendee1->setRole(Attendee::Chair); | 136 | attendee1.setRole(Attendee::Chair); | ||
137 | attendee1->setUid(QStringLiteral("Shooby Doo Bop")); | 137 | attendee1.setUid(QStringLiteral("Shooby Doo Bop")); | ||
138 | attendee1->setDelegate(QStringLiteral("I AM THE Delegate")); | 138 | attendee1.setDelegate(QStringLiteral("I AM THE Delegate")); | ||
139 | attendee1->setDelegator(QStringLiteral("AND I AM THE Delegator")); | 139 | attendee1.setDelegator(QStringLiteral("AND I AM THE Delegator")); | ||
140 | attendee1->setCuType(QStringLiteral("X-SPECIAL")); | 140 | attendee1.setCuType(QStringLiteral("X-SPECIAL")); | ||
141 | attendee1->setCustomProperty("name", QStringLiteral("value")); | 141 | attendee1.setCustomProperty("name", QStringLiteral("value")); | ||
142 | attendee1->setCustomProperty("foo", QStringLiteral("bar")); | 142 | attendee1.setCustomProperty("foo", QStringLiteral("bar")); | ||
143 | 143 | | |||
144 | QByteArray byteArray; | 144 | QByteArray byteArray; | ||
145 | QDataStream out_stream(&byteArray, QIODevice::WriteOnly); | 145 | QDataStream out_stream(&byteArray, QIODevice::WriteOnly); | ||
146 | 146 | | |||
147 | out_stream << attendee1; | 147 | out_stream << attendee1; | ||
148 | 148 | | |||
149 | QDataStream in_stream(&byteArray, QIODevice::ReadOnly); | 149 | QDataStream in_stream(&byteArray, QIODevice::ReadOnly); | ||
150 | 150 | | |||
151 | Person person; | 151 | Person person; | ||
152 | bool rsvp; | 152 | bool rsvp; | ||
153 | QString delegate, delegator, cuType, uid; | 153 | QString delegate, delegator, cuType, uid; | ||
154 | CustomProperties customProperties; | 154 | CustomProperties customProperties; | ||
155 | Attendee::Role role; | 155 | Attendee::Role role; | ||
156 | Attendee::PartStat status; | 156 | Attendee::PartStat status; | ||
157 | uint role_int, status_int; | 157 | uint role_int, status_int; | ||
158 | 158 | | |||
159 | in_stream >> person; | 159 | in_stream >> person; | ||
160 | QVERIFY(person.name() == attendee1->name()); | 160 | QVERIFY(person.name() == attendee1.name()); | ||
161 | QVERIFY(person.email() == attendee1->email()); | 161 | QVERIFY(person.email() == attendee1.email()); | ||
162 | 162 | | |||
163 | in_stream >> rsvp; | 163 | in_stream >> rsvp; | ||
164 | QVERIFY(rsvp == attendee1->RSVP()); | 164 | QVERIFY(rsvp == attendee1.RSVP()); | ||
165 | 165 | | |||
166 | in_stream >> role_int; | 166 | in_stream >> role_int; | ||
167 | role = Attendee::Role(role_int); | 167 | role = Attendee::Role(role_int); | ||
168 | QVERIFY(role == attendee1->role()); | 168 | QVERIFY(role == attendee1.role()); | ||
169 | 169 | | |||
170 | in_stream >> status_int; | 170 | in_stream >> status_int; | ||
171 | status = Attendee::PartStat(status_int); | 171 | status = Attendee::PartStat(status_int); | ||
172 | QVERIFY(status == attendee1->status()); | 172 | QVERIFY(status == attendee1.status()); | ||
173 | 173 | | |||
174 | in_stream >> uid; | 174 | in_stream >> uid; | ||
175 | QVERIFY(uid == attendee1->uid()); | 175 | QVERIFY(uid == attendee1.uid()); | ||
176 | 176 | | |||
177 | in_stream >> delegate; | 177 | in_stream >> delegate; | ||
178 | QVERIFY(delegate == attendee1->delegate()); | 178 | QVERIFY(delegate == attendee1.delegate()); | ||
179 | 179 | | |||
180 | in_stream >> delegator; | 180 | in_stream >> delegator; | ||
181 | QVERIFY(delegator == attendee1->delegator()); | 181 | QVERIFY(delegator == attendee1.delegator()); | ||
182 | 182 | | |||
183 | in_stream >> cuType; | 183 | in_stream >> cuType; | ||
184 | QVERIFY(cuType == attendee1->cuTypeStr()); | 184 | QVERIFY(cuType == attendee1.cuTypeStr()); | ||
185 | 185 | | |||
186 | in_stream >> customProperties; | 186 | in_stream >> customProperties; | ||
187 | QVERIFY(customProperties == attendee1->customProperties()); | 187 | QVERIFY(customProperties == attendee1.customProperties()); | ||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | void AttendeeTest::testDataStreamIn() | 190 | void AttendeeTest::testDataStreamIn() | ||
191 | { | 191 | { | ||
192 | Attendee::Ptr attendee1(new Attendee(QStringLiteral("fred"), QStringLiteral("fred@flintstone.com"))); | 192 | Attendee attendee1(QStringLiteral("fred"), QStringLiteral("fred@flintstone.com")); | ||
193 | attendee1->setRSVP(true); | 193 | attendee1.setRSVP(true); | ||
194 | attendee1->setRole(Attendee::Chair); | 194 | attendee1.setRole(Attendee::Chair); | ||
195 | attendee1->setCuType(QStringLiteral("IANA-FOO")); | 195 | attendee1.setCuType(QStringLiteral("IANA-FOO")); | ||
196 | attendee1->setUid(QStringLiteral("Shooby Doo Bop")); | 196 | attendee1.setUid(QStringLiteral("Shooby Doo Bop")); | ||
197 | attendee1->setDelegate(QStringLiteral("I AM THE Delegate")); | 197 | attendee1.setDelegate(QStringLiteral("I AM THE Delegate")); | ||
198 | attendee1->setDelegator(QStringLiteral("AND I AM THE Delegator")); | 198 | attendee1.setDelegator(QStringLiteral("AND I AM THE Delegator")); | ||
199 | attendee1->setCustomProperty("name", QStringLiteral("value")); | 199 | attendee1.setCustomProperty("name", QStringLiteral("value")); | ||
200 | attendee1->setCustomProperty("foo", QStringLiteral("bar")); | 200 | attendee1.setCustomProperty("foo", QStringLiteral("bar")); | ||
201 | QVERIFY(!attendee1.isNull()); | ||||
201 | 202 | | |||
202 | QByteArray byteArray; | 203 | QByteArray byteArray; | ||
203 | QDataStream out_stream(&byteArray, QIODevice::WriteOnly); | 204 | QDataStream out_stream(&byteArray, QIODevice::WriteOnly); | ||
204 | 205 | | |||
205 | out_stream << attendee1; | 206 | out_stream << attendee1; | ||
206 | 207 | | |||
207 | Attendee::Ptr attendee2; | 208 | Attendee attendee2; | ||
208 | QDataStream in_stream(&byteArray, QIODevice::ReadOnly); | 209 | QDataStream in_stream(&byteArray, QIODevice::ReadOnly); | ||
209 | 210 | | |||
210 | in_stream >> attendee2; | 211 | in_stream >> attendee2; | ||
211 | 212 | | |||
212 | QVERIFY(attendee2); | 213 | QVERIFY(!attendee2.isNull()); | ||
213 | QVERIFY(attendee2->uid() == attendee1->uid()); | 214 | QVERIFY(attendee2.uid() == attendee1.uid()); | ||
214 | QVERIFY(attendee2->RSVP() == attendee1->RSVP()); | 215 | QVERIFY(attendee2.RSVP() == attendee1.RSVP()); | ||
215 | QVERIFY(attendee2->role() == attendee1->role()); | 216 | QVERIFY(attendee2.role() == attendee1.role()); | ||
216 | QVERIFY(attendee2->cuTypeStr() == attendee1->cuTypeStr()); | 217 | QVERIFY(attendee2.cuTypeStr() == attendee1.cuTypeStr()); | ||
217 | QVERIFY(attendee2->status() == attendee1->status()); | 218 | QVERIFY(attendee2.status() == attendee1.status()); | ||
218 | QVERIFY(attendee2->delegate() == attendee1->delegate()); | 219 | QVERIFY(attendee2.delegate() == attendee1.delegate()); | ||
219 | QVERIFY(attendee2->delegator() == attendee1->delegator()); | 220 | QVERIFY(attendee2.delegator() == attendee1.delegator()); | ||
220 | QVERIFY(attendee2->customProperties() == attendee1->customProperties()); | 221 | QVERIFY(attendee2.customProperties() == attendee1.customProperties()); | ||
221 | QVERIFY(*attendee1 == *attendee2); | 222 | QVERIFY(attendee1 == attendee2); | ||
222 | } | 223 | } | ||
223 | 224 | | |||
224 | void AttendeeTest::testUid() | 225 | void AttendeeTest::testUid() | ||
225 | { | 226 | { | ||
226 | Attendee::Ptr a(new Attendee(QStringLiteral("me"), QStringLiteral("test@dev.null"))); | 227 | Attendee a(QStringLiteral("me"), QStringLiteral("test@dev.null")); | ||
227 | QVERIFY(!a->uid().isEmpty()); | 228 | QVERIFY(!a.uid().isEmpty()); | ||
228 | a->setUid(QStringLiteral("42")); | 229 | a.setUid(QStringLiteral("42")); | ||
229 | QCOMPARE(a->uid(), QLatin1String("42")); | 230 | QCOMPARE(a.uid(), QLatin1String("42")); | ||
230 | a->setUid({}); | 231 | a.setUid({}); | ||
231 | QVERIFY(!a->uid().isEmpty()); | 232 | QVERIFY(!a.uid().isEmpty()); | ||
232 | } | 233 | } |