Commit 340c6e42 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotest

parent 4d82decf
Pipeline #44849 passed with stage
in 9 minutes and 18 seconds
......@@ -20,16 +20,28 @@
#include "groupmanagementdialogtest.h"
#include "groupmanagementdialog.h"
#include "groupmanagementwidget.h"
#include <QDialogButtonBox>
#include <QTest>
#include <QVBoxLayout>
#include <QStandardPaths>
QTEST_MAIN(GroupManagementDialogTest)
GroupManagementDialogTest::GroupManagementDialogTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
void GroupManagementDialogTest::shouldHaveDefaultValues()
{
GroupManagementDialog w;
//TODO
QVERIFY(!w.windowTitle().isEmpty());
auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
auto mGroupManagementWidget = w.findChild<GroupManagementWidget *>(QStringLiteral("mGroupManagementWidget"));
QVERIFY(mGroupManagementWidget);
auto buttonBox = w.findChild<QDialogButtonBox *>(QStringLiteral("buttonBox"));
QVERIFY(buttonBox);
}
......@@ -21,13 +21,22 @@
#include "groupmanagementdialog.h"
#include "groupmanagementwidget.h"
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <KConfigGroup>
#include <KSharedConfig>
namespace {
static const char myGroupManagementDialogGroupName[] = "GroupManagementDialog";
}
GroupManagementDialog::GroupManagementDialog(QWidget *parent)
: QDialog(parent)
, mGroupManagementWidget(new GroupManagementWidget(this))
{
setWindowTitle(i18nc("@title:window", "Manage Group"));
mGroupManagementWidget->setObjectName(QStringLiteral("mGroupManagementWidget"));
auto mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
......@@ -35,9 +44,27 @@ GroupManagementDialog::GroupManagementDialog(QWidget *parent)
buttonBox->setObjectName(QStringLiteral("buttonBox"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &GroupManagementDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &GroupManagementDialog::reject);
mainLayout->addWidget(mGroupManagementWidget);
mainLayout->addWidget(buttonBox);
readConfig();
}
GroupManagementDialog::~GroupManagementDialog()
{
writeConfig();
}
void GroupManagementDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), myGroupManagementDialogGroupName);
const QSize sizeDialog = group.readEntry("Size", QSize(400, 300));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
void GroupManagementDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), myGroupManagementDialogGroupName);
group.writeEntry("Size", size());
}
......@@ -32,6 +32,8 @@ public:
explicit GroupManagementDialog(QWidget *parent = nullptr);
~GroupManagementDialog() override;
private:
void writeConfig();
void readConfig();
GroupManagementWidget *const mGroupManagementWidget;
};
......
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