mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Add the beginning of the Preferences test
And it actually helped me to find a bug. yey. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e54f81855d
commit
3dce5de12d
3 changed files with 51 additions and 0 deletions
|
@ -19,6 +19,7 @@ TEST(TestPlan testplan.cpp)
|
|||
TEST(TestDiveSiteDuplication testdivesiteduplication.cpp)
|
||||
TEST(TestRenumber testrenumber.cpp)
|
||||
TEST(TestGitStorage testgitstorage.cpp)
|
||||
TEST(TestPreferences testpreferences.cpp)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
||||
DEPENDS
|
||||
|
@ -29,5 +30,6 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
|||
TestGitStorage
|
||||
TestPlan
|
||||
TestDiveSiteDuplication
|
||||
TestPreferences
|
||||
TestRenumber
|
||||
)
|
||||
|
|
35
tests/testpreferences.cpp
Normal file
35
tests/testpreferences.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "testpreferences.h"
|
||||
|
||||
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#define TEST(METHOD, VALUE) \
|
||||
QCOMPARE(METHOD, VALUE); \
|
||||
pref->sync(); \
|
||||
pref->load(); \
|
||||
QCOMPARE(METHOD, VALUE);
|
||||
|
||||
|
||||
void TestPreferences::testPreferences()
|
||||
{
|
||||
auto pref = SettingsObjectWrapper::instance();
|
||||
pref->load();
|
||||
|
||||
pref->animation_settings->setAnimationSpeed(20);
|
||||
TEST(pref->animation_settings->animationSpeed(), 20);
|
||||
pref->animation_settings->setAnimationSpeed(30);
|
||||
TEST(pref->animation_settings->animationSpeed(), 30);
|
||||
|
||||
pref->cloud_storage->setBackgroundSync(true);
|
||||
TEST(pref->cloud_storage->backgroundSync(), true);
|
||||
pref->cloud_storage->setBackgroundSync(false);
|
||||
TEST(pref->cloud_storage->backgroundSync(), false);
|
||||
|
||||
pref->cloud_storage->setBaseUrl("test_one");
|
||||
TEST(pref->cloud_storage->baseUrl(), QStringLiteral("test_one"));
|
||||
pref->cloud_storage->setBaseUrl("test_two");
|
||||
TEST(pref->cloud_storage->baseUrl(), QStringLiteral("test_two"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestPreferences)
|
14
tests/testpreferences.h
Normal file
14
tests/testpreferences.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef TESTDIVESITEDUPLICATION_H
|
||||
#define TESTDIVESITEDUPLICATION_H
|
||||
|
||||
#include <QTest>
|
||||
#include <functional>
|
||||
|
||||
class TestPreferences : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void testPreferences();
|
||||
};
|
||||
|
||||
#endif // TESTDIVESITEDUPLICATION_H
|
Loading…
Reference in a new issue