diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dc5b463..b8d8579 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,3 +7,6 @@ macro(add_gpui_test test_name test_executable) endmacro(add_gpui_test) add_subdirectory(auto) + +# copy test data directory +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 73fd302..5cf478d 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(gui) add_subdirectory(io) +add_subdirectory(plugins) diff --git a/tests/auto/plugins/CMakeLists.txt b/tests/auto/plugins/CMakeLists.txt new file mode 100644 index 0000000..f78b2f6 --- /dev/null +++ b/tests/auto/plugins/CMakeLists.txt @@ -0,0 +1,7 @@ +find_package(GPUI COMPONENTS io model admx-plugin REQUIRED) +include_directories(${GPUI_INCLUDE_DIRS}) + +find_package(Qt5 COMPONENTS Core Test REQUIRED) +set(QT_USE_QTTEST TRUE) + +add_subdirectory(admx) diff --git a/tests/auto/plugins/admx/CMakeLists.txt b/tests/auto/plugins/admx/CMakeLists.txt new file mode 100644 index 0000000..f06fc14 --- /dev/null +++ b/tests/auto/plugins/admx/CMakeLists.txt @@ -0,0 +1,6 @@ +find_package(XercesC REQUIRED) + +qt5_wrap_cpp(MOC_SOURCES admxtest.h) +add_executable(admxtest admxtest.cpp ${MOC_SOURCES}) +target_link_libraries(admxtest ${GPUI_LIBRARIES} admx-plugin Qt5::Core Qt5::Test XercesC::XercesC) +add_gpui_test(plugins.admxtest admxtest) diff --git a/tests/auto/plugins/admx/admxtest.cpp b/tests/auto/plugins/admx/admxtest.cpp new file mode 100644 index 0000000..4e13223 --- /dev/null +++ b/tests/auto/plugins/admx/admxtest.cpp @@ -0,0 +1,56 @@ +/*********************************************************************************************************************** +** +** 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 "admxtest.h" + +#include "../../../../src/io/policyfile.h" +#include "../../../../src/model/admx/policy.h" +#include "../../../../src/model/admx/policyelement.h" +#include "../../../../src/plugins/admx/admxformat.h" + +#include + +const std::string dataPath = "../../../data/"; + +using namespace io; +using namespace model::admx; + +namespace tests { + +void AdmxTest::read() +{ + gpui::AdmxFormat format; + + std::ifstream file; + + file.open (dataPath + "example.admx", std::ifstream::in); + + if (file.good()) { + std::unique_ptr policies = std::make_unique(); + + format.read(file, policies.get()); + } + + file.close(); +} + +} + +QTEST_MAIN(tests::AdmxTest) diff --git a/tests/auto/plugins/admx/admxtest.h b/tests/auto/plugins/admx/admxtest.h new file mode 100644 index 0000000..dba4722 --- /dev/null +++ b/tests/auto/plugins/admx/admxtest.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_ADMX_TEST_H +#define GPUI_ADMX_TEST_H + +#include + +namespace tests { + class AdmxTest : public QObject + { + Q_OBJECT + + private slots: + void read(); + }; +} + +#endif // GPUI_ADMX_TEST_H diff --git a/tests/data/example.admx b/tests/data/example.admx new file mode 100644 index 0000000..9c396ae --- /dev/null +++ b/tests/data/example.admx @@ -0,0 +1,375 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + String3 + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + String3 + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + String3 + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + 0 + + + + + + + 1 + + + 0 + + + + + + + + + + + + + + + + + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +