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

make a general apply_unmodified() test

add this test to all edit tests
This commit is contained in:
Dmitry Degtyarev 2021-07-14 12:35:00 +04:00
parent 600fca88e1
commit 0fca55f71c
23 changed files with 68 additions and 27 deletions

View File

@ -262,6 +262,23 @@ void ADMCTest::add_widget(QWidget *widget) {
layout->addWidget(widget); layout->addWidget(widget);
} }
// Edit should do nothing if value wasn't modified
void ADMCTest::test_edit_apply_unmodified(AttributeEdit *edit, const QString &dn) {
const AdObject object_before = ad.search_object(dn);
edit->load(ad, object_before);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object_after = ad.search_object(dn);
qInfo() << object_before.get_value(ATTRIBUTE_ACCOUNT_EXPIRES);
qInfo() << object_after.get_value(ATTRIBUTE_ACCOUNT_EXPIRES);
QVERIFY(object_before.get_attributes_data() == object_after.get_attributes_data());
}
void select_base_widget_add(SelectBaseWidget *widget, const QString &dn) { void select_base_widget_add(SelectBaseWidget *widget, const QString &dn) {
auto browse_button = widget->findChild<QPushButton *>(); auto browse_button = widget->findChild<QPushButton *>();
QVERIFY(browse_button != nullptr); QVERIFY(browse_button != nullptr);

View File

@ -108,6 +108,8 @@ protected:
// Adds a widget to layout in parent widget // Adds a widget to layout in parent widget
void add_widget(QWidget *widget); void add_widget(QWidget *widget);
void test_edit_apply_unmodified(AttributeEdit *edit, const QString &dn);
private: private:
QFormLayout *layout; QFormLayout *layout;
}; };

View File

@ -77,16 +77,8 @@ void ADMCTestCountryEdit::load() {
QVERIFY(edit_value == test_value); QVERIFY(edit_value == test_value);
} }
// Edit should do nothing if value wasn't modified
void ADMCTestCountryEdit::apply_unmodified() { void ADMCTestCountryEdit::apply_unmodified() {
const AdObject object_before_apply = ad.search_object(dn); test_edit_apply_unmodified(edit, dn);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object_after_apply = ad.search_object(dn);
QVERIFY(object_before_apply.get_attributes_data() == object_after_apply.get_attributes_data());
} }
// Edit should do change attribute to value. // Edit should do change attribute to value.

View File

