Two new tests. Check if empty standard/individual measurement file is valid.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-16 11:13:23 +03:00
parent e350d81ab2
commit 93d63ef8ca
4 changed files with 180 additions and 3 deletions

View File

@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += testlib gui printsupport
QT += testlib gui printsupport xml xmlpatterns
TARGET = ValentinaTests
@ -46,7 +46,8 @@ SOURCES += \
tst_measurementregexp.cpp \
tst_tapecommandline.cpp \
tst_valentinacommandline.cpp \
tst_qmutokenparser.cpp
tst_qmutokenparser.cpp \
tst_vmeasurements.cpp
HEADERS += \
tst_vposter.h \
@ -60,7 +61,8 @@ HEADERS += \
tst_measurementregexp.h \
tst_tapecommandline.h \
tst_valentinacommandline.h \
tst_qmutokenparser.h
tst_qmutokenparser.h \
tst_vmeasurements.h
# Set using ccache. Function enable_ccache() defined in common.pri.
$$enable_ccache()
@ -124,6 +126,15 @@ CONFIG(debug, debug|release){
}
}
# VFormat static library (depend on VPatternDB, IFC)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat
INCLUDEPATH += $$PWD/../../libs/vformat
DEPENDPATH += $$PWD/../../libs/vformat
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a
#VPatternDB static library (depend on vgeometry, vmisc, VLayout)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb

View File

@ -38,9 +38,12 @@
#include "tst_tapecommandline.h"
#include "tst_valentinacommandline.h"
#include "tst_qmutokenparser.h"
#include "tst_vmeasurements.h"
int main(int argc, char** argv)
{
Q_INIT_RESOURCE(schema);
QApplication app( argc, argv );// For QPrinter
int status = 0;
@ -60,6 +63,7 @@ int main(int argc, char** argv)
ASSERT_TEST(new TST_TapeCommandLine());
ASSERT_TEST(new TST_ValentinaCommandLine());
ASSERT_TEST(new TST_QmuTokenParser());
ASSERT_TEST(new TST_VMeasurements());
return status;
}

View File

@ -0,0 +1,116 @@
/************************************************************************
**
** @file tst_vmeasurements.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 10, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina 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.
**
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "tst_vmeasurements.h"
#include "../vformat/vmeasurements.h"
#include "../ifc/xml/vvstconverter.h"
#include "../ifc/xml/vvitconverter.h"
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_VMeasurements::TST_VMeasurements(QObject *parent) :
QObject(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CreateEmptyStandardFile check if empty standard measurement file is valid.
*/
void TST_VMeasurements::CreateEmptyStandardFile()
{
Unit mUnit = Unit::Cm;
const int height = 176;
const int size = 50;
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
data->SetHeight(height);
data->SetSize(size);
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
QTemporaryFile file;
if (file.open())
{
QString error;
const bool result = m->SaveDocument(file.fileName(), error);
QVERIFY2(result, error.toUtf8().constData());
}
else
{
QFAIL("Can't open temporary file.");
}
try
{
VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, file.fileName());
}
catch (VException &e)
{
QFAIL(e.ErrorMessage().toUtf8().constData());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CreateEmptyIndividualFile check if empty individual measurement file is valid.
*/
void TST_VMeasurements::CreateEmptyIndividualFile()
{
Unit mUnit = Unit::Cm;
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, data.data()));
QTemporaryFile file;
if (file.open())
{
QString error;
const bool result = m->SaveDocument(file.fileName(), error);
QVERIFY2(result, error.toUtf8().constData());
}
else
{
QFAIL("Can't open temporary file.");
}
try
{
VDomDocument::ValidateXML(VVITConverter::CurrentSchema, file.fileName());
}
catch (VException &e)
{
QFAIL(e.ErrorMessage().toUtf8().constData());
}
}

View File

@ -0,0 +1,46 @@
/************************************************************************
**
** @file tst_vmeasurements.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 10, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina 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.
**
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef TST_VMEASUREMENTS_H
#define TST_VMEASUREMENTS_H
#include <QObject>
class TST_VMeasurements : public QObject
{
Q_OBJECT
public:
explicit TST_VMeasurements(QObject *parent = nullptr);
private slots:
void CreateEmptyStandardFile();
void CreateEmptyIndividualFile();
};
#endif // TST_VMEASUREMENTS_H