Commit fc4e41a6 authored by Laurent Montel's avatar Laurent Montel 😁

continue to implement autotest

parent e146a754
......@@ -19,7 +19,12 @@
#include "templateparseremailaddressrequesterakonaditest.h"
#include "../templateparseremailaddressrequesterakonadi.h"
#include <QHBoxLayout>
#include <QLineEdit>
#include <QSignalSpy>
#include <QTest>
#include <QDebug>
#include <Akonadi/Contact/EmailAddressRequester>
TemplateParserEmailAddressRequesterAkonadiTest::TemplateParserEmailAddressRequesterAkonadiTest(QObject *parent)
: QObject(parent)
......@@ -30,6 +35,48 @@ TemplateParserEmailAddressRequesterAkonadiTest::TemplateParserEmailAddressReques
void TemplateParserEmailAddressRequesterAkonadiTest::shouldHaveDefaultValues()
{
TemplateParserEmailAddressRequesterAkonadi w;
QHBoxLayout *mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->margin(), 0);
Akonadi::EmailAddressRequester *mLineEdit = w.findChild<Akonadi::EmailAddressRequester *>(QStringLiteral("EmailAddressRequester"));
QVERIFY(mLineEdit);
QVERIFY(mLineEdit->text().isEmpty());
}
void TemplateParserEmailAddressRequesterAkonadiTest::shouldAssignValue()
{
TemplateParserEmailAddressRequesterAkonadi w;
Akonadi::EmailAddressRequester *mLineEdit = w.findChild<Akonadi::EmailAddressRequester *>(QStringLiteral("EmailAddressRequester"));
const QString str{QStringLiteral("foo")};
w.setText(str);
QCOMPARE(w.text(), str);
QCOMPARE(mLineEdit->text(), str);
}
void TemplateParserEmailAddressRequesterAkonadiTest::shouldClearValue()
{
TemplateParserEmailAddressRequesterAkonadi w;
Akonadi::EmailAddressRequester *mLineEdit = w.findChild<Akonadi::EmailAddressRequester *>(QStringLiteral("EmailAddressRequester"));
const QString str{QStringLiteral("foo")};
w.setText(str);
QCOMPARE(w.text(), str);
w.clear();
QVERIFY(w.text().isEmpty());
QVERIFY(mLineEdit->text().isEmpty());
}
void TemplateParserEmailAddressRequesterAkonadiTest::shouldEmitSignal()
{
TemplateParserEmailAddressRequesterAkonadi w;
QSignalSpy spy(&w, &TemplateParser::TemplateParserEmailAddressRequesterBase::textChanged);
w.setText(QStringLiteral("foo"));
QCOMPARE(spy.at(0).count(), 1);
w.clear();
QCOMPARE(spy.at(1).count(), 1);
w.setText(QStringLiteral("foo"));
QCOMPARE(spy.at(2).count(), 1);
}
......
......@@ -31,6 +31,9 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValues();
void shouldEmitSignal();
void shouldClearValue();
void shouldAssignValue();
};
#endif // TEMPLATEPARSEREMAILADDRESSREQUESTERAKONADITEST_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment