コード例 #1
0
ファイル: calendarurltest.cpp プロジェクト: KDE/kcontacts
void CalendarUrlTest::shouldGenerateVCardWithParameter()
{
    KContacts::AddresseeList lst;
    KContacts::Addressee addr;
    addr.setEmails(QStringList() << QStringLiteral("*****@*****.**"));
    addr.setUid(QStringLiteral("testuid"));
    CalendarUrl url;
    url.setType(CalendarUrl::CALUri);
    url.setUrl(QUrl(QStringLiteral("https://sherlockholmes.com/calendar/sherlockholmes")));
    QMap<QString, QStringList> params;
    params.insert(QStringLiteral("Foo2"), QStringList() << QStringLiteral("bla2") << QStringLiteral("blo2"));
    url.setParameters(params);
    addr.insertCalendarUrl(url);
    lst << addr;
    KContacts::VCardTool vcard;
    const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v4_0);
    QByteArray expected = QByteArray("BEGIN:VCARD\r\n"
                                     "VERSION:4.0\r\n"
                                     "CALURI;FOO2=bla2,blo2:https://sherlockholmes.com/calendar/sherlockholmes\r\n"
                                     "EMAIL:[email protected]\r\n"
                                     "N:;;;;\r\n"
                                     "UID:testuid\r\n"
                                     "END:VCARD\r\n\r\n");
    QCOMPARE(ba, expected);
}
コード例 #2
0
ファイル: calendarurltest.cpp プロジェクト: KDE/kcontacts
void CalendarUrlTest::shouldGenerateVCard()
{
    QFETCH(KContacts::CalendarUrl::CalendarType, type);
    QFETCH(QByteArray, value);

    KContacts::AddresseeList lst;
    KContacts::Addressee addr;
    addr.setEmails(QStringList() << QStringLiteral("*****@*****.**"));
    addr.setUid(QStringLiteral("testuid"));
    CalendarUrl url;
    url.setType(type);
    url.setUrl(QUrl(QStringLiteral("https://sherlockholmes.com/calendar/sherlockholmes")));
    addr.insertCalendarUrl(url);
    lst << addr;
    KContacts::VCardTool vcard;
    const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v4_0);
    QByteArray expected;
    // Different order
    if (type == KContacts::CalendarUrl::FBUrl) {
        expected = QByteArray("BEGIN:VCARD\r\n"
                              "VERSION:4.0\r\n"
                              "EMAIL:[email protected]\r\n");
        expected += value + QByteArray(":https://sherlockholmes.com/calendar/sherlockholmes\r\n"
                                       "N:;;;;\r\n"
                                       "UID:testuid\r\n"
                                       "END:VCARD\r\n\r\n");
    } else {
        expected = QByteArray("BEGIN:VCARD\r\n"
                              "VERSION:4.0\r\n");
        expected += value + QByteArray(":https://sherlockholmes.com/calendar/sherlockholmes\r\n"
                                       "EMAIL:[email protected]\r\n"
                                       "N:;;;;\r\n"
                                       "UID:testuid\r\n"
                                       "END:VCARD\r\n\r\n");
    }

    QCOMPARE(ba, expected);
}