diff options
author | Chris Adams <chris.adams@jollamobile.com> | 2015-11-02 21:08:16 +1000 |
---|---|---|
committer | Christopher Adams <chris.adams@jollamobile.com> | 2015-11-12 01:24:10 +0000 |
commit | 480303e8ee89fb1d39b4f00f77559f3021e2ccae (patch) | |
tree | d94f0f920082b434ac8c42d33ce1ae6f181ae4d4 /tests | |
parent | 6ff25f70afa5b4cdb84845b29c8b01371b7d3e19 (diff) |
QtContacts: detail-leaf-class API improvements
This commit improves the API of various detail leaf classes by adding
support for more commonly-required fields.
It also fixes the QContactGender class so that the enum definitions
are sensible and consistent with the rest of the API.
Finally, it adds support for providing per-detail provenance
information, to enable the Aggregate/Facet contact story.
Change-Id: Idf465f99963d372ec4f0d439cf9f3be8a7823202
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp | 7 | ||||
-rw-r--r-- | tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp b/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp index 5fb75b6e0..a96550596 100644 --- a/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp +++ b/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp @@ -224,6 +224,13 @@ void tst_QContactDetail::assignment() p1 = p2; QVERIFY(p1 == p2); + QContactManagerEngine::setDetailProvenance(&p2, QStringLiteral("test-provenance")); + QCOMPARE(p2.provenance(), QStringLiteral("test-provenance")); + QCOMPARE(p1.provenance(), QString()); + QVERIFY(p1 == p2); // provenance shouldn't affect comparison + p1 = p2; // but should be copied on copy/assignment + QCOMPARE(p2.provenance(), p1.provenance()); + QContactEmailAddress e1; e1.setEmailAddress("test@nokia.com"); QVERIFY(e1 != p1); diff --git a/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp b/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp index bae8bdbb6..26f7d80b9 100644 --- a/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp +++ b/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp @@ -247,10 +247,13 @@ void tst_QContactDetails::avatar() QCOMPARE(a1.value<QUrl>(QContactAvatar::FieldImageUrl), QUrl("1234")); a2.setVideoUrl(QUrl("videoUrl")); a2.setImageUrl(QUrl("imageUrl")); + a2.setMetaData(QString("1234")); QCOMPARE(a2.videoUrl(), QUrl("videoUrl")); QCOMPARE(a2.value<QUrl>(QContactAvatar::FieldVideoUrl), QUrl("videoUrl")); QCOMPARE(a2.imageUrl(), QUrl("imageUrl")); QCOMPARE(a2.value<QUrl>(QContactAvatar::FieldImageUrl), QUrl("imageUrl")); + QCOMPARE(a2.metaData(), QString("1234")); + QCOMPARE(a2.value<QString>(QContactAvatar::FieldMetaData), QString("1234")); // test property add QVERIFY(c.saveDetail(&a1)); @@ -750,11 +753,13 @@ void tst_QContactDetails::name() n1.setMiddleName("William Preston"); n1.setLastName("Gumboots"); n1.setSuffix("Esquire"); + n1.setCustomLabel("Frederick The Example"); QCOMPARE(n1.prefix(), QString("Dr")); QCOMPARE(n1.firstName(), QString("Freddy")); QCOMPARE(n1.middleName(), QString("William Preston")); QCOMPARE(n1.lastName(), QString("Gumboots")); QCOMPARE(n1.suffix(), QString("Esquire")); + QCOMPARE(n1.customLabel(), QString("Frederick The Example")); // Values based (QString) QCOMPARE(n1.value(QContactName::FieldPrefix).toString(), QString("Dr")); @@ -762,6 +767,7 @@ void tst_QContactDetails::name() QCOMPARE(n1.value(QContactName::FieldMiddleName).toString(), QString("William Preston")); QCOMPARE(n1.value(QContactName::FieldLastName).toString(), QString("Gumboots")); QCOMPARE(n1.value(QContactName::FieldSuffix).toString(), QString("Esquire")); + QCOMPARE(n1.value(QContactName::FieldCustomLabel).toString(), QString("Frederick The Example")); // test property add QVERIFY(c.saveDetail(&n1)); @@ -983,6 +989,11 @@ void tst_QContactDetails::phoneNumber() QCOMPARE(p1.number(), QString("1234")); QCOMPARE(p1.value(QContactPhoneNumber::FieldNumber).toString(), QString("1234")); + // normalized number + p1.setNormalizedNumber("123"); + QCOMPARE(p1.normalizedNumber(), QString("123")); + QCOMPARE(p1.value(QContactPhoneNumber::FieldNormalizedNumber).toString(), QString("123")); + // Sub types p1.setSubTypes(QList<int>() << QContactPhoneNumber::SubTypeCar); QCOMPARE(p1.subTypes(), QList<int>() << QContactPhoneNumber::SubTypeCar); @@ -1192,16 +1203,21 @@ void tst_QContactDetails::timestamp() QContactTimestamp t1, t2; QDateTime modified = QDateTime::currentDateTime(); QDateTime created = modified.addSecs(-43); + QDateTime deleted = modified.addSecs(20); // test property set t1.setCreated(created); + t1.setDeleted(deleted); QCOMPARE(t1.created(), created); QCOMPARE(t1.value(QContactTimestamp::FieldCreationTimestamp).toDateTime(), created); + QCOMPARE(t1.deleted(), deleted); + QCOMPARE(t1.value(QContactTimestamp::FieldDeletionTimestamp).toDateTime(), deleted); // test property add QVERIFY(c.saveDetail(&t1)); QCOMPARE(c.details(QContactTimestamp::Type).count(), 1); QCOMPARE(QContactTimestamp(c.details(QContactTimestamp::Type).value(0)).created(), t1.created()); + QCOMPARE(QContactTimestamp(c.details(QContactTimestamp::Type).value(0)).deleted(), t1.deleted()); // test property update t1.setValue(QContactTimestamp::FieldContext, QContactDetail::ContextWork); @@ -1210,6 +1226,7 @@ void tst_QContactDetails::timestamp() QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldContext).value<QList<int> >(), QList<int>() << QContactDetail::ContextWork); QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldCreationTimestamp).toDateTime(), created); QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldModificationTimestamp).toDateTime(), modified); + QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldDeletionTimestamp).toDateTime(), deleted); // test property remove QVERIFY(c.removeDetail(&t1)); |