From 8f7f1cacd60f150f5d2520d3c9c47d31322fd4c1 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Thu, 5 Jul 2018 22:34:04 +0200 Subject: tests: make qprefdisplay test file Remove display tests from testpreferences and make a new file Signed-off-by: Jan Iversen --- tests/testqPrefDisplay.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/testqPrefDisplay.cpp (limited to 'tests/testqPrefDisplay.cpp') 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 +#include + +#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) -- cgit v1.2.3-70-g09d2