21 #include "emaileditwidgettest.h"
22 #include "../emaileditwidget.h"
24 #include <QToolButton>
25 #include <qtest_kde.h>
26 #include "kabc/addressee.h"
27 EmailEditWidgetTest::EmailEditWidgetTest(
QObject *parent)
33 EmailEditWidgetTest::~EmailEditWidgetTest()
38 void EmailEditWidgetTest::shouldHaveDefaultValue()
41 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget,
QLatin1String(
"emailedit"));
43 QVERIFY(lineedit->text().isEmpty());
49 void EmailEditWidgetTest::shouldReadOnly()
52 widget.setReadOnly(
true);
53 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget,
QLatin1String(
"emailedit"));
56 QVERIFY(lineedit->isReadOnly());
57 QVERIFY(!toolButton->isEnabled());
60 void EmailEditWidgetTest::shouldSelectFirstEmail()
63 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget,
QLatin1String(
"emailedit"));
65 KABC::Email::List lst;
67 lst << KABC::Email(firstEmail);
69 addr.setEmailList(lst);
70 widget.loadContact(addr);
71 QCOMPARE(lineedit->text(), firstEmail);
74 void EmailEditWidgetTest::shouldChangeEmail()
77 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget,
QLatin1String(
"emailedit"));
79 KABC::Email::List lst;
81 lst << KABC::Email(firstEmail);
83 addr.setEmailList(lst);
84 widget.loadContact(addr);
86 lineedit->setText(changedEmail);
87 KABC::Addressee result;
88 widget.storeContact(result);
89 QVERIFY(!result.emailList().isEmpty());
90 QCOMPARE(result.emailList().first().mail(), changedEmail);
93 QTEST_KDEMAIN(EmailEditWidgetTest, GUI)