diff options
author | jan Iversen <jani@apache.org> | 2018-08-28 12:33:47 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-09-11 17:25:00 -0700 |
commit | c01d9f60c14ec9ee58892504e9f5c346dbb24e7e (patch) | |
tree | 10edfbe1f86c3d9097ca8206b44b42f6ed60e060 /tests/testqPrefDiveComputer.cpp | |
parent | 93ba8c583a4b38d34811f5592160ece31ddd7ea8 (diff) | |
download | subsurface-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/testqPrefDiveComputer.cpp')
-rw-r--r-- | tests/testqPrefDiveComputer.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/testqPrefDiveComputer.cpp b/tests/testqPrefDiveComputer.cpp index b7b1c1dd7..1ba97c4ed 100644 --- a/tests/testqPrefDiveComputer.cpp +++ b/tests/testqPrefDiveComputer.cpp @@ -6,6 +6,7 @@ #include "core/settings/qPrefDiveComputer.h" #include <QTest> +#include <QSignalSpy> void TestQPrefDiveComputer::initTestCase() { @@ -153,4 +154,31 @@ void TestQPrefDiveComputer::test_oldPreferences() TEST(dc->vendor(), QStringLiteral("OSTS")); } +void TestQPrefDiveComputer::test_signals() +{ + QSignalSpy spy1(qPrefDiveComputer::instance(), SIGNAL(deviceChanged(QString))); + QSignalSpy spy2(qPrefDiveComputer::instance(), SIGNAL(device_nameChanged(QString))); + QSignalSpy spy3(qPrefDiveComputer::instance(), SIGNAL(download_modeChanged(int))); + QSignalSpy spy4(qPrefDiveComputer::instance(), SIGNAL(productChanged(QString))); + QSignalSpy spy5(qPrefDiveComputer::instance(), SIGNAL(vendorChanged(QString))); + + qPrefDiveComputer::set_device("t_signal device"); + qPrefDiveComputer::set_device_name("t_signal device name"); + qPrefDiveComputer::set_download_mode(-100); + qPrefDiveComputer::set_product("t_signal product"); + qPrefDiveComputer::set_vendor("t_signal vendor"); + + QCOMPARE(spy1.count(), 1); + QCOMPARE(spy2.count(), 1); + QCOMPARE(spy3.count(), 1); + QCOMPARE(spy4.count(), 1); + QCOMPARE(spy5.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toString() == "t_signal device"); + QVERIFY(spy2.takeFirst().at(0).toString() == "t_signal device name"); + QVERIFY(spy3.takeFirst().at(0).toInt() == -100); + QVERIFY(spy4.takeFirst().at(0).toString() == "t_signal product"); + QVERIFY(spy5.takeFirst().at(0).toString() == "t_signal vendor"); +} + QTEST_MAIN(TestQPrefDiveComputer) |