From 6c1aa701d6a459c3bdca0396dfc603711956b508 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Thu, 5 Jul 2018 22:34:04 +0200 Subject: tests: make qprefdisplay test file Remove display tests from testpreferences and make a new file Signed-off-by: Jan Iversen --- tests/testqml.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/testqml.cpp b/tests/testqml.cpp index 0b75d8d48..e77d2c84f 100644 --- a/tests/testqml.cpp +++ b/tests/testqml.cpp @@ -8,6 +8,7 @@ #include "core/settings/qPref.h" #include "core/qt-gui.h" +#include "core/settings/qPrefDisplay.h" // this is the content of QUICK_TEST_MAIN amended with // registration of ssrf classes -- cgit v1.2.3-70-g09d2 From 33949735f2965a2249b2915b7c38e30202520bf4 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Thu, 12 Jul 2018 12:36:19 +0200 Subject: 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 --- tests/CMakeLists.txt | 1 + tests/testpreferences.cpp | 5 --- tests/testqPrefAnimations.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++ tests/testqPrefAnimations.h | 19 ++++++++++ 4 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 tests/testqPrefAnimations.cpp create mode 100644 tests/testqPrefAnimations.h (limited to 'tests') 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 + +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 + +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 -- cgit v1.2.3-70-g09d2 From f63217495d27c77b2f7f866caec568a19ee9543d Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Thu, 12 Jul 2018 12:44:53 +0200 Subject: tests: add qPrefAnimations qml testcases add test of qml C++ interface Signed-off-by: Jan Iversen --- tests/testqml.cpp | 1 - tests/tst_qPrefAnimations.qml | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/tst_qPrefAnimations.qml (limited to 'tests') diff --git a/tests/testqml.cpp b/tests/testqml.cpp index e77d2c84f..0b75d8d48 100644 --- a/tests/testqml.cpp +++ b/tests/testqml.cpp @@ -8,7 +8,6 @@ #include "core/settings/qPref.h" #include "core/qt-gui.h" -#include "core/settings/qPrefDisplay.h" // this is the content of QUICK_TEST_MAIN amended with // registration of ssrf classes diff --git a/tests/tst_qPrefAnimations.qml b/tests/tst_qPrefAnimations.qml new file mode 100644 index 000000000..01e59fa42 --- /dev/null +++ b/tests/tst_qPrefAnimations.qml @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +import QtQuick 2.6 +import QtTest 1.2 +import org.subsurfacedivelog.mobile 1.0 + +TestCase { + name: "qPrefAnimations" + + SsrfAnimationsPrefs { + id: tst + } + + function test_variables() { + var x1 = tst.animation_speed; + tst.animation_speed = 37 + compare(tst.animation_speed, 37) + } + +} -- cgit v1.2.3-70-g09d2