aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testqPrefUnits.cpp
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-08-28 12:33:47 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-11 17:25:00 -0700
commitc01d9f60c14ec9ee58892504e9f5c346dbb24e7e (patch)
tree10edfbe1f86c3d9097ca8206b44b42f6ed60e060 /tests/testqPrefUnits.cpp
parent93ba8c583a4b38d34811f5592160ece31ddd7ea8 (diff)
downloadsubsurface-c01d9f60c14ec9ee58892504e9f5c346dbb24e7e.tar.gz
tests: add signal test to call testqPref*cpp
Add signal testing of all variables this commit contains all qPref* that work directly followup commit will do changes to qPref* to make signals work Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'tests/testqPrefUnits.cpp')
-rw-r--r--tests/testqPrefUnits.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/testqPrefUnits.cpp b/tests/testqPrefUnits.cpp
index 6e54808cb..a3416e1f2 100644
--- a/tests/testqPrefUnits.cpp
+++ b/tests/testqPrefUnits.cpp
@@ -6,6 +6,7 @@
#include "core/settings/qPrefUnit.h"
#include <QTest>
+#include <QSignalSpy>
void TestQPrefUnits::initTestCase()
{
@@ -233,4 +234,57 @@ void TestQPrefUnits::test_oldPreferences()
TEST(units->coordinates_traditional(), true);
}
+void TestQPrefUnits::test_signals()
+{
+ QSignalSpy spy1(qPrefUnits::instance(), SIGNAL(coordinates_traditionalChanged(bool)));
+ QSignalSpy spy2(qPrefUnits::instance(), SIGNAL(duration_unitsChanged(int)));
+ QSignalSpy spy3(qPrefUnits::instance(), SIGNAL(lengthChanged(int)));
+ QSignalSpy spy4(qPrefUnits::instance(), SIGNAL(pressureChanged(int)));
+ QSignalSpy spy5(qPrefUnits::instance(), SIGNAL(show_units_tableChanged(bool)));
+ QSignalSpy spy6(qPrefUnits::instance(), SIGNAL(temperatureChanged(int)));
+ QSignalSpy spy7(qPrefUnits::instance(), SIGNAL(vertical_speed_timeChanged(int)));
+ QSignalSpy spy8(qPrefUnits::instance(), SIGNAL(volumeChanged(int)));
+ QSignalSpy spy9(qPrefUnits::instance(), SIGNAL(weightChanged(int)));
+
+ prefs.coordinates_traditional = true;
+ qPrefUnits::set_coordinates_traditional(false);
+ prefs.units.duration_units = units::MIXED;
+ qPrefUnits::set_duration_units(units::MINUTES_ONLY);
+ prefs.units.length = units::METERS;
+ qPrefUnits::set_length(units::FEET);
+ prefs.units.pressure = units::BAR;
+ qPrefUnits::set_pressure(units::PSI);
+ prefs.units.show_units_table = true;
+ qPrefUnits::set_show_units_table(false);
+ prefs.units.temperature = units::CELSIUS;
+ qPrefUnits::set_temperature(units::FAHRENHEIT);
+ prefs.units.vertical_speed_time = units::MINUTES;
+ qPrefUnits::set_vertical_speed_time(units::SECONDS);
+ prefs.units.volume = units::LITER;
+ qPrefUnits::set_volume(units::CUFT);
+ prefs.units.weight = units::KG;
+ qPrefUnits::set_weight(units::LBS);
+
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy5.count(), 1);
+ QCOMPARE(spy6.count(), 1);
+ QCOMPARE(spy7.count(), 1);
+ QCOMPARE(spy9.count(), 1);
+ QCOMPARE(spy9.count(), 1);
+
+ QVERIFY(spy1.takeFirst().at(0).toBool() == false);
+ QVERIFY(spy2.takeFirst().at(0).toInt() == units::MINUTES_ONLY);
+ QVERIFY(spy3.takeFirst().at(0).toInt() == units::FEET);
+ QVERIFY(spy4.takeFirst().at(0).toInt() == units::PSI);
+ QVERIFY(spy5.takeFirst().at(0).toBool() == false);
+ QVERIFY(spy6.takeFirst().at(0).toInt() == units::FAHRENHEIT);
+ QVERIFY(spy7.takeFirst().at(0).toInt() == units::SECONDS);
+ QVERIFY(spy8.takeFirst().at(0).toInt() == units::CUFT);
+ QVERIFY(spy9.takeFirst().at(0).toInt() == units::LBS);
+}
+
+
QTEST_MAIN(TestQPrefUnits)