diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/testpreferences.cpp | 17 | ||||
-rw-r--r-- | tests/testqPrefDisplay.cpp | 42 | ||||
-rw-r--r-- | tests/testqPrefDisplay.h | 16 | ||||
-rw-r--r-- | tests/testqml.cpp | 9 |
5 files changed, 67 insertions, 19 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 863e9dd8e..771504794 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -97,6 +97,7 @@ TEST(TestDiveSiteDuplication testdivesiteduplication.cpp) TEST(TestRenumber testrenumber.cpp) TEST(TestGitStorage testgitstorage.cpp) TEST(TestPreferences testpreferences.cpp) +TEST(TestQPrefDisplay testqPrefDisplay.cpp) TEST(TestPicture testpicture.cpp) TEST(TestMerge testmerge.cpp) TEST(TestTagList testtaglist.cpp) @@ -112,6 +113,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} TestGitStorage TestPlan TestDiveSiteDuplication + TestQPrefDisplay TestPreferences TestRenumber TestPicture diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp index 38c132ee5..7a0fa64fd 100644 --- a/tests/testpreferences.cpp +++ b/tests/testpreferences.cpp @@ -445,23 +445,6 @@ void TestPreferences::testPreferences() TEST(general->pscrRatio(), 1); TEST(general->useDefaultFile(), false); - auto display = qPrefDisplay::instance(); - display->set_divelist_font("comic"); - display->set_font_size(10.0); - display->set_display_invalid_dives(true); - - TEST(display->divelist_font(),QStringLiteral("comic")); - TEST(display->font_size(), 10.0); - TEST(display->display_invalid_dives(), true); - - display->set_divelist_font("helvetica"); - display->set_font_size(14.0); - display->set_display_invalid_dives(false); - - TEST(display->divelist_font(),QStringLiteral("helvetica")); - TEST(display->font_size(), 14.0); - TEST(display->display_invalid_dives(), false); - auto language = pref->language_settings; language->setLangLocale ("en_US"); language->setLanguage ("en"); diff --git a/tests/testqPrefDisplay.cpp b/tests/testqPrefDisplay.cpp new file mode 100644 index 000000000..bfd5b5eae --- /dev/null +++ b/tests/testqPrefDisplay.cpp @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "testqPrefDisplay.h" + +#include "core/settings/qPrefDisplay.h" + +#include <QtTest> +#include <QDate> + +#define TEST(METHOD, VALUE) \ +QCOMPARE(METHOD, VALUE); \ +display->sync(); \ +display->load(); \ +QCOMPARE(METHOD, VALUE); + +void TestQPrefDisplay::initTestCase() +{ + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("SubsurfaceTestQPrefDisplay"); +} + +void TestQPrefDisplay::test1() +{ + auto display = qPrefDisplay::instance(); + display->set_divelist_font("comic"); + display->set_font_size(10.0); + display->set_display_invalid_dives(true); + + TEST(display->divelist_font(),QStringLiteral("comic")); + TEST(display->font_size(), 10.0); + TEST(display->display_invalid_dives(), true); + + display->set_divelist_font("helvetica"); + display->set_font_size(14.0); + display->set_display_invalid_dives(false); + + TEST(display->divelist_font(),QStringLiteral("helvetica")); + TEST(display->font_size(), 14.0); + TEST(display->display_invalid_dives(), false); +} + +QTEST_MAIN(TestQPrefDisplay) diff --git a/tests/testqPrefDisplay.h b/tests/testqPrefDisplay.h new file mode 100644 index 000000000..1885e8686 --- /dev/null +++ b/tests/testqPrefDisplay.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef TESTQPREFDISPLAY_H +#define TESTQPREFDISPLAY_H + +#include <QTest> +#include <functional> + +class TestQPrefDisplay : public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + void test1(); +}; + +#endif // TESTQPREFDISPLAY_H diff --git a/tests/testqml.cpp b/tests/testqml.cpp index 8ba04da90..0b75d8d48 100644 --- a/tests/testqml.cpp +++ b/tests/testqml.cpp @@ -4,6 +4,7 @@ #include <QtTest> #include <QQmlEngine> #include <QQmlContext> +#include <QApplication> #include "core/settings/qPref.h" #include "core/qt-gui.h" @@ -18,8 +19,12 @@ int main(int argc, char **argv) QTEST_ADD_GPU_BLACKLIST_SUPPORT QTEST_SET_MAIN_SOURCE_PATH - // check that qPref exists - new qPref; + // check that qPref classes exists + qPref::instance(); + qPrefDisplay::instance(); + + // prepare Qt application + new QApplication(argc, argv); // check that we have a directory if (argc < 2) { |