summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-10 19:51:43 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-12 12:33:55 -0700
commit75767c456a2889d213621866a9f7fbb108f3366d (patch)
tree1f941f73a58718affe6c199c510e08e0eec75f95 /tests
parent114b3d9d470e65c25bcb5711daf053478f30e319 (diff)
downloadsubsurface-75767c456a2889d213621866a9f7fbb108f3366d.tar.gz
Turn application state into enum
The application state was encoded in a QByteArray. Thus, there was no compile-time checking. Typos would lead to silent failures. Turn the application state into an enum. Use the enum-class construct, so that the values don't polute the global namespace. Moreover, this makes them strongly typed, i.e. they don't auto-convert to integers. A disadvantage is that the enums now have to be cast to int explicitly when used to index an array. Replace two hash-maps in MainWindow to arrays of fixed sizes. Move the application-state details into their own files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/testplan.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/tests/testplan.cpp b/tests/testplan.cpp
index 1d32aacfb..7f48dbef2 100644
--- a/tests/testplan.cpp
+++ b/tests/testplan.cpp
@@ -5,6 +5,7 @@
#include "core/qthelper.h"
#include "core/subsurfacestartup.h"
#include "core/units.h"
+#include "core/applicationstate.h"
#include <QDebug>
#define DEBUG 1
@@ -469,7 +470,7 @@ void TestPlan::testVpmbMetric45m30minTx()
struct diveplan testPlan = {};
setupPlanVpmb45m30mTx(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -500,7 +501,7 @@ void TestPlan::testVpmbMetric60m10minTx()
struct diveplan testPlan = {};
setupPlanVpmb60m10mTx(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -531,7 +532,7 @@ void TestPlan::testVpmbMetric60m30minAir()
struct diveplan testPlan = {};
setupPlanVpmb60m30minAir(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -562,7 +563,7 @@ void TestPlan::testVpmbMetric60m30minEan50()
struct diveplan testPlan = {};
setupPlanVpmb60m30minEan50(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -599,7 +600,7 @@ void TestPlan::testVpmbMetric60m30minTx()
struct diveplan testPlan = {};
setupPlanVpmb60m30minTx(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -636,7 +637,7 @@ void TestPlan::testVpmbMetric100m60min()
struct diveplan testPlan = {};
setupPlanVpmb100m60min(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -680,7 +681,7 @@ void TestPlan::testMultipleGases()
struct diveplan testPlan = {};
setupPlanSeveralGases(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -706,7 +707,7 @@ void TestPlan::testVpmbMetricMultiLevelAir()
struct diveplan testPlan = {};
setupPlanVpmbMultiLevelAir(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -737,7 +738,7 @@ void TestPlan::testVpmbMetric100m10min()
struct diveplan testPlan = {};
setupPlanVpmb100m10min(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
@@ -784,7 +785,7 @@ void TestPlan::testVpmbMetricRepeat()
struct diveplan testPlan = {};
setupPlanVpmb30m20min(&testPlan);
- setCurrentAppState("PlanDive");
+ setAppState(ApplicationState::PlanDive);
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);