tests: update qPrefDisplay test cases

remove include of QtTest in header, becaue it is not needed,
add include of QObject in header, so moc can generate code.
add QTest in cpp file, which replaces QtTest

Change content of strings to test divelist_font to a not normal
font name, to ensure less confusion by readers. Remark the old
surrounding code accept illegal font names, but correcting this
is not covered in this commit.

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-07-17 16:19:56 +02:00 committed by Dirk Hohndel
parent 3c3729711c
commit 0363e590f3
2 changed files with 12 additions and 11 deletions

View file

@ -1,11 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
#include "testqPrefDisplay.h"
#include "core/settings/qPrefDisplay.h"
#include "core/settings/qPref.h"
#include "core/pref.h"
#include "core/qthelper.h"
#include <QDate>
#include <QTest>
void TestQPrefDisplay::initTestCase()
{
@ -40,13 +41,13 @@ void TestQPrefDisplay::test_set_struct()
auto display = qPrefDisplay::instance();
display->set_display_invalid_dives(true);
display->set_divelist_font("comic");
display->set_divelist_font("doNotCareAtAll");
display->set_font_size(12.0);
display->set_show_developer(false);
display->set_theme("myTheme");
QCOMPARE(prefs.display_invalid_dives, true);
QCOMPARE(prefs.divelist_font, "comic");
QCOMPARE(prefs.divelist_font, "doNotCareAtAll");
QCOMPARE(prefs.font_size, 12.0);
QCOMPARE(prefs.show_developer, false);
QCOMPARE(prefs.theme, "myTheme");
@ -59,20 +60,20 @@ void TestQPrefDisplay::test_set_load_struct()
auto display = qPrefDisplay::instance();
display->set_display_invalid_dives(false);
display->set_divelist_font("helvitica");
display->set_divelist_font("doNotCareString");
display->set_font_size(15.0);
display->set_show_developer(true);
display->set_theme("myTheme2");
prefs.display_invalid_dives = true;
prefs.divelist_font = copy_qstring("comic");
prefs.divelist_font = copy_qstring("doNotCareAtAll");
prefs.font_size = 12.0;
prefs.show_developer = false;
prefs.theme = copy_qstring("myTheme");
display->load();
QCOMPARE(prefs.display_invalid_dives, false);
QCOMPARE(prefs.divelist_font, "helvitica");
QCOMPARE(prefs.divelist_font, "doNotCareString");
QCOMPARE(prefs.font_size, 15.0);
QCOMPARE(prefs.show_developer, true);
QCOMPARE(prefs.theme, "myTheme2");
@ -85,21 +86,21 @@ void TestQPrefDisplay::test_struct_disk()
auto display = qPrefDisplay::instance();
prefs.display_invalid_dives = true;
prefs.divelist_font = copy_qstring("helvitica");
prefs.divelist_font = copy_qstring("doNotCareAtAll");
prefs.font_size = 17.0;
prefs.show_developer = false;
prefs.theme = copy_qstring("myTheme3");
display->sync();
prefs.display_invalid_dives = false;
prefs.divelist_font = copy_qstring("comic");
prefs.divelist_font = copy_qstring("noString");
prefs.font_size = 11.0;
prefs.show_developer = true;
prefs.theme = copy_qstring("myTheme");
display->load();
QCOMPARE(prefs.display_invalid_dives, true);
QCOMPARE(prefs.divelist_font, "helvitica");
QCOMPARE(prefs.divelist_font, "doNotCareAtAll");
QCOMPARE(prefs.font_size, 17.0);
QCOMPARE(prefs.show_developer, false);
QCOMPARE(prefs.theme, "myTheme3");
@ -117,7 +118,7 @@ void TestQPrefDisplay::test_multiple()
auto display_direct = new qPrefDisplay;
prefs.display_invalid_dives = true;
prefs.divelist_font = copy_qstring("helvetica");
prefs.divelist_font = copy_qstring("multipleCharsInString");
prefs.font_size = 15.0;
prefs.show_developer = false;
prefs.theme = copy_qstring("myTheme8");

View file

@ -2,7 +2,7 @@
#ifndef TESTQPREFDISPLAY_H
#define TESTQPREFDISPLAY_H
#include <QtTest>
#include <QObject>
class TestQPrefDisplay : public QObject
{