diff options
author | jan Iversen <jani@apache.org> | 2019-01-18 08:07:00 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-27 04:03:25 +0900 |
commit | fc7aec540242b874857cec16fd337e04f18675df (patch) | |
tree | 0b04ba51e2f7f4f83ba5d7e09552bc0187ded40f /tests | |
parent | 573a4a5e2da9531fbaa9e82da57131edc691a851 (diff) | |
download | subsurface-fc7aec540242b874857cec16fd337e04f18675df.tar.gz |
core/settings: make qPrefUnit accesable from QML
Use string literals to communicate with QML.
Instead of passing arounds enum/int value, it seems easier to pass string literals to QML and have that code respond to those
Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testqPrefUnits.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/tests/testqPrefUnits.cpp b/tests/testqPrefUnits.cpp index decae35a8..76d5b9684 100644 --- a/tests/testqPrefUnits.cpp +++ b/tests/testqPrefUnits.cpp @@ -32,14 +32,14 @@ void TestQPrefUnits::test_struct_get() prefs.units.weight = units::KG; QCOMPARE(tst->coordinates_traditional(), true); - QCOMPARE(tst->duration_units(), units::MIXED); - QCOMPARE(tst->length(), units::METERS); - QCOMPARE(tst->pressure(), units::BAR); + QCOMPARE(tst->duration_units(), QStringLiteral("mixed")); + QCOMPARE(tst->length(), QStringLiteral("meters")); + QCOMPARE(tst->pressure(), QStringLiteral("bar")); QCOMPARE(tst->show_units_table(), true); - QCOMPARE(tst->temperature(), units::CELSIUS); - QCOMPARE(tst->vertical_speed_time(), units::SECONDS); - QCOMPARE(tst->volume(), units::LITER); - QCOMPARE(tst->weight(), units::KG); + QCOMPARE(tst->temperature(), QStringLiteral("celcius")); + QCOMPARE(tst->vertical_speed_time(), QStringLiteral("seconds")); + QCOMPARE(tst->volume(), QStringLiteral("liter")); + QCOMPARE(tst->weight(), QStringLiteral("kg")); } void TestQPrefUnits::test_set_struct() @@ -157,9 +157,9 @@ void TestQPrefUnits::test_multiple() auto tst = qPrefUnits::instance(); QCOMPARE(tst->length(), qPrefUnits::length()); - QCOMPARE(tst->length(), units::METERS); + QCOMPARE(tst->length(), QStringLiteral("meters")); QCOMPARE(tst->pressure(), qPrefUnits::pressure()); - QCOMPARE(tst->pressure(), units::BAR); + QCOMPARE(tst->pressure(), QStringLiteral("meters")); } void TestQPrefUnits::test_unit_system() @@ -170,20 +170,20 @@ void TestQPrefUnits::test_unit_system() tst->set_unit_system("metric"); QCOMPARE(prefs.unit_system, METRIC); - QCOMPARE(tst->unit_system(), QString("metric")); + QCOMPARE(tst->unit_system(), QStringLiteral("metric")); tst->set_unit_system("imperial"); QCOMPARE(prefs.unit_system, IMPERIAL); - QCOMPARE(tst->unit_system(), QString("imperial")); + QCOMPARE(tst->unit_system(), QStringLiteral("imperial")); tst->set_unit_system("personalized"); QCOMPARE(prefs.unit_system, PERSONALIZE); - QCOMPARE(tst->unit_system(), QString("personalized")); + QCOMPARE(tst->unit_system(), QStringLiteral("personalized")); prefs.unit_system = METRIC; - QCOMPARE(tst->unit_system(), QString("metric")); + QCOMPARE(tst->unit_system(), QStringLiteral("metric")); prefs.unit_system = IMPERIAL; - QCOMPARE(tst->unit_system(), QString("imperial")); + QCOMPARE(tst->unit_system(), QStringLiteral("imperial")); prefs.unit_system = PERSONALIZE; - QCOMPARE(tst->unit_system(), QString("personalized")); + QCOMPARE(tst->unit_system(), QStringLiteral("personalized")); } #define TEST(METHOD, VALUE) \ @@ -205,12 +205,12 @@ void TestQPrefUnits::test_oldPreferences() units->set_coordinates_traditional(false); units->set_vertical_speed_time(units::SECONDS); - TEST(units->length(), units::METERS); - TEST(units->pressure(), units::BAR); - TEST(units->volume(), units::LITER); - TEST(units->temperature(), units::CELSIUS); - TEST(units->weight(), units::KG); - TEST(units->vertical_speed_time(), units::SECONDS); + TEST(units->length(), QStringLiteral("meters")); + TEST(units->pressure(), QStringLiteral("bar")); + TEST(units->volume(), QStringLiteral("liter")); + TEST(units->temperature(), QStringLiteral("celcius")); + TEST(units->weight(), QStringLiteral("kg")); + TEST(units->vertical_speed_time(), QStringLiteral("seconds")); TEST(units->unit_system(), QStringLiteral("metric")); TEST(units->coordinates_traditional(), false); @@ -223,12 +223,12 @@ void TestQPrefUnits::test_oldPreferences() units->set_unit_system(QStringLiteral("fake-metric-system")); units->set_coordinates_traditional(true); - TEST(units->length(), units::FEET); - TEST(units->pressure(), units::PSI); - TEST(units->volume(), units::CUFT); - TEST(units->temperature(), units::FAHRENHEIT); - TEST(units->weight(), units::LBS); - TEST(units->vertical_speed_time(), units::MINUTES); + TEST(units->length(), QStringLiteral("feet")); + TEST(units->pressure(), QStringLiteral("psi")); + TEST(units->volume(), QStringLiteral("cuft")); + TEST(units->temperature(), QStringLiteral("fahrenheit")); + TEST(units->weight(), QStringLiteral("lbs")); + TEST(units->vertical_speed_time(), QStringLiteral("minutes")); TEST(units->unit_system(), QStringLiteral("personalized")); TEST(units->coordinates_traditional(), true); } |