2015-05-07 15:12:53 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file abstracttest.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 7 5, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-05-07 15:12:53 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-05-07 15:12:53 +02:00
|
|
|
**
|
|
|
|
** 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 ABSTRACTTEST_H
|
|
|
|
#define ABSTRACTTEST_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaObject>
|
2015-05-07 15:12:53 +02:00
|
|
|
#include <QObject>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
template <class T> class QVector;
|
2019-08-07 16:53:18 +02:00
|
|
|
class VSAPoint;
|
2015-05-07 15:12:53 +02:00
|
|
|
|
2015-10-23 19:47:33 +02:00
|
|
|
#include <ciso646>
|
|
|
|
|
2016-08-21 17:57:08 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define V_UNUSED __attribute__ ((unused))
|
|
|
|
#else
|
|
|
|
#define V_UNUSED
|
|
|
|
#endif
|
|
|
|
|
2015-10-03 13:09:06 +02:00
|
|
|
// Return codes for testing run application
|
2016-08-21 17:57:08 +02:00
|
|
|
static const auto V_UNUSED TST_EX_BIN = -1; // Can't find binary.
|
2016-12-03 09:20:45 +01:00
|
|
|
static const auto V_UNUSED TST_EX_FINISH_TIME_OUT = -2; // The operation timed out or an error occurred.
|
|
|
|
static const auto V_UNUSED TST_EX_START_TIME_OUT = -3; // The operation timed out or an error occurred.
|
|
|
|
static const auto V_UNUSED TST_EX_CRASH = -4; // Program crashed.
|
2016-08-21 17:57:08 +02:00
|
|
|
|
|
|
|
#undef V_UNUSED
|
2015-10-03 13:09:06 +02:00
|
|
|
|
2015-10-16 13:55:23 +02:00
|
|
|
enum ErrorState {ErrorLoad = 0, ErrorInstall, ErrorSize, NoError};
|
|
|
|
|
2019-08-29 14:01:27 +02:00
|
|
|
class VPiece;
|
|
|
|
class VContainer;
|
|
|
|
class VPointF;
|
|
|
|
class VSplinePoint;
|
|
|
|
class VPieceNode;
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class GOType : qint8;
|
2019-09-05 13:13:22 +02:00
|
|
|
struct VPiecePassmarkData;
|
2019-08-29 14:01:27 +02:00
|
|
|
|
2015-05-07 15:12:53 +02:00
|
|
|
class AbstractTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-02-24 16:31:44 +01:00
|
|
|
explicit AbstractTest(QObject *parent = nullptr);
|
2015-05-07 15:12:53 +02:00
|
|
|
|
2019-08-07 16:53:18 +02:00
|
|
|
void VectorFromJson(const QString &json, QVector<QPointF>& vector);
|
|
|
|
void VectorFromJson(const QString &json, QVector<VSAPoint>& vector);
|
|
|
|
|
2019-08-29 14:01:27 +02:00
|
|
|
void PieceFromJson(const QString &json, VPiece &piece, QSharedPointer<VContainer> &data);
|
|
|
|
|
2019-09-05 13:13:22 +02:00
|
|
|
void PassmarkDataFromJson(const QString &json, VPiecePassmarkData& data);
|
|
|
|
void PassmarkShapeFromJson(const QString &json, QVector<QLineF> &shape);
|
|
|
|
|
2015-05-07 15:12:53 +02:00
|
|
|
protected:
|
|
|
|
void Comparison(const QVector<QPointF> &ekv, const QVector<QPointF> &ekvOrig) const;
|
2019-01-02 14:58:59 +01:00
|
|
|
void Comparison(const QPointF &result, const QPointF &expected) const;
|
2019-01-09 16:46:02 +01:00
|
|
|
void Comparison(const QVector<QLineF> &result, const QVector<QLineF> &expected) const;
|
2015-05-07 15:12:53 +02:00
|
|
|
|
2015-09-28 12:42:26 +02:00
|
|
|
QString ValentinaPath() const;
|
|
|
|
QString TapePath() const;
|
2015-10-16 13:55:23 +02:00
|
|
|
QString TranslationsPath() const;
|
2015-09-28 12:42:26 +02:00
|
|
|
|
2016-12-03 09:20:45 +01:00
|
|
|
int Run(int exit, const QString &program, const QStringList &arguments, QString &error, int msecs = 120000);
|
2015-09-28 12:42:26 +02:00
|
|
|
bool CopyRecursively(const QString &srcFilePath, const QString &tgtFilePath) const;
|
2019-08-29 14:01:27 +02:00
|
|
|
|
|
|
|
void PrepareDocument(const QString &json, QByteArray &data) const;
|
|
|
|
void TestRoot(const QJsonObject &root, const QString &attribute, const QString &file);
|
|
|
|
|
2019-09-05 16:21:06 +02:00
|
|
|
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
|
|
|
|
void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
|
|
|
|
const QString &defaultValue = QString());
|
|
|
|
template <typename T, typename std::enable_if<std::is_enum<T>::value>::type* = nullptr>
|
|
|
|
void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
|
|
|
|
const QString &defaultValue = QString());
|
|
|
|
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
|
2019-08-29 14:01:27 +02:00
|
|
|
void ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
|
|
|
|
const QString &defaultValue = QString());
|
|
|
|
void ReadStringValue(const QJsonObject &itemObject, const QString &attribute, QString &value,
|
|
|
|
const QString &defaultValue = QString());
|
|
|
|
void ReadBooleanValue(const QJsonObject &itemObject, const QString &attribute, bool &value,
|
|
|
|
const QString &defaultValue = QString());
|
|
|
|
void ReadPointValue(const QJsonObject &itemObject, const QString &attribute, VPointF &value);
|
|
|
|
void ReadSplinePointValues(const QJsonObject &itemObject, const QString &attribute, QVector<VSplinePoint> &points);
|
|
|
|
void ReadSplinePointValue(const QJsonObject &itemObject, VSplinePoint &point);
|
|
|
|
void ReadPieceNodeValue(const QJsonObject &itemObject, VPieceNode &node);
|
|
|
|
|
2019-09-05 13:13:22 +02:00
|
|
|
void QPointFromJson(const QJsonObject &itemObject, QPointF &point);
|
|
|
|
void VPointFromJson(const QJsonObject &itemObject, VPointF &point);
|
|
|
|
void QLineFromJson(const QJsonObject &itemObject, QLineF &line);
|
|
|
|
void SAPointFromJson(const QJsonObject &itemObject, VSAPoint &point);
|
2019-08-29 14:01:27 +02:00
|
|
|
void SplineFromJson(const QJsonObject &itemObject, QSharedPointer<VContainer> &data);
|
|
|
|
void SplinePathFromJson(const QJsonObject &itemObject, QSharedPointer<VContainer> &data);
|
|
|
|
|
|
|
|
void DBFromJson(const QJsonObject &dbObject, QSharedPointer<VContainer> &data);
|
|
|
|
void MainPathFromJson(const QJsonObject &pieceObject, VPiece &piece);
|
2015-05-07 15:12:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ABSTRACTTEST_H
|