Commit a5724bb4 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotest

parent f84e0e22
......@@ -18,7 +18,11 @@
*/
#include "snippetcustomfileattachmentnamedialogtest.h"
#include "snippets/snippetcustomfileattachmentnamedialog.h"
#include "snippets/snippetcustomfileattachmentnamewidget.h"
#include <QDialogButtonBox>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(SnippetCustomFileAttachmentNameDialogTest)
SnippetCustomFileAttachmentNameDialogTest::SnippetCustomFileAttachmentNameDialogTest(QObject *parent)
......@@ -26,3 +30,18 @@ SnippetCustomFileAttachmentNameDialogTest::SnippetCustomFileAttachmentNameDialog
{
}
void SnippetCustomFileAttachmentNameDialogTest::shouldHaveDefaultValues()
{
MailCommon::SnippetCustomFileAttachmentNameDialog dlg;
QVBoxLayout *mainLayout = dlg.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
MailCommon::SnippetCustomFileAttachmentNameWidget *mCustomWidget = dlg.findChild<MailCommon::SnippetCustomFileAttachmentNameWidget *>(QStringLiteral("mCustomWidget"));
QVERIFY(mCustomWidget);
mainLayout->addWidget(mCustomWidget);
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("button"));
QVERIFY(buttonBox);
QCOMPARE(buttonBox->standardButtons(), {QDialogButtonBox::Ok | QDialogButtonBox::Cancel});
}
......@@ -28,6 +28,8 @@ class SnippetCustomFileAttachmentNameDialogTest : public QObject
public:
explicit SnippetCustomFileAttachmentNameDialogTest(QObject *parent = nullptr);
~SnippetCustomFileAttachmentNameDialogTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // SNIPPETCUSTOMFILEATTACHMENTNAMEDIALOGTEST_H
......@@ -18,7 +18,10 @@
*/
#include "snippetcustomfileattachmentnamewidgettest.h"
#include "snippets/snippetcustomfileattachmentnamewidget.h"
#include <QLineEdit>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(SnippetCustomFileAttachmentNameWidgetTest)
SnippetCustomFileAttachmentNameWidgetTest::SnippetCustomFileAttachmentNameWidgetTest(QObject *parent)
......@@ -26,3 +29,16 @@ SnippetCustomFileAttachmentNameWidgetTest::SnippetCustomFileAttachmentNameWidget
{
}
void SnippetCustomFileAttachmentNameWidgetTest::shouldHaveDefaultValues()
{
MailCommon::SnippetCustomFileAttachmentNameWidget w;
QHBoxLayout *mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
QLineEdit *mLineEdit = w.findChild<QLineEdit *>(QStringLiteral("mLineEdit"));
QVERIFY(mLineEdit);
QVERIFY(mLineEdit->text().isEmpty());
}
......@@ -28,6 +28,8 @@ class SnippetCustomFileAttachmentNameWidgetTest : public QObject
public:
explicit SnippetCustomFileAttachmentNameWidgetTest(QObject *parent = nullptr);
~SnippetCustomFileAttachmentNameWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // SNIPPETCUSTOMFILEATTACHMENTNAMEWIDGETTEST_H
......@@ -18,7 +18,9 @@
*/
#include "snippetcustomfileattachmentnamedialog.h"
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <QVBoxLayout>
#include "snippetcustomfileattachmentnamewidget.h"
......@@ -32,6 +34,16 @@ SnippetCustomFileAttachmentNameDialog::SnippetCustomFileAttachmentNameDialog(QWi
mCustomWidget = new SnippetCustomFileAttachmentNameWidget(this);
mCustomWidget->setObjectName(QStringLiteral("mCustomWidget"));
mainLayout->addWidget(mCustomWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("button"));
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &SnippetCustomFileAttachmentNameDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SnippetCustomFileAttachmentNameDialog::reject);
mainLayout->addWidget(buttonBox);
}
SnippetCustomFileAttachmentNameDialog::~SnippetCustomFileAttachmentNameDialog()
......
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