Ejemplo n.º 1
0
void EmailEditWidgetTest::shouldSelectFirstEmail()
{
    EmailEditWidget widget;
    QLineEdit *lineedit = widget.findChild<QLineEdit *>(QStringLiteral("emailedit"));
    KContacts::Addressee addr;
    KContacts::Email::List lst;
    const QString firstEmail(QStringLiteral("*****@*****.**"));
    lst << KContacts::Email(firstEmail);
    lst << KContacts::Email(QStringLiteral("*****@*****.**"));
    addr.setEmailList(lst);
    widget.loadContact(addr);
    QCOMPARE(lineedit->text(), firstEmail);
}
Ejemplo n.º 2
0
void MailWidgetLister::storeContact(KContacts::Addressee &contact) const
{
    const QList<QWidget *> widgetList = widgets();
    KContacts::Email::List emailList;
    emailList.reserve(widgetList.count());
    for (QWidget *widget : widgetList) {
        MailWidget *w = qobject_cast<MailWidget *>(widget);
        KContacts::Email newEmail = w->email();
        if (newEmail.isValid()) {
            emailList << newEmail;
        }
    }
    contact.setEmailList(emailList);
}
Ejemplo n.º 3
0
void EmailEditWidgetTest::shouldChangeEmail()
{
    EmailEditWidget widget;
    QLineEdit *lineedit = widget.findChild<QLineEdit *>(QStringLiteral("emailedit"));
    KContacts::Addressee addr;
    KContacts::Email::List lst;
    const QString firstEmail(QStringLiteral("*****@*****.**"));
    lst << KContacts::Email(firstEmail);
    lst << KContacts::Email(QStringLiteral("*****@*****.**"));
    addr.setEmailList(lst);
    widget.loadContact(addr);
    const QString changedEmail(QStringLiteral("*****@*****.**"));
    lineedit->setText(changedEmail);
    KContacts::Addressee result;
    widget.storeContact(result);
    QVERIFY(!result.emailList().isEmpty());
    QCOMPARE(result.emailList().first().mail(), changedEmail);
}