diff options
author | jan Iversen <jani@apache.org> | 2018-07-12 12:36:19 +0200 |
---|---|---|
committer | jan Iversen <jani@apache.org> | 2018-07-12 22:35:36 +0200 |
commit | 33949735f2965a2249b2915b7c38e30202520bf4 (patch) | |
tree | dfa0f65ae5b97390930ec48f29dc30c2504fa10f | |
parent | d4e76dac9e8dbbb784c7133a4cc918de3121f35c (diff) | |
download | subsurface-33949735f2965a2249b2915b7c38e30202520bf4.tar.gz |
tests: add qPrefAnimations testcases
add test cases to secure struct preferences and qPrefAnimations work together
remove animation tests from testpreferences
Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/testpreferences.cpp | 5 | ||||
-rw-r--r-- | tests/testqPrefAnimations.cpp | 81 | ||||
-rw-r--r-- | tests/testqPrefAnimations.h | 19 |
4 files changed, 101 insertions, 5 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 771504794..0f30bfecb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -98,6 +98,7 @@ TEST(TestRenumber testrenumber.cpp) TEST(TestGitStorage testgitstorage.cpp) TEST(TestPreferences testpreferences.cpp) TEST(TestQPrefDisplay testqPrefDisplay.cpp) +TEST(TestQPrefAnimations testqPrefAnimations.cpp) TEST(TestPicture testpicture.cpp) TEST(TestMerge testmerge.cpp) TEST(TestTagList testtaglist.cpp) diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp index 7a0fa64fd..d950c49f9 100644 --- a/tests/testpreferences.cpp +++ b/tests/testpreferences.cpp @@ -482,11 +482,6 @@ void TestPreferences::testPreferences() TEST(language->dateFormatOverride(),true); TEST(language->useSystemLanguage(), true); - pref->animation_settings->setAnimationSpeed(20); - TEST(pref->animation_settings->animationSpeed(), 20); - pref->animation_settings->setAnimationSpeed(30); - TEST(pref->animation_settings->animationSpeed(), 30); - auto location = pref->location_settings; location->setTimeThreshold(10); location->setDistanceThreshold(20); diff --git a/tests/testqPrefAnimations.cpp b/tests/testqPrefAnimations.cpp new file mode 100644 index 000000000..db0e31218 --- /dev/null +++ b/tests/testqPrefAnimations.cpp @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "testqPrefAnimations.h" + +#include "core/settings/qPrefAnimations.h" +#include "core/pref.h" +#include "core/qthelper.h" + +#include <QDate> + +void TestQPrefAnimations::initTestCase() +{ + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("SubsurfaceTestQPrefAnimations"); +} + +void TestQPrefAnimations::test_struct_get() +{ + // Test struct pref -> get func. + + auto tst = qPrefAnimations::instance(); + + prefs.animation_speed = 17; + + QCOMPARE(tst->animation_speed(), prefs.animation_speed); +} + +void TestQPrefAnimations::test_set_struct() +{ + // Test set func -> struct pref + + auto tst = qPrefAnimations::instance(); + + tst->set_animation_speed(27); + + QCOMPARE(prefs.animation_speed, 27); +} + +void TestQPrefAnimations::test_set_load_struct() +{ + // test set func -> load -> struct pref + + auto tst = qPrefAnimations::instance(); + + tst->set_animation_speed(33); + + prefs.animation_speed = 17; + + tst->load(); + QCOMPARE(prefs.animation_speed, 33); +} + +void TestQPrefAnimations::test_struct_disk() +{ + // test struct prefs -> disk + + auto tst = qPrefAnimations::instance(); + + prefs.animation_speed = 27; + + tst->sync(); + prefs.animation_speed = 35; + + tst->load(); + QCOMPARE(prefs.animation_speed, 27); +} + +void TestQPrefAnimations::test_multiple() +{ + // test multiple instances have the same information + + prefs.animation_speed = 37; + auto tst_direct = new qPrefAnimations; + + prefs.animation_speed = 25; + auto tst = qPrefAnimations::instance(); + + QCOMPARE(tst->animation_speed(), tst_direct->animation_speed()); +} + +QTEST_MAIN(TestQPrefAnimations) diff --git a/tests/testqPrefAnimations.h b/tests/testqPrefAnimations.h new file mode 100644 index 000000000..162baf8fd --- /dev/null +++ b/tests/testqPrefAnimations.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef TESTQPREFANIMATIONS_H +#define TESTQPREFANIMATIONS_H + +#include <QtTest> + +class TestQPrefAnimations : public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + void test_struct_get(); + void test_set_struct(); + void test_set_load_struct(); + void test_struct_disk(); + void test_multiple(); +}; + +#endif // TESTQPREFANIMATIONS_H |