mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
tests: make qprefdisplay test file
Remove display tests from testpreferences and make a new file Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
928fc1ee79
commit
8f7f1cacd6
5 changed files with 67 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
42
tests/testqPrefDisplay.cpp
Normal file
42
tests/testqPrefDisplay.cpp
Normal file
|
@ -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)
|
16
tests/testqPrefDisplay.h
Normal file
16
tests/testqPrefDisplay.h
Normal file
|
@ -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
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue