2015-09-28 12:42:26 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file tst_tapecommandline.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 25 9, 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_tapecommandline.h"
|
2015-10-03 13:09:06 +02:00
|
|
|
#include "../vmisc/vsysexits.h"
|
2016-12-03 09:20:45 +01:00
|
|
|
#include "logging.h"
|
2015-09-28 12:42:26 +02:00
|
|
|
|
|
|
|
#include <QtTest>
|
|
|
|
|
|
|
|
const QString tmpTestFolder = QStringLiteral("tst_tape_tmp");
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
TST_TapeCommandLine::TST_TapeCommandLine(QObject *parent)
|
|
|
|
:AbstractTest(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-07-25 17:25:13 +02:00
|
|
|
void TST_TapeCommandLine::initTestCase()
|
2015-09-28 12:42:26 +02:00
|
|
|
{
|
|
|
|
QDir tmpDir(tmpTestFolder);
|
|
|
|
if (not tmpDir.removeRecursively())
|
|
|
|
{
|
|
|
|
QFAIL("Fail to remove temp directory.");
|
|
|
|
}
|
|
|
|
|
2015-12-22 15:42:00 +01:00
|
|
|
if (not CopyRecursively(QApplication::applicationDirPath() + QDir::separator() + QStringLiteral("tst_tape"),
|
|
|
|
QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder))
|
2015-09-28 12:42:26 +02:00
|
|
|
{
|
|
|
|
QFAIL("Fail to prepare files for testing.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void TST_TapeCommandLine::OpenMeasurements_data() const
|
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("file");
|
2015-10-03 13:09:06 +02:00
|
|
|
QTest::addColumn<int>("exitCode");
|
2015-09-28 12:42:26 +02:00
|
|
|
|
2015-10-03 13:09:06 +02:00
|
|
|
// The file doesn't exist!
|
|
|
|
QTest::newRow("Send wrong path to a file") << "wrongPath.vit"
|
|
|
|
<< V_EX_NOINPUT;
|
|
|
|
|
|
|
|
QTest::newRow("Old individual format to new version") << "keiko.vit"
|
|
|
|
<< V_EX_OK;
|
|
|
|
|
|
|
|
QTest::newRow("Open empty file") << "empty.vit"
|
|
|
|
<< V_EX_OK;
|
|
|
|
|
2015-11-12 09:42:28 +01:00
|
|
|
QTest::newRow("Open the VIT file with all know measurements (v0.3.0)") << "all_measurements_v0.3.0.vit"
|
2015-10-03 13:09:06 +02:00
|
|
|
<< V_EX_OK;
|
|
|
|
|
2015-11-12 09:42:28 +01:00
|
|
|
QTest::newRow("Open the VST file with all know measurements (v0.4.0)") << "all_measurements_v0.4.0.vst"
|
2015-10-03 13:09:06 +02:00
|
|
|
<< V_EX_OK;
|
|
|
|
|
2015-11-12 09:42:28 +01:00
|
|
|
QTest::newRow("Open the VST file for man ru GOST (v0.3.0).") << "GOST_man_ru_v0.3.0.vst"
|
|
|
|
<< V_EX_OK;
|
|
|
|
|
|
|
|
QTest::newRow("Open the VIT file with all know measurements (v0.3.3)") << "all_measurements_v0.3.3.vit"
|
|
|
|
<< V_EX_OK;
|
|
|
|
|
|
|
|
QTest::newRow("Open the VST file with all know measurements (v0.4.2)") << "all_measurements_v0.4.2.vst"
|
|
|
|
<< V_EX_OK;
|
|
|
|
|
|
|
|
QTest::newRow("Open the VST file for man ru GOST (v0.4.2).") << "GOST_man_ru_v0.4.2.vst"
|
2015-10-03 13:09:06 +02:00
|
|
|
<< V_EX_OK;
|
|
|
|
|
|
|
|
QTest::newRow("Broken file. Not unique name.") << "broken1.vit"
|
|
|
|
<< V_EX_NOINPUT;
|
|
|
|
|
|
|
|
QTest::newRow("Broken file. Measurement name can't be empty.") << "broken1.vit"
|
|
|
|
<< V_EX_NOINPUT;
|
|
|
|
|
|
|
|
QTest::newRow("Broken file. An empty value shouldn't break a file.") << "broken3.vit"
|
|
|
|
<< V_EX_OK;
|
|
|
|
|
|
|
|
QTest::newRow("Broken file. Invalid measurement name.") << "broken4.vit"
|
|
|
|
<< V_EX_NOINPUT;
|
2015-11-12 12:06:14 +01:00
|
|
|
|
|
|
|
QTest::newRow("Empty text VIT file.") << "text.vit"
|
|
|
|
<< V_EX_NOINPUT;
|
|
|
|
|
|
|
|
QTest::newRow("Empty text VST file.") << "text.vst"
|
|
|
|
<< V_EX_NOINPUT;
|
2015-09-28 12:42:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void TST_TapeCommandLine::OpenMeasurements()
|
|
|
|
{
|
|
|
|
QFETCH(QString, file);
|
2015-10-03 13:09:06 +02:00
|
|
|
QFETCH(int, exitCode);
|
2015-09-28 12:42:26 +02:00
|
|
|
|
2016-12-03 09:20:45 +01:00
|
|
|
QString error;
|
2016-11-04 14:15:11 +01:00
|
|
|
const int exit = Run(exitCode, TapePath(), QStringList() << "--test"
|
|
|
|
<< QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder + QDir::separator() +
|
2016-12-03 09:20:45 +01:00
|
|
|
file, error);
|
2015-09-28 12:42:26 +02:00
|
|
|
|
2016-12-03 09:20:45 +01:00
|
|
|
QVERIFY2(exit == exitCode, qUtf8Printable(error));
|
2015-09-28 12:42:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-07-25 17:25:13 +02:00
|
|
|
void TST_TapeCommandLine::cleanupTestCase()
|
2015-09-28 12:42:26 +02:00
|
|
|
{
|
|
|
|
QDir tmpDir(tmpTestFolder);
|
|
|
|
if (not tmpDir.removeRecursively())
|
|
|
|
{
|
|
|
|
QWARN("Fail to remove temp directory.");
|
|
|
|
}
|
|
|
|
}
|