1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-22 18:03:57 +03:00

add tests for gpoptions edit

This commit is contained in:
Dmitry Degtyarev 2021-07-26 16:08:27 +04:00
parent f74b4db13b
commit 31265a2ba0
4 changed files with 125 additions and 0 deletions

View File

@ -95,6 +95,7 @@ Tests for ADMC
%_bindir/admc_test_delegation_edit
%_bindir/admc_test_string_other_edit
%_bindir/admc_test_account_option_edit
%_bindir/admc_test_gpoptions_edit
%_bindir/admc_test_octet_editor
%_bindir/admc_test_bool_editor
%_bindir/admc_test_string_editor

View File

@ -58,6 +58,7 @@ set(TEST_TARGETS
admc_test_delegation_edit
admc_test_string_other_edit
admc_test_account_option_edit
admc_test_gpoptions_edit
admc_test_octet_editor
admc_test_bool_editor
admc_test_datetime_editor

View File

@ -0,0 +1,78 @@
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2021 BaseALT Ltd.
* Copyright (C) 2020-2021 Dmitry Degtyarev
*
* 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 3 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. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_gpoptions_edit.h"
#include "edits/gpoptions_edit.h"
#include <QFormLayout>
#include <QCheckBox>
#define TEST_ATTRIBUTE ATTRIBUTE_FIRST_NAME
void ADMCTestGpoptionsEdit::init() {
ADMCTest::init();
edit = new GpoptionsEdit(&edits, parent_widget);
add_attribute_edit(edit);
check = parent_widget->findChild<QCheckBox *>();
QVERIFY(check != nullptr);
const QString name = TEST_OU;
dn = test_object_dn(name, CLASS_OU);
const bool create_success = ad.object_add(dn, CLASS_OU);
QVERIFY(create_success);
}
void ADMCTestGpoptionsEdit::test_emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
check->setChecked(true);
QVERIFY(edited_signal_emitted);
}
void ADMCTestGpoptionsEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const QString edit_value = check->text();
;
QCOMPARE(check->isChecked(), false);
}
void ADMCTestGpoptionsEdit::apply() {
check->setChecked(true);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object = ad.search_object(dn);
const QString current_value = object.get_string(ATTRIBUTE_GPOPTIONS);
QCOMPARE(current_value, GPOPTIONS_BLOCK_INHERITANCE);
}
QTEST_MAIN(ADMCTestGpoptionsEdit)

View File

@ -0,0 +1,45 @@
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2021 BaseALT Ltd.
* Copyright (C) 2020-2021 Dmitry Degtyarev
*
* 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 3 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. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADMC_TEST_GPOPTIONS_EDIT_H
#define ADMC_TEST_GPOPTIONS_EDIT_H
#include "admc_test.h"
class GpoptionsEdit;
class QCheckBox;
class ADMCTestGpoptionsEdit : public ADMCTest {
Q_OBJECT
private slots:
void init() override;
void test_emit_edited_signal();
void load();
void apply();
private:
GpoptionsEdit *edit;
QCheckBox *check;
QString dn;
};
#endif /* ADMC_TEST_GPOPTIONS_EDIT_H */