diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 7ae9b033f..8e342da83 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -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 diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index 69d2fd1ea..4af00d0aa 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -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() diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index df9ba7327..3a89e33f6 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -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) diff --git a/src/test/ValentinaTest/testvapplication.h b/src/test/ValentinaTest/testvapplication.h new file mode 100644 index 000000000..33d7a452a --- /dev/null +++ b/src/test/ValentinaTest/testvapplication.h @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#ifndef TESTVAPPLICATION_H +#define TESTVAPPLICATION_H + +#include "../vmisc/vabstractapplication.h" + +#if defined(qApp) +#undef qApp +#endif +#define qApp (static_cast(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 + diff --git a/src/test/ValentinaTest/tst_vtranslatevars.cpp b/src/test/ValentinaTest/tst_vtranslatevars.cpp index 4dc35b3fd..5d4d3a8be 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.cpp +++ b/src/test/ValentinaTest/tst_vtranslatevars.cpp @@ -30,6 +30,7 @@ #include "../vmisc/logging.h" #include "../vpatterndb/vtranslatevars.h" #include "../qmuparser/qmuparsererror.h" +#include "testvapplication.h" #include @@ -45,6 +46,7 @@ TST_VTranslateVars::TST_VTranslateVars(QObject *parent) void TST_VTranslateVars::initTestCase() { m_trMs = new VTranslateVars(); + qApp->SetTrVars(m_trMs); } //---------------------------------------------------------------------------------------------------------------------