Test VLockGuard.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-26 10:31:36 +02:00
parent 1e99d00a54
commit 7102071b19
4 changed files with 102 additions and 2 deletions

View File

@ -48,7 +48,8 @@ SOURCES += \
tst_valentinacommandline.cpp \ tst_valentinacommandline.cpp \
tst_qmutokenparser.cpp \ tst_qmutokenparser.cpp \
tst_vmeasurements.cpp \ tst_vmeasurements.cpp \
tst_qmuparsererrormsg.cpp tst_qmuparsererrormsg.cpp \
tst_vlockguard.cpp
HEADERS += \ HEADERS += \
tst_vposter.h \ tst_vposter.h \
@ -64,7 +65,8 @@ HEADERS += \
tst_valentinacommandline.h \ tst_valentinacommandline.h \
tst_qmutokenparser.h \ tst_qmutokenparser.h \
tst_vmeasurements.h \ tst_vmeasurements.h \
tst_qmuparsererrormsg.h tst_qmuparsererrormsg.h \
tst_vlockguard.h
# Set using ccache. Function enable_ccache() defined in common.pri. # Set using ccache. Function enable_ccache() defined in common.pri.
$$enable_ccache() $$enable_ccache()

View File

@ -40,6 +40,7 @@
#include "tst_qmutokenparser.h" #include "tst_qmutokenparser.h"
#include "tst_vmeasurements.h" #include "tst_vmeasurements.h"
#include "tst_qmuparsererrormsg.h" #include "tst_qmuparsererrormsg.h"
#include "tst_vlockguard.h"
int main(int argc, char** argv) 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_QmuTokenParser());
ASSERT_TEST(new TST_VMeasurements()); ASSERT_TEST(new TST_VMeasurements());
ASSERT_TEST(new TST_QmuParserErrorMsg()); ASSERT_TEST(new TST_QmuParserErrorMsg());
ASSERT_TEST(new TST_VLockGuard());
return status; return status;
} }

View File

@ -0,0 +1,52 @@
/************************************************************************
**
** @file tst_vlockguard.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <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_vlockguard.h"
#include "../vmisc/vlockguard.h"
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_VLockGuard::TST_VLockGuard(QObject *parent)
:QObject(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VLockGuard::TryLock() const
{
QString fileName(QApplication::applicationDirPath() + "/lockFile.txt");
std::shared_ptr<VLockGuard<char>> 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!");
}

View File

@ -0,0 +1,44 @@
/************************************************************************
**
** @file tst_vlockguard.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <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 TST_VLOCKGUARD_H
#define TST_VLOCKGUARD_H
#include <QObject>
class TST_VLockGuard : public QObject
{
Q_OBJECT
public:
explicit TST_VLockGuard(QObject *parent = nullptr);
private slots:
void TryLock() const;
};
#endif // TST_VLOCKGUARD_H