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);
}
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);
}
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);
}