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

improve tests

use QCOMPARE() instead of QVERIFY() where possible for better messages
remove != nullptr from QVERIFY() calls to reduce visual clutter
This commit is contained in:
Dmitry Degtyarev 2021-10-01 14:23:56 +04:00
parent cc312dd48f
commit d486af4c8e
32 changed files with 189 additions and 189 deletions

View File

@ -191,30 +191,30 @@ void ADMCTest::close_message_box() {
void ADMCTest::select_in_select_dialog(SelectObjectDialog *select_dialog, const QString &dn) {
auto add_button = select_dialog->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
add_button->click();
// Find dialog has been opened, so switch to it
auto find_select_dialog = select_dialog->findChild<SelectObjectAdvancedDialog *>();
QVERIFY(find_select_dialog != nullptr);
QVERIFY(find_select_dialog);
QVERIFY(QTest::qWaitForWindowExposed(find_select_dialog, 1000));
// Enter group name in "Name" edit
const QString name = dn_get_name(dn);
auto simple_tab = select_dialog->findChild<FilterWidgetSimpleTab *>();
QVERIFY(simple_tab != nullptr);
QVERIFY(simple_tab);
auto name_edit = simple_tab->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
name_edit->setText(name);
// Press "Find" button
auto find_button = find_select_dialog->findChild<QPushButton *>("find_button");
QVERIFY(find_button != nullptr);
QVERIFY(find_button);
find_button->click();
// Switch to find results
auto find_results_view = find_select_dialog->findChild<QTreeView *>();
QVERIFY(find_results_view != nullptr);
QVERIFY(find_results_view);
wait_for_find_results_to_load(find_results_view);
@ -228,17 +228,17 @@ void ADMCTest::select_in_select_dialog(SelectObjectDialog *select_dialog, const
void ADMCTest::select_object_dialog_select(const QString &dn) {
auto select_dialog = parent_widget->findChild<SelectObjectDialog *>();
QVERIFY(select_dialog != nullptr);
QVERIFY(select_dialog);
auto select_base_widget = select_dialog->findChild<SelectBaseWidget *>();
QVERIFY(select_base_widget != nullptr);
QVERIFY(select_base_widget);
select_base_widget_add(select_base_widget, test_arena_dn());
auto edit = select_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(edit != nullptr);
QVERIFY(edit);
auto add_button = select_dialog->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
edit->setText(dn_get_name(dn));
add_button->click();
@ -272,16 +272,16 @@ void ADMCTest::test_edit_apply_unmodified(AttributeEdit *edit, const QString &dn
void select_base_widget_add(SelectBaseWidget *widget, const QString &dn) {
auto browse_button = widget->findChild<QPushButton *>();
QVERIFY(browse_button != nullptr);
QVERIFY(browse_button);
browse_button->click();
auto select_container_dialog = widget->findChild<SelectContainerDialog *>();
QVERIFY(select_container_dialog != nullptr);
QVERIFY(select_container_dialog);
QVERIFY(QTest::qWaitForWindowExposed(select_container_dialog, 1000));
auto select_container_view = select_container_dialog->findChild<QTreeView *>();
QVERIFY(select_container_view != nullptr);
QVERIFY(select_container_view);
navigate_until_object(select_container_view, dn, ContainerRole_DN);
select_container_dialog->accept();

View File

@ -189,7 +189,7 @@ void ADMCTestAdInterface::group_add_member() {
const AdObject group_object = ad.search_object(group_dn);
const QList<QString> member_list = group_object.get_strings(ATTRIBUTE_MEMBER);
QVERIFY(member_list == QList<QString>({user_dn}));
QCOMPARE(member_list, QList<QString>({user_dn}));
}
void ADMCTestAdInterface::group_remove_member() {
@ -218,7 +218,7 @@ void ADMCTestAdInterface::group_set_scope() {
const AdObject group_object = ad.search_object(group_dn);
const GroupScope current_scope = group_object.get_group_scope();
QVERIFY(current_scope == scope);
QCOMPARE(current_scope, scope);
}
}
@ -234,7 +234,7 @@ void ADMCTestAdInterface::group_set_type() {
const AdObject group_object = ad.search_object(group_dn);
const GroupType current_type = group_object.get_group_type();
QVERIFY(current_type == type);
QCOMPARE(current_type, type);
}
}

View File

@ -52,22 +52,22 @@ void ADMCTestAttributesTab::init() {
add_widget(attributes_tab);
filter_menu = attributes_tab->findChild<AttributesFilterMenu *>();
QVERIFY(filter_menu != nullptr);
QVERIFY(filter_menu);
view = attributes_tab->findChild<QTreeView *>();
QVERIFY(view != nullptr);
QVERIFY(view);
model = attributes_tab->findChild<QStandardItemModel *>();
QVERIFY(model != nullptr);
QVERIFY(model);
proxy = attributes_tab->findChild<QSortFilterProxyModel *>();
QVERIFY(proxy != nullptr);
QVERIFY(proxy);
filter_button = attributes_tab->findChild<QPushButton *>("filter_button");
QVERIFY(filter_button != nullptr);
QVERIFY(filter_button);
edit_button = attributes_tab->findChild<QPushButton *>("edit_button");
QVERIFY(filter_button != nullptr);
QVERIFY(filter_button);
// Create test user
const QString name = TEST_USER;
@ -166,19 +166,19 @@ void ADMCTestAttributesTab::apply() {
edit_button->click();
auto multi_editor = attributes_tab->findChild<MultiEditor *>();
QVERIFY(multi_editor != nullptr);
QVERIFY(multi_editor);
QVERIFY(QTest::qWaitForWindowExposed(multi_editor, 1000));
auto add_button = multi_editor->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
add_button->click();
auto string_editor = multi_editor->findChild<StringEditor *>();
QVERIFY(string_editor != nullptr);
QVERIFY(string_editor);
QVERIFY(QTest::qWaitForWindowExposed(string_editor, 1000));
auto string_editor_edit = string_editor->findChild<QLineEdit *>();
QVERIFY(string_editor_edit != nullptr);
QVERIFY(string_editor_edit);
string_editor_edit->setText(correct_value);
string_editor->accept();
@ -188,13 +188,13 @@ void ADMCTestAttributesTab::apply() {
const AdObject object = ad.search_object(dn);
const QString description_value = object.get_string(ATTRIBUTE_DESCRIPTION);
QVERIFY(description_value == correct_value);
QCOMPARE(description_value, correct_value);
}
void ADMCTestAttributesTab::set_filter(const QList<AttributeFilter> &filter_list, const bool state) {
for (const AttributeFilter &filter : filter_list) {
QAction *action = filter_menu->findChild<QAction *>(QString::number(filter));
QVERIFY(action != nullptr);
QVERIFY(action);
action->setChecked(state);
}
}

View File

@ -43,7 +43,7 @@ void ADMCTestBoolEditor::init() {
QFETCH_GLOBAL(QString, button_name);
button = parent_widget->findChild<QRadioButton *>(button_name);
QVERIFY(button != nullptr);
QVERIFY(button);
}
void ADMCTestBoolEditor::load() {

View File

@ -34,7 +34,7 @@ void ADMCTestCountryEdit::init() {
add_attribute_edit(edit);
combo = parent_widget->findChild<QComboBox *>();
QVERIFY(combo != nullptr);
QVERIFY(combo);
// Create test user
const QString name = TEST_USER;
@ -74,7 +74,7 @@ void ADMCTestCountryEdit::load() {
edit->load(ad, object);
const int edit_value = combo->currentData().toInt();
QVERIFY(edit_value == test_value);
QCOMPARE(edit_value, test_value);
}
void ADMCTestCountryEdit::apply_unmodified() {
@ -98,7 +98,7 @@ void ADMCTestCountryEdit::apply_modified() {
const int current_value = object_after.get_int(ATTRIBUTE_COUNTRY_CODE);
const QString country_abbreviation_after = object_after.get_string(ATTRIBUTE_COUNTRY_ABBREVIATION);
const QString country_after = object_after.get_string(ATTRIBUTE_COUNTRY);
QVERIFY(current_value == new_value);
QCOMPARE(current_value, new_value);
// NOTE: figuring out what abbreviation and country
// strings are actually supposed to be requires parsing

View File

@ -49,7 +49,7 @@ void ADMCTestDateTimeEdit::load() {
const QDateTime correct_datetime = object.get_datetime(ATTRIBUTE_WHEN_CHANGED, g_adconfig);
const QDateTime datetime = qedit->dateTime();
QVERIFY(datetime == correct_datetime);
QCOMPARE(datetime, correct_datetime);
}
QTEST_MAIN(ADMCTestDateTimeEdit)

View File

@ -38,7 +38,7 @@ void ADMCTestDateTimeEditor::init() {
void ADMCTestDateTimeEditor::load() {
edit->load({QByteArray("20210706131457.0Z")});
const QDateTime correct_datetime = QDateTime(QDate(2021, 7, 6), QTime(13, 14, 57));
QVERIFY(datetime_edit->dateTime() == correct_datetime);
QCOMPARE(datetime_edit->dateTime(), correct_datetime);
}
// NOTE: datetime edit always returns empty list, see

View File

@ -41,7 +41,7 @@ void ADMCTestDelegationEdit::init() {
QFETCH_GLOBAL(QString, button_name);
button = parent_widget->findChild<QRadioButton *>(button_name);
QVERIFY(button != nullptr);
QVERIFY(button);
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);

View File

@ -41,22 +41,22 @@ void ADMCTestEditQueryItemWidget::init() {
add_widget(widget);
name_edit = widget->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
description_edit = widget->findChild<QLineEdit *>("description_edit");
QVERIFY(description_edit != nullptr);
QVERIFY(description_edit);
scope_checkbox = widget->findChild<QCheckBox *>();
QVERIFY(scope_checkbox != nullptr);
QVERIFY(scope_checkbox);
SelectBaseWidget *select_base_widget = widget->findChild<SelectBaseWidget *>();
QVERIFY(select_base_widget != nullptr);
QVERIFY(select_base_widget);
base_combo = select_base_widget->findChild<QComboBox *>();
QVERIFY(base_combo != nullptr);
QVERIFY(base_combo);
edit_filter_button = widget->findChild<QPushButton *>("edit_filter_button");
QVERIFY(edit_filter_button != nullptr);
QVERIFY(edit_filter_button);
filter_display = widget->findChild<QTextEdit *>("filter_display");
}
@ -81,15 +81,15 @@ void ADMCTestEditQueryItemWidget::save_and_load() {
edit_filter_button->click();
FilterDialog *dialog = widget->findChild<FilterDialog *>();
QVERIFY(dialog != nullptr);
QVERIFY(dialog);
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
QTabWidget *tab_widget = dialog->findChild<QTabWidget *>();
QVERIFY(tab_widget != nullptr);
QVERIFY(tab_widget);
QWidget *simple_tab = tab_widget->widget(0);
QVERIFY(simple_tab != nullptr);
QVERIFY(simple_tab);
QLineEdit *filter_name_edit = simple_tab->findChild<QLineEdit *>("name_edit");
filter_name_edit->setText("test");

View File

@ -47,7 +47,7 @@ void ADMCTestExpiryEdit::init() {
QFETCH_GLOBAL(QString, check_name);
check = parent_widget->findChild<QCheckBox *>(check_name);
QVERIFY(check != nullptr);
QVERIFY(check);
// Create test user
const QString name = TEST_USER;

View File

@ -44,30 +44,30 @@ void ADMCTestFilterWidget::init() {
add_widget(filter_widget);
tab_widget = filter_widget->findChild<QTabWidget *>();
QVERIFY(tab_widget != nullptr);
QVERIFY(tab_widget);
simple_tab = tab_widget->widget(SIMPLE_TAB_INDEX);
QVERIFY(simple_tab != nullptr);
QVERIFY(simple_tab);
normal_tab = tab_widget->widget(NORMAL_TAB_INDEX);
QVERIFY(normal_tab != nullptr);
QVERIFY(normal_tab);
advanced_tab = tab_widget->widget(ADVANCED_TAB_INDEX);
QVERIFY(advanced_tab != nullptr);
QVERIFY(advanced_tab);
}
void ADMCTestFilterWidget::test_simple_tab() {
tab_widget->setCurrentIndex(SIMPLE_TAB_INDEX);
auto select_classes_widget = simple_tab->findChild<SelectClassesWidget *>();
QVERIFY(select_classes_widget != nullptr);
QVERIFY(select_classes_widget);
auto select_button = select_classes_widget->findChild<QPushButton *>();
QVERIFY(select_button != nullptr);
QVERIFY(select_button);
select_button->click();
auto select_classes_dialog = select_classes_widget->findChild<QDialog *>();
QVERIFY(select_classes_dialog != nullptr);
QVERIFY(select_classes_dialog);
QVERIFY(QTest::qWaitForWindowExposed(select_classes_dialog, 1000));
const QList<QCheckBox *> checkbox_list = select_classes_dialog->findChildren<QCheckBox *>();
@ -85,7 +85,7 @@ void ADMCTestFilterWidget::test_simple_tab() {
const QString correct_filter = "(&(name=*test*)(objectClass=user))";
const QString filter = filter_widget->get_filter();
QVERIFY(correct_filter == filter);
QCOMPARE(correct_filter, filter);
// Serialize
const QVariant state = filter_widget->save_state();
@ -97,21 +97,21 @@ void ADMCTestFilterWidget::test_simple_tab() {
filter_widget->restore_state(state);
const QString filter_deserialized = filter_widget->get_filter();
QVERIFY(correct_filter == filter_deserialized);
QCOMPARE(correct_filter, filter_deserialized);
}
void ADMCTestFilterWidget::test_normal_tab() {
tab_widget->setCurrentIndex(NORMAL_TAB_INDEX);
auto select_classes_widget = normal_tab->findChild<SelectClassesWidget *>();
QVERIFY(select_classes_widget != nullptr);
QVERIFY(select_classes_widget);
auto select_button = select_classes_widget->findChild<QPushButton *>();
QVERIFY(select_button != nullptr);
QVERIFY(select_button);
select_button->click();
auto select_classes_dialog = select_classes_widget->findChild<QDialog *>();
QVERIFY(select_classes_dialog != nullptr);
QVERIFY(select_classes_dialog);
QVERIFY(QTest::qWaitForWindowExposed(select_classes_dialog, 1000));
const QList<QCheckBox *> checkbox_list = select_classes_dialog->findChildren<QCheckBox *>();
@ -125,16 +125,16 @@ void ADMCTestFilterWidget::test_normal_tab() {
select_classes_dialog->accept();
QLineEdit *value_edit = normal_tab->findChild<QLineEdit *>("value_edit");
QVERIFY(value_edit != nullptr);
QVERIFY(value_edit);
value_edit->setText("value");
QPushButton *add_button = normal_tab->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
add_button->click();
const QString correct_filter = "(&(objectClass=user)(assistant=value))";
const QString filter = filter_widget->get_filter();
QVERIFY(correct_filter == filter);
QCOMPARE(correct_filter, filter);
// Serialize
const QVariant state = filter_widget->save_state();
@ -147,20 +147,20 @@ void ADMCTestFilterWidget::test_normal_tab() {
filter_widget->restore_state(state);
const QString filter_deserialized = filter_widget->get_filter();
QVERIFY(correct_filter == filter_deserialized);
QCOMPARE(correct_filter, filter_deserialized);
}
void ADMCTestFilterWidget::test_advanced_tab() {
tab_widget->setCurrentIndex(ADVANCED_TAB_INDEX);
auto edit = advanced_tab->findChild<QPlainTextEdit *>();
QVERIFY(edit != nullptr);
QVERIFY(edit);
edit->setPlainText("test");
const QString correct_filter = "test";
const QString filter = filter_widget->get_filter();
QVERIFY(correct_filter == filter);
QCOMPARE(correct_filter, filter);
// Serialize
const QVariant state = filter_widget->save_state();
@ -172,7 +172,7 @@ void ADMCTestFilterWidget::test_advanced_tab() {
filter_widget->restore_state(state);
const QString filter_deserialized = filter_widget->get_filter();
QVERIFY(correct_filter == filter_deserialized);
QCOMPARE(correct_filter, filter_deserialized);
}
QTEST_MAIN(ADMCTestFilterWidget)

View File

@ -58,7 +58,7 @@ void ADMCTestGplink::equals() {
Gplink gplink_1(test_gplink_string);
Gplink gplink_2(test_gplink_string);
QVERIFY(gplink_1.equals(gplink_2));
QCOMPARE(gplink_1.to_string(), gplink_2.to_string());
}
void ADMCTestGplink::contains_data() {

View File

@ -34,7 +34,7 @@ void ADMCTestGpoptionsEdit::init() {
add_attribute_edit(edit);
check = parent_widget->findChild<QCheckBox *>();
QVERIFY(check != nullptr);
QVERIFY(check);
const QString name = TEST_OU;
dn = test_object_dn(name, CLASS_OU);

View File

@ -55,7 +55,7 @@ void ADMCTestGroupScopeEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QVERIFY(combo->currentIndex() == 0);
QCOMPARE(combo->currentIndex(), 0);
}
void ADMCTestGroupScopeEdit::apply_unmodified() {
@ -71,7 +71,7 @@ void ADMCTestGroupScopeEdit::apply() {
const AdObject updated_object = ad.search_object(dn);
const GroupScope scope = updated_object.get_group_scope();
QVERIFY(scope == GroupScope_DomainLocal);
QCOMPARE(scope, GroupScope_DomainLocal);
}
QTEST_MAIN(ADMCTestGroupScopeEdit)

View File

@ -55,7 +55,7 @@ void ADMCTestGroupTypeEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QVERIFY(combo->currentIndex() == 0);
QCOMPARE(combo->currentIndex(), 0);
}
void ADMCTestGroupTypeEdit::apply_unmodified() {
@ -71,7 +71,7 @@ void ADMCTestGroupTypeEdit::apply() {
const AdObject updated_object = ad.search_object(dn);
const GroupType type = updated_object.get_group_type();
QVERIFY(type == GroupType_Distribution);
QCOMPARE(type, GroupType_Distribution);
}
QTEST_MAIN(ADMCTestGroupTypeEdit)

View File

@ -35,21 +35,21 @@ void ADMCTestLogonComputersEdit::init() {
add_attribute_edit(edit);
dialog = parent_widget->findChild<LogonComputersDialog *>();
QVERIFY(dialog != nullptr);
QVERIFY(dialog);
open_dialog_button = parent_widget->findChild<QPushButton *>("logon_computers_edit_button");
list = dialog->findChild<QListWidget *>("list");
QVERIFY(list != nullptr);
QVERIFY(list);
value_edit = dialog->findChild<QLineEdit *>("edit");
QVERIFY(value_edit != nullptr);
QVERIFY(value_edit);
add_button = dialog->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
remove_button = dialog->findChild<QPushButton *>("remove_button");
QVERIFY(remove_button != nullptr);
QVERIFY(remove_button);
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
@ -67,7 +67,7 @@ void ADMCTestLogonComputersEdit::load() {
open_dialog_button->click();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
QVERIFY(list->count() == 2);
QCOMPARE(list->count(), 2);
test_list_item(0, "test");
test_list_item(1, "value");
}
@ -96,7 +96,7 @@ void ADMCTestLogonComputersEdit::add() {
add_button->click();
QVERIFY(list->count() == 3);
QCOMPARE(list->count(), 3);
test_list_item(0, "test");
test_list_item(1, "value");
test_list_item(2, "new");
@ -110,14 +110,14 @@ void ADMCTestLogonComputersEdit::remove() {
remove_button->click();
QVERIFY(list->count() == 1);
QCOMPARE(list->count(), 1);
test_list_item(0, "value");
}
void ADMCTestLogonComputersEdit::test_list_item(const int row, const QString &text) {
auto item = list->item(row);
QVERIFY(item != nullptr);
QVERIFY(item->text() == text);
QVERIFY(item);
QCOMPARE(item->text(), text);
}
void ADMCTestLogonComputersEdit::apply_unmodified() {
@ -138,7 +138,7 @@ void ADMCTestLogonComputersEdit::apply() {
const AdObject updated_object = ad.search_object(dn);
const QString updated_value = updated_object.get_string(ATTRIBUTE_USER_WORKSTATIONS);
QVERIFY(updated_value == "test,value,new");
QCOMPARE(updated_value, "test,value,new");
}
QTEST_MAIN(ADMCTestLogonComputersEdit)

View File

@ -38,10 +38,10 @@ void ADMCTestLogonHoursDialog::init() {
utc_time_button = dialog->findChild<QRadioButton *>("utc_time_button");
view = dialog->findChild<QTableView *>();
QVERIFY(view != nullptr);
QVERIFY(view);
model = dialog->findChild<QStandardItemModel *>();
QVERIFY(model != nullptr);
QVERIFY(model);
selection_model = view->selectionModel();
}
@ -84,11 +84,11 @@ const QList<QList<bool>> test_bools = []() {
void ADMCTestLogonHoursDialog::conversion_funs() {
const QList<QList<bool>> converted_bools = logon_hours_to_bools(test_bytes);
QVERIFY(converted_bools == test_bools);
QCOMPARE(converted_bools, test_bools);
const QByteArray converted_bytes = logon_hours_to_bytes(test_bools);
QVERIFY(converted_bytes == test_bytes);
QCOMPARE(converted_bytes, test_bytes);
}
void ADMCTestLogonHoursDialog::load() {
@ -105,7 +105,7 @@ void ADMCTestLogonHoursDialog::load() {
model->index(2, 6),
};
QVERIFY(selected_set == correct_selected_set);
QCOMPARE(selected_set, correct_selected_set);
}
// Dialog should handle loading undefined value, where
@ -114,13 +114,13 @@ void ADMCTestLogonHoursDialog::load_undefined() {
dialog->load(QByteArray());
const QByteArray out = dialog->get();
QVERIFY(out == empty_bytes);
QCOMPARE(out, empty_bytes);
}
void ADMCTestLogonHoursDialog::get_unchanged() {
dialog->load(test_bytes);
const QByteArray returned_bytes = dialog->get();
QVERIFY(returned_bytes == test_bytes);
QCOMPARE(returned_bytes, test_bytes);
}
void ADMCTestLogonHoursDialog::handle_timezone() {
@ -139,7 +139,7 @@ void ADMCTestLogonHoursDialog::handle_timezone() {
model->index(Weekday_Tuesday, 0),
};
const QList<QModelIndex> utc_selected = selection_model->selectedIndexes();
QVERIFY(utc_selected == correct_utc_selected);
QCOMPARE(utc_selected, correct_utc_selected);
// Then local time
local_time_button->setChecked(true);
@ -163,7 +163,7 @@ void ADMCTestLogonHoursDialog::handle_timezone() {
return QList<QModelIndex>({model->index(row, col)});
}();
const QList<QModelIndex> local_selected = selection_model->selectedIndexes();
QVERIFY(local_selected == correct_local_selected);
QCOMPARE(local_selected, correct_local_selected);
}
QTEST_MAIN(ADMCTestLogonHoursDialog)

View File

@ -63,7 +63,7 @@ void ADMCTestManagerEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QVERIFY(manager_display->text() == manager_dn);
QCOMPARE(manager_display->text(), manager_dn);
}
void ADMCTestManagerEdit::apply_unmodified() {
@ -82,7 +82,7 @@ void ADMCTestManagerEdit::apply_after_change() {
const AdObject updated_object = ad.search_object(dn);
const QString updated_manager = updated_object.get_string(ATTRIBUTE_MANAGER);
QVERIFY(updated_manager == manager_dn);
QCOMPARE(updated_manager, manager_dn);
}
void ADMCTestManagerEdit::apply_after_clear() {

View File

@ -40,16 +40,16 @@ void ADMCTestMemberOfTab::init() {
add_widget(member_of_tab);
view = member_of_tab->findChild<QTreeView *>();
QVERIFY(view != nullptr);
QVERIFY(view);
model = member_of_tab->findChild<QStandardItemModel *>();
QVERIFY(model != nullptr);
QVERIFY(model);
add_button = member_of_tab->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
remove_button = member_of_tab->findChild<QPushButton *>("remove_button");
QVERIFY(remove_button != nullptr);
QVERIFY(remove_button);
// Create test user
const QString user_name = TEST_USER;
@ -71,7 +71,7 @@ void ADMCTestMemberOfTab::init() {
// Loading a group without members should result in empty
// model
void ADMCTestMemberOfTab::load_empty() {
QVERIFY(model->rowCount() == 1);
QCOMPARE(model->rowCount(), 1);
}
// Loading a group with members should put members in the
@ -83,10 +83,10 @@ void ADMCTestMemberOfTab::load() {
const AdObject object = ad.search_object(user_dn);
member_of_tab->load(ad, object);
QVERIFY(model->rowCount() == 2);
QCOMPARE(model->rowCount(), 2);
auto item = model->item(1, 0);
QVERIFY(item->text() == dn_get_name(group_dn));
QCOMPARE(item->text(), dn_get_name(group_dn));
}
// Removing members should remove members from model and group
@ -103,7 +103,7 @@ void ADMCTestMemberOfTab::remove() {
const AdObject updated_object = ad.search_object(user_dn);
const QList<QString> member_list = updated_object.get_strings(ATTRIBUTE_MEMBER_OF);
QVERIFY(model->rowCount() == 1);
QCOMPARE(model->rowCount(), 1);
QVERIFY(member_list.isEmpty());
}
@ -113,8 +113,8 @@ void ADMCTestMemberOfTab::add() {
select_object_dialog_select(group_dn);
// Check ui state before applying
QVERIFY(model->rowCount() == 2);
QVERIFY(model->item(1, 0)->text() == dn_get_name(group_dn));
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->item(1, 0)->text(), dn_get_name(group_dn));
// Apply and check object state
member_of_tab->apply(ad, user_dn);
@ -123,8 +123,8 @@ void ADMCTestMemberOfTab::add() {
QVERIFY(member_of_list.contains(group_dn));
// Check ui state after applying (just in case)
QVERIFY(model->rowCount() == 2);
QVERIFY(model->item(1, 0)->text() == dn_get_name(group_dn));
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->item(1, 0)->text(), dn_get_name(group_dn));
}
QTEST_MAIN(ADMCTestMemberOfTab)

View File

@ -37,16 +37,16 @@ void ADMCTestMembersTab::init() {
add_widget(members_tab);
view = members_tab->findChild<QTreeView *>();
QVERIFY(view != nullptr);
QVERIFY(view);
model = members_tab->findChild<QStandardItemModel *>();
QVERIFY(model != nullptr);
QVERIFY(model);
add_button = members_tab->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
remove_button = members_tab->findChild<QPushButton *>("remove_button");
QVERIFY(remove_button != nullptr);
QVERIFY(remove_button);
// Create test user
const QString user_name = TEST_USER;
@ -68,7 +68,7 @@ void ADMCTestMembersTab::init() {
// Loading a group without members should result in empty
// model
void ADMCTestMembersTab::load_empty() {
QVERIFY(model->rowCount() == 0);
QCOMPARE(model->rowCount(), 0);
}
// Loading a group with members should put members in the
@ -80,10 +80,10 @@ void ADMCTestMembersTab::load() {
const AdObject object = ad.search_object(group_dn);
members_tab->load(ad, object);
QVERIFY(model->rowCount() == 1);
QCOMPARE(model->rowCount(), 1);
auto item = model->item(0, 0);
QVERIFY(item->text() == dn_get_name(user_dn));
QCOMPARE(item->text(), dn_get_name(user_dn));
}
// Removing members should remove members from model and group
@ -100,7 +100,7 @@ void ADMCTestMembersTab::remove() {
const AdObject updated_object = ad.search_object(group_dn);
const QList<QString> member_list = updated_object.get_strings(ATTRIBUTE_MEMBER);
QVERIFY(model->rowCount() == 0);
QCOMPARE(model->rowCount(), 0);
QVERIFY(member_list.isEmpty());
}
@ -110,18 +110,18 @@ void ADMCTestMembersTab::add() {
select_object_dialog_select(user_dn);
// Check ui state before applying
QVERIFY(model->rowCount() == 1);
QVERIFY(model->item(0, 0)->text() == dn_get_name(user_dn));
QCOMPARE(model->rowCount(), 1);
QCOMPARE(model->item(0, 0)->text(), dn_get_name(user_dn));
// Apply and check object state
members_tab->apply(ad, group_dn);
const AdObject object = ad.search_object(group_dn);
const QList<QString> member_list = object.get_strings(ATTRIBUTE_MEMBER);
QVERIFY(member_list == QList<QString>({user_dn}));
QCOMPARE(member_list, QList<QString>({user_dn}));
// Check ui state after applying (just in case)
QVERIFY(model->rowCount() == 1);
QVERIFY(model->item(0, 0)->text() == dn_get_name(user_dn));
QCOMPARE(model->rowCount(), 1);
QCOMPARE(model->item(0, 0)->text(), dn_get_name(user_dn));
}
QTEST_MAIN(ADMCTestMembersTab)

View File

@ -48,20 +48,20 @@ void ADMCTestMultiEditor::init() {
void ADMCTestMultiEditor::load_empty() {
edit->load({});
QVERIFY(list_widget->count() == 0);
QCOMPARE(list_widget->count(), 0);
}
void ADMCTestMultiEditor::load() {
edit->load(test_value);
QListWidgetItem *item = list_widget->item(0);
QVERIFY(item != nullptr);
QVERIFY(item->text() == "hello");
QVERIFY(item);
QCOMPARE(item->text(), "hello");
}
void ADMCTestMultiEditor::get_new_values() {
edit->load(test_value);
const QList<QByteArray> current = edit->get_new_values();
QVERIFY(current == test_value);
QCOMPARE(current, test_value);
}
void ADMCTestMultiEditor::add() {
@ -70,7 +70,7 @@ void ADMCTestMultiEditor::add() {
add_button->click();
auto string_editor = edit->findChild<StringEditor *>();
QVERIFY(string_editor != nullptr);
QVERIFY(string_editor);
auto line_edit = string_editor->findChild<QLineEdit *>();
QVERIFY(line_edit);
@ -81,11 +81,11 @@ void ADMCTestMultiEditor::add() {
string_editor->accept();
QVERIFY(list_widget->count() == 2);
QCOMPARE(list_widget->count(), 2);
auto added_item = list_widget->item(1);
QVERIFY(added_item != nullptr);
QVERIFY(added_item->text() == new_value);
QVERIFY(added_item);
QCOMPARE(added_item->text(), new_value);
}
void ADMCTestMultiEditor::remove() {
@ -98,9 +98,9 @@ void ADMCTestMultiEditor::remove() {
list_widget->setCurrentRow(1);
remove_button->click();
QVERIFY(list_widget->count() == 2);
QVERIFY(list_widget->item(0)->text() == "first");
QVERIFY(list_widget->item(1)->text() == "third");
QCOMPARE(list_widget->count(), 2);
QCOMPARE(list_widget->item(0)->text(), "first");
QCOMPARE(list_widget->item(1)->text(), "third");
}
QTEST_MAIN(ADMCTestMultiEditor)

View File

@ -57,19 +57,19 @@ void ADMCTestObjectMenu::object_menu_new_user() {
// Fill out edits
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
name_edit->setText(name);
auto sama_edit = create_dialog->findChild<QLineEdit *>("sama_edit");
QVERIFY(sama_edit != nullptr);
QVERIFY(sama_edit);
sama_edit->setText(logon_name);
auto password_main_edit = create_dialog->findChild<QLineEdit *>("password_main_edit");
QVERIFY(password_main_edit != nullptr);
QVERIFY(password_main_edit);
password_main_edit->setText(password);
auto password_confirm_edit = create_dialog->findChild<QLineEdit *>("password_confirm_edit");
QVERIFY(password_confirm_edit != nullptr);
QVERIFY(password_confirm_edit);
password_confirm_edit->setText(password);
create_dialog->accept();
@ -91,7 +91,7 @@ void ADMCTestObjectMenu::object_menu_new_ou() {
// Enter name
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
name_edit->setText(name);
create_dialog->accept();
@ -114,12 +114,12 @@ void ADMCTestObjectMenu::object_menu_new_computer() {
// Enter name
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
name_edit->setText(name);
// Enter logon name
auto sama_edit = create_dialog->findChild<QLineEdit *>("sama_edit");
QVERIFY(sama_edit != nullptr);
QVERIFY(sama_edit);
sama_edit->setText(name);
create_dialog->accept();
@ -142,12 +142,12 @@ void ADMCTestObjectMenu::object_menu_new_group() {
// Enter name
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
name_edit->setText(name);
// Enter logon name
auto sama_edit = create_dialog->findChild<QLineEdit *>("sama_edit");
QVERIFY(sama_edit != nullptr);
QVERIFY(sama_edit);
sama_edit->setText(name);
create_dialog->accept();
@ -174,14 +174,14 @@ void ADMCTestObjectMenu::object_menu_find_simple() {
// Enter name in search field
auto simple_tab = find_dialog->findChild<FilterWidgetSimpleTab *>();
QVERIFY(simple_tab != nullptr);
QVERIFY(simple_tab);
auto name_edit = simple_tab->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
name_edit->setText(user_name);
// Press find button
auto find_button = find_dialog->findChild<QPushButton *>("find_button");
QVERIFY(find_button != nullptr);
QVERIFY(find_button);
find_button->click();
// Confirm that results are not empty
@ -208,9 +208,9 @@ void ADMCTestObjectMenu::object_menu_find_advanced() {
QVERIFY(QTest::qWaitForWindowExposed(find_dialog, 1000));
auto tab_widget = find_dialog->findChild<QTabWidget *>();
QVERIFY(tab_widget != nullptr);
QVERIFY(tab_widget);
auto advanced_tab = find_dialog->findChild<FilterWidgetAdvancedTab *>();
QVERIFY(advanced_tab != nullptr);
QVERIFY(advanced_tab);
tab_widget->setCurrentWidget(advanced_tab);
auto filter_edit = advanced_tab->findChild<QPlainTextEdit *>();
@ -218,7 +218,7 @@ void ADMCTestObjectMenu::object_menu_find_advanced() {
filter_edit->setPlainText(filter);
auto find_button = find_dialog->findChild<QPushButton *>("find_button");
QVERIFY(find_button != nullptr);
QVERIFY(find_button);
find_button->click();
auto find_results = find_dialog->findChild<QTreeView *>();
@ -248,7 +248,7 @@ void ADMCTestObjectMenu::object_menu_rename() {
// Enter new name
auto name_edit = rename_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit != nullptr);
QVERIFY(name_edit);
name_edit->setText(new_name);
rename_dialog->accept();

View File

@ -70,7 +70,7 @@ void ADMCTestPolicyResultsWidget::init() {
view = results_view->detail_view();
model = widget->findChild<QStandardItemModel *>();
QVERIFY(model != nullptr);
QVERIFY(model);
}
void ADMCTestPolicyResultsWidget::load_empty() {
@ -99,7 +99,7 @@ void ADMCTestPolicyResultsWidget::load() {
QList<QStandardItem *> item_list;
for (int col = 0; col < 4; col++) {
QStandardItem *item = model->item(0, col);
QVERIFY(item != nullptr);
QVERIFY(item);
item_list.append(item);
}

View File

@ -38,7 +38,7 @@ void ADMCTestProtectDeletionEdit::init() {
add_attribute_edit(edit);
checkbox = parent_widget->findChild<QCheckBox *>();
QVERIFY(checkbox != nullptr);
QVERIFY(checkbox);
dn = test_object_dn(TEST_OU, CLASS_OU);
const bool create_success = ad.object_add(dn, CLASS_OU);
@ -85,7 +85,7 @@ void ADMCTestProtectDeletionEdit::apply() {
QVERIFY(apply_2_success);
const bool delete_2_success = ad.object_delete(dn);
QCOMPARE(delete_2_success, true);
QVERIFY(delete_2_success);
}
QTEST_MAIN(ADMCTestProtectDeletionEdit)

View File

@ -38,7 +38,7 @@ void ADMCTestSelectBaseWidget::init() {
add_widget(select_base_widget);
combo = select_base_widget->findChild<QComboBox *>();
QVERIFY(combo != nullptr);
QVERIFY(combo);
// Create test OU's
const QList<QString> ou_name_list = {
@ -62,7 +62,7 @@ void ADMCTestSelectBaseWidget::default_to_domain_head() {
const QString domain_head = g_adconfig->domain_head();
const QString base = select_base_widget->get_base();
QVERIFY(base == domain_head);
QCOMPARE(base, domain_head);
}
// After selecting a search base, the widget should return
@ -110,7 +110,7 @@ void ADMCTestSelectBaseWidget::save_state() {
// Check that deserialization successfully restored
// original state
const QString base_deserialized = select_base_widget->get_base();
QVERIFY(base_original == base_deserialized);
QCOMPARE(base_original, base_deserialized);
}
QTEST_MAIN(ADMCTestSelectBaseWidget)

View File

@ -40,10 +40,10 @@ void ADMCTestSelectObjectDialog::init() {
select_base_widget_add(select_base_widget, test_arena_dn());
edit = dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(edit != nullptr);
QVERIFY(edit);
add_button = dialog->findChild<QPushButton *>("add_button");
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
}
void ADMCTestSelectObjectDialog::empty() {
@ -93,7 +93,7 @@ void ADMCTestSelectObjectDialog::multiple_matches() {
select_object_in_multi_match_dialog(TEST_USER, dn2);
const QList<QString> selected = dialog->get_selected();
QVERIFY(selected == QList<QString>({dn2}));
QCOMPARE(selected, QList<QString>({dn2}));
}
// Adding same object two times should open message box
@ -107,7 +107,7 @@ void ADMCTestSelectObjectDialog::one_match_duplicate() {
add_button->click();
const QList<QString> selected_first = dialog->get_selected();
QVERIFY(selected_first == QList<QString>({dn}));
QCOMPARE(selected_first, QList<QString>({dn}));
edit->setText(TEST_USER);
@ -116,7 +116,7 @@ void ADMCTestSelectObjectDialog::one_match_duplicate() {
close_message_box();
const QList<QString> selected_second = dialog->get_selected();
QVERIFY(selected_second == QList<QString>({dn}));
QCOMPARE(selected_second, QList<QString>({dn}));
}
// Duplicates should also be processed for multiple match
@ -133,12 +133,12 @@ void ADMCTestSelectObjectDialog::multiple_match_duplicate() {
select_object_in_multi_match_dialog(TEST_USER, dn2);
const QList<QString> selected_first = dialog->get_selected();
QVERIFY(selected_first == QList<QString>({dn2}));
QCOMPARE(selected_first, QList<QString>({dn2}));
select_object_in_multi_match_dialog(TEST_USER, dn2);
const QList<QString> selected_second = dialog->get_selected();
QVERIFY(selected_second == QList<QString>({dn2}));
QCOMPARE(selected_second, QList<QString>({dn2}));
}
void ADMCTestSelectObjectDialog::select_object_in_multi_match_dialog(const QString &name, const QString &dn) {
@ -147,17 +147,17 @@ void ADMCTestSelectObjectDialog::select_object_in_multi_match_dialog(const QStri
add_button->click();
auto match_dialog = dialog->findChild<SelectObjectMatchDialog *>();
QVERIFY(match_dialog != nullptr);
QVERIFY(match_dialog);
auto match_dialog_view = match_dialog->findChild<QTreeView *>();
QVERIFY(match_dialog_view != nullptr);
QVERIFY(match_dialog_view);
wait_for_find_results_to_load(match_dialog_view);
navigate_until_object(match_dialog_view, dn, ObjectRole_DN);
auto ok_button = match_dialog->findChild<QPushButton *>();
QVERIFY(ok_button != nullptr);
QVERIFY(ok_button);
ok_button->click();

View File

@ -34,7 +34,7 @@ void ADMCTestStringEdit::init() {
add_attribute_edit(edit);
line_edit = parent_widget->findChild<QLineEdit *>();
QVERIFY(line_edit != nullptr);
QVERIFY(line_edit);
// Create test user
const QString name = TEST_USER;
@ -69,7 +69,7 @@ void ADMCTestStringEdit::load() {
const QString edit_value = line_edit->text();
;
QVERIFY(edit_value == test_value);
QCOMPARE(edit_value, test_value);
}
void ADMCTestStringEdit::apply_unmodified() {
@ -87,7 +87,7 @@ void ADMCTestStringEdit::apply_modified() {
const AdObject object = ad.search_object(dn);
const QString current_value = object.get_string(TEST_ATTRIBUTE);
QVERIFY(current_value == new_value);
QCOMPARE(current_value, new_value);
}
QTEST_MAIN(ADMCTestStringEdit)

View File

@ -42,14 +42,14 @@ void ADMCTestStringEditor::load_empty() {
void ADMCTestStringEditor::load() {
edit->load({QByteArray("hello")});
QVERIFY(line_edit->text() == "hello");
QCOMPARE(line_edit->text(), "hello");
}
void ADMCTestStringEditor::get_new_values() {
const QList<QByteArray> correct_value_list = {QByteArray("hello")};
edit->load(correct_value_list);
const QList<QByteArray> value_list = edit->get_new_values();
QVERIFY(correct_value_list == value_list);
QCOMPARE(correct_value_list, value_list);
}
QTEST_MAIN(ADMCTestStringEditor)

View File

@ -34,7 +34,7 @@ void ADMCTestStringLargeEdit::init() {
add_attribute_edit(edit);
text_edit = parent_widget->findChild<QPlainTextEdit *>();
QVERIFY(text_edit != nullptr);
QVERIFY(text_edit);
// Create test user
const QString name = TEST_USER;
@ -69,7 +69,7 @@ void ADMCTestStringLargeEdit::load() {
const QString edit_value = text_edit->toPlainText();
;
QVERIFY(edit_value == test_value);
QCOMPARE(edit_value, test_value);
}
void ADMCTestStringLargeEdit::apply_unmodified() {
@ -87,7 +87,7 @@ void ADMCTestStringLargeEdit::apply() {
const AdObject object = ad.search_object(dn);
const QString current_value = object.get_string(TEST_ATTRIBUTE);
QVERIFY(current_value == new_value);
QCOMPARE(current_value, new_value);
}
QTEST_MAIN(ADMCTestStringLargeEdit)

View File

@ -48,10 +48,10 @@ void ADMCTestStringOtherEdit::init() {
add_attribute_edit(edit);
line_edit = parent_widget->findChild<QLineEdit *>();
QVERIFY(line_edit != nullptr);
QVERIFY(line_edit);
other_button = parent_widget->findChild<QPushButton *>();
QVERIFY(other_button != nullptr);
QVERIFY(other_button);
// Create test user
const QString name = TEST_USER;
@ -91,19 +91,19 @@ void ADMCTestStringOtherEdit::test_emit_edited_signal() {
// Edit should contain current attribute value after load()
// call
void ADMCTestStringOtherEdit::load() {
QVERIFY(line_edit->text() == main_value);
QCOMPARE(line_edit->text(), main_value);
other_button->click();
auto multi_editor = parent_widget->findChild<MultiEditor *>();
QVERIFY(multi_editor != nullptr);
QVERIFY(multi_editor);
auto list_widget = multi_editor->findChild<QListWidget *>();
QVERIFY(list_widget != nullptr);
QVERIFY(list_widget);
QVERIFY(line_edit->text() == main_value);
QCOMPARE(line_edit->text(), main_value);
for (int i = 0; i < 3; i++) {
QVERIFY(list_widget->item(i)->text() == other_value_list[i]);
QCOMPARE(list_widget->item(i)->text(), other_value_list[i]);
}
}
@ -120,11 +120,11 @@ void ADMCTestStringOtherEdit::apply_modified_main_value() {
const AdObject object = ad.search_object(dn);
const QString current_value_main = object.get_string(TEST_ATTRIBUTE_MAIN);
QVERIFY(current_value_main == new_value);
QCOMPARE(current_value_main, new_value);
const QList<QByteArray> current_value_other = object.get_values(TEST_ATTRIBUTE_OTHER);
QVERIFY(current_value_other == other_value_list);
QCOMPARE(current_value_other, other_value_list);
}
void ADMCTestStringOtherEdit::apply_modified_other_value() {
@ -136,31 +136,31 @@ void ADMCTestStringOtherEdit::apply_modified_other_value() {
const AdObject object = ad.search_object(dn);
const QString current_value_main = object.get_string(TEST_ATTRIBUTE_MAIN);
QVERIFY(current_value_main == main_value);
QCOMPARE(current_value_main, main_value);
const QList<QByteArray> current_value_other = object.get_values(TEST_ATTRIBUTE_OTHER);
QList<QByteArray> correct_value_other = other_value_list;
correct_value_other.append(new_value);
QVERIFY(current_value_other == correct_value_other);
QCOMPARE(current_value_other, correct_value_other);
}
void ADMCTestStringOtherEdit::add_new_other_value() {
other_button->click();
auto multi_editor = parent_widget->findChild<MultiEditor *>();
QVERIFY(multi_editor != nullptr);
QVERIFY(multi_editor);
auto add_button = multi_editor->findChild<QPushButton *>();
QVERIFY(add_button != nullptr);
QVERIFY(add_button);
add_button->click();
auto string_editor = multi_editor->findChild<StringEditor *>();
QVERIFY(string_editor != nullptr);
QVERIFY(string_editor);
auto string_editor_line_edit = string_editor->findChild<QLineEdit *>();
QVERIFY(string_editor_line_edit != nullptr);
QVERIFY(string_editor_line_edit);
string_editor_line_edit->setText(new_value);

View File

@ -38,7 +38,7 @@ void ADMCTestUnlockEdit::init() {
add_attribute_edit(unlock_edit);
checkbox = parent_widget->findChild<QCheckBox *>();
QVERIFY(checkbox != nullptr);
QVERIFY(checkbox);
// Create test user
const QString name = TEST_USER;

View File

@ -36,10 +36,10 @@ void ADMCTestUpnEdit::init() {
add_attribute_edit(upn_edit);
prefix_edit = parent_widget->findChild<QLineEdit *>();
QVERIFY(prefix_edit != nullptr);
QVERIFY(prefix_edit);
suffix_edit = parent_widget->findChild<QComboBox *>();
QVERIFY(suffix_edit != nullptr);
QVERIFY(suffix_edit);
// Create test user
const QString name = TEST_USER;
@ -57,10 +57,10 @@ void ADMCTestUpnEdit::init() {
// Edit should load prefix and suffix into widgets correctly
void ADMCTestUpnEdit::test_load() {
const QString prefix = prefix_edit->text();
QVERIFY(prefix == TEST_USER);
QCOMPARE(prefix, TEST_USER);
const QString suffix = suffix_edit->currentText();
QVERIFY(suffix == TEST_SUFFIX);
QCOMPARE(suffix, TEST_SUFFIX);
}
// edited() signal should be emitted when prefix or suffix