Commit 050d5281 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Move XSD tests into separate unit test

parent 954c36a2
......@@ -42,3 +42,17 @@ target_link_libraries(test_languageresources
)
add_test(NAME test_languageresources COMMAND test_languageresources)
ecm_mark_as_test(test_languageresources)
# test correctness of XSD files
set(TestXsdSchemes_SRCS
xsdschemes/testxsdschemes.cpp
)
add_executable(test_xsdschemes ${TestXsdSchemes_SRCS} )
target_link_libraries(test_xsdschemes
Qt5::Test
Qt5::XmlPatterns
Qt5::Core
)
add_test(NAME test_xsdschemes COMMAND test_xsdschemes)
ecm_mark_as_test(test_xsdschemes)
/*
* Copyright 2013 Oindrila Gupta <oindrila.gupta92@gmail.com>
*
* 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) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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/>.
*/
#include "testxsdschemes.h"
#include <QTest>
#include <QDebug>
#include <QUrl>
#include <QXmlSchema>
#include <QXmlSchemaValidator>
TestXsdSchemes::TestXsdSchemes()
{
}
void TestXsdSchemes::init()
{
// TODO initialization of test case
}
void TestXsdSchemes::cleanup()
{
// TODO cleanup after test run
}
void TestXsdSchemes::languageSchemeValidationTest()
{
QUrl languageFile = QUrl::fromLocalFile(":/artikulate/schemes/language.xsd");
QXmlSchema languageSchema;
QVERIFY(languageSchema.load(languageFile));
QVERIFY(languageSchema.isValid());
}
void TestXsdSchemes::courseSchemeValidationTest()
{
QUrl schemeFile = QUrl::fromLocalFile(":/artikulate/schemes/course.xsd");
QXmlSchema courseSchema;
QVERIFY(courseSchema.load(schemeFile));
QVERIFY(courseSchema.isValid());
}
void TestXsdSchemes::schemeValidationTest()
{
QUrl skeletonFile = QUrl::fromLocalFile(":/artikulate/schemes/skeleton.xsd");
QXmlSchema skeletonScheme;
QVERIFY(skeletonScheme.load(skeletonFile));
QVERIFY(skeletonScheme.isValid());
}
QTEST_GUILESS_MAIN(TestXsdSchemes)
/*
* Copyright 2019 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* 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) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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/>.
*/
#ifndef TESTXSDSCHEMES_H
#define TESTXSDSCHEMES_H
#include <QObject>
class TestXsdSchemes : public QObject
{
Q_OBJECT
public:
TestXsdSchemes();
private slots:
/**
* Called before every test case.
*/
void init();
/**
* Called after every test case.
*/
void cleanup();
/**
* @brief Test if language XSD specification is valid.
*/
void languageSchemeValidationTest();
/**
* @brief Test if course XSD specification is valid.
*/
void courseSchemeValidationTest();
/**
* @brief Test if course XSD specification is valid.
*/
void schemeValidationTest();
};
#endif
......@@ -49,14 +49,6 @@ void TestCourseResource::cleanup()
{
}
void TestCourseResource::courseSchemeValidationTest()
{
QUrl schemeFile = QUrl::fromLocalFile(":/artikulate/schemes/course.xsd");
QXmlSchema courseSchema;
QVERIFY(courseSchema.load(schemeFile));
QVERIFY(courseSchema.isValid());
}
void TestCourseResource::loadCourseResource()
{
std::unique_ptr<Language> language(new Language);
......
......@@ -42,11 +42,6 @@ private slots:
*/
void cleanup();
/**
* @brief Test if course XSD specification is valid.
*/
void courseSchemeValidationTest();
/**
* @brief Test simple loading of course resource XML file
*/
......
......@@ -48,14 +48,6 @@ void TestSkeletonResource::cleanup()
{
}
void TestSkeletonResource::schemeValidationTest()
{
QUrl skeletonFile = QUrl::fromLocalFile(":/artikulate/schemes/skeleton.xsd");
QXmlSchema skeletonScheme;
QVERIFY(skeletonScheme.load(skeletonFile));
QVERIFY(skeletonScheme.isValid());
}
void TestSkeletonResource::loadSkeletonResource()
{
std::shared_ptr<Language> language(new Language);
......
......@@ -42,11 +42,6 @@ private slots:
*/
void cleanup();
/**
* @brief Test if course XSD specification is valid.
*/
void schemeValidationTest();
/**
* @brief Test simple loading of course resource XML file
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment