void tst_QOrganizerItemDetails::audibleReminder() { QOrganizerItemAudibleReminder r; QOrganizerItem oi; QVERIFY(r.isEmpty()); QVERIFY(r.reminderType() == QOrganizerItemReminder::AudibleReminder); QVERIFY(r.secondsBeforeStart() == 0); QVERIFY(r.repetitionCount() == 0); QVERIFY(r.repetitionDelay() == 0); r.setSecondsBeforeStart(45); QVERIFY(!r.isEmpty()); r.removeValue(QOrganizerItemReminder::FieldSecondsBeforeStart); QVERIFY(r.isEmpty()); QOrganizerItemReminder baseR; baseR = r; QVERIFY(baseR.isEmpty()); baseR.setSecondsBeforeStart(50); QVERIFY(baseR.secondsBeforeStart() == 50); QVERIFY(r.secondsBeforeStart() == 0); QVERIFY(!baseR.isEmpty()); QVERIFY(r.isEmpty()); r.setRepetition(3, 100); QVERIFY(r.repetitionCount() == 3); QVERIFY(r.repetitionDelay() == 100); QVERIFY(!r.isEmpty()); r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start. QVERIFY(r.secondsBeforeStart() == 30); // add QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 0); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeAudibleReminder) == r); // update r.setSecondsBeforeStart(300); r.setDataUrl(QUrl("http://www.test.com")); QVERIFY(r.dataUrl() == QUrl("http://www.test.com")); QVERIFY(oi.detail(QOrganizerItemDetail::TypeAudibleReminder) != r); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 1); // should update, not add another QVERIFY(oi.detail(QOrganizerItemDetail::TypeAudibleReminder) == r); // remove QVERIFY(oi.removeDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 0); }
void tst_QOrganizerItemDetails::attendee() { QOrganizerEventAttendee a; QOrganizerItem oi; QVERIFY(a.isEmpty()); QVERIFY(a.name().isEmpty()); QVERIFY(a.emailAddress().isEmpty()); QVERIFY(a.attendeeId().isEmpty()); QVERIFY(a.participationRole() == 0); QVERIFY(a.participationStatus() == 0); a.setAttendeeId("123456"); QVERIFY(a.attendeeId() == QString("123456")); a.setEmailAddress("*****@*****.**"); QVERIFY(a.emailAddress() == QString("*****@*****.**")); a.setName("people"); QVERIFY(a.name() == QString("people")); a.setParticipationRole(QOrganizerEventAttendee::RoleRequiredParticipant); QVERIFY(a.participationRole() == QOrganizerEventAttendee::RoleRequiredParticipant); a.setParticipationStatus(QOrganizerEventAttendee::StatusAccepted); QVERIFY(a.participationStatus() == QOrganizerEventAttendee::StatusAccepted); // add QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 0); QVERIFY(oi.saveDetail(&a)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventAttendee) == a); // update a.setAttendeeId("54321"); a.setName("newpeople"); a.setEmailAddress("*****@*****.**"); QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventAttendee) != a); QVERIFY(oi.saveDetail(&a)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventAttendee) == a); // add one more attendee QOrganizerEventAttendee a1; a1.setAttendeeId("777777"); a1.setName("people1"); a1.setEmailAddress("*****@*****.**"); QVERIFY(oi.saveDetail(&a1)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 2); // remove QVERIFY(oi.removeDetail(&a)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 1); QVERIFY(oi.removeDetail(&a1)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 0); }
void tst_QOrganizerItemDetails::displayLabel() { QOrganizerItemDisplayLabel d1; QOrganizerItem oi; QVERIFY(d1.label().isEmpty()); QVERIFY(d1.value(QOrganizerItemDisplayLabel::FieldLabel).isNull()); d1.setValue(QOrganizerItemDisplayLabel::FieldLabel, "Test"); QVERIFY(d1.value(QOrganizerItemDisplayLabel::FieldLabel) == QString("Test")); QVERIFY(d1.label() == QString("Test")); QOrganizerItemDisplayLabel d2; d2.setValue(QOrganizerItemDisplayLabel::FieldLabel, "Test 2"); // test property add - should update. QVERIFY(oi.saveDetail(&d2)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 1); QVERIFY(oi.saveDetail(&d1)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 1); // test property update - should update d1.setLabel("Test 3"); QVERIFY(oi.saveDetail(&d1)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeDisplayLabel).value(QOrganizerItemDisplayLabel::FieldLabel) == QString("Test 3")); // test property remove QVERIFY(oi.removeDetail(&d1)); // can remove display label. it's unique but not required. QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 0); }
void tst_QOrganizerItemDetails::description() { QOrganizerItemDescription d1; QOrganizerItem oi; QVERIFY(d1.description().isEmpty()); QVERIFY(d1.value(QOrganizerItemDescription::FieldDescription).isNull()); d1.setValue(QOrganizerItemDescription::FieldDescription, "Test"); QVERIFY(d1.value(QOrganizerItemDescription::FieldDescription) == QString("Test")); QVERIFY(d1.description() == QString("Test")); QOrganizerItemDescription d2; d2.setValue(QOrganizerItemDescription::FieldDescription, "Test 2"); // test property add -- description is unique. QVERIFY(oi.saveDetail(&d2)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 1); // count should be 1 QVERIFY(oi.saveDetail(&d1)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 1); // count should be 1 // test property update d1.setDescription("Test 3"); QVERIFY(oi.saveDetail(&d1)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 1); // count should be 1 QVERIFY(oi.detail(QOrganizerItemDetail::TypeDescription).value(QOrganizerItemDescription::FieldDescription) == QString("Test 3")); // test property remove QVERIFY(oi.removeDetail(&d1)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 0); }
void tst_QOrganizerItemDetails::emailReminder() { QOrganizerItemEmailReminder r; QOrganizerItem oi; QVERIFY(r.isEmpty()); QVERIFY(r.reminderType() == QOrganizerItemReminder::EmailReminder); QVERIFY(r.secondsBeforeStart() == 0); QVERIFY(r.repetitionCount() == 0); QVERIFY(r.repetitionDelay() == 0); r.setRepetition(3, 100); QVERIFY(r.repetitionCount() == 3); QVERIFY(r.repetitionDelay() == 100); QVERIFY(!r.isEmpty()); r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start. QVERIFY(r.secondsBeforeStart() == 30); // add QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 0); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeEmailReminder) == r); // update r.setSecondsBeforeStart(300); r.setContents("subject", "body", QVariantList()); r.setRecipients(QStringList() << "recipient" << "other recipient"); QVERIFY(r.subject() == QString("subject")); QVERIFY(r.body() == QString("body")); QVERIFY(r.attachments() == QVariantList()); QVERIFY(r.recipients() == (QStringList() << "recipient" << "other recipient")); QVERIFY(oi.detail(QOrganizerItemDetail::TypeEmailReminder) != r); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 1); // should update, not add another QVERIFY(oi.detail(QOrganizerItemDetail::TypeEmailReminder) == r); // remove QVERIFY(oi.removeDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 0); }
void tst_QOrganizerItemDetails::reminder() { QOrganizerItemReminder r; QOrganizerItem oi; QVERIFY(r.isEmpty()); QVERIFY(r.reminderType() == QOrganizerItemReminder::NoReminder); QVERIFY(r.secondsBeforeStart() == 0); QVERIFY(r.repetitionCount() == 0); QVERIFY(r.repetitionDelay() == 0); r.setSecondsBeforeStart(45); QVERIFY(!r.isEmpty()); r.removeValue(QOrganizerItemReminder::FieldSecondsBeforeStart); QVERIFY(r.isEmpty()); r.setRepetition(3, 100); QVERIFY(r.repetitionCount() == 3); QVERIFY(r.repetitionDelay() == 100); QVERIFY(!r.isEmpty()); r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start. QVERIFY(r.secondsBeforeStart() == 30); // add QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 0); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeReminder) == r); // update r.setSecondsBeforeStart(300); QVERIFY(oi.detail(QOrganizerItemDetail::TypeReminder) != r); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 1); // should update, not add another QVERIFY(oi.detail(QOrganizerItemDetail::TypeReminder) == r); // remove QVERIFY(oi.removeDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 0); }
void tst_QOrganizerItemDetails::visualReminder() { QOrganizerItemVisualReminder r; QOrganizerItem oi; QVERIFY(r.isEmpty()); QVERIFY(r.reminderType() == QOrganizerItemReminder::VisualReminder); QVERIFY(r.secondsBeforeStart() == 0); QVERIFY(r.repetitionCount() == 0); QVERIFY(r.repetitionDelay() == 0); r.setRepetition(3, 100); QVERIFY(r.repetitionCount() == 3); QVERIFY(r.repetitionDelay() == 100); QVERIFY(!r.isEmpty()); r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start. QVERIFY(r.secondsBeforeStart() == 30); // add QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 0); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeVisualReminder) == r); // update r.setSecondsBeforeStart(300); r.setMessage("test"); r.setDataUrl(QUrl("http://www.test.com")); QVERIFY(r.message() == QString("test")); QVERIFY(r.dataUrl() == QUrl("http://www.test.com")); QVERIFY(oi.detail(QOrganizerItemDetail::TypeVisualReminder) != r); QVERIFY(oi.saveDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 1); // should update, not add another QVERIFY(oi.detail(QOrganizerItemDetail::TypeVisualReminder) == r); // remove QVERIFY(oi.removeDetail(&r)); QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 0); }
void tst_QOrganizerItemDetails::priority() { QOrganizerItemPriority p; QOrganizerItem oi; QVERIFY(p.isEmpty()); p.setValue(QOrganizerItemPriority::FieldPriority, QOrganizerItemPriority::VeryHighPriority); QVERIFY(p.priority() == QOrganizerItemPriority::VeryHighPriority); QVERIFY(oi.saveDetail(&p)); QVERIFY(oi.details(QOrganizerItemDetail::TypePriority).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypePriority) == p); p.setPriority(QOrganizerItemPriority::VeryLowPriority); QVERIFY(oi.detail(QOrganizerItemDetail::TypePriority) != p); QVERIFY(oi.saveDetail(&p)); QVERIFY(oi.details(QOrganizerItemDetail::TypePriority).size() == 1); // update shouldn't add another detail. QVERIFY(oi.detail(QOrganizerItemDetail::TypePriority) == p); QVERIFY(oi.removeDetail(&p)); QVERIFY(oi.details(QOrganizerItemDetail::TypePriority).size() == 0); }
void tst_QOrganizerItemDetails::location() { QOrganizerItemLocation l1; QOrganizerItem oi; QVERIFY(l1.isEmpty()); l1.setLatitude(89.999); QVERIFY(!l1.isEmpty()); QVERIFY(l1.latitude() == 89.999); l1.setValue(QOrganizerItemLocation::FieldLatitude, -89.12345); QVERIFY(l1.value(QOrganizerItemLocation::FieldLatitude) == -89.12345); l1.setLatitude(-90.12345); l1.setLatitude(91); QVERIFY(l1.latitude() == -89.12345); l1.setLongitude(179); QVERIFY(l1.longitude() == 179); l1.setValue(QOrganizerItemLocation::FieldLongitude, -179.54321); QVERIFY(l1.value(QOrganizerItemLocation::FieldLongitude) == -179.54321); l1.setLongitude(180.1); l1.setLongitude(-180.1); QVERIFY(l1.longitude() == -179.54321); l1.setLabel("test"); QVERIFY(l1.label() == QString("test")); QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 0); QVERIFY(oi.saveDetail(&l1)); QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeLocation) == l1); l1.setLabel("test 2"); QVERIFY(oi.detail(QOrganizerItemDetail::TypeLocation) != l1); QVERIFY(oi.saveDetail(&l1)); // update. QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 1); // should update, not add another. QVERIFY(oi.detail(QOrganizerItemDetail::TypeLocation) == l1); oi.removeDetail(&l1); QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 0); }
void tst_QOrganizerItemDetails::classification() { QOrganizerItemClassification classification; QOrganizerItem oi; QVERIFY(classification.isEmpty()); // setters/getters classification.setClassification(QOrganizerItemClassification::AccessPublic); QVERIFY(classification.classification() == QOrganizerItemClassification::AccessPublic); classification.setClassification(QOrganizerItemClassification::AccessPrivate); QVERIFY(classification.classification() == QOrganizerItemClassification::AccessPrivate); classification.setClassification(QOrganizerItemClassification::AccessConfidential); QVERIFY(classification.classification() == QOrganizerItemClassification::AccessConfidential); // add QCOMPARE(0, oi.details(QOrganizerItemDetail::TypeClassification).size()); QVERIFY(oi.saveDetail(&classification)); QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeClassification).size()); QCOMPARE(classification, static_cast<QOrganizerItemClassification>(oi.detail(QOrganizerItemDetail::TypeClassification))); // update classification.setValue(QOrganizerItemClassification::FieldClassification, QOrganizerItemClassification::AccessPrivate); QVERIFY(oi.detail(QOrganizerItemDetail::TypeClassification) != classification); QVERIFY(oi.saveDetail(&classification)); QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeClassification).size()); QVERIFY(oi.detail(QOrganizerItemDetail::TypeClassification) == classification); // try adding another, amount of details should stay the same QOrganizerItemClassification classification2; classification2.setClassification(QOrganizerItemClassification::AccessConfidential); QVERIFY(oi.saveDetail(&classification2)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeClassification).size(), 1); // remove QVERIFY(oi.removeDetail(&classification2)); QCOMPARE(oi.details(QOrganizerItemDetail::TypeClassification).size(), 0); }
void tst_QOrganizerItemDetails::parent() { QOrganizerItemParent p; QOrganizerItem oi; // hrm, how to test parent local id? QVERIFY(p.isEmpty()); p.setOriginalDate(QDate(2010, 10, 13)); QVERIFY(p.originalDate() == QDate(2010, 10, 13)); QVERIFY(!p.isEmpty()); QVERIFY(oi.saveDetail(&p)); QVERIFY(oi.details(QOrganizerItemDetail::TypeParent).size() == 1); QVERIFY(oi.detail(QOrganizerItemDetail::TypeParent) == p); p.setOriginalDate(QDate(2010, 10, 14)); QVERIFY(oi.detail(QOrganizerItemDetail::TypeParent) != p); QVERIFY(oi.saveDetail(&p)); // update QVERIFY(oi.detail(QOrganizerItemDetail::TypeParent) == p); QVERIFY(oi.removeDetail(&p)); QVERIFY(oi.details(QOrganizerItemDetail::TypeParent).size() == 0); }
detailKeys.clear(); foreach (const QOrganizerItemDetail& det, allDetails) { int currKey = det.key(); QVERIFY(!detailKeys.contains(currKey)); detailKeys.append(currKey); } // now test for default construction sanity QOrganizerItem oi; // Test there are no details (apart from type) by default QVERIFY(oi.isEmpty() == true); QCOMPARE(oi.details().count(), 1); QCOMPARE(oi.details(QOrganizerItemLocation::DefinitionName).count(), 0); QCOMPARE(oi.details<QOrganizerItemLocation>().count(), 0); QVERIFY(oi.detail(QOrganizerItemLocation::DefinitionName).isEmpty()); QVERIFY(oi.detail<QOrganizerItemLocation>().isEmpty()); QCOMPARE(oi.details(QOrganizerItemLocation::DefinitionName.latin1()).count(), 0); QVERIFY(oi.detail(QOrganizerItemLocation::DefinitionName.latin1()).isEmpty()); QCOMPARE(oi.details(QLatin1String(QOrganizerItemLocation::DefinitionName)).count(), 0); QVERIFY(oi.detail(QLatin1String(QOrganizerItemLocation::DefinitionName)).isEmpty()); // Test retrieving the default details (type) QList<QOrganizerItemDetail> details = oi.details(QString()); QVERIFY(details.at(0).definitionName() == QOrganizerItemType::DefinitionName); QOrganizerItemDetail detail = oi.detail("nonexistent"); QVERIFY(detail.isEmpty()); QVERIFY(detail.definitionName().isEmpty()); // retrieve the first detail using the empty definition name accessor.
void tst_QOrganizerItemDetails::rsvp() { QOrganizerEventRsvp rsvp; QOrganizerItem oi; QVERIFY(rsvp.isEmpty()); QVERIFY(rsvp.organizerName().isEmpty()); QVERIFY(rsvp.organizerEmail().isEmpty()); QVERIFY(rsvp.responseDate().isNull()); QVERIFY(!rsvp.responseDate().isValid()); QVERIFY(rsvp.responseDeadline().isNull()); QVERIFY(!rsvp.responseDeadline().isValid()); QVERIFY(rsvp.participationRole() == 0); QVERIFY(rsvp.participationStatus() == 0); QVERIFY(rsvp.responseRequirement() == 0); rsvp.setOrganizerName("Donald Duck"); QVERIFY(rsvp.organizerName() == QString("Donald Duck")); rsvp.setOrganizerEmail("*****@*****.**"); QVERIFY(rsvp.organizerEmail() == QString("*****@*****.**")); QDate testDate(2010, 10, 10); rsvp.setResponseDate(testDate); QVERIFY(!rsvp.responseDate().isNull()); QVERIFY(rsvp.responseDate().isValid()); QCOMPARE(testDate, rsvp.responseDate()); rsvp.setResponseDeadline(testDate); QVERIFY(!rsvp.responseDeadline().isNull()); QVERIFY(rsvp.responseDeadline().isValid()); QCOMPARE(testDate, rsvp.responseDeadline()); rsvp.setParticipationRole(QOrganizerEventAttendee::RoleOrganizer); QVERIFY(rsvp.participationRole() == QOrganizerEventAttendee::RoleOrganizer); rsvp.setParticipationStatus(QOrganizerEventAttendee::StatusAccepted); QVERIFY(rsvp.participationStatus() == QOrganizerEventAttendee::StatusAccepted); rsvp.setResponseRequirement(QOrganizerEventRsvp::ResponseRequired); QVERIFY(rsvp.responseRequirement() == QOrganizerEventRsvp::ResponseRequired); // add QCOMPARE(0, oi.details(QOrganizerItemDetail::TypeEventRsvp).size()); QVERIFY(oi.saveDetail(&rsvp)); QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeEventRsvp).size()); QVERIFY(rsvp == oi.detail(QOrganizerItemDetail::TypeEventRsvp)); // update rsvp.setOrganizerName("Mickey Mouse"); rsvp.setOrganizerEmail("*****@*****.**"); QDate testDate2(2011, 11, 11); rsvp.setResponseDate(testDate2); rsvp.setResponseDeadline(testDate2); rsvp.setParticipationRole(QOrganizerEventAttendee::RoleChairperson); rsvp.setParticipationStatus(QOrganizerEventAttendee::StatusDelegated); rsvp.setResponseRequirement(QOrganizerEventRsvp::ResponseNotRequired); QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventRsvp) != rsvp); QVERIFY(oi.saveDetail(&rsvp)); QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeEventRsvp).size()); QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventRsvp) == rsvp); // add another rsvp - not supported by all the backends QOrganizerEventRsvp rsvp2; rsvp2.setOrganizerName("Goofy"); QVERIFY(oi.saveDetail(&rsvp2)); QCOMPARE(2, oi.details(QOrganizerItemDetail::TypeEventRsvp).size()); // remove QVERIFY(oi.removeDetail(&rsvp2)); QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeEventRsvp).size()); QVERIFY(oi.removeDetail(&rsvp)); QCOMPARE(0, oi.details(QOrganizerItemDetail::TypeEventRsvp).size()); }