summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-06-13 09:03:19 +0200
committerMontel Laurent <[email protected]>2017-06-13 09:03:19 +0200
commitfc4e41a6e3a5ca10d4129b248284f05bee8794df (patch)
treeb8a583cfc8ddfc4ead4caf0998e0c6a51a23b3dd
parente146a7541aae32e3121ad8c938ac5d4f06d8967d (diff)
continue to implement autotest
-rw-r--r--plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.cpp47
-rw-r--r--plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.h3
2 files changed, 50 insertions, 0 deletions
diff --git a/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.cpp b/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.cpp
index 44c157e..47e750a 100644
--- a/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.cpp
+++ b/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.cpp
@@ -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);
}
diff --git a/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.h b/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.h
index a949db4..c0e4fc0 100644
--- a/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.h
+++ b/plugins/templateparser/autotests/templateparseremailaddressrequesterakonaditest.h
@@ -31,6 +31,9 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValues();
+ void shouldEmitSignal();
+ void shouldClearValue();
+ void shouldAssignValue();
};
#endif // TEMPLATEPARSEREMAILADDRESSREQUESTERAKONADITEST_H