@ -25,6 +25,9 @@
#include <QDateTimeEdit> #include <QDateTimeEdit>
// NOTE: no apply_unmodified() test because all datetime
// attributes are read-only
void ADMCTestDateTimeEdit::init() { void ADMCTestDateTimeEdit::init() {
ADMCTest::init(); ADMCTest::init();

View File

@ -82,6 +82,10 @@ void ADMCTestDelegationEdit::load() {
do_test(false); do_test(false);
} }
void ADMCTestDelegationEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestDelegationEdit::apply() { void ADMCTestDelegationEdit::apply() {
auto do_test = [&](const bool is_on) { auto do_test = [&](const bool is_on) {
// First set current state to opposite // First set current state to opposite

View File

@ -34,6 +34,7 @@ private slots:
void emit_edited_signal(); void emit_edited_signal();
void load(); void load();
void apply_unmodified();
void apply(); void apply();
private: private:

View File

@ -80,6 +80,10 @@ void ADMCTestExpiryEdit::load() {
QVERIFY(!end_of_check->isChecked()); QVERIFY(!end_of_check->isChecked());
} }
void ADMCTestExpiryEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestExpiryEdit::apply_date() { void ADMCTestExpiryEdit::apply_date() {
load(); load();

View File

@ -36,6 +36,7 @@ private slots:
void edited_signal_from_check(); void edited_signal_from_check();
void edited_signal_from_date(); void edited_signal_from_date();
void load(); void load();
void apply_unmodified();
void apply_date(); void apply_date();
void apply_never(); void apply_never();

View File

@ -58,6 +58,10 @@ void ADMCTestGroupScopeEdit::load() {
QVERIFY(combo->currentIndex() == 0); QVERIFY(combo->currentIndex() == 0);
} }
void ADMCTestGroupScopeEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestGroupScopeEdit::apply() { void ADMCTestGroupScopeEdit::apply() {
load(); load();

View File

@ -34,6 +34,7 @@ private slots:
void edited_signal(); void edited_signal();
void load(); void load();
void apply_unmodified();
void apply(); void apply();
private: private:

View File

@ -58,6 +58,10 @@ void ADMCTestGroupTypeEdit::load() {
QVERIFY(combo->currentIndex() == 0); QVERIFY(combo->currentIndex() == 0);
} }
void ADMCTestGroupTypeEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestGroupTypeEdit::apply() { void ADMCTestGroupTypeEdit::apply() {
load(); load();

View File

@ -34,6 +34,7 @@ private slots:
void edited_signal(); void edited_signal();
void load(); void load();
void apply_unmodified();
void apply(); void apply();
private: private:

View File

@ -120,6 +120,10 @@ void ADMCTestLogonComputers::test_list_item(const int row, const QString &text)
QVERIFY(item->text() == text); QVERIFY(item->text() == text);
} }
void ADMCTestLogonComputers::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestLogonComputers::apply() { void ADMCTestLogonComputers::apply() {
open_dialog_button->click(); open_dialog_button->click();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000)); QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));

View File

@ -38,6 +38,7 @@ private slots:
void emit_edited_signal(); void emit_edited_signal();
void add(); void add();
void remove(); void remove();
void apply_unmodified();
void apply(); void apply();
private: private:

View File

@ -66,6 +66,10 @@ void ADMCTestManagerEdit::load() {
QVERIFY(manager_display->text() == manager_dn); QVERIFY(manager_display->text() == manager_dn);
} }
void ADMCTestManagerEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestManagerEdit::apply_after_change() { void ADMCTestManagerEdit::apply_after_change() {
const AdObject object = ad.search_object(dn); const AdObject object = ad.search_object(dn);
edit->load(ad, object); edit->load(ad, object);

View File

@ -35,6 +35,7 @@ private slots:
void load_empty(); void load_empty();
void load(); void load();
void apply_unmodified();
void apply_after_change(); void apply_after_change();
void apply_after_clear(); void apply_after_clear();
void properties(); void properties();

View File

@ -26,6 +26,9 @@
#include <QLineEdit> #include <QLineEdit>
#include <QDateEdit> #include <QDateEdit>
// NOTE: no apply_unmodified() test because password edit
// always changes object when applying
void ADMCTestPasswordEdit::init() { void ADMCTestPasswordEdit::init() {
ADMCTest::init(); ADMCTest::init();

View File

@ -72,16 +72,8 @@ void ADMCTestStringEdit::load() {
QVERIFY(edit_value == test_value); QVERIFY(edit_value == test_value);
} }
// Edit should do nothing if value wasn't modified
void ADMCTestStringEdit::apply_unmodified() { void ADMCTestStringEdit::apply_unmodified() {
const AdObject object_before_apply = ad.search_object(dn); test_edit_apply_unmodified(edit, dn);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object_after_apply = ad.search_object(dn);
QVERIFY(object_before_apply.get_attributes_data() == object_after_apply.get_attributes_data());
} }
// Edit should do change attribute to value // Edit should do change attribute to value

View File

@ -107,16 +107,8 @@ void ADMCTestStringOtherEdit::load() {
} }
} }
// Edit should do nothing if value wasn't modified
void ADMCTestStringOtherEdit::apply_unmodified() { void ADMCTestStringOtherEdit::apply_unmodified() {
const AdObject object_before_apply = ad.search_object(dn); test_edit_apply_unmodified(edit, dn);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object_after_apply = ad.search_object(dn);
QVERIFY(object_before_apply.get_attributes_data() == object_after_apply.get_attributes_data());
} }
void ADMCTestStringOtherEdit::apply_modified_main_value() { void ADMCTestStringOtherEdit::apply_modified_main_value() {

View File

@ -77,6 +77,10 @@ void ADMCTestUnlockEdit::unchecked_after_load() {
QVERIFY2(checkbox_is_unchecked, "Checkbox wasn't unchecked after load() call"); QVERIFY2(checkbox_is_unchecked, "Checkbox wasn't unchecked after load() call");
} }
void ADMCTestUnlockEdit::apply_unmodified() {
test_edit_apply_unmodified(unlock_edit, dn);
}
// Edit should do nothing if checkbox is unchecked (locked // Edit should do nothing if checkbox is unchecked (locked
// user stays locked) // user stays locked)
void ADMCTestUnlockEdit::test_apply_unchecked() { void ADMCTestUnlockEdit::test_apply_unchecked() {

View File

@ -34,6 +34,7 @@ private slots:
void test_emit_edited_signal(); void test_emit_edited_signal();
void unchecked_after_load(); void unchecked_after_load();
void apply_unmodified();
void test_apply_unchecked(); void test_apply_unchecked();
void test_apply_checked(); void test_apply_checked();
void uncheck_after_apply(); void uncheck_after_apply();

View File

@ -90,6 +90,10 @@ void ADMCTestUpnEdit::test_emit_edited() {
QVERIFY(edited_signal_emitted); QVERIFY(edited_signal_emitted);
} }
void ADMCTestUpnEdit::apply_unmodified() {
test_edit_apply_unmodified(upn_edit, dn);
}
// Edit should apply changes to suffix // Edit should apply changes to suffix
void ADMCTestUpnEdit::test_apply_suffix() { void ADMCTestUpnEdit::test_apply_suffix() {
change_suffix_in_edit(); change_suffix_in_edit();

View File

@ -35,6 +35,7 @@ private slots:
void test_load(); void test_load();
void test_emit_edited(); void test_emit_edited();
void apply_unmodified();
void test_apply_suffix(); void test_apply_suffix();
void test_apply_prefix(); void test_apply_prefix();
void test_apply_prefix_and_suffix(); void test_apply_prefix_and_suffix();