summaryrefslogtreecommitdiffstats
path: root/tests/testqPrefDisplay.cpp
blob: bfd5b5eae7fb031a611c271bb5fd625e20e12623 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)