diff options
author | jan Iversen <jani@apache.org> | 2018-08-05 14:13:37 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-12 07:36:10 -0700 |
commit | 863c04f3f7cde734068c20dcab6f4edee810473c (patch) | |
tree | 2dfeb2ca5e83d6f3c9d2122439c090a2c68bd614 | |
parent | cb2dc7515b3b14eed268ff580b30759d2c2272a5 (diff) | |
download | subsurface-863c04f3f7cde734068c20dcab6f4edee810473c.tar.gz |
tests: add qPrefTechincalDetails testcases
add test cases to secure struct preferences and qPrefTechnicalDetails work together
Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/testqPrefTechnicalDetails.cpp | 340 | ||||
-rw-r--r-- | tests/testqPrefTechnicalDetails.h | 19 |
3 files changed, 361 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bfda4383d..882f0e03a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -108,6 +108,7 @@ TEST(TestQPrefDiveComputer testqPrefDiveComputer.cpp) TEST(TestQPrefDivePlanner testqPrefDivePlanner.cpp) TEST(TestQPrefFacebook testqPrefFacebook.cpp) TEST(TestQPrefProxy testqPrefProxy.cpp) +TEST(TestQPrefTechnicalDetails testqPrefTechnicalDetails.cpp) TEST(TestQPrefUnits testqPrefUnits.cpp) TEST(TestQPrefUpdateManager testqPrefUpdateManager.cpp) add_test(NAME TestQML COMMAND $<TARGET_FILE:TestQML> ${SUBSURFACE_SOURCE}/tests) @@ -135,6 +136,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} TestQPrefDivePlanner TestQPrefFacebook TestQPrefProxy + TestQPrefTechnicalDetails TestQPrefUnits TestQPrefUpdateManager TestQML diff --git a/tests/testqPrefTechnicalDetails.cpp b/tests/testqPrefTechnicalDetails.cpp new file mode 100644 index 000000000..107e1c20b --- /dev/null +++ b/tests/testqPrefTechnicalDetails.cpp @@ -0,0 +1,340 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "testqPrefTechnicalDetails.h" + +#include "core/pref.h" +#include "core/qthelper.h" +#include "core/settings/qPref.h" + +#include <QTest> + +void TestQPrefTechnicalDetails::initTestCase() +{ + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("SubsurfaceTestQPrefTechnicalDetails"); +} + +void TestQPrefTechnicalDetails::test_struct_get() +{ + // Test struct pref -> get func. + + auto tst = qPrefTechnicalDetails::instance(); + + prefs.calcalltissues = true; + prefs.calcceiling = true; + prefs.calcceiling3m = true; + prefs.calcndltts = true; + prefs.dcceiling = true; + prefs.display_deco_mode = BUEHLMANN; + prefs.display_unused_tanks = true; + prefs.ead = true; + prefs.gfhigh = 27; + prefs.gflow = 25; + prefs.gf_low_at_maxdepth = true; + prefs.hrgraph = true; + prefs.mod = true; + prefs.modpO2 = 1.02; + prefs.percentagegraph = true; + prefs.redceiling = true; + prefs.rulergraph = true; + prefs.show_average_depth = true; + prefs.show_ccr_sensors = true; + prefs.show_ccr_setpoint = true; + prefs.show_icd = true; + prefs.show_pictures_in_profile = true; + prefs.show_sac = true; + prefs.show_scr_ocpo2 = true; + prefs.tankbar = true; + prefs.vpmb_conservatism = 123; + prefs.zoomed_plot = true; + + QCOMPARE(tst->calcceiling(), prefs.calcceiling); + QCOMPARE(tst->calcceiling3m(), prefs.calcceiling3m); + QCOMPARE(tst->calcndltts(), prefs.calcndltts); + QCOMPARE(tst->dcceiling(), prefs.dcceiling); + QCOMPARE(tst->display_deco_mode(), prefs.display_deco_mode); + QCOMPARE(tst->display_unused_tanks(), prefs.display_unused_tanks); + QCOMPARE(tst->ead(), prefs.ead); + QCOMPARE(tst->gfhigh(), (int)prefs.gfhigh); + QCOMPARE(tst->gflow(), (int)prefs.gflow); + QCOMPARE(tst->gf_low_at_maxdepth(), prefs.gf_low_at_maxdepth); + QCOMPARE(tst->hrgraph(), prefs.hrgraph); + QCOMPARE(tst->mod(), prefs.mod); + QCOMPARE(tst->modpO2(), prefs.modpO2); + QCOMPARE(tst->percentagegraph(), prefs.percentagegraph); + QCOMPARE(tst->redceiling(), prefs.redceiling); + QCOMPARE(tst->rulergraph(), prefs.rulergraph); + QCOMPARE(tst->show_average_depth(), prefs.show_average_depth); + QCOMPARE(tst->show_ccr_sensors(), prefs.show_ccr_sensors); + QCOMPARE(tst->show_ccr_setpoint(), prefs.show_ccr_setpoint); + QCOMPARE(tst->show_icd(), prefs.show_icd); + QCOMPARE(tst->show_pictures_in_profile(), prefs.show_pictures_in_profile); + QCOMPARE(tst->show_sac(), prefs.show_sac); + QCOMPARE(tst->show_scr_ocpo2(), prefs.show_scr_ocpo2); + QCOMPARE(tst->tankbar(), prefs.tankbar); + QCOMPARE(tst->vpmb_conservatism(), (int)prefs.vpmb_conservatism); + QCOMPARE(tst->zoomed_plot(), prefs.zoomed_plot); +} + +void TestQPrefTechnicalDetails::test_set_struct() +{ + // Test set func -> struct pref + + auto tst = qPrefTechnicalDetails::instance(); + + tst->set_calcalltissues(false); + tst->set_calcceiling(false); + tst->set_calcceiling3m(false); + tst->set_calcndltts(false); + tst->set_dcceiling(false); + tst->set_display_deco_mode(RECREATIONAL); + tst->set_display_unused_tanks(false); + tst->set_ead(false); + tst->set_gfhigh(29); + tst->set_gflow(24); + tst->set_gf_low_at_maxdepth(false); + tst->set_hrgraph(false); + tst->set_mod(false); + tst->set_modpO2(1.12); + tst->set_percentagegraph(false); + tst->set_redceiling(false); + tst->set_rulergraph(false); + tst->set_show_average_depth(false); + tst->set_show_ccr_sensors(false); + tst->set_show_ccr_setpoint(false); + tst->set_show_icd(false); + tst->set_show_pictures_in_profile(false); + tst->set_show_sac(false); + tst->set_show_scr_ocpo2(false); + tst->set_tankbar(false); + tst->set_vpmb_conservatism(64); + tst->set_zoomed_plot(false); + + QCOMPARE(prefs.calcceiling, false); + QCOMPARE(prefs.calcceiling3m, false); + QCOMPARE(prefs.calcndltts, false); + QCOMPARE(prefs.dcceiling, false); + QCOMPARE(prefs.display_deco_mode, RECREATIONAL); + QCOMPARE(prefs.display_unused_tanks, false); + QCOMPARE(prefs.ead, false); + QCOMPARE((int)prefs.gfhigh, 29); + QCOMPARE((int)prefs.gflow, 24); + QCOMPARE(prefs.gf_low_at_maxdepth, false); + QCOMPARE(prefs.hrgraph, false); + QCOMPARE(prefs.mod, false); + QCOMPARE(prefs.modpO2, 1.12); + QCOMPARE(prefs.percentagegraph, false); + QCOMPARE(prefs.redceiling, false); + QCOMPARE(prefs.rulergraph, false); + QCOMPARE(prefs.show_average_depth, false); + QCOMPARE(prefs.show_ccr_sensors, false); + QCOMPARE(prefs.show_ccr_setpoint, false); + QCOMPARE(prefs.show_icd, false); + QCOMPARE(prefs.show_pictures_in_profile, false); + QCOMPARE(prefs.show_sac, false); + QCOMPARE(prefs.show_scr_ocpo2, false); + QCOMPARE(prefs.tankbar, false); + QCOMPARE((int)prefs.vpmb_conservatism, 64); + QCOMPARE(prefs.zoomed_plot, false); +} + +void TestQPrefTechnicalDetails::test_set_load_struct() +{ + // test set func -> load -> struct pref + + auto tst = qPrefTechnicalDetails::instance(); + + tst->set_calcalltissues(false); + tst->set_calcceiling(false); + tst->set_calcceiling3m(false); + tst->set_calcndltts(false); + tst->set_dcceiling(false); + tst->set_display_deco_mode(RECREATIONAL); + tst->set_display_unused_tanks(false); + tst->set_ead(false); + tst->set_gfhigh(29); + tst->set_gflow(24); + tst->set_gf_low_at_maxdepth(false); + tst->set_hrgraph(false); + tst->set_mod(false); + tst->set_modpO2(1.12); + tst->set_percentagegraph(false); + tst->set_redceiling(false); + tst->set_rulergraph(false); + tst->set_show_average_depth(false); + tst->set_show_ccr_sensors(false); + tst->set_show_ccr_setpoint(false); + tst->set_show_icd(false); + tst->set_show_pictures_in_profile(false); + tst->set_show_sac(false); + tst->set_show_scr_ocpo2(false); + tst->set_tankbar(false); + tst->set_vpmb_conservatism(64); + tst->set_zoomed_plot(false); + + prefs.calcalltissues = true; + prefs.calcceiling = true; + prefs.calcceiling3m = true; + prefs.calcndltts = true; + prefs.dcceiling = true; + prefs.display_deco_mode = BUEHLMANN; + prefs.display_unused_tanks = true; + prefs.ead = true; + prefs.gfhigh = 27; + prefs.gflow = 25; + prefs.gf_low_at_maxdepth = true; + prefs.hrgraph = true; + prefs.mod = true; + prefs.modpO2 = 1.02; + prefs.percentagegraph = true; + prefs.redceiling = true; + prefs.rulergraph = true; + prefs.show_average_depth = true; + prefs.show_ccr_sensors = true; + prefs.show_ccr_setpoint = true; + prefs.show_icd = true; + prefs.show_pictures_in_profile = true; + prefs.show_sac = true; + prefs.show_scr_ocpo2 = true; + prefs.tankbar = true; + prefs.vpmb_conservatism = 123; + prefs.zoomed_plot = true; + + tst->load(); + QCOMPARE(prefs.calcceiling, false); + QCOMPARE(prefs.calcceiling3m, false); + QCOMPARE(prefs.calcndltts, false); + QCOMPARE(prefs.dcceiling, false); + QCOMPARE(prefs.display_deco_mode, RECREATIONAL); + QCOMPARE(prefs.display_unused_tanks, false); + QCOMPARE(prefs.ead, false); + QCOMPARE((int)prefs.gfhigh, 29); + QCOMPARE((int)prefs.gflow, 24); + QCOMPARE(prefs.gf_low_at_maxdepth, false); + QCOMPARE(prefs.hrgraph, false); + QCOMPARE(prefs.mod, false); + QCOMPARE(prefs.modpO2, 1.12); + QCOMPARE(prefs.percentagegraph, false); + QCOMPARE(prefs.redceiling, false); + QCOMPARE(prefs.rulergraph, false); + QCOMPARE(prefs.show_average_depth, false); + QCOMPARE(prefs.show_ccr_sensors, false); + QCOMPARE(prefs.show_ccr_setpoint, false); + QCOMPARE(prefs.show_icd, false); + QCOMPARE(prefs.show_pictures_in_profile, false); + QCOMPARE(prefs.show_sac, false); + QCOMPARE(prefs.show_scr_ocpo2, false); + QCOMPARE(prefs.tankbar, false); + QCOMPARE((int)prefs.vpmb_conservatism, 64); + QCOMPARE(prefs.zoomed_plot, false); +} + +void TestQPrefTechnicalDetails::test_struct_disk() +{ + // test struct prefs -> disk + + auto tst = qPrefTechnicalDetails::instance(); + + prefs.calcalltissues = true; + prefs.calcceiling = true; + prefs.calcceiling3m = true; + prefs.calcndltts = true; + prefs.dcceiling = true; + prefs.display_deco_mode = BUEHLMANN; + prefs.display_unused_tanks = true; + prefs.ead = true; + prefs.gfhigh = 11; + prefs.gflow = 12; + prefs.gf_low_at_maxdepth = true; + prefs.hrgraph = true; + prefs.mod = true; + prefs.modpO2 = 1.14; + prefs.percentagegraph = true; + prefs.redceiling = true; + prefs.rulergraph = true; + prefs.show_average_depth = true; + prefs.show_ccr_sensors = true; + prefs.show_ccr_setpoint = true; + prefs.show_icd = true; + prefs.show_pictures_in_profile = true; + prefs.show_sac = true; + prefs.show_scr_ocpo2 = true; + prefs.tankbar = true; + prefs.vpmb_conservatism = 15; + prefs.zoomed_plot = true; + + tst->sync(); + prefs.calcalltissues = false; + prefs.calcceiling = false; + prefs.calcceiling3m = false; + prefs.calcndltts = false; + prefs.dcceiling = false; + prefs.display_deco_mode = RECREATIONAL; + prefs.display_unused_tanks = false; + prefs.ead = false; + prefs.gfhigh = 27; + prefs.gflow = 25; + prefs.gf_low_at_maxdepth = false; + prefs.hrgraph = false; + prefs.mod = false; + prefs.modpO2 = 1.02; + prefs.percentagegraph = false; + prefs.redceiling = false; + prefs.rulergraph = false; + prefs.show_average_depth = false; + prefs.show_ccr_sensors = false; + prefs.show_ccr_setpoint = false; + prefs.show_icd = false; + prefs.show_pictures_in_profile = false; + prefs.show_sac = false; + prefs.show_scr_ocpo2 = false; + prefs.tankbar = false; + prefs.vpmb_conservatism = 123; + prefs.zoomed_plot = false; + + tst->load(); + QCOMPARE(prefs.calcceiling, true); + QCOMPARE(prefs.calcceiling3m, true); + QCOMPARE(prefs.calcndltts, true); + QCOMPARE(prefs.dcceiling, true); + QCOMPARE(prefs.display_deco_mode, BUEHLMANN); + QCOMPARE(prefs.display_unused_tanks, true); + QCOMPARE(prefs.ead, true); + QCOMPARE((int)prefs.gfhigh, 11); + QCOMPARE((int)prefs.gflow, 12); + QCOMPARE(prefs.gf_low_at_maxdepth, true); + QCOMPARE(prefs.hrgraph, true); + QCOMPARE(prefs.mod, true); + QCOMPARE(prefs.modpO2, 1.14); + QCOMPARE(prefs.percentagegraph, true); + QCOMPARE(prefs.redceiling, true); + QCOMPARE(prefs.rulergraph, true); + QCOMPARE(prefs.show_average_depth, true); + QCOMPARE(prefs.show_ccr_sensors, true); + QCOMPARE(prefs.show_ccr_setpoint, true); + QCOMPARE(prefs.show_icd, true); + QCOMPARE(prefs.show_pictures_in_profile, true); + QCOMPARE(prefs.show_sac, true); + QCOMPARE(prefs.show_scr_ocpo2, true); + QCOMPARE(prefs.tankbar, true); + QCOMPARE((int)prefs.vpmb_conservatism, 15); + QCOMPARE(prefs.zoomed_plot, true); +} + +void TestQPrefTechnicalDetails::test_multiple() +{ + // test multiple instances have the same information + + prefs.gfhigh = 27; + auto tst_direct = new qPrefTechnicalDetails; + + prefs.gflow = 25; + auto tst = qPrefTechnicalDetails::instance(); + + QCOMPARE(tst->gfhigh(), tst_direct->gfhigh()); + QCOMPARE(tst->gflow(), tst_direct->gflow()); + QCOMPARE(tst_direct->gfhigh(), 27); + QCOMPARE(tst_direct->gflow(), 25); +} + +QTEST_MAIN(TestQPrefTechnicalDetails) diff --git a/tests/testqPrefTechnicalDetails.h b/tests/testqPrefTechnicalDetails.h new file mode 100644 index 000000000..8e935a621 --- /dev/null +++ b/tests/testqPrefTechnicalDetails.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef TESTQPREFTECHNICALDETAILS_H +#define TESTQPREFTECHNICALDETAILS_H + +#include <QObject> + +class TestQPrefTechnicalDetails : 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 // TESTQPREFTECHNICALDETAILS_H |