diff options
author | jan Iversen <jani@apache.org> | 2018-08-20 11:51:48 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-25 11:49:47 -0700 |
commit | ebc0e6d3f3edb90851295399dd22e081fe00a0c8 (patch) | |
tree | 5d08f827e6ed92eb26a778b540e132dbfad5742a /tests | |
parent | 82b626b3fdd82bbe251d56a9972941ed207825a3 (diff) | |
download | subsurface-ebc0e6d3f3edb90851295399dd22e081fe00a0c8.tar.gz |
core/tests: merge Animations and add vars. to qPrefDisplay
Add class variable tooltip_position to qPrefDisplay
Add class variable lastDir to qPrefDisplay
qPrefDisplay is updated to use new qPrefPrivate functions
Adjust test cases incl. qml tests
qPrefAnimations only has 1 variable, that really is a display variable
Merge the variable into qPrefDisplay, to simplify setup (and avoid loading
extra page in qml).
correct theme to save in correct place, and make it a static
class variable
Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/testqPrefAnimations.cpp | 83 | ||||
-rw-r--r-- | tests/testqPrefAnimations.h | 18 | ||||
-rw-r--r-- | tests/testqPrefDisplay.cpp | 64 | ||||
-rw-r--r-- | tests/tst_qPrefAnimations.qml | 19 | ||||
-rw-r--r-- | tests/tst_qPrefDisplay.qml | 49 |
6 files changed, 102 insertions, 133 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fd1be7ea6..4d59536bd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -100,7 +100,6 @@ TEST(TestPicture testpicture.cpp) TEST(TestMerge testmerge.cpp) TEST(TestTagList testtaglist.cpp) -TEST(TestQPrefAnimations testqPrefAnimations.cpp) TEST(TestQPrefCloudStorage testqPrefCloudStorage.cpp) TEST(TestQPrefDisplay testqPrefDisplay.cpp) TEST(TestQPrefDiveComputer testqPrefDiveComputer.cpp) @@ -132,7 +131,6 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} TestMerge TestTagList - TestQPrefAnimations TestQPrefCloudStorage TestQPrefDisplay TestQPrefDiveComputer diff --git a/tests/testqPrefAnimations.cpp b/tests/testqPrefAnimations.cpp deleted file mode 100644 index 90292f28f..000000000 --- a/tests/testqPrefAnimations.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include "testqPrefAnimations.h" - -#include "core/pref.h" -#include "core/qthelper.h" -#include "core/settings/qPref.h" - -#include <QDate> -#include <QTest> - -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()); - QCOMPARE(tst_direct->animation_speed(), 25); -} - -QTEST_MAIN(TestQPrefAnimations) diff --git a/tests/testqPrefAnimations.h b/tests/testqPrefAnimations.h deleted file mode 100644 index f0ed4a195..000000000 --- a/tests/testqPrefAnimations.h +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#ifndef TESTQPREFANIMATIONS_H -#define TESTQPREFANIMATIONS_H - -#include <QObject> - -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 diff --git a/tests/testqPrefDisplay.cpp b/tests/testqPrefDisplay.cpp index 0f534c0da..ce4d627ed 100644 --- a/tests/testqPrefDisplay.cpp +++ b/tests/testqPrefDisplay.cpp @@ -21,17 +21,17 @@ void TestQPrefDisplay::test_struct_get() auto display = qPrefDisplay::instance(); + prefs.animation_speed = 17; prefs.display_invalid_dives = true; prefs.divelist_font = copy_qstring("comic"); prefs.font_size = 12.0; prefs.show_developer = false; - prefs.theme = copy_qstring("myTheme"); + QCOMPARE(display->animation_speed(), prefs.animation_speed); QCOMPARE(display->display_invalid_dives(), prefs.display_invalid_dives); QCOMPARE(display->divelist_font(), QString(prefs.divelist_font)); QCOMPARE(display->font_size(), prefs.font_size); QCOMPARE(display->show_developer(), prefs.show_developer); - QCOMPARE(display->theme(), QString(prefs.theme)); } void TestQPrefDisplay::test_set_struct() @@ -40,17 +40,39 @@ void TestQPrefDisplay::test_set_struct() auto display = qPrefDisplay::instance(); + display->set_animation_speed(27); display->set_display_invalid_dives(true); display->set_divelist_font("doNotCareAtAll"); display->set_font_size(12.0); display->set_show_developer(false); display->set_theme("myTheme"); - + display->set_lastDir("test1"); + display->set_tooltip_position(QPointF(512, 3)); + display->set_UserSurvey("my1"); + display->set_mainSplitter("main1"); + display->set_topSplitter("top1"); + display->set_bottomSplitter("bottom1"); + display->set_maximized(false); + display->set_geometry("geo1"); + display->set_windowState("win1"); + display->set_lastState(17); + + QCOMPARE(prefs.animation_speed, 27); QCOMPARE(prefs.display_invalid_dives, true); QCOMPARE(prefs.divelist_font, "doNotCareAtAll"); QCOMPARE(prefs.font_size, 12.0); QCOMPARE(prefs.show_developer, false); - QCOMPARE(prefs.theme, "myTheme"); + QCOMPARE(display->theme(), QString("myTheme")); + QCOMPARE(display->lastDir(), QString("test1")); + QCOMPARE(display->tooltip_position(), QPointF(512, 3)); + QCOMPARE(display->UserSurvey(), QString("my1")); + QCOMPARE(display->mainSplitter(), QByteArray("main1")); + QCOMPARE(display->topSplitter(), QByteArray("top1")); + QCOMPARE(display->bottomSplitter(), QByteArray("bottom1")); + QCOMPARE(display->maximized(), false); + QCOMPARE(display->geometry(), QByteArray("geo1")); + QCOMPARE(display->windowState(), QByteArray("win1")); + QCOMPARE(display->lastState(), 17); } void TestQPrefDisplay::test_set_load_struct() @@ -59,24 +81,46 @@ void TestQPrefDisplay::test_set_load_struct() auto display = qPrefDisplay::instance(); + display->set_animation_speed(33); display->set_display_invalid_dives(false); display->set_divelist_font("doNotCareString"); display->set_font_size(15.0); display->set_show_developer(true); display->set_theme("myTheme2"); - + display->set_lastDir("test2"); + display->set_tooltip_position(QPointF(612, 3)); + display->set_UserSurvey("my2"); + display->set_mainSplitter("main2"); + display->set_topSplitter("top2"); + display->set_bottomSplitter("bottom2"); + display->set_maximized(true); + display->set_geometry("geo2"); + display->set_windowState("win2"); + display->set_lastState(27); + + prefs.animation_speed = 17; prefs.display_invalid_dives = true; prefs.divelist_font = copy_qstring("doNotCareAtAll"); prefs.font_size = 12.0; prefs.show_developer = false; - prefs.theme = copy_qstring("myTheme"); display->load(); + QCOMPARE(prefs.animation_speed, 33); QCOMPARE(prefs.display_invalid_dives, false); QCOMPARE(prefs.divelist_font, "doNotCareString"); QCOMPARE(prefs.font_size, 15.0); QCOMPARE(prefs.show_developer, true); - QCOMPARE(prefs.theme, "myTheme2"); + QCOMPARE(display->theme(), QString("myTheme2")); + QCOMPARE(display->lastDir(), QString("test2")); + QCOMPARE(display->tooltip_position(), QPointF(612, 3)); + QCOMPARE(display->UserSurvey(), QString("my2")); + QCOMPARE(display->mainSplitter(), QByteArray("main2")); + QCOMPARE(display->topSplitter(), QByteArray("top2")); + QCOMPARE(display->bottomSplitter(), QByteArray("bottom2")); + QCOMPARE(display->maximized(), true); + QCOMPARE(display->geometry(), QByteArray("geo2")); + QCOMPARE(display->windowState(), QByteArray("win2")); + QCOMPARE(display->lastState(), 27); } void TestQPrefDisplay::test_struct_disk() @@ -85,25 +129,25 @@ void TestQPrefDisplay::test_struct_disk() auto display = qPrefDisplay::instance(); + prefs.animation_speed = 27; prefs.display_invalid_dives = true; prefs.divelist_font = copy_qstring("doNotCareAtAll"); prefs.font_size = 17.0; prefs.show_developer = false; - prefs.theme = copy_qstring("myTheme3"); display->sync(); + prefs.animation_speed = 35; prefs.display_invalid_dives = false; prefs.divelist_font = copy_qstring("noString"); prefs.font_size = 11.0; prefs.show_developer = true; - prefs.theme = copy_qstring("myTheme"); display->load(); + QCOMPARE(prefs.animation_speed, 27); QCOMPARE(prefs.display_invalid_dives, true); QCOMPARE(prefs.divelist_font, "doNotCareAtAll"); QCOMPARE(prefs.font_size, 17.0); QCOMPARE(prefs.show_developer, false); - QCOMPARE(prefs.theme, "myTheme3"); } void TestQPrefDisplay::test_multiple() diff --git a/tests/tst_qPrefAnimations.qml b/tests/tst_qPrefAnimations.qml deleted file mode 100644 index 01e59fa42..000000000 --- a/tests/tst_qPrefAnimations.qml +++ /dev/null @@ -1,19 +0,0 @@ -// 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) - } - -} diff --git a/tests/tst_qPrefDisplay.qml b/tests/tst_qPrefDisplay.qml index eb4e11e30..e25f17bf8 100644 --- a/tests/tst_qPrefDisplay.qml +++ b/tests/tst_qPrefDisplay.qml @@ -11,21 +11,68 @@ TestCase { } function test_variables() { + var x0 = display.animation_speed + display.animation_speed = 37 + compare(display.animation_speed, 37) + var x1 = display.divelist_font display.divelist_font = "helvitica" compare(display.divelist_font, "helvitica") + var x2 = display.font_size display.font_size = 12.0 compare(display.font_size, 12.0) + var x3 = display.display_invalid_dives display.display_invalid_dives = !x3 compare(display.display_invalid_dives, !x3) + var x4 = display.show_developer display.show_developer = !x4 compare(display.show_developer, !x4) + var x5 = display.theme display.theme = "myColor" compare(display.theme, "myColor") - } +//TBD var x6 = display.tooltip_position +//TBD display.tooltip_position = ?? +//TBD compare(display.tooltip_position, ??) + + var x7 = display.lastDir + display.lastDir = "myDir" + compare(display.lastDir, "myDir") + + var x8 = display.UserSurvey + display.UserSurvey = "yes" + compare(display.UserSurvey, "yes") + +//TBD var x9 = display.mainSplitter +//TBD display.mainSplitter = ??? +//TBD compare(display.mainSplitter, ???) + +//TBD var x10 = display.topSplitter +//TBD display.topSplitter = ??? +//TBD compare(display.topSplitter, ???) + +//TBD var x11 = display.bottomSplitter +//TBD display.bottomSplitter = ??? +//TBD compare(display.bottomSplitter, ???) + + var x12 = display.maximized + display.maximized = true + compare(display.maximized, true) + +//TBD var x13 = display.geometry +//TBD display.geometry = ??? +//TBD compare(display.geometry, ???) + +//TBD var x14 = display.windowState +//TBD display.windowState = ??? +//TBD compare(display.windowState, ???) + + var x15 = display.lastState + display.lastState = 17 + compare(display.lastState, 17) + } } |