Commit 4a1ef8c3 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotest

parent 837bffd9
......@@ -25,3 +25,9 @@ add_executable( selectiontypetreewidgettest selectiontypetreewidgettest.cpp ../w
add_test(selectiontypetreewidgettest selectiontypetreewidgettest)
ecm_mark_as_test(selectiontypetreewidgettest)
target_link_libraries(selectiontypetreewidgettest Qt5::Test Qt5::Widgets KF5::I18n KF5::ItemViews pimsettingexporterprivate KF5::ConfigCore KF5::ConfigGui KF5::PimCommon)
add_executable( selectiontypedialogtest selectiontypedialogtest.cpp ../widgets/selectiontypetreewidget.cpp ../dialog/selectiontypedialog.cpp ${pimsettingexporter_kcfg_SRCS})
add_test(selectiontypedialogtest selectiontypedialogtest)
ecm_mark_as_test(selectiontypedialogtest)
target_link_libraries(selectiontypedialogtest Qt5::Test Qt5::Widgets KF5::I18n KF5::ItemViews pimsettingexporterprivate KF5::ConfigCore KF5::ConfigGui KF5::PimCommon)
/*
Copyright (C) 2017 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "selectiontypedialogtest.h"
#include "../dialog/selectiontypedialog.h"
#include <QStandardPaths>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QTest>
#include <gui/widgets/selectiontypetreewidget.h>
SelectionTypeDialogTest::SelectionTypeDialogTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
SelectionTypeDialogTest::~SelectionTypeDialogTest()
{
}
SelectionTypeDialogTest::SelectionTypeDialogTest(QObject *parent) : QObject(parent)
void SelectionTypeDialogTest::shouldHaveDefaultValue()
{
SelectionTypeDialog dlg;
QVERIFY(dlg.isModal());
QVERIFY(!dlg.windowTitle().isEmpty());
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
SelectionTypeTreeWidget *mSelectionTreeWidget = dlg.findChild<SelectionTypeTreeWidget *>(QStringLiteral("mSelectionTreeWidget"));
QVERIFY(mSelectionTreeWidget);
QCheckBox *mUseTemplateByDefault = dlg.findChild<QCheckBox*>(QStringLiteral("mUseTemplateByDefault"));
QVERIFY(mUseTemplateByDefault);
QVERIFY(!mUseTemplateByDefault->isChecked());
QPushButton *selectAll = dlg.findChild<QPushButton *>(QStringLiteral("selectAll"));
QVERIFY(selectAll);
QVERIFY(selectAll->isEnabled());
QPushButton *unselectAll = dlg.findChild<QPushButton *>(QStringLiteral("unselectAll"));
QVERIFY(unselectAll);
QVERIFY(unselectAll->isEnabled());
QPushButton *mSaveTemplate = dlg.findChild<QPushButton *>(QStringLiteral("mSaveTemplate"));
QVERIFY(mSaveTemplate);
QVERIFY(mSaveTemplate->isEnabled());
QPushButton *mLoadTemplate = dlg.findChild<QPushButton *>(QStringLiteral("mLoadTemplate"));
QVERIFY(mLoadTemplate);
QVERIFY(mLoadTemplate->isEnabled());
}
QTEST_MAIN(SelectionTypeDialogTest)
/*
Copyright (C) 2017 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef SELECTIONTYPEDIALOGTEST_H
#define SELECTIONTYPEDIALOGTEST_H
#include <QObject>
class SelectionTypeDialogTest : public QObject
{
Q_OBJECT
public:
explicit SelectionTypeDialogTest(QObject *parent = nullptr);
signals:
public slots:
~SelectionTypeDialogTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // SELECTIONTYPEDIALOGTEST_H
\ No newline at end of file
#endif // SELECTIONTYPEDIALOGTEST_H
......@@ -38,6 +38,7 @@ SelectionTypeDialog::SelectionTypeDialog(QWidget *parent)
QVBoxLayout *topLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......@@ -45,35 +46,36 @@ SelectionTypeDialog::SelectionTypeDialog(QWidget *parent)
connect(buttonBox, &QDialogButtonBox::rejected, this, &SelectionTypeDialog::reject);
okButton->setDefault(true);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setMargin(0);
mSelectionTreeWidget = new SelectionTypeTreeWidget(this);
mainLayout->addWidget(mSelectionTreeWidget);
mSelectionTreeWidget->setObjectName(QStringLiteral("mSelectionTreeWidget"));
topLayout->addWidget(mSelectionTreeWidget);
mUseTemplateByDefault = new QCheckBox(i18n("Use this template by default"), this);
mainLayout->addWidget(mUseTemplateByDefault);
mUseTemplateByDefault->setObjectName(QStringLiteral("mUseTemplateByDefault"));
topLayout->addWidget(mUseTemplateByDefault);
QHBoxLayout *hbox = new QHBoxLayout;
QPushButton *selectAll = new QPushButton(i18n("Select All"), this);
selectAll->setObjectName(QStringLiteral("selectAll"));
connect(selectAll, &QPushButton::clicked, this, &SelectionTypeDialog::slotSelectAll);
hbox->addWidget(selectAll);
QPushButton *unselectAll = new QPushButton(i18n("Unselect All"), this);
unselectAll->setObjectName(QStringLiteral("unselectAll"));
connect(unselectAll, &QPushButton::clicked, this, &SelectionTypeDialog::slotUnselectAll);
hbox->addWidget(unselectAll);
QPushButton *saveTemplate = new QPushButton(i18n("Save as Template..."), this);
connect(saveTemplate, &QPushButton::clicked, this, &SelectionTypeDialog::slotSaveAsTemplate);
hbox->addWidget(saveTemplate);
mSaveTemplate = new QPushButton(i18n("Save as Template..."), this);
mSaveTemplate->setObjectName(QStringLiteral("mSaveTemplate"));
connect(mSaveTemplate, &QPushButton::clicked, this, &SelectionTypeDialog::slotSaveAsTemplate);
hbox->addWidget(mSaveTemplate);
QPushButton *loadTemplate = new QPushButton(i18n("Load Template..."), this);
connect(loadTemplate, &QPushButton::clicked, this, &SelectionTypeDialog::slotLoadTemplate);
hbox->addWidget(loadTemplate);
mLoadTemplate = new QPushButton(i18n("Load Template..."), this);
mLoadTemplate->setObjectName(QStringLiteral("mLoadTemplate"));
connect(mLoadTemplate, &QPushButton::clicked, this, &SelectionTypeDialog::slotLoadTemplate);
hbox->addWidget(mLoadTemplate);
mainLayout->addLayout(hbox);
topLayout->addWidget(mainWidget);
topLayout->addLayout(hbox);
topLayout->addWidget(buttonBox);
readConfig();
}
......
......@@ -50,6 +50,8 @@ private:
void saveDefaultTemplate();
SelectionTypeTreeWidget *mSelectionTreeWidget;
QCheckBox *mUseTemplateByDefault;
QPushButton *mSaveTemplate;
QPushButton *mLoadTemplate;
};
#endif // SELECTIONTYPEDIALOG_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