1
0
mirror of https://github.com/altlinux/admc.git synced 2025-02-03 05:47:02 +03:00
admc/tests/admc_test.h

125 lines
3.9 KiB
C
Raw Normal View History

/*
* ADMC - AD Management Center
*
2022-04-06 15:59:32 +04:00
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 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/>.
*/
2021-02-11 14:54:40 +04:00
#ifndef ADMC_TEST_H
#define ADMC_TEST_H
/**
* Base test class for testing ADMC. Implements init and
* cleanup f-ns that create a fresh testing environment for
* each test.
*/
#include <QTest>
2021-03-25 15:08:39 +04:00
#include "adldap.h"
class QTreeView;
2021-06-25 15:32:23 +04:00
class SelectObjectDialog;
class SelectBaseWidget;
class QFormLayout;
class AttributeEdit;
#define TEST_USER "ADMCTEST-test-user"
#define TEST_USER_LOGON "ADMCTEST-test-user-logon"
#define TEST_PASSWORD "ADMCTEST-pass123!"
#define TEST_OU "ADMCTEST-test-ou"
#define TEST_GROUP "ADMCTEST-test-group"
2022-03-11 16:32:36 +04:00
// NOTE: use shorter length for computer to fit within
// 16 char length limit for sam account name
#define TEST_COMPUTER "ADMCTEST-pc"
2022-03-16 13:51:24 +04:00
#define TEST_OBJECT "ADMCTEST-object"
2021-02-11 14:54:40 +04:00
class ADMCTest : public QObject {
Q_OBJECT
public slots:
2021-02-08 12:38:23 +04:00
// NOTE: initTestCase(), cleanupTestCase(), init() and
// cleanup() are special slots called by QTest.
// Called before first test
virtual void initTestCase();
// Called after last test
virtual void cleanupTestCase();
// Called before and after each test
virtual void init();
virtual void cleanup();
protected:
AdInterface ad;
// Use this as parents for widgets used inside tests.
// For every test a new parent will be created and after
// test completes, parent is deleted which deletes all
// child widgets as well.
QWidget *parent_widget = nullptr;
// This list is just for passing to edit ctors
QList<AttributeEdit *> edits;
// For easy setup and cleanup of each test, we use an
// object named "test-arena" which is an OU. It is
// created before every test and deleted after every
// test. All test activity should happen inside this
// object.
QString test_arena_dn();
// Creates dn for object with given name whose parent is
// test arena. Class is used to determine suffix.
QString test_object_dn(const QString &name, const QString &object_class);
2021-02-05 18:04:07 +04:00
// Tests object's existance on the server.
bool object_exists(const QString &dn);
2021-02-05 18:04:07 +04:00
// Call this after pressing "Find" button. Needed
// because find results are loaded in separate thread.
void wait_for_find_results_to_load(QTreeView *view);
void select_in_select_dialog(SelectObjectDialog *select_dialog, const QString &dn);
2021-06-25 15:32:23 +04:00
// This is for closing message boxes opened using
2021-06-30 15:13:32 +04:00
// open(). Won't work for QMessageBox static f-ns
void close_message_box();
bool message_box_is_open() const;
2021-06-30 13:58:28 +04:00
// Selects an object via an already open select object
// dialog. Object must be inside test arena
void select_object_dialog_select(const QString &dn);
// Adds a widget to layout in parent widget
void add_widget(QWidget *widget);
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);
2022-03-29 12:27:40 +04:00
void test_lineedit_autofill(QLineEdit *src_edit, QLineEdit *dest_edit);
2021-02-11 14:54:40 +04:00
#endif /* ADMC_TEST_H */