diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index fbc073f9a..8c2e09243 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -48,7 +48,8 @@ SOURCES += \ tst_valentinacommandline.cpp \ tst_qmutokenparser.cpp \ tst_vmeasurements.cpp \ - tst_qmuparsererrormsg.cpp + tst_qmuparsererrormsg.cpp \ + tst_vlockguard.cpp HEADERS += \ tst_vposter.h \ @@ -64,7 +65,8 @@ HEADERS += \ tst_valentinacommandline.h \ tst_qmutokenparser.h \ tst_vmeasurements.h \ - tst_qmuparsererrormsg.h + tst_qmuparsererrormsg.h \ + tst_vlockguard.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 97bc40375..6e197e22f 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -40,6 +40,7 @@ #include "tst_qmutokenparser.h" #include "tst_vmeasurements.h" #include "tst_qmuparsererrormsg.h" +#include "tst_vlockguard.h" int main(int argc, char** argv) { @@ -66,6 +67,7 @@ int main(int argc, char** argv) ASSERT_TEST(new TST_QmuTokenParser()); ASSERT_TEST(new TST_VMeasurements()); ASSERT_TEST(new TST_QmuParserErrorMsg()); + ASSERT_TEST(new TST_VLockGuard()); return status; } diff --git a/src/test/ValentinaTest/tst_vlockguard.cpp b/src/test/ValentinaTest/tst_vlockguard.cpp new file mode 100644 index 000000000..7574eca9a --- /dev/null +++ b/src/test/ValentinaTest/tst_vlockguard.cpp @@ -0,0 +1,52 @@ +/************************************************************************ + ** + ** @file tst_vlockguard.cpp + ** @author Roman Telezhynskyi + ** @date 26 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 + ** 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 . + ** + *************************************************************************/ + +#include "tst_vlockguard.h" +#include "../vmisc/vlockguard.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +TST_VLockGuard::TST_VLockGuard(QObject *parent) + :QObject(parent) +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VLockGuard::TryLock() const +{ + QString fileName(QApplication::applicationDirPath() + "/lockFile.txt"); + std::shared_ptr> lock; + VlpCreateLock(lock, fileName); + + fileName = lock->GetLockFile(); + QVERIFY2(QFileInfo(fileName).exists(), "Lock file doesn't exist!"); + + lock.reset(); + QVERIFY2(not QFileInfo(fileName).exists(), "Lock file still exists!"); +} diff --git a/src/test/ValentinaTest/tst_vlockguard.h b/src/test/ValentinaTest/tst_vlockguard.h new file mode 100644 index 000000000..b418f623f --- /dev/null +++ b/src/test/ValentinaTest/tst_vlockguard.h @@ -0,0 +1,44 @@ +/************************************************************************ + ** + ** @file tst_vlockguard.h + ** @author Roman Telezhynskyi + ** @date 26 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 + ** 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 TST_VLOCKGUARD_H +#define TST_VLOCKGUARD_H + +#include + +class TST_VLockGuard : public QObject +{ + Q_OBJECT +public: + explicit TST_VLockGuard(QObject *parent = nullptr); + +private slots: + void TryLock() const; +}; + +#endif // TST_VLOCKGUARD_H