gui/test: Extract temporary file creation to a separate file

This commit is contained in:
Povilas Kanapickas 2021-01-10 13:39:34 +02:00
parent 7f76d3cdcc
commit e7da893f5a
2 changed files with 32 additions and 8 deletions

View File

@ -15,6 +15,7 @@
*/
#include "../src/KeySequence.h"
#include "Utils.h"
#include <gtest/gtest.h>
#include <cstdio>
@ -73,14 +74,7 @@ namespace {
Qt::Key_Launch1,
Qt::Key_Select,
};
QString getTemporaryFilename()
{
QTemporaryFile temp_file;
temp_file.open();
return temp_file.fileName();
}
}
} // namespace
class KeySequenceLoadSaveTestFixture :
public ::testing::TestWithParam<std::tr1::tuple<Qt::Key, QSettings::Format>> {};

30
src/gui/test/Utils.h Normal file
View File

@ -0,0 +1,30 @@
/* barrier -- mouse and keyboard sharing utility
Copyright (C) 2021 Povilas Kanapickas <povilas@radix.lt>
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
found in the file LICENSE that should have accompanied this file.
This package 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BARRIER_GUI_TEST_UTILS_H
#define BARRIER_GUI_TEST_UTILS_H
#include <QtCore/QFile>
#include <QtCore/QTemporaryFile>
inline QString getTemporaryFilename()
{
QTemporaryFile temp_file;
temp_file.open();
return temp_file.fileName();
}
#endif // BARRIER_GUI_TEST_UTILS_H