1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
// SPDX-License-Identifier: GPL-2.0
#include "testpreferences.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QDate>
#include <QtTest>
#define TEST(METHOD, VALUE) \
QCOMPARE(METHOD, VALUE); \
pref->sync(); \
pref->load(); \
QCOMPARE(METHOD, VALUE);
void TestPreferences::initTestCase()
{
QCoreApplication::setOrganizationName("Subsurface");
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
QCoreApplication::setApplicationName("SubsurfaceTestPreferences");
}
void TestPreferences::testPreferences()
{
auto pref = SettingsObjectWrapper::instance();
pref->load();
auto tecDetails = pref->techDetails;
tecDetails->setModpO2(0.2);
TEST(tecDetails->modpO2(), 0.2);
tecDetails->setModpO2(1.0);
TEST(tecDetails->modpO2(), 1.0);
tecDetails->setGflow(2);
TEST(tecDetails->gflow(), 2);
tecDetails->setGflow(3);
TEST(tecDetails->gflow(), 3);
tecDetails->setGfhigh(4);
TEST(tecDetails->gfhigh(), 4);
tecDetails->setGfhigh(5);
TEST(tecDetails->gfhigh(), 5);
tecDetails->setVpmbConservatism(5);
TEST(tecDetails->vpmbConservatism(), (short)5);
tecDetails->setVpmbConservatism(6);
TEST(tecDetails->vpmbConservatism(), (short)6);
tecDetails->setEad(true);
TEST(tecDetails->ead(), true);
tecDetails->setMod(true);
TEST(tecDetails->mod(), true);
tecDetails->setDCceiling(true);
TEST(tecDetails->dcceiling(), true);
tecDetails->setRedceiling(true);
TEST(tecDetails->redceiling(), true);
tecDetails->setCalcceiling(true);
TEST(tecDetails->calcceiling(), true);
tecDetails->setCalcceiling3m(true);
TEST(tecDetails->calcceiling3m(), true);
tecDetails->setCalcalltissues(true);
TEST(tecDetails->calcalltissues(), true);
tecDetails->setCalcndltts(true);
TEST(tecDetails->calcndltts(), true);
tecDetails->setBuehlmann(true);
TEST(tecDetails->buehlmann(), true);
tecDetails->setHRgraph(true);
TEST(tecDetails->hrgraph(), true);
tecDetails->setTankBar(true);
TEST(tecDetails->tankBar(), true);
tecDetails->setPercentageGraph(true);
TEST(tecDetails->percentageGraph(), true);
tecDetails->setRulerGraph(true);
TEST(tecDetails->rulerGraph(), true);
tecDetails->setShowCCRSetpoint(true);
TEST(tecDetails->showCCRSetpoint(), true);
tecDetails->setShowCCRSensors(true);
TEST(tecDetails->showCCRSensors(), true);
tecDetails->setZoomedPlot(true);
TEST(tecDetails->zoomedPlot(), true);
tecDetails->setShowSac(true);
TEST(tecDetails->showSac(), true);
tecDetails->setDisplayUnusedTanks(true);
TEST(tecDetails->displayUnusedTanks(), true);
tecDetails->setShowAverageDepth(true);
TEST(tecDetails->showAverageDepth(), true);
tecDetails->setShowPicturesInProfile(true);
TEST(tecDetails->showPicturesInProfile(), true);
tecDetails->setEad(false);
TEST(tecDetails->ead(), false);
tecDetails->setMod(false);
TEST(tecDetails->mod(), false);
tecDetails->setDCceiling(false);
TEST(tecDetails->dcceiling(), false);
tecDetails->setRedceiling(false);
TEST(tecDetails->redceiling(), false);
tecDetails->setCalcceiling(false);
TEST(tecDetails->calcceiling(), false);
tecDetails->setCalcceiling3m(false);
TEST(tecDetails->calcceiling3m(), false);
tecDetails->setCalcalltissues(false);
TEST(tecDetails->calcalltissues(), false);
tecDetails->setCalcndltts(false);
TEST(tecDetails->calcndltts(), false);
tecDetails->setBuehlmann(false);
TEST(tecDetails->buehlmann(), false);
tecDetails->setHRgraph(false);
TEST(tecDetails->hrgraph(), false);
tecDetails->setTankBar(false);
TEST(tecDetails->tankBar(), false);
tecDetails->setPercentageGraph(false);
TEST(tecDetails->percentageGraph(), false);
tecDetails->setRulerGraph(false);
TEST(tecDetails->rulerGraph(), false);
tecDetails->setShowCCRSetpoint(false);
TEST(tecDetails->showCCRSetpoint(), false);
tecDetails->setShowCCRSensors(false);
TEST(tecDetails->showCCRSensors(), false);
tecDetails->setZoomedPlot(false);
TEST(tecDetails->zoomedPlot(), false);
tecDetails->setShowSac(false);
TEST(tecDetails->showSac(), false);
tecDetails->setDisplayUnusedTanks(false);
TEST(tecDetails->displayUnusedTanks(), false);
tecDetails->setShowAverageDepth(false);
TEST(tecDetails->showAverageDepth(), false);
tecDetails->setShowPicturesInProfile(false);
TEST(tecDetails->showPicturesInProfile(), false);
auto pp = pref->pp_gas;
pp->setShowPn2(false);
pp->setShowPhe(false);
pp->setShowPo2(false);
pp->setPo2ThresholdMin(1.0);
pp->setPo2ThresholdMax(2.0);
pp->setPn2Threshold(3.0);
pp->setPheThreshold(4.0);
TEST(pp->showPn2(), false);
TEST(pp->showPhe(), false);
TEST(pp->showPo2(), false);
TEST(pp->pn2Threshold(), 3.0);
TEST(pp->pheThreshold(), 4.0);
TEST(pp->po2ThresholdMin(), 1.0);
TEST(pp->po2ThresholdMax(), 2.0);
pp->setShowPn2(true);
pp->setShowPhe(true);
pp->setShowPo2(true);
pp->setPo2ThresholdMin(4.0);
pp->setPo2ThresholdMax(5.0);
pp->setPn2Threshold(6.0);
pp->setPheThreshold(7.0);
TEST(pp->showPn2(), true);
TEST(pp->showPhe(), true);
TEST(pp->showPo2(), true);
TEST(pp->pn2Threshold(), 6.0);
TEST(pp->pheThreshold(), 7.0);
TEST(pp->po2ThresholdMin(), 4.0);
TEST(pp->po2ThresholdMax(), 5.0);
auto geo = pref->geocoding;
geo->setFirstTaxonomyCategory(TC_NONE);
geo->setSecondTaxonomyCategory(TC_OCEAN);
geo->setThirdTaxonomyCategory(TC_COUNTRY);
TEST(geo->firstTaxonomyCategory(), TC_NONE);
TEST(geo->secondTaxonomyCategory(), TC_OCEAN);
TEST(geo->thirdTaxonomyCategory(), TC_COUNTRY);
geo->setFirstTaxonomyCategory(TC_OCEAN);
geo->setSecondTaxonomyCategory(TC_COUNTRY);
geo->setThirdTaxonomyCategory(TC_NONE);
TEST(geo->firstTaxonomyCategory(), TC_OCEAN);
TEST(geo->secondTaxonomyCategory(), TC_COUNTRY);
TEST(geo->thirdTaxonomyCategory(), TC_NONE);
auto general = pref->general_settings;
general->setDefaultFilename("filename");
general->setDefaultCylinder("cylinder_2");
//TODOl: Change this to a enum. // This is 'undefined', it will need to figure out later between no_file or use_deault file.
general->setDefaultFileBehavior(0);
general->setDefaultSetPoint(0);
general->setO2Consumption(0);
general->setPscrRatio(0);
general->setUseDefaultFile(true);
TEST(general->defaultFilename(), QStringLiteral("filename"));
TEST(general->defaultCylinder(), QStringLiteral("cylinder_2"));
TEST(general->defaultFileBehavior(), (short)LOCAL_DEFAULT_FILE); // since we have a default file, here it returns
TEST(general->defaultSetPoint(), 0);
TEST(general->o2Consumption(), 0);
TEST(general->pscrRatio(), 0);
TEST(general->useDefaultFile(), true);
general->setDefaultFilename("no_file_name");
general->setDefaultCylinder("cylinder_1");
//TODOl: Change this to a enum.
general->setDefaultFileBehavior(CLOUD_DEFAULT_FILE);
general->setDefaultSetPoint(1);
general->setO2Consumption(1);
general->setPscrRatio(1);
general->setUseDefaultFile(false);
TEST(general->defaultFilename(), QStringLiteral("no_file_name"));
TEST(general->defaultCylinder(), QStringLiteral("cylinder_1"));
TEST(general->defaultFileBehavior(), (short)CLOUD_DEFAULT_FILE);
TEST(general->defaultSetPoint(), 1);
TEST(general->o2Consumption(), 1);
TEST(general->pscrRatio(), 1);
TEST(general->useDefaultFile(), false);
auto language = pref->language_settings;
language->setLangLocale("en_US");
language->setLanguage("en");
language->setTimeFormat("hh:mm");
language->setDateFormat("dd/mm/yy");
language->setDateFormatShort("dd/mm");
language->setTimeFormatOverride(false);
language->setDateFormatOverride(false);
language->setUseSystemLanguage(false);
TEST(language->langLocale(), QStringLiteral("en_US"));
TEST(language->language(), QStringLiteral("en"));
TEST(language->timeFormat(), QStringLiteral("hh:mm"));
TEST(language->dateFormat(), QStringLiteral("dd/mm/yy"));
TEST(language->dateFormatShort(), QStringLiteral("dd/mm"));
TEST(language->timeFormatOverride(), false);
TEST(language->dateFormatOverride(), false);
TEST(language->useSystemLanguage(), false);
language->setLangLocale("en_EN");
language->setLanguage("br");
language->setTimeFormat("mm:hh");
language->setDateFormat("yy/mm/dd");
language->setDateFormatShort("dd/yy");
language->setTimeFormatOverride(true);
language->setDateFormatOverride(true);
language->setUseSystemLanguage(true);
TEST(language->langLocale(), QStringLiteral("en_EN"));
TEST(language->language(), QStringLiteral("br"));
TEST(language->timeFormat(), QStringLiteral("mm:hh"));
TEST(language->dateFormat(), QStringLiteral("yy/mm/dd"));
TEST(language->dateFormatShort(), QStringLiteral("dd/yy"));
TEST(language->timeFormatOverride(), true);
TEST(language->dateFormatOverride(), true);
TEST(language->useSystemLanguage(), true);
auto location = pref->location_settings;
location->setTimeThreshold(10);
location->setDistanceThreshold(20);
TEST(location->timeThreshold(), 10);
TEST(location->distanceThreshold(), 20);
location->setTimeThreshold(30);
location->setDistanceThreshold(40);
TEST(location->timeThreshold(), 30);
TEST(location->distanceThreshold(), 40);
}
QTEST_MAIN(TestPreferences)
|