Fix test crash.
--HG-- branch : develop
This commit is contained in:
parent
143c5b4941
commit
95a21e07cc
|
@ -930,6 +930,7 @@ QString VTranslateVars::TryFormulaFromUser(const QString &formula, bool osSepara
|
|||
{
|
||||
try
|
||||
{
|
||||
SCASSERT(qApp->TrVars() != nullptr)
|
||||
return qApp->TrVars()->FormulaFromUser(formula, osSeparator);
|
||||
}
|
||||
catch (qmu::QmuParserError &e)// In case something bad will happen
|
||||
|
|
|
@ -90,7 +90,8 @@ HEADERS += \
|
|||
tst_readval.h \
|
||||
tst_vtranslatevars.h \
|
||||
tst_vabstractpiece.h \
|
||||
tst_vtooluniondetails.h
|
||||
tst_vtooluniondetails.h \
|
||||
testvapplication.h
|
||||
|
||||
# Set using ccache. Function enable_ccache() defined in common.pri.
|
||||
$$enable_ccache()
|
||||
|
|
|
@ -53,48 +53,7 @@
|
|||
|
||||
#include "../vmisc/def.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
|
||||
class TestVApplication : public VAbstractApplication
|
||||
{
|
||||
public:
|
||||
|
||||
TestVApplication(int &argc, char ** argv);
|
||||
virtual ~TestVApplication() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
virtual const VTranslateVars *TrVars();
|
||||
virtual void OpenSettings();
|
||||
virtual bool IsAppInGUIMode() const;
|
||||
virtual void InitTrVars();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
TestVApplication::TestVApplication(int &argc, char **argv)
|
||||
: VAbstractApplication(argc, argv)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const VTranslateVars *TestVApplication::TrVars()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TestVApplication::OpenSettings()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool TestVApplication::IsAppInGUIMode() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TestVApplication::InitTrVars()
|
||||
{
|
||||
}
|
||||
#include "testvapplication.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int main(int argc, char** argv)
|
||||
|
|
75
src/test/ValentinaTest/testvapplication.h
Normal file
75
src/test/ValentinaTest/testvapplication.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 30 9, 2017
|
||||
**
|
||||
** @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) 2017 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 TESTVAPPLICATION_H
|
||||
#define TESTVAPPLICATION_H
|
||||
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
|
||||
#if defined(qApp)
|
||||
#undef qApp
|
||||
#endif
|
||||
#define qApp (static_cast<TestVApplication*>(QCoreApplication::instance()))
|
||||
|
||||
class TestVApplication : public VAbstractApplication
|
||||
{
|
||||
public:
|
||||
TestVApplication(int &argc, char ** argv)
|
||||
: VAbstractApplication(argc, argv),
|
||||
m_trVars(nullptr)
|
||||
{}
|
||||
|
||||
virtual ~TestVApplication() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
virtual const VTranslateVars *TrVars() Q_DECL_OVERRIDE
|
||||
{
|
||||
return m_trVars;
|
||||
}
|
||||
|
||||
virtual void OpenSettings() Q_DECL_OVERRIDE
|
||||
{}
|
||||
|
||||
virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void InitTrVars() Q_DECL_OVERRIDE
|
||||
{}
|
||||
|
||||
void SetTrVars(VTranslateVars *trVars)
|
||||
{
|
||||
m_trVars = trVars;
|
||||
}
|
||||
private:
|
||||
Q_DISABLE_COPY(TestVApplication)
|
||||
VTranslateVars *m_trVars;
|
||||
};
|
||||
|
||||
#endif // TESTVAPPLICATION_H
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
#include "../vmisc/logging.h"
|
||||
#include "../vpatterndb/vtranslatevars.h"
|
||||
#include "../qmuparser/qmuparsererror.h"
|
||||
#include "testvapplication.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
|
@ -45,6 +46,7 @@ TST_VTranslateVars::TST_VTranslateVars(QObject *parent)
|
|||
void TST_VTranslateVars::initTestCase()
|
||||
{
|
||||
m_trMs = new VTranslateVars();
|
||||
qApp->SetTrVars(m_trMs);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user