| 1 | #include "../settingsdialog/optioncategory.h" |
| 2 | #include "../settingsdialog/optioncategorymodel.h" |
| 3 | #include "../settingsdialog/qtsettings.h" |
| 4 | #include "../settingsdialog/settingsdialog.h" |
| 5 | |
| 6 | #include "../misc/disablewarningsmoc.h" |
| 7 | |
| 8 | #include <QtTest/QtTest> |
| 9 | |
| 10 | using namespace QtUtilities; |
| 11 | |
| 12 | class DialogsTests : public QObject { |
| 13 | Q_OBJECT |
| 14 | |
| 15 | private Q_SLOTS: |
| 16 | void testSettingsDialog(); |
| 17 | }; |
| 18 | |
| 19 | void DialogsTests::testSettingsDialog() |
| 20 | { |
| 21 | // show single category |
| 22 | auto settingsDlg = SettingsDialog(); |
| 23 | auto qtSettings = QtSettings(); |
| 24 | settingsDlg.setSingleCategory(qtSettings.category()); |
| 25 | |
| 26 | // add another empty category |
| 27 | auto *const testCategory = new OptionCategory(); |
| 28 | testCategory->setDisplayName(QStringLiteral("Test category")); |
| 29 | testCategory->setIcon(QIcon::fromTheme(QStringLiteral("preferences"))); |
| 30 | settingsDlg.showCategory(nullptr); // ensure no current category is shown anymore |
| 31 | settingsDlg.setSingleCategory(nullptr); |
| 32 | auto *const qtCategory = qtSettings.category(); |
| 33 | settingsDlg.categoryModel()->setCategories(QList<OptionCategory *>({ testCategory, qtCategory })); |
| 34 | settingsDlg.showCategory(qtCategory); |
| 35 | settingsDlg.show(); |
| 36 | } |
| 37 | |
| 38 | QT_UTILITIES_DISABLE_WARNINGS_FOR_MOC_INCLUDE |
| 39 | QTEST_MAIN(DialogsTests) |
| 40 | #include "dialogs.moc" |