diff --git a/tests/auto/plugins/preferences/ini/CMakeLists.txt b/tests/auto/plugins/preferences/ini/CMakeLists.txt new file mode 100644 index 0000000..acc4658 --- /dev/null +++ b/tests/auto/plugins/preferences/ini/CMakeLists.txt @@ -0,0 +1,28 @@ +find_package(Qt5 COMPONENTS Core Gui Widgets Test REQUIRED) + +find_package(XercesC REQUIRED) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + iniwidgettest.cpp + ../../../../../src/plugins/preferences/ini/iniwidget.cpp + ../../../../../src/plugins/preferences/ini/inischema.cpp + ../../../../../src/plugins/preferences/ini/modelbuilder.cpp +) + +set(UI_FORMS + ../../../../../src/plugins/preferences/ini/iniwidget.ui +) + +set(MOC_HEADERS + iniwidgettest.h + ../../../../../src/plugins/preferences/ini/iniwidget.h +) + +qt5_wrap_ui(UI_SOURCES ${UI_FORMS}) +qt5_wrap_cpp(MOC_SOURCES ${MOC_HEADERS}) + +add_executable(iniwidgettest ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}) +target_link_libraries(iniwidgettest ${GPUI_LIBRARIES} ini-plugin Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test XercesC::XercesC) +add_gpui_test(plugins.iniwidgettest iniwidgettest) diff --git a/tests/auto/plugins/preferences/ini/iniwidgettest.cpp b/tests/auto/plugins/preferences/ini/iniwidgettest.cpp new file mode 100644 index 0000000..52933a5 --- /dev/null +++ b/tests/auto/plugins/preferences/ini/iniwidgettest.cpp @@ -0,0 +1,60 @@ +/*********************************************************************************************************************** +** +** Copyright (C) 2021 BaseALT Ltd. +** +** 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 2 +** 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, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** +***********************************************************************************************************************/ + +#include "iniwidgettest.h" + +#include + +#include "../../../../../src/plugins/preferences/ini/modelbuilder.h" +#include "../../../../../src/plugins/preferences/ini/iniroles.h" +#include "../../../../../src/plugins/preferences/ini/inischema.h" +#include "../../../../../src/plugins/preferences/ini/iniwidget.h" + +const std::string dataPath = "../../../../data/"; + +namespace tests { + +void IniWidgetTest::show() +{ + std::ifstream file; + + file.open(dataPath + "ini.xml", std::ifstream::in); + if (file.good()) { + auto modelSource = IniFiles_(file, ::xsd::cxx::tree::flags::dont_validate); + auto modelBuilder = std::make_unique(); + auto model = modelBuilder->schemaToModel(modelSource); + + auto selectionModel = std::make_unique(model.get()); + + auto widget = std::make_unique(*model, *selectionModel); + widget->show(); + + selectionModel->setCurrentIndex(model->item(0, 0)->index(), + QItemSelectionModel::Select | QItemSelectionModel::Rows); + + QTest::qWait(10000); + } + + file.close(); +} + +} + +QTEST_MAIN(tests::IniWidgetTest) diff --git a/tests/auto/plugins/preferences/ini/iniwidgettest.h b/tests/auto/plugins/preferences/ini/iniwidgettest.h new file mode 100644 index 0000000..9131c2b --- /dev/null +++ b/tests/auto/plugins/preferences/ini/iniwidgettest.h @@ -0,0 +1,36 @@ +/*********************************************************************************************************************** +** +** Copyright (C) 2021 BaseALT Ltd. +** +** 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 2 +** 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, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** +***********************************************************************************************************************/ + +#ifndef GPUI_INI_WIDGET_TEST_H +#define GPUI_INI_WIDGET_TEST_H + +#include + +namespace tests { + class IniWidgetTest : public QObject + { + Q_OBJECT + + private slots: + void show(); + }; +} + +#endif // GPUI_INI_WIDGET_TEST_H