| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | 
| 4 | ** Contact: http://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the test suite of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | 
| 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 http://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU Lesser General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | 
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | 
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | 
| 22 | ** following information to ensure the GNU Lesser General Public License | 
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | 
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
| 25 | ** | 
| 26 | ** As a special exception, The Qt Company gives you certain additional | 
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | 
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
| 29 | ** | 
| 30 | ** $QT_END_LICENSE$ | 
| 31 | ** | 
| 32 | ****************************************************************************/ | 
| 33 | #include <QtTest/QtTest> | 
| 34 | #include <QMetaType> | 
| 35 |  | 
| 36 | #include <QtContacts/qcontacts.h> | 
| 37 |  | 
| 38 | //TESTED_COMPONENT=src/contacts | 
| 39 |  | 
| 40 | QTCONTACTS_USE_NAMESPACE | 
| 41 |  | 
| 42 | Q_DECLARE_METATYPE(QContact) | 
| 43 | Q_DECLARE_METATYPE(QContactFilter) | 
| 44 |  | 
| 45 | static inline QContactId makeId(const QString &managerName, uint id) | 
| 46 | { | 
| 47 |     return QContactId(QStringLiteral("qtcontacts:basic%1:" ).arg(a: managerName), QByteArray(reinterpret_cast<const char *>(&id), sizeof(uint))); | 
| 48 | } | 
| 49 |  | 
| 50 | static inline QContactCollectionId makeCollectionId(uint id) | 
| 51 | { | 
| 52 |     return QContactCollectionId(QStringLiteral("qtcontacts:basic:" ), QByteArray(reinterpret_cast<const char *>(&id), sizeof(uint))); | 
| 53 | } | 
| 54 |  | 
| 55 | class tst_QContactFilter : public QObject | 
| 56 | { | 
| 57 | Q_OBJECT | 
| 58 |  | 
| 59 | public: | 
| 60 |     tst_QContactFilter(); | 
| 61 |     virtual ~tst_QContactFilter(); | 
| 62 |  | 
| 63 | public slots: | 
| 64 |     void init(); | 
| 65 |     void cleanup(); | 
| 66 | private slots: | 
| 67 |     void classHierarchy(); | 
| 68 |     void intersectionFilter(); | 
| 69 |     void unionFilter(); | 
| 70 |     void detailFilter(); | 
| 71 |     void detailRangeFilter(); | 
| 72 |     void changeLogFilter(); | 
| 73 |     void actionFilter(); | 
| 74 |     void relationshipFilter(); | 
| 75 |     void boringFilters(); | 
| 76 |     void idListFilter(); | 
| 77 |     void canonicalizedFilter(); | 
| 78 |     void canonicalizedFilter_data(); | 
| 79 |     void testFilter(); | 
| 80 |     void testFilter_data(); | 
| 81 |     void collectionFilter(); | 
| 82 |  | 
| 83 |     void datastream(); | 
| 84 |     void datastream_data(); | 
| 85 |     void testDebugStreamOut(); | 
| 86 |     void testDebugStreamOut_data(); | 
| 87 |     void traits(); | 
| 88 | }; | 
| 89 |  | 
| 90 | tst_QContactFilter::tst_QContactFilter() | 
| 91 | { | 
| 92 | } | 
| 93 |  | 
| 94 | tst_QContactFilter::~tst_QContactFilter() | 
| 95 | { | 
| 96 | } | 
| 97 |  | 
| 98 | void tst_QContactFilter::init() | 
| 99 | { | 
| 100 | } | 
| 101 |  | 
| 102 | void tst_QContactFilter::cleanup() | 
| 103 | { | 
| 104 | } | 
| 105 |  | 
| 106 | void tst_QContactFilter::classHierarchy() | 
| 107 | { | 
| 108 |     /* Test "casting" up and down the hierarchy */ | 
| 109 |     QContactDetailRangeFilter drf; | 
| 110 |     QVERIFY(drf.type() == QContactFilter::ContactDetailRangeFilter); | 
| 111 |     drf.setDetailType(type: QContactDetail::TypeExtendedDetail, field: QContactExtendedDetail::FieldName); | 
| 112 |     drf.setRange(min: 1, max: 20); | 
| 113 |  | 
| 114 |     QContactFilter f = drf; | 
| 115 |     QVERIFY(f.type() == QContactFilter::ContactDetailRangeFilter); | 
| 116 |  | 
| 117 |     QContactDetailRangeFilter drf2 = f; | 
| 118 |     QVERIFY(drf2.type() == QContactFilter::ContactDetailRangeFilter); | 
| 119 |     QVERIFY(drf2.detailType() == QContactDetail::TypeExtendedDetail); | 
| 120 |     QVERIFY(drf2.detailField() == QContactExtendedDetail::FieldName); | 
| 121 |     QVERIFY(drf2.maxValue() == 20); | 
| 122 |     QVERIFY(drf2.minValue() == 1); | 
| 123 |  | 
| 124 |     /* Now try to check if we dangle pointers at all */ | 
| 125 |     { | 
| 126 |         QContactFilter f2 = drf2; | 
| 127 |     } | 
| 128 |     QVERIFY(drf2.type() == QContactFilter::ContactDetailRangeFilter); | 
| 129 |     QVERIFY(drf2.detailType() == QContactDetail::TypeExtendedDetail); | 
| 130 |     QVERIFY(drf2.detailField() == QContactExtendedDetail::FieldName); | 
| 131 |     QVERIFY(drf2.maxValue() == 20); | 
| 132 |     QVERIFY(drf2.minValue() == 1); | 
| 133 |  | 
| 134 |     { | 
| 135 |         QContactDetailRangeFilter rf2 = drf2; | 
| 136 |         rf2.setDetailType(type: QContactDetail::TypeAddress, field: QContactAddress::FieldStreet); | 
| 137 |         QVERIFY(rf2.detailType() == QContactDetail::TypeAddress); | 
| 138 |         QVERIFY(drf2.detailType() == QContactDetail::TypeExtendedDetail); | 
| 139 |     } | 
| 140 |     QVERIFY(drf2.type() == QContactFilter::ContactDetailRangeFilter); | 
| 141 |     QVERIFY(drf2.detailType() == QContactDetail::TypeExtendedDetail); | 
| 142 |     QVERIFY(drf2.detailField() == QContactExtendedDetail::FieldName); | 
| 143 |     QVERIFY(drf2.maxValue() == 20); | 
| 144 |     QVERIFY(drf2.minValue() == 1); | 
| 145 |  | 
| 146 |     /* Try creating a default filter and making sure we don't break */ | 
| 147 |     QContactFilter deff, deff2; | 
| 148 |  | 
| 149 |     QVERIFY(deff.type() == QContactFilter::DefaultFilter); | 
| 150 |     QVERIFY(deff == deff); | 
| 151 |     QVERIFY(deff == deff2); | 
| 152 |     QVERIFY(deff != drf2); | 
| 153 |     QVERIFY(drf2 != deff); | 
| 154 |  | 
| 155 |     QContactFilter fdeff = deff; | 
| 156 |     QVERIFY(fdeff.type() == QContactFilter::DefaultFilter); | 
| 157 |     QVERIFY(fdeff == deff); | 
| 158 |     QVERIFY(fdeff == deff2); | 
| 159 |  | 
| 160 |     /* Now some "invalid" filters */ | 
| 161 |     QContactInvalidFilter iff, iff2; | 
| 162 |  | 
| 163 |     QVERIFY(iff.type() == QContactFilter::InvalidFilter); | 
| 164 |     QVERIFY(iff == iff); | 
| 165 |     QVERIFY(iff == iff2); | 
| 166 |     QVERIFY(iff != drf2); | 
| 167 |     QVERIFY(drf2 != iff); | 
| 168 |  | 
| 169 |     QContactFilter fiff = iff; | 
| 170 |     QVERIFY(fiff.type() == QContactFilter::InvalidFilter); | 
| 171 |     QVERIFY(fiff == iff); | 
| 172 |     QVERIFY(fiff == iff2); | 
| 173 |  | 
| 174 |     /* Now test some "cross casting" */ | 
| 175 |  | 
| 176 | } | 
| 177 |  | 
| 178 | void tst_QContactFilter::intersectionFilter() | 
| 179 | { | 
| 180 |     /* Test boolean ops */ | 
| 181 |     QContactDetailFilter df; | 
| 182 |     df.setDetailType(type: QContactDetail::TypeExtendedDetail, field: QContactExtendedDetail::FieldName); | 
| 183 |  | 
| 184 |     QContactDetailFilter df2; | 
| 185 |     df2.setDetailType(type: QContactDetail::TypeAddress, field: QContactAddress::FieldStreet); | 
| 186 |  | 
| 187 |     QContactDetailFilter df3; | 
| 188 |     df3.setDetailType(type: QContactDetail::TypePhoneNumber, field: QContactPhoneNumber::FieldNumber); | 
| 189 |  | 
| 190 |     QContactIntersectionFilter bf; | 
| 191 |     bf << df << df2; | 
| 192 |  | 
| 193 |     QContactFilter f = df & df2; | 
| 194 |  | 
| 195 |     QVERIFY(bf == f); | 
| 196 |  | 
| 197 |     QContactFilter f2 = bf & df3; | 
| 198 |     QVERIFY(f2.type() == QContactFilter::IntersectionFilter); | 
| 199 |     QContactIntersectionFilter bf2 = f2; | 
| 200 |     QVERIFY(bf2 == f2); | 
| 201 |     QCOMPARE(bf2.filters().count(), 2); | 
| 202 |     QVERIFY(bf2.filters().at(0) == bf); | 
| 203 |     QVERIFY(bf2.filters().at(1) == df3); | 
| 204 |  | 
| 205 |     f2 = df3 & bf; | 
| 206 |     QVERIFY(f2.type() == QContactFilter::IntersectionFilter); | 
| 207 |     bf2 = f2; | 
| 208 |     QVERIFY(bf2 == f2); | 
| 209 |     QCOMPARE(bf2.filters().count(), 2); | 
| 210 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 211 |     QVERIFY(bf2.filters().at(1) == bf); | 
| 212 |  | 
| 213 |     /* Save this list */ | 
| 214 |     QList<QContactFilter> filterList = bf2.filters(); | 
| 215 |  | 
| 216 |     f2 = df & df2 & df3; | 
| 217 |     QVERIFY(f2.type() == QContactFilter::IntersectionFilter); | 
| 218 |     bf2 = f2; | 
| 219 |     QVERIFY(bf2 == f2); | 
| 220 |     QCOMPARE(bf2.filters().count(), 2); | 
| 221 |     QVERIFY(bf2.filters().at(0) == (df & df2)); | 
| 222 |     QVERIFY(bf2.filters().at(1) == df3); | 
| 223 |  | 
| 224 |     /* Self assignment should do nothing */ | 
| 225 |     bf2 = bf2; | 
| 226 |     QVERIFY(bf2 == f2); | 
| 227 |  | 
| 228 |     /* Test set filter */ | 
| 229 |     bf2.setFilters(filterList); | 
| 230 |     QCOMPARE(bf2.filters().count(), 2); | 
| 231 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 232 |     QVERIFY(bf2.filters().at(1) == bf); | 
| 233 |  | 
| 234 |     /* Test remove */ | 
| 235 |     bf2.remove(filter: bf); | 
| 236 |     QCOMPARE(bf2.filters().count(), 1); | 
| 237 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 238 |  | 
| 239 |     /* Double remove, should do nothing */ | 
| 240 |     bf2.remove(filter: bf); | 
| 241 |     QCOMPARE(bf2.filters().count(), 1); | 
| 242 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 243 |  | 
| 244 |     /* Append/prepend */ | 
| 245 |     QContactIntersectionFilter bf3; | 
| 246 |     bf3.append(filter: df); | 
| 247 |     QVERIFY(bf3.filters().count() == 1); | 
| 248 |     bf3.prepend(filter: df2); | 
| 249 |     QVERIFY(bf3.filters().count() == 2); | 
| 250 |     QVERIFY(bf3.filters().at(0) == df2); | 
| 251 |     QVERIFY(bf3.filters().at(1) == df); | 
| 252 |     bf3.append(filter: df3); | 
| 253 |     QVERIFY(bf3.filters().count() == 3); | 
| 254 |     QVERIFY(bf3.filters().at(0) == df2); | 
| 255 |     QVERIFY(bf3.filters().at(1) == df); | 
| 256 |     QVERIFY(bf3.filters().at(2) == df3); | 
| 257 |     bf3.prepend(filter: df3); | 
| 258 |     QVERIFY(bf3.filters().count() == 4); | 
| 259 |     QVERIFY(bf3.filters().at(0) == df3); | 
| 260 |     QVERIFY(bf3.filters().at(1) == df2); | 
| 261 |     QVERIFY(bf3.filters().at(2) == df); | 
| 262 |     QVERIFY(bf3.filters().at(3) == df3); | 
| 263 | } | 
| 264 |  | 
| 265 | void tst_QContactFilter::unionFilter() | 
| 266 | { | 
| 267 |     /* Test boolean ops */ | 
| 268 |     QContactDetailFilter df; | 
| 269 |     df.setDetailType(type: QContactDetail::TypeExtendedDetail, field: QContactExtendedDetail::FieldName); | 
| 270 |  | 
| 271 |     QContactDetailFilter df2; | 
| 272 |     df2.setDetailType(type: QContactDetail::TypeAddress, field: QContactAddress::FieldStreet); | 
| 273 |  | 
| 274 |     QContactDetailFilter df3; | 
| 275 |     df3.setDetailType(type: QContactDetail::TypePhoneNumber, field: QContactPhoneNumber::FieldNumber); | 
| 276 |  | 
| 277 |     QContactUnionFilter bf; | 
| 278 |     bf << df << df2; | 
| 279 |  | 
| 280 |     QContactFilter f = df | df2; | 
| 281 |  | 
| 282 |     QVERIFY(bf == f); | 
| 283 |  | 
| 284 |     QContactFilter f2 = bf | df3; | 
| 285 |     QVERIFY(f2.type() == QContactFilter::UnionFilter); | 
| 286 |     QContactUnionFilter bf2 = f2; | 
| 287 |     QVERIFY(bf2 == f2); | 
| 288 |     QCOMPARE(bf2.filters().count(), 3); | 
| 289 |     QVERIFY(bf2.filters().at(0) == df); | 
| 290 |     QVERIFY(bf2.filters().at(1) == df2); | 
| 291 |     QVERIFY(bf2.filters().at(2) == df3); | 
| 292 |  | 
| 293 |     f2 = df3 | bf; | 
| 294 |     QVERIFY(f2.type() == QContactFilter::UnionFilter); | 
| 295 |     bf2 = f2; | 
| 296 |     QVERIFY(bf2 == f2); | 
| 297 |     QCOMPARE(bf2.filters().count(), 3); | 
| 298 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 299 |     QVERIFY(bf2.filters().at(1) == df); | 
| 300 |     QVERIFY(bf2.filters().at(2) == df2); | 
| 301 |  | 
| 302 |     /* Save this list */ | 
| 303 |     QList<QContactFilter> filterList = bf2.filters(); | 
| 304 |  | 
| 305 |     f2 = df | df2 | df3; | 
| 306 |     QVERIFY(f2.type() == QContactFilter::UnionFilter); | 
| 307 |     bf2 = f2; | 
| 308 |     QVERIFY(bf2 == f2); | 
| 309 |     QCOMPARE(bf2.filters().count(), 3); | 
| 310 |     QVERIFY(bf2.filters().at(0) == df); | 
| 311 |     QVERIFY(bf2.filters().at(1) == df2); | 
| 312 |     QVERIFY(bf2.filters().at(2) == df3); | 
| 313 |  | 
| 314 |     /* Self assignment should do nothing */ | 
| 315 |     bf2 = bf2; | 
| 316 |     QVERIFY(bf2 == f2); | 
| 317 |  | 
| 318 |     /* Test set filter */ | 
| 319 |     bf2.setFilters(filterList); | 
| 320 |     QCOMPARE(bf2.filters().count(), 3); | 
| 321 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 322 |     QVERIFY(bf2.filters().at(1) == df); | 
| 323 |     QVERIFY(bf2.filters().at(2) == df2); | 
| 324 |  | 
| 325 |     /* Test remove */ | 
| 326 |     bf2.remove(filter: df); | 
| 327 |     QCOMPARE(bf2.filters().count(), 2); | 
| 328 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 329 |     QVERIFY(bf2.filters().at(1) == df2); | 
| 330 |  | 
| 331 |     /* Double remove, should do nothing */ | 
| 332 |     bf2.remove(filter: df); | 
| 333 |     QCOMPARE(bf2.filters().count(), 2); | 
| 334 |     QVERIFY(bf2.filters().at(0) == df3); | 
| 335 |     QVERIFY(bf2.filters().at(1) == df2); | 
| 336 |  | 
| 337 |     /* Append/prepend */ | 
| 338 |     QContactUnionFilter bf3; | 
| 339 |     bf3.append(filter: df); | 
| 340 |     QVERIFY(bf3.filters().count() == 1); | 
| 341 |     bf3.prepend(filter: df2); | 
| 342 |     QVERIFY(bf3.filters().count() == 2); | 
| 343 |     QVERIFY(bf3.filters().at(0) == df2); | 
| 344 |     QVERIFY(bf3.filters().at(1) == df); | 
| 345 |     bf3.append(filter: df3); | 
| 346 |     QVERIFY(bf3.filters().count() == 3); | 
| 347 |     QVERIFY(bf3.filters().at(0) == df2); | 
| 348 |     QVERIFY(bf3.filters().at(1) == df); | 
| 349 |     QVERIFY(bf3.filters().at(2) == df3); | 
| 350 |     bf3.prepend(filter: df3); | 
| 351 |     QVERIFY(bf3.filters().count() == 4); | 
| 352 |     QVERIFY(bf3.filters().at(0) == df3); | 
| 353 |     QVERIFY(bf3.filters().at(1) == df2); | 
| 354 |     QVERIFY(bf3.filters().at(2) == df); | 
| 355 |     QVERIFY(bf3.filters().at(3) == df3); | 
| 356 | } | 
| 357 |  | 
| 358 | void tst_QContactFilter::actionFilter() | 
| 359 | { | 
| 360 |     QContactActionFilter af; | 
| 361 |  | 
| 362 |     /* Test initial conditions */ | 
| 363 |     QVERIFY(af.type() == QContactFilter::ActionFilter); | 
| 364 |     QVERIFY(af.actionName().isEmpty()); | 
| 365 |  | 
| 366 |     af.setActionName("Action Name" ); | 
| 367 |     QVERIFY(af.actionName() == "Action Name" ); | 
| 368 |  | 
| 369 |     af.setActionName(QString()); | 
| 370 |     QVERIFY(af.actionName().isEmpty()); | 
| 371 |  | 
| 372 |     /* Test op= */ | 
| 373 |     QContactFilter f = af; | 
| 374 |     QVERIFY(f == af); | 
| 375 |  | 
| 376 |     QContactActionFilter af2 = f; | 
| 377 |     QVERIFY(af2 == af); | 
| 378 |  | 
| 379 |     /* Self assignment should do nothing */ | 
| 380 |     af2 = af2; | 
| 381 |     QVERIFY(af2 == af); | 
| 382 |  | 
| 383 |     QContactDetailFilter dfil; | 
| 384 |     QContactActionFilter af3(dfil); | 
| 385 |     QVERIFY(af3.type() == QContactFilter::ActionFilter); | 
| 386 |     QContactActionFilter af4(af); | 
| 387 |     QVERIFY(af4 == af); | 
| 388 |     af = dfil; | 
| 389 |     QVERIFY(af == af3); | 
| 390 |     af = af3; | 
| 391 |     af.setActionName("test" ); // should force a detach | 
| 392 | } | 
| 393 |  | 
| 394 | void tst_QContactFilter::changeLogFilter() | 
| 395 | { | 
| 396 |     QContactChangeLogFilter cf; | 
| 397 |     QContactChangeLogFilter cfadded(QContactChangeLogFilter::EventAdded); | 
| 398 |     QContactChangeLogFilter cfchanged(QContactChangeLogFilter::EventChanged); | 
| 399 |     QContactChangeLogFilter cfremoved(QContactChangeLogFilter::EventRemoved); | 
| 400 |  | 
| 401 |     QVERIFY(cf.type() == QContactFilter::ChangeLogFilter); | 
| 402 |     QVERIFY(cf.eventType() == QContactChangeLogFilter::EventAdded); | 
| 403 |  | 
| 404 |     QVERIFY(cfadded.type() == QContactFilter::ChangeLogFilter); | 
| 405 |     QVERIFY(cfadded.eventType() == QContactChangeLogFilter::EventAdded); | 
| 406 |  | 
| 407 |     QVERIFY(cfchanged.type() == QContactFilter::ChangeLogFilter); | 
| 408 |     QVERIFY(cfchanged.eventType() == QContactChangeLogFilter::EventChanged); | 
| 409 |  | 
| 410 |     QVERIFY(cfremoved.type() == QContactFilter::ChangeLogFilter); | 
| 411 |     QVERIFY(cfremoved.eventType() == QContactChangeLogFilter::EventRemoved); | 
| 412 |  | 
| 413 |  | 
| 414 |     /* Just to break the naming scheme */ | 
| 415 |     cfchanged.setEventType(QContactChangeLogFilter::EventAdded); | 
| 416 |     QVERIFY(cfchanged.eventType() == QContactChangeLogFilter::EventAdded); | 
| 417 |  | 
| 418 |     QVERIFY(cf.since() == QDateTime()); | 
| 419 |  | 
| 420 |     QDateTime now = QDateTime::currentDateTime(); | 
| 421 |     cf.setSince(now); | 
| 422 |  | 
| 423 |     QVERIFY(cf.since() == now); | 
| 424 |  | 
| 425 |     cf.setSince(QDateTime()); | 
| 426 |     QVERIFY(cf.since() == QDateTime()); | 
| 427 |  | 
| 428 |     /* Test op= */ | 
| 429 |     QContactFilter f = cf; | 
| 430 |     QVERIFY(f == cf); | 
| 431 |  | 
| 432 |     QContactChangeLogFilter cf2 = f; | 
| 433 |     QVERIFY(cf2 == cf); | 
| 434 |  | 
| 435 |     /* Self assignment should do nothing */ | 
| 436 |     cf2 = cf2; | 
| 437 |     QVERIFY(cf2 == cf); | 
| 438 |  | 
| 439 |     QContactDetailFilter dfil; | 
| 440 |     QContactChangeLogFilter cf3(dfil); | 
| 441 |     QVERIFY(cf3.type() == QContactFilter::ChangeLogFilter); | 
| 442 |     QContactChangeLogFilter cf4(cf); | 
| 443 |     QVERIFY(cf4 == cf); | 
| 444 |     cf = dfil; | 
| 445 |     QVERIFY(cf == cf3); | 
| 446 |     cf = cf3; | 
| 447 |     cf.setEventType(QContactChangeLogFilter::EventRemoved); // force a detach | 
| 448 | } | 
| 449 |  | 
| 450 | void tst_QContactFilter::detailFilter() | 
| 451 | { | 
| 452 |     QContactDetailFilter df; | 
| 453 |  | 
| 454 |     QVERIFY(df.type() == QContactFilter::ContactDetailFilter); | 
| 455 |     QVERIFY(df.detailType() == QContactDetail::TypeUndefined); | 
| 456 |     QVERIFY(df.detailField() == -1); | 
| 457 |     QVERIFY(df.matchFlags() == 0); | 
| 458 |     QVERIFY(df.value().isNull()); | 
| 459 |  | 
| 460 |     df.setDetailType(type: QContactDetail::TypeAddress); | 
| 461 |     QVERIFY(df.detailType() == QContactDetail::TypeAddress); | 
| 462 |     QVERIFY(df.detailField() == -1); | 
| 463 |     QVERIFY(df.matchFlags() == 0); | 
| 464 |     QVERIFY(df.value().isNull()); | 
| 465 |  | 
| 466 |     df.setDetailType(type: QContactDetail::TypeAddress, field: QContactAddress::FieldStreet); | 
| 467 |     QVERIFY(df.detailType() == QContactDetail::TypeAddress); | 
| 468 |     QVERIFY(df.detailField() == QContactAddress::FieldStreet); | 
| 469 |     QVERIFY(df.matchFlags() == 0); | 
| 470 |     QVERIFY(df.value().isNull()); | 
| 471 |  | 
| 472 |     df.setMatchFlags(QContactFilter::MatchExactly); | 
| 473 |     QVERIFY(df.matchFlags() == QContactFilter::MatchExactly); | 
| 474 |  | 
| 475 |     df.setValue(5); | 
| 476 |     QVERIFY(df.value() == 5); | 
| 477 |  | 
| 478 |     df.setValue("String value" ); | 
| 479 |     QVERIFY(df.value() == "String value" ); | 
| 480 |  | 
| 481 |     /* Test op= */ | 
| 482 |     QContactFilter f = df; | 
| 483 |     QVERIFY(f == df); | 
| 484 |  | 
| 485 |     QContactDetailFilter df2 = f; | 
| 486 |     QVERIFY(df2 == df); | 
| 487 |     QVERIFY(df2.detailType() == QContactDetail::TypeAddress); | 
| 488 |     QVERIFY(df2.detailField() == QContactAddress::FieldStreet); | 
| 489 |  | 
| 490 |     /* Self assignment should do nothing */ | 
| 491 |     df2 = df2; | 
| 492 |     QVERIFY(df2 == df); | 
| 493 |  | 
| 494 |     /* Some cross casting */ | 
| 495 |     QContactDetailRangeFilter rf; | 
| 496 |  | 
| 497 |     /* Directly */ | 
| 498 |     df2 = rf; | 
| 499 |     QVERIFY(df2.type() == QContactFilter::ContactDetailFilter); | 
| 500 |     QVERIFY(df2.detailType() == QContactDetail::TypeUndefined); | 
| 501 |     QVERIFY(df2.detailField() == -1); | 
| 502 |     QVERIFY(df2.value().isNull()); | 
| 503 |  | 
| 504 |     /* reset it */ | 
| 505 |     df2 = df; | 
| 506 |     QVERIFY(df2.detailType() == QContactDetail::TypeAddress); | 
| 507 |     QVERIFY(df2.detailField() == QContactAddress::FieldStreet); | 
| 508 |  | 
| 509 |     /* Through base class */ | 
| 510 |     f = rf; | 
| 511 |     df2 = f; | 
| 512 |     QVERIFY(df2.detailType() == QContactDetail::TypeUndefined); | 
| 513 |     QVERIFY(df2.detailField() == -1); | 
| 514 |     QVERIFY(df2.value().isNull()); | 
| 515 |  | 
| 516 |     /* Now test copy ctor */ | 
| 517 |     QContactDetailFilter df3(rf); | 
| 518 |     QVERIFY(df3.type() == QContactFilter::ContactDetailFilter); | 
| 519 |     QVERIFY(df3.detailType() == QContactDetail::TypeUndefined); | 
| 520 |     QVERIFY(df3.detailField() == -1); | 
| 521 |     QVERIFY(df3.value().isNull()); | 
| 522 |  | 
| 523 |     /* reset it */ | 
| 524 |     df3 = df; | 
| 525 |     QVERIFY(df3.detailType() == QContactDetail::TypeAddress); | 
| 526 |     QVERIFY(df3.detailField() == QContactAddress::FieldStreet); | 
| 527 |  | 
| 528 |     /* Now test copy ctor through base class */ | 
| 529 |     QContactDetailFilter df4(f); | 
| 530 |     QVERIFY(df4.type() == QContactFilter::ContactDetailFilter); | 
| 531 |     QVERIFY(df4.detailType() == QContactDetail::TypeUndefined); | 
| 532 |     QVERIFY(df4.detailField() == -1); | 
| 533 |     QVERIFY(df4.value().isNull()); | 
| 534 |  | 
| 535 |     /* reset it */ | 
| 536 |     df4 = df; | 
| 537 |     QVERIFY(df4.detailType() == QContactDetail::TypeAddress); | 
| 538 |     QVERIFY(df4.detailField() == QContactAddress::FieldStreet); | 
| 539 | } | 
| 540 |  | 
| 541 | void tst_QContactFilter::detailRangeFilter() | 
| 542 | { | 
| 543 |     QContactDetailRangeFilter rf; | 
| 544 |  | 
| 545 |     QVERIFY(rf.type() == QContactFilter::ContactDetailRangeFilter); | 
| 546 |  | 
| 547 |     QVERIFY(rf.detailType() == QContactDetail::TypeUndefined); | 
| 548 |     QVERIFY(rf.detailField() == -1); | 
| 549 |     QVERIFY(rf.matchFlags() == 0); | 
| 550 |  | 
| 551 |     QVERIFY(rf.minValue().isNull()); | 
| 552 |     QVERIFY(rf.maxValue().isNull()); | 
| 553 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 554 |  | 
| 555 |     rf.setDetailType(type: QContactDetail::TypeExtendedDetail); | 
| 556 |     QVERIFY(rf.detailType() == QContactDetail::TypeExtendedDetail); | 
| 557 |     QVERIFY(rf.detailField() == -1); | 
| 558 |     QVERIFY(rf.matchFlags() == 0); | 
| 559 |  | 
| 560 |     QVERIFY(rf.minValue().isNull()); | 
| 561 |     QVERIFY(rf.maxValue().isNull()); | 
| 562 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 563 |  | 
| 564 |     rf.setDetailType(type: QContactDetail::TypeExtendedDetail, field: QContactExtendedDetail::FieldName); | 
| 565 |     QVERIFY(rf.detailType() == QContactDetail::TypeExtendedDetail); | 
| 566 |     QVERIFY(rf.detailField() == QContactExtendedDetail::FieldName); | 
| 567 |     QVERIFY(rf.matchFlags() == 0); | 
| 568 |  | 
| 569 |     QVERIFY(rf.minValue().isNull()); | 
| 570 |     QVERIFY(rf.maxValue().isNull()); | 
| 571 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 572 |  | 
| 573 |     rf.setMatchFlags(QContactFilter::MatchExactly); | 
| 574 |     QVERIFY(rf.matchFlags() == QContactFilter::MatchExactly); | 
| 575 |  | 
| 576 |     rf.setMatchFlags(QContactFilter::MatchCaseSensitive); | 
| 577 |     QVERIFY(rf.matchFlags() == QContactFilter::MatchCaseSensitive); | 
| 578 |  | 
| 579 |     // Contains is not allowed | 
| 580 |     rf.setMatchFlags(QContactFilter::MatchCaseSensitive | QContactFilter::MatchContains); | 
| 581 |     QVERIFY(rf.matchFlags() == QContactFilter::MatchCaseSensitive); | 
| 582 |  | 
| 583 |     rf.setMatchFlags(QContactFilter::MatchEndsWith); | 
| 584 |     QVERIFY(rf.matchFlags() == QContactFilter::MatchExactly); // 0 | 
| 585 |  | 
| 586 |     rf.setRange(min: 5, max: 10); | 
| 587 |     QVERIFY(rf.minValue() == 5); | 
| 588 |     QVERIFY(rf.maxValue() == 10); | 
| 589 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 590 |  | 
| 591 |     rf.setRange(min: QVariant(), max: 11); | 
| 592 |     QVERIFY(rf.minValue().isNull()); | 
| 593 |     QVERIFY(rf.maxValue() == 11); | 
| 594 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 595 |  | 
| 596 |     rf.setRange(min: 6, max: QVariant()); | 
| 597 |     QVERIFY(rf.minValue() == 6); | 
| 598 |     QVERIFY(rf.maxValue().isNull()); | 
| 599 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 600 |  | 
| 601 |     rf.setRange(min: QVariant(), max: QVariant()); | 
| 602 |     QVERIFY(rf.minValue().isNull()); | 
| 603 |     QVERIFY(rf.maxValue().isNull()); | 
| 604 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 605 |  | 
| 606 |     rf.setRange(min: 5, max: 10, flags: QContactDetailRangeFilter::ExcludeLower); | 
| 607 |     QVERIFY(rf.minValue() == 5); | 
| 608 |     QVERIFY(rf.maxValue() == 10); | 
| 609 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::ExcludeLower)); | 
| 610 |  | 
| 611 |     rf.setRange(min: QVariant(), max: 11, flags: QContactDetailRangeFilter::IncludeUpper); | 
| 612 |     QVERIFY(rf.minValue().isNull()); | 
| 613 |     QVERIFY(rf.maxValue() == 11); | 
| 614 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::IncludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 615 |  | 
| 616 |     rf.setRange(min: 6, max: QVariant(), flags: QContactDetailRangeFilter::ExcludeLower | QContactDetailRangeFilter::IncludeUpper); | 
| 617 |     QVERIFY(rf.minValue() == 6); | 
| 618 |     QVERIFY(rf.maxValue().isNull()); | 
| 619 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::IncludeUpper | QContactDetailRangeFilter::ExcludeLower)); | 
| 620 |  | 
| 621 |     rf.setRange(min: QVariant(), max: QVariant(), flags: QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower); | 
| 622 |     QVERIFY(rf.minValue().isNull()); | 
| 623 |     QVERIFY(rf.maxValue().isNull()); | 
| 624 |     QVERIFY(rf.rangeFlags() == (QContactDetailRangeFilter::ExcludeUpper | QContactDetailRangeFilter::IncludeLower)); | 
| 625 |  | 
| 626 |     /* Test op= */ | 
| 627 |     QContactFilter f = rf; | 
| 628 |     QVERIFY(f == rf); | 
| 629 |  | 
| 630 |     QContactDetailRangeFilter rf2 = f; | 
| 631 |     QVERIFY(rf2 == rf); | 
| 632 |  | 
| 633 |     rf2 = rf; | 
| 634 |     QVERIFY(rf2 == f); | 
| 635 |  | 
| 636 |     /* Self assignment should do nothing */ | 
| 637 |     rf2 = rf2; | 
| 638 |     QVERIFY(rf2 == rf); | 
| 639 | } | 
| 640 |  | 
| 641 | void tst_QContactFilter::relationshipFilter() | 
| 642 | { | 
| 643 |     QContactRelationshipFilter crf; | 
| 644 |  | 
| 645 |     QVERIFY(crf.type() == QContactFilter::RelationshipFilter); | 
| 646 |  | 
| 647 |  | 
| 648 |     QVERIFY(crf.relationshipType() == QString()); | 
| 649 |     QVERIFY(crf.relatedContactId() == QContactId()); | 
| 650 |  | 
| 651 |     QContact newContact; | 
| 652 |     newContact.setId(makeId(managerName: "test" , id: 5)); | 
| 653 |     crf.setRelatedContactId(newContact.id()); | 
| 654 |  | 
| 655 |     QVERIFY(crf.relationshipType() == QString()); | 
| 656 |     QVERIFY(crf.relatedContactId() == newContact.id()); | 
| 657 |  | 
| 658 |     crf.setRelatedContactRole(QContactRelationship::First); | 
| 659 |  | 
| 660 |     QVERIFY(crf.relationshipType() == QString()); | 
| 661 |     QVERIFY(crf.relatedContactId() == newContact.id()); | 
| 662 |  | 
| 663 |     crf.setRelationshipType(QContactRelationship::HasManager()); | 
| 664 |  | 
| 665 |     QVERIFY(crf.relationshipType() == QContactRelationship::HasManager()); | 
| 666 |     QVERIFY(crf.relatedContactId() == newContact.id()); | 
| 667 |  | 
| 668 |     /* Test op= */ | 
| 669 |     QContactFilter f = crf; | 
| 670 |     QVERIFY(f == crf); | 
| 671 |  | 
| 672 |     QContactRelationshipFilter crf2 = f; | 
| 673 |     QVERIFY(crf2 == crf); | 
| 674 |  | 
| 675 |     /* Self assignment should do nothing */ | 
| 676 |     crf2 = crf2; | 
| 677 |     QVERIFY(crf2 == crf); | 
| 678 |  | 
| 679 |     QContactDetailFilter dfil; | 
| 680 |     QContactRelationshipFilter crf3(dfil); | 
| 681 |     QVERIFY(crf3.type() == QContactFilter::RelationshipFilter); // should be a blank rel fil | 
| 682 |     QContactRelationshipFilter crf4(crf); | 
| 683 |     QVERIFY(crf4 == crf); | 
| 684 |     crf = dfil; | 
| 685 |     QVERIFY(crf == crf3); | 
| 686 |     crf = crf3; | 
| 687 |     crf.setRelationshipType("test" ); // force a detach | 
| 688 | } | 
| 689 |  | 
| 690 |  | 
| 691 |  | 
| 692 | void tst_QContactFilter::boringFilters() | 
| 693 | { | 
| 694 |     QContactFilter all; | 
| 695 |     QVERIFY(all.type() == QContactFilter::DefaultFilter); | 
| 696 |  | 
| 697 |     QContactInvalidFilter invalid; | 
| 698 |     QVERIFY(invalid.type() == QContactFilter::InvalidFilter); | 
| 699 |  | 
| 700 |     QVERIFY(all != invalid); | 
| 701 |     QVERIFY(!(all == invalid)); | 
| 702 |  | 
| 703 |     /* Test op= */ | 
| 704 |     QContactFilter f = all; | 
| 705 |     QVERIFY(f == all); | 
| 706 |  | 
| 707 |     QContactFilter f2; | 
| 708 |     f2 = f; | 
| 709 |     QVERIFY(f2 == all); | 
| 710 |  | 
| 711 |     /* Self assignment should do nothing */ | 
| 712 |     f2 = f2; | 
| 713 |     QVERIFY(f2 == all); | 
| 714 |  | 
| 715 |     /* InvalidFilter, op= */ | 
| 716 |     QContactInvalidFilter inv2 = invalid; | 
| 717 |     QVERIFY(inv2 == invalid); | 
| 718 |  | 
| 719 |     QContactInvalidFilter inv3; | 
| 720 |     inv3 = inv2; | 
| 721 |     QVERIFY(inv3 == invalid); | 
| 722 |  | 
| 723 |     inv3 = inv3; | 
| 724 |     QVERIFY(inv3 == invalid); | 
| 725 |  | 
| 726 |     inv3 = all; | 
| 727 |     QVERIFY(inv3 == invalid); // won't be all | 
| 728 | } | 
| 729 |  | 
| 730 | void tst_QContactFilter::idListFilter() | 
| 731 | { | 
| 732 |     QContactIdFilter idf; | 
| 733 |  | 
| 734 |     QVERIFY(idf.type() == QContactFilter::IdFilter); | 
| 735 |  | 
| 736 |     QVERIFY(idf.ids().count() == 0); | 
| 737 |  | 
| 738 |     QList<QContactId> ids; | 
| 739 |     ids << QContactId() << QContactId() << QContactId(); | 
| 740 |  | 
| 741 |     idf.setIds(ids); | 
| 742 |     QVERIFY(idf.ids() == ids); | 
| 743 |  | 
| 744 |     idf.setIds(QList<QContactId>()); | 
| 745 |     QVERIFY(idf.ids().count() == 0); | 
| 746 |  | 
| 747 |     /* Test op= */ | 
| 748 |     idf.setIds(ids); | 
| 749 |     QContactFilter f = idf; | 
| 750 |     QVERIFY(f == idf); | 
| 751 |  | 
| 752 |     QContactIdFilter idf2 = f; | 
| 753 |     QVERIFY(idf2 == idf); | 
| 754 |     QVERIFY(idf2.ids() == ids); | 
| 755 |  | 
| 756 |     idf2 = idf; | 
| 757 |     QVERIFY(idf2 == f); | 
| 758 |  | 
| 759 |     /* Self assignment should do nothing */ | 
| 760 |     idf2 = idf2; | 
| 761 |     QVERIFY(idf2 == idf); | 
| 762 |  | 
| 763 |     QContactDetailFilter dfil; | 
| 764 |     QContactIdFilter idf3(dfil); | 
| 765 |     QVERIFY(idf3.type() == QContactFilter::IdFilter); // should be a blank id list filter | 
| 766 |     QContactIdFilter idf4(idf); | 
| 767 |     QVERIFY(idf4 == idf); // should be a copy of idf. | 
| 768 |     idf = dfil; // now assign. | 
| 769 |     QVERIFY(idf == idf3); // again, should be a blank id list filter. | 
| 770 |     idf = idf3; | 
| 771 |     idf.setIds(ids); // force a detach | 
| 772 | } | 
| 773 |  | 
| 774 | void tst_QContactFilter::canonicalizedFilter() | 
| 775 | { | 
| 776 |     QFETCH(QContactFilter, in); | 
| 777 |     QFETCH(QContactFilter, expected); | 
| 778 |  | 
| 779 |     QContactFilter out = QContactManagerEngine::canonicalizedFilter(filter: in); | 
| 780 |     QCOMPARE(out, expected); | 
| 781 | } | 
| 782 |  | 
| 783 | void tst_QContactFilter::canonicalizedFilter_data() | 
| 784 | { | 
| 785 |     QTest::addColumn<QContactFilter>(name: "in" ); | 
| 786 |     QTest::addColumn<QContactFilter>(name: "expected" ); | 
| 787 |  | 
| 788 |     QContactFilter detailFilter1 = QContactName::match(name: "1" ); | 
| 789 |     QContactFilter detailFilter2 = QContactName::match(name: "2" ); | 
| 790 |     QContactInvalidFilter invalidFilter; | 
| 791 |     QContactFilter defaultFilter; | 
| 792 |  | 
| 793 |     { | 
| 794 |         QTest::newRow(dataTag: "Normal detail filter" ) | 
| 795 |                 << static_cast<QContactFilter>(detailFilter1) | 
| 796 |                 << static_cast<QContactFilter>(detailFilter1); | 
| 797 |     } | 
| 798 |  | 
| 799 |     { | 
| 800 |         QContactIntersectionFilter qcif; | 
| 801 |         qcif << detailFilter1; | 
| 802 |         qcif << detailFilter2; | 
| 803 |         QTest::newRow(dataTag: "Normal intersection filter" ) | 
| 804 |                 << static_cast<QContactFilter>(qcif) | 
| 805 |                 << static_cast<QContactFilter>(qcif); | 
| 806 |     } | 
| 807 |  | 
| 808 |     { | 
| 809 |         QContactUnionFilter qcuf; | 
| 810 |         qcuf << detailFilter1; | 
| 811 |         qcuf << detailFilter2; | 
| 812 |         QTest::newRow(dataTag: "Normal intersection filter" ) | 
| 813 |                 << static_cast<QContactFilter>(qcuf) | 
| 814 |                 << static_cast<QContactFilter>(qcuf); | 
| 815 |     } | 
| 816 |  | 
| 817 |     { | 
| 818 |         QContactIntersectionFilter qcif; | 
| 819 |         QTest::newRow(dataTag: "Empty intersection" ) | 
| 820 |                 << static_cast<QContactFilter>(qcif) | 
| 821 |                 << static_cast<QContactFilter>(defaultFilter); | 
| 822 |     } | 
| 823 |  | 
| 824 |     { | 
| 825 |         QContactUnionFilter qcuf; | 
| 826 |         QTest::newRow(dataTag: "Empty union" ) | 
| 827 |                 << static_cast<QContactFilter>(qcuf) | 
| 828 |                 << static_cast<QContactFilter>(invalidFilter); | 
| 829 |     } | 
| 830 |  | 
| 831 |     { | 
| 832 |         QContactIntersectionFilter qcif; | 
| 833 |         qcif << detailFilter1; | 
| 834 |         QTest::newRow(dataTag: "Single entry intersection filter" ) | 
| 835 |                 << static_cast<QContactFilter>(qcif) | 
| 836 |                 << static_cast<QContactFilter>(detailFilter1); | 
| 837 |     } | 
| 838 |  | 
| 839 |     { | 
| 840 |         QContactUnionFilter qcuf; | 
| 841 |         qcuf << detailFilter1; | 
| 842 |         QTest::newRow(dataTag: "Single entry union filter" ) | 
| 843 |                 << static_cast<QContactFilter>(qcuf) | 
| 844 |                 << static_cast<QContactFilter>(detailFilter1); | 
| 845 |     } | 
| 846 |  | 
| 847 |     { | 
| 848 |         QContactIntersectionFilter qcif; | 
| 849 |         qcif << invalidFilter; | 
| 850 |         qcif << detailFilter1; | 
| 851 |         qcif << detailFilter2; | 
| 852 |         QTest::newRow(dataTag: "Intersection with invalid" ) | 
| 853 |                 << static_cast<QContactFilter>(qcif) | 
| 854 |                 << static_cast<QContactFilter>(invalidFilter); | 
| 855 |     } | 
| 856 |  | 
| 857 |     { | 
| 858 |         QContactIntersectionFilter qcif; | 
| 859 |         qcif << defaultFilter; | 
| 860 |         qcif << detailFilter1; | 
| 861 |         qcif << detailFilter2; | 
| 862 |         QContactIntersectionFilter expected; | 
| 863 |         expected << detailFilter1; | 
| 864 |         expected << detailFilter2; | 
| 865 |         QTest::newRow(dataTag: "Intersection with default" ) | 
| 866 |                 << static_cast<QContactFilter>(qcif) | 
| 867 |                 << static_cast<QContactFilter>(expected); | 
| 868 |     } | 
| 869 |  | 
| 870 |     { | 
| 871 |         QContactUnionFilter qcuf; | 
| 872 |         qcuf << invalidFilter; | 
| 873 |         qcuf << detailFilter1; | 
| 874 |         qcuf << detailFilter2; | 
| 875 |         QContactUnionFilter expected; | 
| 876 |         expected << detailFilter1; | 
| 877 |         expected << detailFilter2; | 
| 878 |         QTest::newRow(dataTag: "Union with invalid" ) | 
| 879 |                 << static_cast<QContactFilter>(qcuf) | 
| 880 |                 << static_cast<QContactFilter>(expected); | 
| 881 |     } | 
| 882 |  | 
| 883 |     { | 
| 884 |         QContactUnionFilter qcuf; | 
| 885 |         qcuf << defaultFilter; | 
| 886 |         qcuf << detailFilter1; | 
| 887 |         qcuf << detailFilter2; | 
| 888 |         QTest::newRow(dataTag: "Union with default" ) | 
| 889 |                 << static_cast<QContactFilter>(qcuf) | 
| 890 |                 << static_cast<QContactFilter>(defaultFilter); | 
| 891 |     } | 
| 892 |  | 
| 893 |     { | 
| 894 |         QContactIdFilter qclif; | 
| 895 |         QTest::newRow(dataTag: "Empty local id filter" ) | 
| 896 |                 << static_cast<QContactFilter>(qclif) | 
| 897 |                 << static_cast<QContactFilter>(invalidFilter); | 
| 898 |     } | 
| 899 |  | 
| 900 |     { | 
| 901 |         QContactIdFilter qclif; | 
| 902 |         qclif.setIds(QList<QContactId>() << QContactId() << QContactId()); | 
| 903 |         QTest::newRow(dataTag: "Normal local id filter" ) | 
| 904 |                 << static_cast<QContactFilter>(qclif) | 
| 905 |                 << static_cast<QContactFilter>(qclif); | 
| 906 |     } | 
| 907 |  | 
| 908 |     { | 
| 909 |         QContactDetailRangeFilter qcdrf; | 
| 910 |         qcdrf.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 911 |         QContactDetailFilter expected; | 
| 912 |         expected.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 913 |         QTest::newRow(dataTag: "Null valued range filter" ) | 
| 914 |                 << static_cast<QContactFilter>(qcdrf) | 
| 915 |                 << static_cast<QContactFilter>(expected); | 
| 916 |     } | 
| 917 |  | 
| 918 |     { | 
| 919 |         QContactDetailRangeFilter qcdrf; | 
| 920 |         qcdrf.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 921 |         qcdrf.setRange(QStringLiteral("a" ), QStringLiteral("a" )); | 
| 922 |         qcdrf.setMatchFlags(QContactFilter::MatchFixedString); | 
| 923 |         QContactDetailFilter expected; | 
| 924 |         expected.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 925 |         expected.setValue(QStringLiteral("a" )); | 
| 926 |         expected.setMatchFlags(QContactFilter::MatchFixedString); | 
| 927 |         QTest::newRow(dataTag: "Equal valued range filter" ) | 
| 928 |                 << static_cast<QContactFilter>(qcdrf) | 
| 929 |                 << static_cast<QContactFilter>(expected); | 
| 930 |     } | 
| 931 |  | 
| 932 |     { | 
| 933 |         QContactDetailRangeFilter qcdrf; | 
| 934 |         qcdrf.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 935 |         qcdrf.setRange(QStringLiteral("a" ), QStringLiteral("a" ), | 
| 936 |                flags: QContactDetailRangeFilter::ExcludeLower | QContactDetailRangeFilter::ExcludeUpper); | 
| 937 |         qcdrf.setMatchFlags(QContactFilter::MatchFixedString); | 
| 938 |         QTest::newRow(dataTag: "Equal valued range filter with excluded bounds" ) | 
| 939 |                 << static_cast<QContactFilter>(qcdrf) | 
| 940 |                 << static_cast<QContactFilter>(invalidFilter); | 
| 941 |     } | 
| 942 |  | 
| 943 |     { | 
| 944 |         QContactDetailRangeFilter qcdrf; | 
| 945 |         qcdrf.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 946 |         qcdrf.setRange(QStringLiteral("a" ), QStringLiteral("b" )); | 
| 947 |         qcdrf.setMatchFlags(QContactFilter::MatchFixedString); | 
| 948 |         QTest::newRow(dataTag: "Normal range filter" ) | 
| 949 |                 << static_cast<QContactFilter>(qcdrf) | 
| 950 |                 << static_cast<QContactFilter>(qcdrf); | 
| 951 |     } | 
| 952 |  | 
| 953 |     { | 
| 954 |         QContactDetailRangeFilter qcdrf; | 
| 955 |         qcdrf.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 956 |         qcdrf.setRange(min: QVariant(QVariant::String), max: QVariant(QVariant::String)); // null bounds | 
| 957 |         qcdrf.setMatchFlags(QContactFilter::MatchFixedString); | 
| 958 |         QContactDetailFilter qcdf; | 
| 959 |         qcdf.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 960 |         qcdf.setMatchFlags(QContactFilter::MatchFixedString); | 
| 961 |         qcdf.setValue(QVariant(QVariant::String)); | 
| 962 |         QTest::newRow(dataTag: "Null valued range filter" ) | 
| 963 |                 << static_cast<QContactFilter>(qcdrf) | 
| 964 |                 << static_cast<QContactFilter>(qcdf); | 
| 965 |     } | 
| 966 |  | 
| 967 |     { | 
| 968 |         QContactDetailRangeFilter qcdrf; | 
| 969 |         qcdrf.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 970 |         qcdrf.setRange(min: QVariant(QVariant::String), QStringLiteral("a" )); // min is null | 
| 971 |         qcdrf.setMatchFlags(QContactFilter::MatchFixedString); | 
| 972 |         QTest::newRow(dataTag: "One sided range filter" ) | 
| 973 |                 << static_cast<QContactFilter>(qcdrf) | 
| 974 |                 << static_cast<QContactFilter>(qcdrf); | 
| 975 |     } | 
| 976 |  | 
| 977 |     { | 
| 978 |         QContactDetailRangeFilter qcdrf; | 
| 979 |         QTest::newRow(dataTag: "Empty range filter" ) | 
| 980 |                 << static_cast<QContactFilter>(qcdrf) | 
| 981 |                 << static_cast<QContactFilter>(invalidFilter); | 
| 982 |     } | 
| 983 |  | 
| 984 |     { | 
| 985 |         QContactDetailFilter qcdf; | 
| 986 |         QTest::newRow(dataTag: "Empty detail filter" ) | 
| 987 |                 << static_cast<QContactFilter>(qcdf) | 
| 988 |                 << static_cast<QContactFilter>(invalidFilter); | 
| 989 |     } | 
| 990 | } | 
| 991 |  | 
| 992 | void tst_QContactFilter::testFilter() | 
| 993 | { | 
| 994 |     QFETCH(QContact, contact); | 
| 995 |     QFETCH(QContactFilter, filter); | 
| 996 |     QFETCH(bool, expected); | 
| 997 |  | 
| 998 |     QCOMPARE(QContactManagerEngine::testFilter(filter, contact), expected); | 
| 999 | } | 
| 1000 |  | 
| 1001 | void tst_QContactFilter::testFilter_data() | 
| 1002 | { | 
| 1003 |     QTest::addColumn<QContact>(name: "contact" ); | 
| 1004 |     QTest::addColumn<QContactFilter>(name: "filter" ); | 
| 1005 |     QTest::addColumn<bool>(name: "expected" ); | 
| 1006 |  | 
| 1007 |     { | 
| 1008 |         QContact contact; | 
| 1009 |         QContactName name; | 
| 1010 |         name.setFirstName(QStringLiteral("first" )); | 
| 1011 |         name.setMiddleName(QStringLiteral("middle" )); | 
| 1012 |         name.setLastName(QStringLiteral("last" )); | 
| 1013 |         name.setPrefix(QStringLiteral("prefix" )); | 
| 1014 |         name.setSuffix(QStringLiteral("suffix" )); | 
| 1015 |         contact.saveDetail(detail: &name); | 
| 1016 |  | 
| 1017 |         QTest::newRow(dataTag: "QContactName::match firstname" ) | 
| 1018 |                 << contact | 
| 1019 |                 << QContactName::match(name: "first" ) | 
| 1020 |                 << true; | 
| 1021 |         QTest::newRow(dataTag: "QContactName::match lastname" ) | 
| 1022 |                 << contact | 
| 1023 |                 << QContactName::match(name: "last" ) | 
| 1024 |                 << true; | 
| 1025 |         QTest::newRow(dataTag: "QContactName::match middlename" ) | 
| 1026 |                 << contact | 
| 1027 |                 << QContactName::match(name: "middle" ) | 
| 1028 |                 << true; | 
| 1029 |         QTest::newRow(dataTag: "QContactName::match prefix" ) | 
| 1030 |                 << contact | 
| 1031 |                 << QContactName::match(name: "prefix" ) | 
| 1032 |                 << true; | 
| 1033 |         QTest::newRow(dataTag: "QContactName::match suffix" ) | 
| 1034 |                 << contact | 
| 1035 |                 << QContactName::match(name: "suffix" ) | 
| 1036 |                 << true; | 
| 1037 |         QTest::newRow(dataTag: "QContactName::match first last" ) | 
| 1038 |                 << contact | 
| 1039 |                 << QContactName::match(QStringLiteral("first" ), QStringLiteral("last" )) | 
| 1040 |                 << true; | 
| 1041 |         QTest::newRow(dataTag: "QContactName::match substring" ) | 
| 1042 |                 << contact | 
| 1043 |                 << QContactName::match(QStringLiteral("irs" )) | 
| 1044 |                 << true; | 
| 1045 |         QTest::newRow(dataTag: "QContactName::match first last substring" ) | 
| 1046 |                 << contact | 
| 1047 |                 << QContactName::match(QStringLiteral("irs" ), QStringLiteral("as" )) | 
| 1048 |                 << true; | 
| 1049 |         QTest::newRow(dataTag: "QContactName::match negative" ) | 
| 1050 |                 << contact | 
| 1051 |                 << QContactName::match(name: "foo" ) | 
| 1052 |                 << false; | 
| 1053 |  | 
| 1054 |         QContactDetailFilter dfWithEmptyValue; | 
| 1055 |         dfWithEmptyValue.setDetailType(type: QContactName::Type, field: QContactName::FieldFirstName); | 
| 1056 |         dfWithEmptyValue.setMatchFlags(QContactFilter::MatchExactly); | 
| 1057 |         dfWithEmptyValue.setValue("" ); | 
| 1058 |  | 
| 1059 |         QTest::newRow(dataTag: "QContactDetailFilter exact match for empty value" ) | 
| 1060 |                 << contact | 
| 1061 |                 << (QContactFilter)dfWithEmptyValue | 
| 1062 |                 << false; | 
| 1063 |  | 
| 1064 |         QContactDetailFilter dfWithEmptyFieldName; | 
| 1065 |         dfWithEmptyFieldName.setDetailType(type: QContactName::Type); | 
| 1066 |         dfWithEmptyFieldName.setMatchFlags(QContactFilter::MatchExactly); | 
| 1067 |         dfWithEmptyFieldName.setValue("" ); | 
| 1068 |  | 
| 1069 |         QTest::newRow(dataTag: "QContactDetailFilter exact match for detail name but empty field name" ) | 
| 1070 |                 << contact | 
| 1071 |                 << (QContactFilter)dfWithEmptyFieldName | 
| 1072 |                 << true; | 
| 1073 |     } | 
| 1074 |  | 
| 1075 |     { | 
| 1076 |         QContact contact; | 
| 1077 |         QContactDisplayLabel displaylabel; | 
| 1078 |         displaylabel.setLabel("foo" ); | 
| 1079 |         contact.saveDetail(detail: &displaylabel); | 
| 1080 |         QTest::newRow(dataTag: "QContactDisplayLabel::match positive" ) | 
| 1081 |                 << contact | 
| 1082 |                 << QContactDisplayLabel::match(label: "foo" ) | 
| 1083 |                 << true; | 
| 1084 |         QTest::newRow(dataTag: "QContactDisplayLabel::match positive substring" ) | 
| 1085 |                 << contact | 
| 1086 |                 << QContactDisplayLabel::match(label: "o" ) | 
| 1087 |                 << true; | 
| 1088 |         QTest::newRow(dataTag: "QContactDisplayLabel::match negative" ) | 
| 1089 |                 << contact | 
| 1090 |                 << QContactDisplayLabel::match(label: "bar" ) | 
| 1091 |                 << false; | 
| 1092 |     } | 
| 1093 |  | 
| 1094 |     { | 
| 1095 |         QContact contact; | 
| 1096 |         QContactPhoneNumber phone; | 
| 1097 |         phone.setNumber("1234" ); | 
| 1098 |         contact.saveDetail(detail: &phone); | 
| 1099 |         QTest::newRow(dataTag: "QContactPhoneNumber::match positive" ) | 
| 1100 |                 << contact | 
| 1101 |                 << QContactPhoneNumber::match(number: "1234" ) | 
| 1102 |                 << true; | 
| 1103 |         QTest::newRow(dataTag: "QContactPhoneNumber::match negative" ) | 
| 1104 |                 << contact | 
| 1105 |                 << QContactPhoneNumber::match(number: "5678" ) | 
| 1106 |                 << false; | 
| 1107 |     } | 
| 1108 |  | 
| 1109 |     { | 
| 1110 |         QContact contact; | 
| 1111 |         QContactEmailAddress email; | 
| 1112 |         email.setEmailAddress("foo" ); | 
| 1113 |         contact.saveDetail(detail: &email); | 
| 1114 |         QTest::newRow(dataTag: "QContactEmailAddress::match positive" ) | 
| 1115 |                 << contact | 
| 1116 |                 << QContactEmailAddress::match(emailAddress: "foo" ) | 
| 1117 |                 << true; | 
| 1118 |         QTest::newRow(dataTag: "QContactEmailAddress::match positive substring" ) | 
| 1119 |                 << contact | 
| 1120 |                 << QContactEmailAddress::match(emailAddress: "o" ) | 
| 1121 |                 << true; | 
| 1122 |         QTest::newRow(dataTag: "QContactEmailAddress::match negative" ) | 
| 1123 |                 << contact | 
| 1124 |                 << QContactEmailAddress::match(emailAddress: "bar" ) | 
| 1125 |                 << false; | 
| 1126 |     } | 
| 1127 |     { | 
| 1128 |         QContact contact; | 
| 1129 |         QContactOrganization org; | 
| 1130 |         org.setDepartment(QStringList("one" )); // Single department as a stringlist | 
| 1131 |         contact.saveDetail(detail: &org); | 
| 1132 |         QContactDetailFilter df; | 
| 1133 |         df.setDetailType(type: QContactOrganization::Type, field: QContactOrganization::FieldDepartment); | 
| 1134 |  | 
| 1135 |         // First case sensitive | 
| 1136 |         df.setMatchFlags(QContactDetailFilter::MatchCaseSensitive); | 
| 1137 |         df.setValue("one" ); // this is a string | 
| 1138 |         QTest::newRow(dataTag: "QContactOrganization::match single positive against string" ) | 
| 1139 |                 << contact | 
| 1140 |                 << QContactFilter(df) | 
| 1141 |                 << true; | 
| 1142 |  | 
| 1143 |         df.setValue(QStringList("one" )); // this is a stringlist of the same length | 
| 1144 |         QTest::newRow(dataTag: "QContactOrganization::match single positive against stringlist" ) | 
| 1145 |                 << contact | 
| 1146 |                 << QContactFilter(df) | 
| 1147 |                 << true; | 
| 1148 |  | 
| 1149 |         df.setValue(QString("two" )); | 
| 1150 |         QTest::newRow(dataTag: "QContactOrganization::match negative string" ) | 
| 1151 |                 << contact | 
| 1152 |                 << QContactFilter(df) | 
| 1153 |                 << false; | 
| 1154 |  | 
| 1155 |         df.setValue(QStringList("two" )); | 
| 1156 |         QTest::newRow(dataTag: "QContactOrganization::match negative stringlist" ) | 
| 1157 |                 << contact | 
| 1158 |                 << QContactFilter(df) | 
| 1159 |                 << false; | 
| 1160 |  | 
| 1161 |         df.setValue(QString("ONE" )); | 
| 1162 |         QTest::newRow(dataTag: "QContactOrganization::match negative case sensitive string" ) | 
| 1163 |                 << contact | 
| 1164 |                 << QContactFilter(df) | 
| 1165 |                 << false; | 
| 1166 |  | 
| 1167 |         df.setValue(QStringList("ONE" )); | 
| 1168 |         QTest::newRow(dataTag: "QContactOrganization::match negative case sensitive stringlist" ) | 
| 1169 |                 << contact | 
| 1170 |                 << QContactFilter(df) | 
| 1171 |                 << false; | 
| 1172 |  | 
| 1173 |         // Now case insensitive | 
| 1174 |         df.setMatchFlags(0); | 
| 1175 |         df.setValue("one" ); // this is a string | 
| 1176 |         QTest::newRow(dataTag: "QContactOrganization::match positive insensitive against string" ) | 
| 1177 |                 << contact | 
| 1178 |                 << QContactFilter(df) | 
| 1179 |                 << true; | 
| 1180 |  | 
| 1181 |         df.setValue(QStringList("one" )); // this is a stringlist of the same length | 
| 1182 |         QTest::newRow(dataTag: "QContactOrganization::match positive insensitive against stringlist" ) | 
| 1183 |                 << contact | 
| 1184 |                 << QContactFilter(df) | 
| 1185 |                 << true; | 
| 1186 |  | 
| 1187 |         df.setValue(QString("two" )); | 
| 1188 |         QTest::newRow(dataTag: "QContactOrganization::match negative insensitive string" ) | 
| 1189 |                 << contact | 
| 1190 |                 << QContactFilter(df) | 
| 1191 |                 << false; | 
| 1192 |  | 
| 1193 |         df.setValue(QStringList("two" )); | 
| 1194 |         QTest::newRow(dataTag: "QContactOrganization::match negative insensitive stringlist" ) | 
| 1195 |                 << contact | 
| 1196 |                 << QContactFilter(df) | 
| 1197 |                 << false; | 
| 1198 |  | 
| 1199 |         df.setValue(QString("ONE" )); | 
| 1200 |         QTest::newRow(dataTag: "QContactOrganization::match positive case insensitive string 2" ) | 
| 1201 |                 << contact | 
| 1202 |                 << QContactFilter(df) | 
| 1203 |                 << true; | 
| 1204 |  | 
| 1205 |         df.setValue(QStringList("ONE" )); | 
| 1206 |         QTest::newRow(dataTag: "QContactOrganization::match positive case insensitive stringlist 2" ) | 
| 1207 |                 << contact | 
| 1208 |                 << QContactFilter(df) | 
| 1209 |                 << true; | 
| 1210 |     } | 
| 1211 | } | 
| 1212 |  | 
| 1213 | void tst_QContactFilter::collectionFilter() | 
| 1214 | { | 
| 1215 |     QContactCollectionFilter icf; | 
| 1216 |  | 
| 1217 |     QVERIFY(icf.collectionIds().isEmpty()); | 
| 1218 |  | 
| 1219 |     QContactCollectionId id1 = makeCollectionId(id: 5); | 
| 1220 |     QContactCollectionId id2 = makeCollectionId(id: 6); | 
| 1221 |     QContactCollectionId id3 = makeCollectionId(id: 7); | 
| 1222 |     QContactCollectionId id4 = makeCollectionId(id: 12); | 
| 1223 |     QSet<QContactCollectionId> ids; | 
| 1224 |     ids << id1 << id2 << id3; | 
| 1225 |  | 
| 1226 |     icf.setCollectionIds(ids); | 
| 1227 |     QVERIFY(icf.collectionIds() == ids); | 
| 1228 |  | 
| 1229 |     icf.setCollectionId(id4); | 
| 1230 |     ids.clear(); | 
| 1231 |     ids << id4; | 
| 1232 |     QVERIFY(icf.collectionIds() == ids); | 
| 1233 |  | 
| 1234 |     QContactCollectionFilter icf2; | 
| 1235 |     icf2 = icf; | 
| 1236 |     QVERIFY(icf2.collectionIds() == ids); | 
| 1237 |  | 
| 1238 |     QContactFilter fil; | 
| 1239 |     fil = icf; | 
| 1240 |     QVERIFY(fil.type() == QContactFilter::CollectionFilter); | 
| 1241 |  | 
| 1242 |     QContactCollectionFilter icf3(fil); | 
| 1243 |     QVERIFY(fil.type() == QContactFilter::CollectionFilter); | 
| 1244 |     QVERIFY(icf3.collectionIds() == ids); | 
| 1245 | } | 
| 1246 |  | 
| 1247 | void tst_QContactFilter::datastream() | 
| 1248 | { | 
| 1249 |     QFETCH(QContactFilter, filterIn); | 
| 1250 |  | 
| 1251 |     QByteArray buffer; | 
| 1252 |     QDataStream stream1(&buffer, QIODevice::WriteOnly); | 
| 1253 |     stream1 << filterIn; | 
| 1254 |  | 
| 1255 |     QVERIFY(buffer.size() > 0); | 
| 1256 |  | 
| 1257 |     QDataStream stream2(buffer); | 
| 1258 |     QContactFilter filterOut; | 
| 1259 |     stream2 >> filterOut; | 
| 1260 |     QCOMPARE(filterOut, filterIn); | 
| 1261 | } | 
| 1262 |  | 
| 1263 | void tst_QContactFilter::datastream_data() | 
| 1264 | { | 
| 1265 |     QTest::addColumn<QContactFilter>(name: "filterIn" ); | 
| 1266 |  | 
| 1267 |     { | 
| 1268 |         QContactFilter filter; | 
| 1269 |         QTest::newRow(dataTag: "default" ) << filter; | 
| 1270 |     } | 
| 1271 |  | 
| 1272 |     { | 
| 1273 |         QContactActionFilter filter; | 
| 1274 |         filter.setActionName("action name" ); | 
| 1275 |         QTest::newRow(dataTag: "action" ) << (QContactFilter)filter; | 
| 1276 |     } | 
| 1277 |  | 
| 1278 |     { | 
| 1279 |         QContactChangeLogFilter filter; | 
| 1280 |         filter.setEventType(QContactChangeLogFilter::EventAdded); | 
| 1281 |         filter.setSince(QDateTime(QDate(2010, 6, 1), QTime(1, 2, 3))); | 
| 1282 |         QTest::newRow(dataTag: "changelog" ) << (QContactFilter)filter; | 
| 1283 |     } | 
| 1284 |  | 
| 1285 |     { | 
| 1286 |         QContactDetailFilter filter; | 
| 1287 |         filter.setDetailType(type: QContactDetail::TypeAddress, field: QContactPhoneNumber::FieldNumber); | 
| 1288 |         filter.setMatchFlags(QContactFilter::MatchEndsWith); | 
| 1289 |         filter.setValue("ski" ); | 
| 1290 |         QTest::newRow(dataTag: "detail" ) << (QContactFilter)filter; | 
| 1291 |     } | 
| 1292 |  | 
| 1293 |     { | 
| 1294 |         QContactIntersectionFilter filter; | 
| 1295 |         QTest::newRow(dataTag: "intersection" ) << (QContactFilter)filter; | 
| 1296 |     } | 
| 1297 |  | 
| 1298 |     { | 
| 1299 |         QContactInvalidFilter filter; | 
| 1300 |         QTest::newRow(dataTag: "invalid" ) << (QContactFilter)filter; | 
| 1301 |     } | 
| 1302 |  | 
| 1303 |     { | 
| 1304 |         QContactIdFilter filter; | 
| 1305 |         filter.setIds(QList<QContactId>() << QContactId() << QContactId() << QContactId()); | 
| 1306 |         QTest::newRow(dataTag: "localid" ) << (QContactFilter)filter; | 
| 1307 |     } | 
| 1308 |  | 
| 1309 |     { | 
| 1310 |         QContactRelationshipFilter filter; | 
| 1311 |         filter.setRelationshipType("member" ); | 
| 1312 |         filter.setRelatedContactId(QContactId()); | 
| 1313 |         filter.setRelatedContactRole(QContactRelationship::First); | 
| 1314 |         QTest::newRow(dataTag: "relationship" ) << (QContactFilter)filter; | 
| 1315 |     } | 
| 1316 |  | 
| 1317 |     { | 
| 1318 |         QContactUnionFilter filter; | 
| 1319 |         QTest::newRow(dataTag: "union" ) << (QContactFilter)filter; | 
| 1320 |     } | 
| 1321 | } | 
| 1322 |  | 
| 1323 | void tst_QContactFilter::testDebugStreamOut() | 
| 1324 | { | 
| 1325 |     QFETCH(QContactFilter, filterIn); | 
| 1326 |     QFETCH(QString, messageExpected); | 
| 1327 |  | 
| 1328 |     QTest::ignoreMessage(type: QtDebugMsg, message: messageExpected.toUtf8()); | 
| 1329 |     qDebug() << filterIn; | 
| 1330 | } | 
| 1331 |  | 
| 1332 | void tst_QContactFilter::testDebugStreamOut_data() | 
| 1333 | { | 
| 1334 |     QTest::addColumn<QContactFilter>(name: "filterIn" ); | 
| 1335 |     QTest::addColumn<QString>(name: "messageExpected" ); | 
| 1336 |  | 
| 1337 |     { | 
| 1338 |         QContactCollectionFilter filter; | 
| 1339 |         QContactCollectionId id1 = makeCollectionId(id: 5); | 
| 1340 |         QContactCollectionId id2 = makeCollectionId(id: 6); | 
| 1341 |         QContactCollectionId id3 = makeCollectionId(id: 7); | 
| 1342 |         QContactCollectionId id4 = makeCollectionId(id: 12); | 
| 1343 |         QSet<QContactCollectionId> ids; | 
| 1344 |         ids << id1 << id2 << id3; | 
| 1345 |         filter.setCollectionIds(ids); | 
| 1346 |         // Testing method setCollectionIds | 
| 1347 |         QTest::newRow(dataTag: "collection" ) << (QContactFilter)filter << "QContactFilter(QContactCollectionFilter(collectionIds=(QContactCollectionId(qtcontacts:basic::05000000), QContactCollectionId(qtcontacts:basic::06000000), QContactCollectionId(qtcontacts:basic::07000000))))" ; | 
| 1348 |  | 
| 1349 |         filter.setCollectionId(id2); | 
| 1350 |         // Testing method setCollectionId (and the related clearing of the collection) | 
| 1351 |         QTest::newRow(dataTag: "collection" ) << (QContactFilter)filter << "QContactFilter(QContactCollectionFilter(collectionIds=(QContactCollectionId(qtcontacts:basic::06000000))))" ; | 
| 1352 |         filter.setCollectionId(id4); | 
| 1353 |         // Testing again method setCollectionId (and the related clearing of the collection) | 
| 1354 |         QTest::newRow(dataTag: "collection" ) << (QContactFilter)filter << "QContactFilter(QContactCollectionFilter(collectionIds=(QContactCollectionId(qtcontacts:basic::0c000000))))" ; | 
| 1355 |         ids.clear(); | 
| 1356 |         ids << id4; | 
| 1357 |         // Testing again method setCollectionIds | 
| 1358 |         QTest::newRow(dataTag: "collection" ) << (QContactFilter)filter << "QContactFilter(QContactCollectionFilter(collectionIds=(QContactCollectionId(qtcontacts:basic::0c000000))))" ; | 
| 1359 |  | 
| 1360 |         QContactCollectionFilter filter2; | 
| 1361 |         filter2 = filter; | 
| 1362 |         // Testing again method setCollectionIds on the copied filter | 
| 1363 |         QTest::newRow(dataTag: "collection" ) << (QContactFilter)filter2 << "QContactFilter(QContactCollectionFilter(collectionIds=(QContactCollectionId(qtcontacts:basic::0c000000))))" ; | 
| 1364 |  | 
| 1365 |         QContactFilter fil; | 
| 1366 |         fil = filter; | 
| 1367 |         // Testing that the assignment/conversion went fine | 
| 1368 |         QTest::newRow(dataTag: "collection" ) << (QContactFilter)fil << "QContactFilter(QContactCollectionFilter(collectionIds=(QContactCollectionId(qtcontacts:basic::0c000000))))" ; | 
| 1369 |  | 
| 1370 |         QContactCollectionFilter filter3(fil); | 
| 1371 |         QTest::newRow(dataTag: "collection" ) << (QContactFilter)filter3 << "QContactFilter(QContactCollectionFilter(collectionIds=(QContactCollectionId(qtcontacts:basic::0c000000))))" ; | 
| 1372 |     } | 
| 1373 | } | 
| 1374 |  | 
| 1375 | void tst_QContactFilter::traits() | 
| 1376 | { | 
| 1377 |     QCOMPARE(sizeof(QContactFilter), sizeof(void *)); | 
| 1378 |     QVERIFY(QTypeInfo<QContactFilter>::isComplex); | 
| 1379 |     QVERIFY(!QTypeInfo<QContactFilter>::isStatic); | 
| 1380 |     QVERIFY(!QTypeInfo<QContactFilter>::isLarge); | 
| 1381 |     QVERIFY(!QTypeInfo<QContactFilter>::isPointer); | 
| 1382 |     QVERIFY(!QTypeInfo<QContactFilter>::isDummy); | 
| 1383 |  | 
| 1384 |     QCOMPARE(sizeof(QContactDetailFilter), sizeof(void*)); | 
| 1385 |     QCOMPARE(sizeof(QContactChangeLogFilter), sizeof(void*)); | 
| 1386 | } | 
| 1387 |  | 
| 1388 | QTEST_MAIN(tst_QContactFilter) | 
| 1389 | #include "tst_qcontactfilter.moc" | 
| 1390 |  |