diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2016-10-17 17:50:55 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-10-18 11:12:33 -0700 |
commit | a42b05578fe731ce0b722e5c7383d616880289ef (patch) | |
tree | 9edd7965c3da102f508d0c765ff727c6c48755aa | |
parent | 9c4b0170bfc321a31c6f3d0f7cd34edfa74fe1f4 (diff) | |
download | subsurface-a42b05578fe731ce0b722e5c7383d616880289ef.tar.gz |
Tests for Units Preferences
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 4 | ||||
-rw-r--r-- | tests/testpreferences.cpp | 37 |
2 files changed, 40 insertions, 1 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 009ca6403..101e6650c 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1557,7 +1557,9 @@ int UnitsSettings::verticalSpeedTime() const QString UnitsSettings::unitSystem() const { - return QString(); /*FIXME: there's no char * units on the prefs. */ + return prefs.unit_system == METRIC ? QStringLiteral("metric") + : prefs.unit_system == IMPERIAL ? QStringLiteral("imperial") + : QStringLiteral("personalized"); } bool UnitsSettings::coordinatesTraditional() const diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp index 684795891..50389a0c6 100644 --- a/tests/testpreferences.cpp +++ b/tests/testpreferences.cpp @@ -410,6 +410,43 @@ void TestPreferences::testPreferences() TEST(planner->decoSac(),112); TEST(planner->decoMode(),RECREATIONAL); + + auto units = pref->unit_settings; + units->setLength(0); + units->setPressure(0); + units->setVolume(0); + units->setTemperature(0); + units->setWeight(0); + units->setVerticalSpeedTime(0); + units->setUnitSystem(QStringLiteral("metric")); + units->setCoordinatesTraditional(false); + + TEST(units->length(),0); + TEST(units->pressure(),0); + TEST(units->volume(),0); + TEST(units->temperature(),0); + TEST(units->weight(),0); + TEST(units->verticalSpeedTime(),0); + TEST(units->unitSystem(),QStringLiteral("metric")); + TEST(units->coordinatesTraditional(),false); + + units->setLength(1); + units->setPressure(1); + units->setVolume(1); + units->setTemperature(1); + units->setWeight(1); + units->setVerticalSpeedTime(1); + units->setUnitSystem(QStringLiteral("fake-metric-system")); + units->setCoordinatesTraditional(true); + + TEST(units->length(),1); + TEST(units->pressure(),1); + TEST(units->volume(),1); + TEST(units->temperature(),1); + TEST(units->weight(),1); + TEST(units->verticalSpeedTime(),1); + TEST(units->unitSystem(),QStringLiteral("personalized")); + TEST(units->coordinatesTraditional(),true); } QTEST_MAIN(TestPreferences) |