From 3dce5de12ddbf310ed047227f3470d478b505540 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 28 Aug 2016 20:11:29 -0300 Subject: Add the beginning of the Preferences test And it actually helped me to find a bug. yey. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- tests/CMakeLists.txt | 2 ++ tests/testpreferences.cpp | 35 +++++++++++++++++++++++++++++++++++ tests/testpreferences.h | 14 ++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 tests/testpreferences.cpp create mode 100644 tests/testpreferences.h (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d6b2ffc4f..03f550ae0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 ) diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp new file mode 100644 index 000000000..652cf6f1d --- /dev/null +++ b/tests/testpreferences.cpp @@ -0,0 +1,35 @@ +#include "testpreferences.h" + +#include "core/subsurface-qt/SettingsObjectWrapper.h" + +#include + +#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) diff --git a/tests/testpreferences.h b/tests/testpreferences.h new file mode 100644 index 000000000..9b2c44ab3 --- /dev/null +++ b/tests/testpreferences.h @@ -0,0 +1,14 @@ +#ifndef TESTDIVESITEDUPLICATION_H +#define TESTDIVESITEDUPLICATION_H + +#include +#include + +class TestPreferences : public QObject +{ + Q_OBJECT +private slots: + void testPreferences(); +}; + +#endif // TESTDIVESITEDUPLICATION_H -- cgit v1.2.3-70-g09d2