2021-07-13 13:58:37 +04:00
/*
* 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/>.
*/
2021-11-09 16:25:26 +04:00
# include "admc_test_bool_attribute_dialog.h"
2021-07-13 13:58:37 +04:00
2021-11-09 16:25:26 +04:00
# include "attribute_dialogs/bool_attribute_dialog.h"
# include "attribute_dialogs/ui_bool_attribute_dialog.h"
2021-07-13 13:58:37 +04:00
# include <QRadioButton>
2021-11-09 16:25:26 +04:00
void ADMCTestBoolAttributeDialog : : initTestCase_data ( ) {
2021-07-16 17:35:44 +04:00
QTest : : addColumn < QString > ( " button_name " ) ;
2021-11-10 11:01:01 +04:00
QTest : : addColumn < QList < QByteArray > > ( " value_list " ) ;
2021-07-16 17:35:44 +04:00
QTest : : newRow ( " true " ) < < " true_button " < < QList < QByteArray > ( { " TRUE " } ) ;
QTest : : newRow ( " false " ) < < " false_button " < < QList < QByteArray > ( { " FALSE " } ) ;
QTest : : newRow ( " unset " ) < < " unset_button " < < QList < QByteArray > ( ) ;
}
2021-07-13 13:58:37 +04:00
2021-11-09 16:25:26 +04:00
void ADMCTestBoolAttributeDialog : : init ( ) {
2021-07-13 13:58:37 +04:00
ADMCTest : : init ( ) ;
2021-11-10 11:01:01 +04:00
QFETCH_GLOBAL ( QList < QByteArray > , value_list ) ;
2021-07-13 13:58:37 +04:00
2021-11-10 11:01:01 +04:00
dialog = new BoolAttributeDialog ( value_list , ATTRIBUTE_DESCRIPTION , false , parent_widget ) ;
dialog - > open ( ) ;
QVERIFY ( QTest : : qWaitForWindowExposed ( dialog , 1000 ) ) ;
}
void ADMCTestBoolAttributeDialog : : display_value ( ) {
2021-10-18 12:29:43 +04:00
const QHash < QString , QRadioButton * > button_map = {
2021-11-10 11:01:01 +04:00
{ " true_button " , dialog - > ui - > true_button } ,
{ " false_button " , dialog - > ui - > false_button } ,
{ " unset_button " , dialog - > ui - > unset_button } ,
2021-10-18 12:29:43 +04:00
} ;
2021-07-16 17:35:44 +04:00
QFETCH_GLOBAL ( QString , button_name ) ;
2021-10-18 12:29:43 +04:00
button = button_map [ button_name ] ;
2021-07-13 13:58:37 +04:00
2021-07-16 17:35:44 +04:00
QVERIFY ( button - > isChecked ( ) ) ;
2021-07-13 13:58:37 +04:00
}
2021-11-09 16:25:26 +04:00
void ADMCTestBoolAttributeDialog : : get_value_list ( ) {
2021-11-10 11:01:01 +04:00
QFETCH_GLOBAL ( QList < QByteArray > , value_list ) ;
2021-07-13 13:58:37 +04:00
2021-11-10 11:01:01 +04:00
const QList < QByteArray > actual_value_list = dialog - > get_value_list ( ) ;
QCOMPARE ( actual_value_list , value_list ) ;
2021-07-13 13:58:37 +04:00
}
2021-11-09 16:25:26 +04:00
QTEST_MAIN ( ADMCTestBoolAttributeDialog )