1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-25 02:03:35 +03:00

use ui class to access widgets in tests

instead of using findChild() with widget names
now changing a name will cause an error if some test uses old name
This commit is contained in:
Dmitry Degtyarev 2021-10-18 12:29:43 +04:00
parent 580e98b84a
commit 73b2920b74
27 changed files with 187 additions and 246 deletions

View File

@ -33,6 +33,8 @@ namespace Ui {
class ExpiryWidget final : public QWidget {
Q_OBJECT
public:
Ui::ExpiryWidget *ui;
ExpiryWidget(QWidget *parent = nullptr);
void load(const AdObject &object);
@ -43,8 +45,6 @@ signals:
void edited();
private:
Ui::ExpiryWidget *ui;
QString get_new_value() const;
void on_never_check();
void on_end_of_check();

View File

@ -34,14 +34,14 @@ class LogonComputersDialog final : public QDialog {
Q_OBJECT
public:
Ui::LogonComputersDialog *ui;
LogonComputersDialog(QWidget *parent);
void load(const QString &value);
QString get() const;
private:
Ui::LogonComputersDialog *ui;
void on_add_button();
void on_remove_button();
};

View File

@ -27,9 +27,7 @@
#include <QDialog>
class QTableView;
class QStandardItemModel;
class QRadioButton;
// NOTE: this is the order in logon hours value. Different
// from the display order in the dialog where first day is monday
@ -56,6 +54,8 @@ class LogonHoursDialog : public QDialog {
Q_OBJECT
public:
Ui::LogonHoursDialog *ui;
LogonHoursDialog(QWidget *parent);
void load(const QByteArray &value);
@ -65,11 +65,8 @@ public:
void reject() override;
private:
Ui::LogonHoursDialog *ui;
QTableView *view;
QStandardItemModel *model;
QByteArray original_value;
QRadioButton *local_time_button;
void switch_to_local_time();
void on_local_time_button_toggled(bool checked);

View File

@ -35,7 +35,7 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<widget class="QDialogButtonBox" name="button_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>

View File

@ -26,6 +26,9 @@ include_directories(
${PROJECT_SOURCE_DIR}/src/admc
${PROJECT_SOURCE_DIR}/src/adldap
${PROJECT_SOURCE_DIR}/tests
# NOTE: hack to get to generated .ui headers
${PROJECT_SOURCE_DIR}/build/src/admc/admctest_autogen/include
)
# NOTE: ADD ALL TESTS TO THIS LIST

View File

@ -22,6 +22,7 @@
#include "adldap.h"
#include "console_impls/object_impl.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/filter_widget_simple_tab.h"
#include "filter_widget/select_base_widget.h"
#include "globals.h"
@ -30,6 +31,14 @@
#include "select_object_dialog.h"
#include "utils.h"
#include "edits/attribute_edit.h"
#include "find_widget.h"
#include "ui_select_object_dialog.h"
#include "ui_find_widget.h"
#include "ui_select_object_advanced_dialog.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include "filter_widget/ui_select_base_widget.h"
#include "ui_select_container_dialog.h"
#include <QLineEdit>
#include <QMessageBox>
@ -190,8 +199,7 @@ 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);
QPushButton *add_button = select_dialog->ui->add_button;
add_button->click();
// Find dialog has been opened, so switch to it
@ -199,17 +207,15 @@ void ADMCTest::select_in_select_dialog(SelectObjectDialog *select_dialog, const
QVERIFY(find_select_dialog);
QVERIFY(QTest::qWaitForWindowExposed(find_select_dialog, 1000));
FindWidget *find_widget = find_select_dialog->ui->find_widget;
// Enter group name in "Name" edit
const QString name = dn_get_name(dn);
auto simple_tab = select_dialog->findChild<FilterWidgetSimpleTab *>();
QVERIFY(simple_tab);
auto name_edit = simple_tab->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
QLineEdit *name_edit = find_widget->ui->filter_widget->ui->simple_tab->ui->name_edit;
name_edit->setText(name);
// Press "Find" button
auto find_button = find_select_dialog->findChild<QPushButton *>("find_button");
QVERIFY(find_button);
auto find_button = find_widget->ui->find_button;
find_button->click();
// Switch to find results
@ -230,17 +236,13 @@ void ADMCTest::select_object_dialog_select(const QString &dn) {
auto select_dialog = parent_widget->findChild<SelectObjectDialog *>();
QVERIFY(select_dialog);
auto select_base_widget = select_dialog->findChild<SelectBaseWidget *>();
QVERIFY(select_base_widget);
SelectBaseWidget *select_base_widget = select_dialog->ui->select_base_widget;
select_base_widget_add(select_base_widget, test_arena_dn());
auto edit = select_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(edit);
auto add_button = select_dialog->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
QLineEdit *edit = select_dialog->ui->name_edit;
edit->setText(dn_get_name(dn));
QPushButton *add_button = select_dialog->ui->add_button;
add_button->click();
select_dialog->accept();
@ -266,18 +268,15 @@ void ADMCTest::test_edit_apply_unmodified(AttributeEdit *edit, const QString &dn
QVERIFY(object_before.get_attributes_data() == object_after.get_attributes_data());
}
void select_base_widget_add(SelectBaseWidget *widget, const QString &dn) {
auto browse_button = widget->findChild<QPushButton *>();
QVERIFY(browse_button);
void ADMCTest::select_base_widget_add(SelectBaseWidget *widget, const QString &dn) {
QPushButton *browse_button = widget->ui->browse_button;
browse_button->click();
auto select_container_dialog = widget->findChild<SelectContainerDialog *>();
QVERIFY(select_container_dialog);
QVERIFY(QTest::qWaitForWindowExposed(select_container_dialog, 1000));
auto select_container_view = select_container_dialog->findChild<QTreeView *>();
QVERIFY(select_container_view);
QTreeView *select_container_view = select_container_dialog->ui->view;
navigate_until_object(select_container_view, dn, ContainerRole_DN);
select_container_dialog->accept();

View File

@ -107,14 +107,14 @@ protected:
void test_edit_apply_unmodified(AttributeEdit *edit, const QString &dn);
// Add a base to the base combo. Note that it is also
// automatically selected.
void select_base_widget_add(SelectBaseWidget *widget, const QString &dn);
private:
QFormLayout *layout;
};
void navigate_until_object(QTreeView *view, const QString &target_dn, const int dn_role);
// Add a base to the base combo. Note that it is also
// automatically selected.
void select_base_widget_add(SelectBaseWidget *widget, const QString &dn);
#endif /* ADMC_TEST_H */

View File

@ -22,6 +22,9 @@
#include "editors/multi_editor.h"
#include "editors/string_editor.h"
#include "editors/ui_multi_editor.h"
#include "editors/ui_string_editor.h"
#include "tabs/ui_attributes_tab.h"
#include <QDialog>
#include <QLineEdit>
@ -54,8 +57,7 @@ void ADMCTestAttributesTab::init() {
filter_menu = attributes_tab->findChild<AttributesFilterMenu *>();
QVERIFY(filter_menu);
view = attributes_tab->findChild<QTreeView *>();
QVERIFY(view);
view = attributes_tab->ui->view;
model = attributes_tab->findChild<QStandardItemModel *>();
QVERIFY(model);
@ -63,11 +65,9 @@ void ADMCTestAttributesTab::init() {
proxy = attributes_tab->findChild<QSortFilterProxyModel *>();
QVERIFY(proxy);
filter_button = attributes_tab->findChild<QPushButton *>("filter_button");
QVERIFY(filter_button);
filter_button = attributes_tab->ui->filter_button;
edit_button = attributes_tab->findChild<QPushButton *>("edit_button");
QVERIFY(filter_button);
edit_button = attributes_tab->ui->edit_button;
// Create test user
const QString name = TEST_USER;
@ -169,16 +169,14 @@ void ADMCTestAttributesTab::apply() {
QVERIFY(multi_editor);
QVERIFY(QTest::qWaitForWindowExposed(multi_editor, 1000));
auto add_button = multi_editor->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
QPushButton *add_button = multi_editor->ui->add_button;
add_button->click();
auto string_editor = multi_editor->findChild<StringEditor *>();
QVERIFY(string_editor);
QVERIFY(QTest::qWaitForWindowExposed(string_editor, 1000));
auto string_editor_edit = string_editor->findChild<QLineEdit *>();
QVERIFY(string_editor_edit);
QLineEdit *string_editor_edit = string_editor->ui->edit;
string_editor_edit->setText(correct_value);
string_editor->accept();

View File

@ -21,6 +21,7 @@
#include "admc_test_bool_editor.h"
#include "editors/bool_editor.h"
#include "editors/ui_bool_editor.h"
#include <QRadioButton>
@ -41,9 +42,15 @@ void ADMCTestBoolEditor::init() {
edit->open();
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
const QHash<QString, QRadioButton *> button_map = {
{"true_button", edit->ui->true_button},
{"false_button", edit->ui->false_button},
{"unset_button", edit->ui->unset_button},
};
QFETCH_GLOBAL(QString, button_name);
button = parent_widget->findChild<QRadioButton *>(button_name);
QVERIFY(button);
button = button_map[button_name];
}
void ADMCTestBoolEditor::load() {

View File

@ -26,6 +26,10 @@
class BoolEditor;
class QRadioButton;
enum ADMCTestBoolEditorButton {
ADMCTestBoolEditorButton_True
};
class ADMCTestBoolEditor : public ADMCTest {
Q_OBJECT

View File

@ -21,6 +21,7 @@
#include "admc_test_datetime_editor.h"
#include "editors/datetime_editor.h"
#include "editors/ui_datetime_editor.h"
#include <QDateTimeEdit>
@ -31,8 +32,7 @@ void ADMCTestDateTimeEditor::init() {
edit->open();
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
datetime_edit = edit->findChild<QDateTimeEdit *>();
QVERIFY(datetime_edit);
datetime_edit = edit->ui->edit;
}
void ADMCTestDateTimeEditor::load() {

View File

@ -21,9 +21,16 @@
#include "admc_test_edit_query_item_widget.h"
#include "edit_query_item_widget.h"
#include "ui_edit_query_item_widget.h"
#include "console_impls/query_item_impl.h"
#include "filter_widget/select_base_widget.h"
#include "filter_widget/ui_select_base_widget.h"
#include "filter_widget/filter_dialog.h"
#include "ui_filter_dialog.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/filter_widget_simple_tab.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include "tab_widget.h"
#include <QLineEdit>
@ -40,25 +47,17 @@ void ADMCTestEditQueryItemWidget::init() {
widget = new EditQueryItemWidget();
add_widget(widget);
name_edit = widget->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
name_edit = widget->ui->name_edit;
description_edit = widget->ui->description_edit;
scope_checkbox = widget->ui->scope_checkbox;
description_edit = widget->findChild<QLineEdit *>("description_edit");
QVERIFY(description_edit);
SelectBaseWidget *select_base_widget = widget->ui->select_base_widget;
scope_checkbox = widget->findChild<QCheckBox *>();
QVERIFY(scope_checkbox);
base_combo = select_base_widget->ui->combo;
SelectBaseWidget *select_base_widget = widget->findChild<SelectBaseWidget *>();
QVERIFY(select_base_widget);
base_combo = select_base_widget->findChild<QComboBox *>();
QVERIFY(base_combo);
edit_filter_button = widget->ui->edit_filter_button;
edit_filter_button = widget->findChild<QPushButton *>("edit_filter_button");
QVERIFY(edit_filter_button);
filter_display = widget->findChild<QTextEdit *>("filter_display");
filter_display = widget->ui->filter_display;
}
void ADMCTestEditQueryItemWidget::save_and_load() {
@ -85,13 +84,8 @@ void ADMCTestEditQueryItemWidget::save_and_load() {
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
QTabWidget *tab_widget = dialog->findChild<QTabWidget *>();
QVERIFY(tab_widget);
QWidget *simple_tab = tab_widget->widget(0);
QVERIFY(simple_tab);
QLineEdit *filter_name_edit = simple_tab->findChild<QLineEdit *>("name_edit");
FilterWidgetSimpleTab *simple_tab = dialog->ui->filter_widget->ui->simple_tab;
QLineEdit *filter_name_edit = simple_tab->ui->name_edit;
filter_name_edit->setText("test");
dialog->accept();

View File

@ -22,6 +22,7 @@
#include "edits/expiry_edit.h"
#include "edits/expiry_widget.h"
#include "edits/ui_expiry_widget.h"
#include "globals.h"
#include <QFormLayout>
@ -45,11 +46,14 @@ void ADMCTestExpiryEdit::init() {
edit = new ExpiryEdit(widget, &edits, parent_widget);
date_edit = parent_widget->findChild<QDateEdit *>("date_edit");
date_edit = widget->ui->date_edit;
QFETCH_GLOBAL(QString, check_name);
check = parent_widget->findChild<QCheckBox *>(check_name);
QVERIFY(check);
const QHash<QString, QCheckBox *> check_map = {
{"end_of_check", widget->ui->end_of_check},
{"never_check", widget->ui->never_check},
};
check = check_map[check_name];
// Create test user
const QString name = TEST_USER;

View File

@ -22,6 +22,14 @@
#include "filter_classes_widget.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/filter_widget_simple_tab.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include "filter_widget/filter_widget_normal_tab.h"
#include "filter_widget/ui_filter_widget_normal_tab.h"
#include "filter_widget/filter_widget_advanced_tab.h"
#include "filter_widget/ui_filter_widget_advanced_tab.h"
#include "filter_widget/ui_select_classes_widget.h"
#include "filter_widget/select_classes_widget.h"
#include <QCheckBox>
@ -32,10 +40,6 @@
#include <QTabWidget>
#include <QVBoxLayout>
#define SIMPLE_TAB_INDEX 0
#define NORMAL_TAB_INDEX 1
#define ADVANCED_TAB_INDEX 2
void ADMCTestFilterWidget::init() {
ADMCTest::init();
@ -43,27 +47,18 @@ void ADMCTestFilterWidget::init() {
filter_widget->add_classes(ad.adconfig(), filter_classes);
add_widget(filter_widget);
tab_widget = filter_widget->findChild<QTabWidget *>();
QVERIFY(tab_widget);
simple_tab = tab_widget->widget(SIMPLE_TAB_INDEX);
QVERIFY(simple_tab);
normal_tab = tab_widget->widget(NORMAL_TAB_INDEX);
QVERIFY(normal_tab);
advanced_tab = tab_widget->widget(ADVANCED_TAB_INDEX);
QVERIFY(advanced_tab);
tab_widget = filter_widget->ui->tab_widget;
simple_tab = filter_widget->ui->simple_tab;
normal_tab = filter_widget->ui->normal_tab;
advanced_tab = filter_widget->ui->advanced_tab;
}
void ADMCTestFilterWidget::test_simple_tab() {
tab_widget->setCurrentIndex(SIMPLE_TAB_INDEX);
tab_widget->setCurrentWidget(simple_tab);
auto select_classes_widget = simple_tab->findChild<SelectClassesWidget *>();
QVERIFY(select_classes_widget);
SelectClassesWidget *select_classes_widget = simple_tab->ui->select_classes;
auto select_button = select_classes_widget->findChild<QPushButton *>();
QVERIFY(select_button);
QPushButton *select_button = select_classes_widget->ui->select_button;
select_button->click();
auto select_classes_dialog = select_classes_widget->findChild<QDialog *>();
@ -80,7 +75,7 @@ void ADMCTestFilterWidget::test_simple_tab() {
select_classes_dialog->accept();
QLineEdit *name_edit = simple_tab->findChild<QLineEdit *>("name_edit");
QLineEdit *name_edit = simple_tab->ui->name_edit;
name_edit->setText("test");
const QString correct_filter = "(&(name=*test*)(objectClass=user))";
@ -101,13 +96,11 @@ void ADMCTestFilterWidget::test_simple_tab() {
}
void ADMCTestFilterWidget::test_normal_tab() {
tab_widget->setCurrentIndex(NORMAL_TAB_INDEX);
tab_widget->setCurrentWidget(normal_tab);
auto select_classes_widget = normal_tab->findChild<SelectClassesWidget *>();
QVERIFY(select_classes_widget);
SelectClassesWidget *select_classes_widget = normal_tab->ui->select_classes;
auto select_button = select_classes_widget->findChild<QPushButton *>();
QVERIFY(select_button);
QPushButton *select_button = select_classes_widget->ui->select_button;
select_button->click();
auto select_classes_dialog = select_classes_widget->findChild<QDialog *>();
@ -124,12 +117,10 @@ void ADMCTestFilterWidget::test_normal_tab() {
select_classes_dialog->accept();
QLineEdit *value_edit = normal_tab->findChild<QLineEdit *>("value_edit");
QVERIFY(value_edit);
QLineEdit *value_edit = normal_tab->ui->value_edit;
value_edit->setText("value");
QPushButton *add_button = normal_tab->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
QPushButton *add_button = normal_tab->ui->add_button;
add_button->click();
const QString correct_filter = "(&(objectClass=user)(assistant=value))";
@ -151,10 +142,9 @@ void ADMCTestFilterWidget::test_normal_tab() {
}
void ADMCTestFilterWidget::test_advanced_tab() {
tab_widget->setCurrentIndex(ADVANCED_TAB_INDEX);
tab_widget->setCurrentWidget(advanced_tab);
auto edit = advanced_tab->findChild<QPlainTextEdit *>();
QVERIFY(edit);
QPlainTextEdit *edit = advanced_tab->ui->ldap_filter_edit;
edit->setPlainText("test");

View File

@ -25,6 +25,9 @@
class FilterWidget;
class QTabWidget;
class FilterWidgetSimpleTab;
class FilterWidgetNormalTab;
class FilterWidgetAdvancedTab;
class ADMCTestFilterWidget : public ADMCTest {
Q_OBJECT
@ -39,9 +42,9 @@ private slots:
private:
FilterWidget *filter_widget;
QTabWidget *tab_widget;
QWidget *simple_tab;
QWidget *normal_tab;
QWidget *advanced_tab;
FilterWidgetSimpleTab *simple_tab;
FilterWidgetNormalTab *normal_tab;
FilterWidgetAdvancedTab *advanced_tab;
};
#endif /* ADMC_TEST_FILTER_WIDGET_H */

View File

@ -22,6 +22,7 @@
#include "edits/logon_computers_edit.h"
#include "edits/logon_computers_edit_p.h"
#include "edits/ui_logon_computers_dialog.h"
#include <QFormLayout>
#include <QLineEdit>
@ -31,26 +32,17 @@
void ADMCTestLogonComputersEdit::init() {
ADMCTest::init();
auto button = new QPushButton(parent_widget);
open_dialog_button = new QPushButton(parent_widget);
edit = new LogonComputersEdit(button, &edits, parent_widget);
edit = new LogonComputersEdit(open_dialog_button, &edits, parent_widget);
dialog = parent_widget->findChild<LogonComputersDialog *>();
QVERIFY(dialog);
open_dialog_button = parent_widget->findChild<QPushButton *>("logon_computers_edit_button");
list = dialog->findChild<QListWidget *>("list");
QVERIFY(list);
value_edit = dialog->findChild<QLineEdit *>("edit");
QVERIFY(value_edit);
add_button = dialog->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
remove_button = dialog->findChild<QPushButton *>("remove_button");
QVERIFY(remove_button);
list = dialog->ui->list;
value_edit = dialog->ui->edit;
add_button = dialog->ui->add_button;
remove_button = dialog->ui->remove_button;
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);

View File

@ -21,6 +21,7 @@
#include "admc_test_logon_hours_dialog.h"
#include "edits/logon_hours_edit_p.h"
#include "edits/ui_logon_hours_dialog.h"
#include <QTableView>
#include <QStandardItemModel>
@ -33,13 +34,9 @@ void ADMCTestLogonHoursDialog::init() {
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
// NOTE: use utc for
local_time_button = dialog->findChild<QRadioButton *>("local_time_button");
utc_time_button = dialog->findChild<QRadioButton *>("utc_time_button");
view = dialog->findChild<QTableView *>();
QVERIFY(view);
local_time_button = dialog->ui->local_time_button;
utc_time_button = dialog->ui->utc_time_button;
view = dialog->ui->view;
model = dialog->findChild<QStandardItemModel *>();
QVERIFY(model);

View File

@ -22,6 +22,7 @@
#include "edits/manager_edit.h"
#include "edits/manager_widget.h"
#include "edits/ui_manager_widget.h"
#include "globals.h"
#include "properties_dialog.h"
@ -35,10 +36,10 @@ void ADMCTestManagerEdit::init() {
edit = new ManagerEdit(manager_widget, ATTRIBUTE_MANAGER, &edits, parent_widget);
manager_display = parent_widget->findChild<QLineEdit *>("manager_display");
change_button = parent_widget->findChild<QPushButton *>("change_button");
clear_button = parent_widget->findChild<QPushButton *>("clear_button");
properties_button = parent_widget->findChild<QPushButton *>("properties_button");
manager_display = manager_widget->ui->manager_display;
change_button = manager_widget->ui->change_button;
clear_button = manager_widget->ui->clear_button;
properties_button = manager_widget->ui->properties_button;
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);

View File

@ -22,6 +22,7 @@
#include "select_object_dialog.h"
#include "tabs/membership_tab.h"
#include "tabs/ui_membership_tab.h"
#include <QPushButton>
#include <QStandardItemModel>
@ -39,17 +40,11 @@ void ADMCTestMemberOfTab::init() {
member_of_tab = new MemberOfTab();
add_widget(member_of_tab);
view = member_of_tab->findChild<QTreeView *>();
QVERIFY(view);
view = member_of_tab->ui->view;
model = member_of_tab->findChild<QStandardItemModel *>();
QVERIFY(model);
add_button = member_of_tab->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
remove_button = member_of_tab->findChild<QPushButton *>("remove_button");
QVERIFY(remove_button);
add_button = member_of_tab->ui->add_button;
remove_button = member_of_tab->ui->remove_button;
// Create test user
const QString user_name = TEST_USER;

View File

@ -22,6 +22,7 @@
#include "select_object_dialog.h"
#include "tabs/membership_tab.h"
#include "tabs/ui_membership_tab.h"
#include <QPushButton>
#include <QStandardItemModel>
@ -36,17 +37,11 @@ void ADMCTestMembersTab::init() {
members_tab = new MembersTab();
add_widget(members_tab);
view = members_tab->findChild<QTreeView *>();
QVERIFY(view);
view = members_tab->ui->view;
model = members_tab->findChild<QStandardItemModel *>();
QVERIFY(model);
add_button = members_tab->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
remove_button = members_tab->findChild<QPushButton *>("remove_button");
QVERIFY(remove_button);
add_button = members_tab->ui->add_button;
remove_button = members_tab->ui->remove_button;
// Create test user
const QString user_name = TEST_USER;

View File

@ -21,7 +21,9 @@
#include "admc_test_multi_editor.h"
#include "editors/multi_editor.h"
#include "editors/ui_multi_editor.h"
#include "editors/string_editor.h"
#include "editors/ui_string_editor.h"
#include <QListWidget>
#include <QLineEdit>
@ -36,14 +38,9 @@ void ADMCTestMultiEditor::init() {
edit->open();
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
list_widget = edit->findChild<QListWidget *>();
QVERIFY(list_widget);
add_button = edit->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
remove_button = edit->findChild<QPushButton *>("remove_button");
QVERIFY(remove_button);
list_widget = edit->ui->list_widget;
add_button = edit->ui->add_button;
remove_button = edit->ui->remove_button;
}
void ADMCTestMultiEditor::load_empty() {
@ -72,8 +69,7 @@ void ADMCTestMultiEditor::add() {
auto string_editor = edit->findChild<StringEditor *>();
QVERIFY(string_editor);
auto line_edit = string_editor->findChild<QLineEdit *>();
QVERIFY(line_edit);
QLineEdit *line_edit = string_editor->ui->edit;
const QString new_value = "new value";

View File

@ -35,6 +35,16 @@
#include "select_object_advanced_dialog.h"
#include "select_object_dialog.h"
#include "utils.h"
#include "ui_create_user_dialog.h"
#include "ui_create_group_dialog.h"
#include "ui_create_ou_dialog.h"
#include "ui_create_computer_dialog.h"
#include "ui_rename_user_dialog.h"
#include "ui_find_object_dialog.h"
#include "ui_find_widget.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/ui_filter_widget_advanced_tab.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include <QComboBox>
#include <QDebug>
@ -59,22 +69,10 @@ void ADMCTestObjectMenu::object_menu_new_user() {
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
// Fill out edits
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
name_edit->setText(name);
auto sam_name_edit = create_dialog->findChild<QLineEdit *>("sam_name_edit");
QVERIFY(sam_name_edit);
sam_name_edit->setText(logon_name);
auto password_main_edit = create_dialog->findChild<QLineEdit *>("password_main_edit");
QVERIFY(password_main_edit);
password_main_edit->setText(password);
auto password_confirm_edit = create_dialog->findChild<QLineEdit *>("password_confirm_edit");
QVERIFY(password_confirm_edit);
password_confirm_edit->setText(password);
create_dialog->ui->name_edit->setText(name);
create_dialog->ui->sam_name_edit->setText(logon_name);
create_dialog->ui->password_main_edit->setText(password);
create_dialog->ui->password_confirm_edit->setText(password);
create_dialog->accept();
@ -94,10 +92,7 @@ void ADMCTestObjectMenu::object_menu_new_ou() {
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
// Enter name
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
name_edit->setText(name);
create_dialog->ui->name_edit->setText(name);
create_dialog->accept();
@ -118,15 +113,8 @@ void ADMCTestObjectMenu::object_menu_new_computer() {
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
// Enter name
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
name_edit->setText(name);
// Enter logon name
auto sam_name_edit = create_dialog->findChild<QLineEdit *>("sam_name_edit");
QVERIFY(sam_name_edit);
sam_name_edit->setText(name);
create_dialog->ui->name_edit->setText(name);
create_dialog->ui->sam_name_edit->setText(name);
create_dialog->accept();
@ -147,15 +135,8 @@ void ADMCTestObjectMenu::object_menu_new_group() {
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
// Enter name
auto name_edit = create_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
name_edit->setText(name);
// Enter logon name
auto sam_name_edit = create_dialog->findChild<QLineEdit *>("sam_name_edit");
QVERIFY(sam_name_edit);
sam_name_edit->setText(name);
create_dialog->ui->name_edit->setText(name);
create_dialog->ui->sam_name_edit->setText(name);
create_dialog->accept();
@ -179,16 +160,14 @@ void ADMCTestObjectMenu::object_menu_find_simple() {
find_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(find_dialog, 1000));
FindWidget *find_widget = find_dialog->ui->find_widget;
// Enter name in search field
auto simple_tab = find_dialog->findChild<FilterWidgetSimpleTab *>();
QVERIFY(simple_tab);
auto name_edit = simple_tab->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
name_edit->setText(user_name);
FilterWidgetSimpleTab *simple_tab = find_widget->ui->filter_widget->ui->simple_tab;
simple_tab->ui->name_edit->setText(user_name);
// Press find button
auto find_button = find_dialog->findChild<QPushButton *>("find_button");
QVERIFY(find_button);
QPushButton *find_button = find_widget->ui->find_button;
find_button->click();
// Confirm that results are not empty
@ -214,18 +193,16 @@ void ADMCTestObjectMenu::object_menu_find_advanced() {
find_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(find_dialog, 1000));
auto tab_widget = find_dialog->findChild<QTabWidget *>();
QVERIFY(tab_widget);
auto advanced_tab = find_dialog->findChild<FilterWidgetAdvancedTab *>();
QVERIFY(advanced_tab);
FilterWidget *filter_widget = find_dialog->ui->find_widget->ui->filter_widget;
QTabWidget *tab_widget = filter_widget->ui->tab_widget;
FilterWidgetAdvancedTab *advanced_tab = filter_widget->ui->advanced_tab;
tab_widget->setCurrentWidget(advanced_tab);
auto filter_edit = advanced_tab->findChild<QPlainTextEdit *>();
QPlainTextEdit *ldap_filter_edit = advanced_tab->ui->ldap_filter_edit;
const QString filter = filter_CONDITION(Condition_Equals, ATTRIBUTE_DN, user_dn);
filter_edit->setPlainText(filter);
ldap_filter_edit->setPlainText(filter);
auto find_button = find_dialog->findChild<QPushButton *>("find_button");
QVERIFY(find_button);
QPushButton *find_button = find_dialog->ui->find_widget->ui->find_button;
find_button->click();
auto find_results = find_dialog->findChild<QTreeView *>();
@ -253,10 +230,7 @@ void ADMCTestObjectMenu::object_menu_rename() {
rename_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(rename_dialog, 1000));
// Enter new name
auto name_edit = rename_dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(name_edit);
name_edit->setText(new_name);
rename_dialog->ui->name_edit->setText(new_name);
rename_dialog->accept();

View File

@ -21,6 +21,7 @@
#include "admc_test_octet_editor.h"
#include "editors/octet_editor.h"
#include "editors/ui_octet_editor.h"
#include <QPlainTextEdit>
#include <QComboBox>
@ -46,11 +47,8 @@ void ADMCTestOctetEditor::init() {
edit->open();
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
format_combo = edit->findChild<QComboBox *>();
QVERIFY(format_combo);
text_edit = edit->findChild<QPlainTextEdit *>();
QVERIFY(text_edit);
format_combo = edit->ui->format_combo;
text_edit = edit->ui->edit;
}
void ADMCTestOctetEditor::display() {

View File

@ -22,6 +22,7 @@
#include "console_impls/object_impl.h"
#include "filter_widget/select_base_widget.h"
#include "filter_widget/ui_select_base_widget.h"
#include "globals.h"
#include "select_container_dialog.h"
@ -37,8 +38,7 @@ void ADMCTestSelectBaseWidget::init() {
select_base_widget->init(ad.adconfig());
add_widget(select_base_widget);
combo = select_base_widget->findChild<QComboBox *>();
QVERIFY(combo);
combo = select_base_widget->ui->combo;
// Create test OU's
const QList<QString> ou_name_list = {

View File

@ -24,6 +24,8 @@
#include "console_impls/object_impl.h"
#include "filter_widget/select_base_widget.h"
#include "select_object_dialog.h"
#include "ui_select_object_dialog.h"
#include "ui_select_object_match_dialog.h"
#include <QLineEdit>
#include <QPushButton>
@ -36,14 +38,11 @@ void ADMCTestSelectObjectDialog::init() {
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
auto select_base_widget = dialog->findChild<SelectBaseWidget *>();
SelectBaseWidget *select_base_widget = dialog->ui->select_base_widget;
select_base_widget_add(select_base_widget, test_arena_dn());
edit = dialog->findChild<QLineEdit *>("name_edit");
QVERIFY(edit);
add_button = dialog->findChild<QPushButton *>("add_button");
QVERIFY(add_button);
edit = dialog->ui->name_edit;
add_button = dialog->ui->add_button;
}
void ADMCTestSelectObjectDialog::empty() {
@ -149,17 +148,13 @@ void ADMCTestSelectObjectDialog::select_object_in_multi_match_dialog(const QStri
auto match_dialog = dialog->findChild<SelectObjectMatchDialog *>();
QVERIFY(match_dialog);
auto match_dialog_view = match_dialog->findChild<QTreeView *>();
QVERIFY(match_dialog_view);
QTreeView *match_dialog_view = match_dialog->ui->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);
ok_button->click();
match_dialog->accept();
close_message_box();
}

View File

@ -21,6 +21,7 @@
#include "admc_test_string_editor.h"
#include "editors/string_editor.h"
#include "editors/ui_string_editor.h"
#include <QLineEdit>
@ -31,8 +32,7 @@ void ADMCTestStringEditor::init() {
edit->open();
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
line_edit = edit->findChild<QLineEdit *>();
QVERIFY(line_edit);
line_edit = edit->ui->edit;
}
void ADMCTestStringEditor::load_empty() {

View File

@ -22,6 +22,7 @@
#include "edits/string_other_edit.h"
#include "editors/multi_editor.h"
#include "editors/ui_multi_editor.h"
#include "editors/string_editor.h"
#include <QFormLayout>
@ -147,9 +148,7 @@ void ADMCTestStringOtherEdit::add_new_other_value() {
auto multi_editor = parent_widget->findChild<MultiEditor *>();
QVERIFY(multi_editor);
auto add_button = multi_editor->findChild<QPushButton *>();
QVERIFY(add_button);
QPushButton *add_button = multi_editor->ui->add_button;
add_button->click();
auto string_editor = multi_editor->findChild<StringEditor *>();