From e7da893f5a13d519cbc4db22a4c8d45f7e765b76 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 10 Jan 2021 13:39:34 +0200 Subject: [PATCH] gui/test: Extract temporary file creation to a separate file --- src/gui/test/KeySequenceTests.cpp | 10 ++-------- src/gui/test/Utils.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 src/gui/test/Utils.h diff --git a/src/gui/test/KeySequenceTests.cpp b/src/gui/test/KeySequenceTests.cpp index 669d8674..5e089de9 100644 --- a/src/gui/test/KeySequenceTests.cpp +++ b/src/gui/test/KeySequenceTests.cpp @@ -15,6 +15,7 @@ */ #include "../src/KeySequence.h" +#include "Utils.h" #include #include @@ -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> {}; diff --git a/src/gui/test/Utils.h b/src/gui/test/Utils.h new file mode 100644 index 00000000..5ca78c20 --- /dev/null +++ b/src/gui/test/Utils.h @@ -0,0 +1,30 @@ +/* barrier -- mouse and keyboard sharing utility + Copyright (C) 2021 Povilas Kanapickas + + 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 . +*/ + +#ifndef BARRIER_GUI_TEST_UTILS_H +#define BARRIER_GUI_TEST_UTILS_H + +#include +#include + +inline QString getTemporaryFilename() +{ + QTemporaryFile temp_file; + temp_file.open(); + return temp_file.fileName(); +} + +#endif // BARRIER_GUI_TEST_UTILS_H