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 | |
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')
28 files changed, 672 insertions, 1 deletions
diff --git a/tests/testqPrefCloudStorage.cpp b/tests/testqPrefCloudStorage.cpp index 3a20babea..84beda8db 100644 --- a/tests/testqPrefCloudStorage.cpp +++ b/tests/testqPrefCloudStorage.cpp @@ -6,6 +6,7 @@ #include "core/settings/qPrefCloudStorage.h" #include <QTest> +#include <QSignalSpy> void TestQPrefCloudStorage::initTestCase() { @@ -199,4 +200,51 @@ void TestQPrefCloudStorage::test_oldPreferences() TEST(cloud->cloud_verification_status(), 1); } +void TestQPrefCloudStorage::test_signals() +{ + QSignalSpy spy1(qPrefCloudStorage::instance(), SIGNAL(cloud_base_urlChanged(QString))); + QSignalSpy spy2(qPrefCloudStorage::instance(), SIGNAL(cloud_storage_emailChanged(QString))); + QSignalSpy spy3(qPrefCloudStorage::instance(), SIGNAL(cloud_storage_email_encodedChanged(QString))); + QSignalSpy spy4(qPrefCloudStorage::instance(), SIGNAL(cloud_storage_passwordChanged(QString))); + QSignalSpy spy5(qPrefCloudStorage::instance(), SIGNAL(cloud_storage_pinChanged(QString))); + QSignalSpy spy6(qPrefCloudStorage::instance(), SIGNAL(cloud_timeoutChanged(int))); + QSignalSpy spy7(qPrefCloudStorage::instance(), SIGNAL(cloud_verification_statusChanged(int))); + QSignalSpy spy9(qPrefCloudStorage::instance(), SIGNAL(save_password_localChanged(bool))); + QSignalSpy spy10(qPrefCloudStorage::instance(), SIGNAL(save_userid_localChanged(bool))); + QSignalSpy spy11(qPrefCloudStorage::instance(), SIGNAL(useridChanged(QString))); + + qPrefCloudStorage::set_cloud_base_url("signal url"); + qPrefCloudStorage::set_cloud_storage_email("signal myEmail"); + qPrefCloudStorage::set_cloud_storage_email_encoded("signal encodedMyEMail"); + qPrefCloudStorage::set_cloud_storage_password("signal more secret"); + qPrefCloudStorage::set_cloud_storage_pin("signal a pin"); + qPrefCloudStorage::set_cloud_timeout(11); + qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_VERIFIED); + qPrefCloudStorage::set_save_password_local(true); + qPrefCloudStorage::set_save_userid_local(true); + qPrefCloudStorage::set_userid("signal my user"); + + 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(spy10.count(), 1); + QCOMPARE(spy11.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toString() == "signal url"); + QVERIFY(spy2.takeFirst().at(0).toString() == "signal myEmail"); + QVERIFY(spy3.takeFirst().at(0).toString() == "signal encodedMyEMail"); + QVERIFY(spy4.takeFirst().at(0).toString() == "signal more secret"); + QVERIFY(spy5.takeFirst().at(0).toString() == "signal a pin"); + QVERIFY(spy6.takeFirst().at(0).toInt() == 11); + QVERIFY(spy7.takeFirst().at(0).toInt() == qPrefCloudStorage::CS_VERIFIED); + QVERIFY(spy9.takeFirst().at(0).toBool() == true); + QVERIFY(spy10.takeFirst().at(0).toBool() == true); + QVERIFY(spy11.takeFirst().at(0).toString() == "signal my user"); +} + QTEST_MAIN(TestQPrefCloudStorage) diff --git a/tests/testqPrefCloudStorage.h b/tests/testqPrefCloudStorage.h index 077ca74b6..a552d88a5 100644 --- a/tests/testqPrefCloudStorage.h +++ b/tests/testqPrefCloudStorage.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFCLOUDSTORAGE_H diff --git a/tests/testqPrefDisplay.cpp b/tests/testqPrefDisplay.cpp index cf7bf596c..7e385896d 100644 --- a/tests/testqPrefDisplay.cpp +++ b/tests/testqPrefDisplay.cpp @@ -177,7 +177,6 @@ void TestQPrefDisplay::test_signals() QSignalSpy spy7(qPrefDisplay::instance(), SIGNAL(lastDirChanged(QString))); QSignalSpy spy8(qPrefDisplay::instance(), SIGNAL(tooltip_positionChanged(QPointF))); QSignalSpy spy9(qPrefDisplay::instance(), SIGNAL(userSurveyChanged(QString))); - QSignalSpy spy9(qPrefDisplay::instance(), SIGNAL(userSurveyChanged(QString))); QSignalSpy spy10(qPrefDisplay::instance(), SIGNAL(mainSplitterChanged(QByteArray))); QSignalSpy spy11(qPrefDisplay::instance(), SIGNAL(topSplitterChanged(QByteArray))); QSignalSpy spy12(qPrefDisplay::instance(), SIGNAL(bottomSplitterChanged(QByteArray))); diff --git a/tests/testqPrefDisplay.h b/tests/testqPrefDisplay.h index c6a258b88..40d0e73a1 100644 --- a/tests/testqPrefDisplay.h +++ b/tests/testqPrefDisplay.h @@ -13,6 +13,7 @@ private slots: void test_set_load_struct(); void test_struct_disk(); void test_multiple(); + void test_signals(); }; #endif // TESTQPREFDISPLAY_H 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) diff --git a/tests/testqPrefDiveComputer.h b/tests/testqPrefDiveComputer.h index 32f117350..799a5a873 100644 --- a/tests/testqPrefDiveComputer.h +++ b/tests/testqPrefDiveComputer.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFDIVECOMPUTER_H diff --git a/tests/testqPrefDivePlanner.cpp b/tests/testqPrefDivePlanner.cpp index 79a8a9608..0a8812cec 100644 --- a/tests/testqPrefDivePlanner.cpp +++ b/tests/testqPrefDivePlanner.cpp @@ -4,14 +4,17 @@ #include "core/pref.h" #include "core/qthelper.h" #include "core/settings/qPrefDivePlanner.h" +#include "core/settings/qPref.h" #include <QTest> +#include <QSignalSpy> void TestQPrefDivePlanner::initTestCase() { QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); QCoreApplication::setApplicationName("SubsurfaceTestQPrefDivePlanner"); + qPref::instance()->registerQML(NULL); } void TestQPrefDivePlanner::test_struct_get() @@ -434,4 +437,122 @@ void TestQPrefDivePlanner::test_oldPreferences() } +void TestQPrefDivePlanner::test_signals() +{ + QSignalSpy spy1(qPrefDivePlanner::instance(), SIGNAL(ascratelast6mChanged(int))); + QSignalSpy spy2(qPrefDivePlanner::instance(), SIGNAL(ascratestopsChanged(int))); + QSignalSpy spy3(qPrefDivePlanner::instance(), SIGNAL(ascrate50Changed(int))); + QSignalSpy spy4(qPrefDivePlanner::instance(), SIGNAL(ascrate75Changed(int))); + QSignalSpy spy5(qPrefDivePlanner::instance(), SIGNAL(bestmixendChanged(int))); + QSignalSpy spy6(qPrefDivePlanner::instance(), SIGNAL(bottompo2Changed(int))); + QSignalSpy spy7(qPrefDivePlanner::instance(), SIGNAL(bottomsacChanged(int))); + QSignalSpy spy8(qPrefDivePlanner::instance(), SIGNAL(decopo2Changed(int))); + QSignalSpy spy9(qPrefDivePlanner::instance(), SIGNAL(decosacChanged(int))); + QSignalSpy spy10(qPrefDivePlanner::instance(), SIGNAL(descrateChanged(int))); + QSignalSpy spy11(qPrefDivePlanner::instance(), SIGNAL(display_durationChanged(bool))); + QSignalSpy spy12(qPrefDivePlanner::instance(), SIGNAL(display_runtimeChanged(bool))); + QSignalSpy spy13(qPrefDivePlanner::instance(), SIGNAL(display_transitionsChanged(bool))); + QSignalSpy spy14(qPrefDivePlanner::instance(), SIGNAL(display_variationsChanged(bool))); + QSignalSpy spy15(qPrefDivePlanner::instance(), SIGNAL(doo2breaksChanged(bool))); + QSignalSpy spy16(qPrefDivePlanner::instance(), SIGNAL(drop_stone_modeChanged(bool))); + QSignalSpy spy17(qPrefDivePlanner::instance(), SIGNAL(last_stopChanged(bool))); + QSignalSpy spy18(qPrefDivePlanner::instance(), SIGNAL(min_switch_durationChanged(int))); + QSignalSpy spy19(qPrefDivePlanner::instance(), SIGNAL(planner_deco_modeChanged(deco_mode))); + QSignalSpy spy20(qPrefDivePlanner::instance(), SIGNAL(problemsolvingtimeChanged(int))); + QSignalSpy spy21(qPrefDivePlanner::instance(), SIGNAL(reserve_gasChanged(int))); + QSignalSpy spy22(qPrefDivePlanner::instance(), SIGNAL(sacfactorChanged(int))); + QSignalSpy spy23(qPrefDivePlanner::instance(), SIGNAL(safetystopChanged(bool))); + QSignalSpy spy24(qPrefDivePlanner::instance(), SIGNAL(switch_at_req_stopChanged(bool))); + QSignalSpy spy25(qPrefDivePlanner::instance(), SIGNAL(verbatim_planChanged(bool))); + + qPrefDivePlanner::set_ascratelast6m(-20); + qPrefDivePlanner::set_ascratestops(-21); + qPrefDivePlanner::set_ascrate50(-22); + qPrefDivePlanner::set_ascrate75(-23); + qPrefDivePlanner::set_bestmixend(-21); + qPrefDivePlanner::set_bottompo2(-24); + qPrefDivePlanner::set_bottomsac(-25); + qPrefDivePlanner::set_decopo2(-26); + qPrefDivePlanner::set_decosac(-27); + qPrefDivePlanner::set_descrate(-28); + prefs.display_duration = true; + qPrefDivePlanner::set_display_duration(false); + prefs.display_runtime = true; + qPrefDivePlanner::set_display_runtime(false); + prefs.display_transitions = true; + qPrefDivePlanner::set_display_transitions(false); + prefs.display_variations = true; + qPrefDivePlanner::set_display_variations(false); + prefs.doo2breaks = true; + qPrefDivePlanner::set_doo2breaks(false); + prefs.drop_stone_mode = true; + qPrefDivePlanner::set_drop_stone_mode(false); + prefs.last_stop = true; + qPrefDivePlanner::set_last_stop(false); + qPrefDivePlanner::set_min_switch_duration(-29); + qPrefDivePlanner::set_planner_deco_mode(VPMB); + qPrefDivePlanner::set_problemsolvingtime(-30); + qPrefDivePlanner::set_reserve_gas(-31); + qPrefDivePlanner::set_sacfactor(-32); + prefs.safetystop = true; + qPrefDivePlanner::set_safetystop(false); + prefs.switch_at_req_stop = true; + qPrefDivePlanner::set_switch_at_req_stop(false); + prefs.verbatim_plan = true; + qPrefDivePlanner::set_verbatim_plan(false); + + 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(spy8.count(), 1); + QCOMPARE(spy9.count(), 1); + QCOMPARE(spy10.count(), 1); + QCOMPARE(spy11.count(), 1); + QCOMPARE(spy12.count(), 1); + QCOMPARE(spy13.count(), 1); + QCOMPARE(spy14.count(), 1); + QCOMPARE(spy15.count(), 1); + QCOMPARE(spy16.count(), 1); + QCOMPARE(spy17.count(), 1); + QCOMPARE(spy18.count(), 1); + QCOMPARE(spy19.count(), 1); + QCOMPARE(spy20.count(), 1); + QCOMPARE(spy21.count(), 1); + QCOMPARE(spy22.count(), 1); + QCOMPARE(spy23.count(), 1); + QCOMPARE(spy24.count(), 1); + QCOMPARE(spy25.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toInt() == -20); + QVERIFY(spy2.takeFirst().at(0).toInt() == -21); + QVERIFY(spy3.takeFirst().at(0).toInt() == -22); + QVERIFY(spy4.takeFirst().at(0).toInt() == -23); + QVERIFY(spy5.takeFirst().at(0).toInt() == -21); + QVERIFY(spy6.takeFirst().at(0).toInt() == -24); + QVERIFY(spy7.takeFirst().at(0).toInt() == -25); + QVERIFY(spy8.takeFirst().at(0).toInt() == -26); + QVERIFY(spy9.takeFirst().at(0).toInt() == -27); + QVERIFY(spy10.takeFirst().at(0).toInt() == -28); + QVERIFY(spy11.takeFirst().at(0).toBool() == false); + QVERIFY(spy12.takeFirst().at(0).toBool() == false); + QVERIFY(spy13.takeFirst().at(0).toBool() == false); + QVERIFY(spy14.takeFirst().at(0).toBool() == false); + QVERIFY(spy15.takeFirst().at(0).toBool() == false); + QVERIFY(spy16.takeFirst().at(0).toBool() == false); + QVERIFY(spy17.takeFirst().at(0).toBool() == false); + QVERIFY(spy18.takeFirst().at(0).toInt() == -29); + QVERIFY(spy19.takeFirst().at(0).toInt() == VPMB); + QVERIFY(spy20.takeFirst().at(0).toInt() == -30); + QVERIFY(spy21.takeFirst().at(0).toInt() == -31); + QVERIFY(spy22.takeFirst().at(0).toInt() == -32); + QVERIFY(spy23.takeFirst().at(0).toBool() == false); + QVERIFY(spy24.takeFirst().at(0).toBool() == false); + QVERIFY(spy25.takeFirst().at(0).toBool() == false); +} + + QTEST_MAIN(TestQPrefDivePlanner) diff --git a/tests/testqPrefDivePlanner.h b/tests/testqPrefDivePlanner.h index 7d61c3aed..141ea8348 100644 --- a/tests/testqPrefDivePlanner.h +++ b/tests/testqPrefDivePlanner.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFDIVEPLANNER_H diff --git a/tests/testqPrefFacebook.cpp b/tests/testqPrefFacebook.cpp index ebb2e4f02..59063b7a3 100644 --- a/tests/testqPrefFacebook.cpp +++ b/tests/testqPrefFacebook.cpp @@ -6,6 +6,7 @@ #include "core/qthelper.h" #include <QTest> +#include <QSignalSpy> void TestQPrefFacebook::initTestCase() { @@ -86,4 +87,23 @@ void TestQPrefFacebook::test_oldPreferences() TEST(fb->album_id(), QStringLiteral("album-id-2")); } +void TestQPrefFacebook::test_signals() +{ + QSignalSpy spy1(qPrefFacebook::instance(), SIGNAL(access_tokenChanged(QString))); + QSignalSpy spy2(qPrefFacebook::instance(), SIGNAL(album_idChanged(QString))); + QSignalSpy spy3(qPrefFacebook::instance(), SIGNAL(user_idChanged(QString))); + + qPrefFacebook::set_access_token("t_signal token"); + qPrefFacebook::set_album_id("t_signal album"); + qPrefFacebook::set_user_id("t_signal user"); + + QCOMPARE(spy1.count(), 1); + QCOMPARE(spy2.count(), 1); + QCOMPARE(spy3.count(), 1); + QVERIFY(spy1.takeFirst().at(0).toString() == "t_signal token"); + QVERIFY(spy2.takeFirst().at(0).toString() == "t_signal album"); + QVERIFY(spy3.takeFirst().at(0).toString() == "t_signal user"); +} + + QTEST_MAIN(TestQPrefFacebook) diff --git a/tests/testqPrefFacebook.h b/tests/testqPrefFacebook.h index a11b43710..bf17a6576 100644 --- a/tests/testqPrefFacebook.h +++ b/tests/testqPrefFacebook.h @@ -14,6 +14,7 @@ private slots: void test_set_struct(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFFACEBOOK_H diff --git a/tests/testqPrefGeneral.cpp b/tests/testqPrefGeneral.cpp index fc364e78c..f3fbbd02b 100644 --- a/tests/testqPrefGeneral.cpp +++ b/tests/testqPrefGeneral.cpp @@ -4,14 +4,17 @@ #include "core/pref.h" #include "core/qthelper.h" #include "core/settings/qPrefGeneral.h" +#include "core/settings/qPref.h" #include <QTest> +#include <QSignalSpy> void TestQPrefGeneral::initTestCase() { QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); QCoreApplication::setApplicationName("SubsurfaceTestQPrefGeneral"); + qPref::instance()->registerQML(NULL); } void TestQPrefGeneral::test_struct_get() @@ -234,4 +237,55 @@ void TestQPrefGeneral::test_oldPreferences() TEST(general->use_default_file(), false); } +void TestQPrefGeneral::test_signals() +{ + QSignalSpy spy1(qPrefGeneral::instance(), SIGNAL(auto_recalculate_thumbnailsChanged(bool))); + QSignalSpy spy2(qPrefGeneral::instance(), SIGNAL(default_cylinderChanged(QString))); + QSignalSpy spy3(qPrefGeneral::instance(), SIGNAL(default_filenameChanged(QString))); + QSignalSpy spy4(qPrefGeneral::instance(), SIGNAL(default_file_behaviorChanged(def_file_behavior))); + QSignalSpy spy5(qPrefGeneral::instance(), SIGNAL(defaultsetpointChanged(int))); + QSignalSpy spy6(qPrefGeneral::instance(), SIGNAL(extract_video_thumbnailsChanged(bool))); + QSignalSpy spy7(qPrefGeneral::instance(), SIGNAL(extract_video_thumbnails_positionChanged(int))); + QSignalSpy spy8(qPrefGeneral::instance(), SIGNAL(ffmpeg_executableChanged(QString))); + QSignalSpy spy9(qPrefGeneral::instance(), SIGNAL(o2consumptionChanged(int))); + QSignalSpy spy10(qPrefGeneral::instance(), SIGNAL(pscr_ratioChanged(int))); + QSignalSpy spy11(qPrefGeneral::instance(), SIGNAL(use_default_fileChanged(bool))); + QSignalSpy spy12(qPrefGeneral::instance(), SIGNAL(diveshareExport_uidChanged(QString))); + QSignalSpy spy13(qPrefGeneral::instance(), SIGNAL(diveshareExport_privateChanged(bool))); + + prefs.auto_recalculate_thumbnails = true; + qPrefGeneral::set_auto_recalculate_thumbnails(false); + + qPrefGeneral::set_default_cylinder("new base21"); + qPrefGeneral::set_default_filename("new base22"); + qPrefGeneral::set_default_file_behavior(LOCAL_DEFAULT_FILE); + qPrefGeneral::set_defaultsetpoint(24); + qPrefGeneral::set_extract_video_thumbnails(false); + qPrefGeneral::set_extract_video_thumbnails_position(25); + qPrefGeneral::set_ffmpeg_executable("new base26"); + qPrefGeneral::set_o2consumption(27); + qPrefGeneral::set_pscr_ratio(28); + qPrefGeneral::set_use_default_file(false); + qPrefGeneral::set_diveshareExport_uid("uid1"); + qPrefGeneral::set_diveshareExport_private(false); + + QCOMPARE(spy1.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toBool() == false); + + qPrefGeneral::set_default_cylinder("new base21"); + qPrefGeneral::set_default_filename("new base22"); + qPrefGeneral::set_default_file_behavior(LOCAL_DEFAULT_FILE); + qPrefGeneral::set_defaultsetpoint(24); + qPrefGeneral::set_extract_video_thumbnails(false); + qPrefGeneral::set_extract_video_thumbnails_position(25); + qPrefGeneral::set_ffmpeg_executable("new base26"); + qPrefGeneral::set_o2consumption(27); + qPrefGeneral::set_pscr_ratio(28); + qPrefGeneral::set_use_default_file(false); + qPrefGeneral::set_diveshareExport_uid("uid1"); + qPrefGeneral::set_diveshareExport_private(false); +} + + QTEST_MAIN(TestQPrefGeneral) diff --git a/tests/testqPrefGeneral.h b/tests/testqPrefGeneral.h index 73a223396..c7507151b 100644 --- a/tests/testqPrefGeneral.h +++ b/tests/testqPrefGeneral.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFGENERAL_H diff --git a/tests/testqPrefGeocoding.cpp b/tests/testqPrefGeocoding.cpp index 882a2b919..8b9f1442e 100644 --- a/tests/testqPrefGeocoding.cpp +++ b/tests/testqPrefGeocoding.cpp @@ -3,15 +3,18 @@ #include "core/pref.h" #include "core/qthelper.h" +#include "core/settings/qPref.h" #include "core/settings/qPrefGeocoding.h" #include <QTest> +#include <QSignalSpy> void TestQPrefGeocoding::initTestCase() { QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); QCoreApplication::setApplicationName("SubsurfaceTestQPrefGeocoding"); + qPref::instance()->registerQML(NULL); } void TestQPrefGeocoding::test_struct_get() @@ -127,4 +130,27 @@ void TestQPrefGeocoding::test_oldPreferences() TEST(geo->third_taxonomy_category(), TC_NONE); } +void TestQPrefGeocoding::test_signals() +{ + QSignalSpy spy1(qPrefGeocoding::instance(), SIGNAL(first_taxonomy_categoryChanged(taxonomy_category))); + QSignalSpy spy2(qPrefGeocoding::instance(), SIGNAL(second_taxonomy_categoryChanged(taxonomy_category))); + QSignalSpy spy3(qPrefGeocoding::instance(), SIGNAL(third_taxonomy_categoryChanged(taxonomy_category))); + + prefs.geocoding.category[0] = TC_NONE; + qPrefGeocoding::set_first_taxonomy_category(TC_COUNTRY); + prefs.geocoding.category[0] = TC_NONE; + qPrefGeocoding::set_second_taxonomy_category(TC_ADMIN_L1); + prefs.geocoding.category[0] = TC_NONE; + qPrefGeocoding::set_third_taxonomy_category(TC_ADMIN_L2); + + QCOMPARE(spy1.count(), 1); + QCOMPARE(spy2.count(), 1); + QCOMPARE(spy3.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toInt() == TC_COUNTRY); + QVERIFY(spy2.takeFirst().at(0).toInt() == TC_ADMIN_L1); + QVERIFY(spy3.takeFirst().at(0).toInt() == TC_ADMIN_L2); +} + + QTEST_MAIN(TestQPrefGeocoding) diff --git a/tests/testqPrefGeocoding.h b/tests/testqPrefGeocoding.h index deb02dc67..6545bd697 100644 --- a/tests/testqPrefGeocoding.h +++ b/tests/testqPrefGeocoding.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFGEOCODING_H diff --git a/tests/testqPrefLanguage.cpp b/tests/testqPrefLanguage.cpp index 1db5c53b1..f94946e76 100644 --- a/tests/testqPrefLanguage.cpp +++ b/tests/testqPrefLanguage.cpp @@ -6,6 +6,7 @@ #include "core/settings/qPrefLanguage.h" #include <QTest> +#include <QSignalSpy> void TestQPrefLanguage::initTestCase() { @@ -198,4 +199,47 @@ void TestQPrefLanguage::test_oldPreferences() } +void TestQPrefLanguage::test_signals() +{ + QSignalSpy spy1(qPrefLanguage::instance(), SIGNAL(date_formatChanged(QString))); + QSignalSpy spy2(qPrefLanguage::instance(), SIGNAL(date_format_overrideChanged(bool))); + QSignalSpy spy3(qPrefLanguage::instance(), SIGNAL(date_format_shortChanged(QString))); + QSignalSpy spy4(qPrefLanguage::instance(), SIGNAL(languageChanged(QString))); + QSignalSpy spy5(qPrefLanguage::instance(), SIGNAL(lang_localeChanged(QString))); + QSignalSpy spy6(qPrefLanguage::instance(), SIGNAL(time_formatChanged(QString))); + QSignalSpy spy7(qPrefLanguage::instance(), SIGNAL(time_format_overrideChanged(bool))); + QSignalSpy spy8(qPrefLanguage::instance(), SIGNAL(use_system_languageChanged(bool))); + + qPrefLanguage::set_date_format("signal date2"); + prefs.date_format_override = true; + qPrefLanguage::set_date_format_override(false); + qPrefLanguage::set_date_format_short("signal short2"); + qPrefLanguage::set_language("signal lang format"); + qPrefLanguage::set_lang_locale("signal loc lang2"); + qPrefLanguage::set_time_format("signal time2"); + prefs.time_format_override = true; + qPrefLanguage::set_time_format_override(false); + prefs.locale.use_system_language = true; + qPrefLanguage::set_use_system_language(false); + + 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(spy8.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toString() == "signal date2"); + QVERIFY(spy2.takeFirst().at(0).toBool() == false); + QVERIFY(spy3.takeFirst().at(0).toString() == "signal short2"); + QVERIFY(spy4.takeFirst().at(0).toString() == "signal lang format"); + QVERIFY(spy5.takeFirst().at(0).toString() == "signal loc lang2"); + QVERIFY(spy6.takeFirst().at(0).toString() == "signal time2"); + QVERIFY(spy7.takeFirst().at(0).toBool() == false); + QVERIFY(spy8.takeFirst().at(0).toBool() == false); +} + + QTEST_MAIN(TestQPrefLanguage) diff --git a/tests/testqPrefLanguage.h b/tests/testqPrefLanguage.h index c10b99930..e6393cf3c 100644 --- a/tests/testqPrefLanguage.h +++ b/tests/testqPrefLanguage.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFLANGUAGE_H diff --git a/tests/testqPrefLocationService.cpp b/tests/testqPrefLocationService.cpp index fbd374a4b..0f383212c 100644 --- a/tests/testqPrefLocationService.cpp +++ b/tests/testqPrefLocationService.cpp @@ -6,6 +6,7 @@ #include "core/settings/qPrefLocationService.h" #include <QTest> +#include <QSignalSpy> void TestQPrefLocationService::initTestCase() { @@ -114,4 +115,20 @@ void TestQPrefLocationService::test_oldPreferences() TEST(location->distance_threshold(), 40); } +void TestQPrefLocationService::test_signals() +{ + QSignalSpy spy1(qPrefLocationService::instance(), SIGNAL(distance_thresholdChanged(int))); + QSignalSpy spy2(qPrefLocationService::instance(), SIGNAL(time_thresholdChanged(int))); + + qPrefLocationService::set_distance_threshold(-2000); + qPrefLocationService::set_time_threshold(-90); + + QCOMPARE(spy1.count(), 1); + QCOMPARE(spy2.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toInt() == -2000); + QVERIFY(spy2.takeFirst().at(0).toInt() == -90); +} + + QTEST_MAIN(TestQPrefLocationService) diff --git a/tests/testqPrefLocationService.h b/tests/testqPrefLocationService.h index e9d1b5dac..9579cec27 100644 --- a/tests/testqPrefLocationService.h +++ b/tests/testqPrefLocationService.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFLOCATIONSERVICE_H diff --git a/tests/testqPrefPartialPressureGas.cpp b/tests/testqPrefPartialPressureGas.cpp index a98b1c2e0..31b1850c7 100644 --- a/tests/testqPrefPartialPressureGas.cpp +++ b/tests/testqPrefPartialPressureGas.cpp @@ -6,6 +6,7 @@ #include "core/settings/qPrefPartialPressureGas.h" #include <QTest> +#include <QSignalSpy> void TestQPrefPartialPressureGas::initTestCase() { @@ -184,4 +185,43 @@ void TestQPrefPartialPressureGas::test_oldPreferences() } +void TestQPrefPartialPressureGas::test_signals() +{ + QSignalSpy spy1(qPrefPartialPressureGas::instance(), SIGNAL(pheChanged(bool))); + QSignalSpy spy2(qPrefPartialPressureGas::instance(), SIGNAL(phe_thresholdChanged(double))); + QSignalSpy spy3(qPrefPartialPressureGas::instance(), SIGNAL(pn2Changed(bool))); + QSignalSpy spy4(qPrefPartialPressureGas::instance(), SIGNAL(pn2_thresholdChanged(double))); + QSignalSpy spy5(qPrefPartialPressureGas::instance(), SIGNAL(po2Changed(bool))); + QSignalSpy spy6(qPrefPartialPressureGas::instance(), SIGNAL(po2_threshold_maxChanged(double))); + QSignalSpy spy7(qPrefPartialPressureGas::instance(), SIGNAL(po2_threshold_minChanged(double))); + + prefs.pp_graphs.phe = true; + qPrefPartialPressureGas::set_phe(false); + qPrefPartialPressureGas::set_phe_threshold(-22.2); + prefs.pp_graphs.pn2 = true; + qPrefPartialPressureGas::set_pn2(false); + qPrefPartialPressureGas::set_pn2_threshold(-22.3); + prefs.pp_graphs.po2 = true; + qPrefPartialPressureGas::set_po2(false); + qPrefPartialPressureGas::set_po2_threshold_max(-22.4); + qPrefPartialPressureGas::set_po2_threshold_min(-22.5); + + 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); + + QVERIFY(spy1.takeFirst().at(0).toBool() == false); + QVERIFY(spy2.takeFirst().at(0).toDouble() == -22.2); + QVERIFY(spy3.takeFirst().at(0).toBool() == false); + QVERIFY(spy4.takeFirst().at(0).toDouble() == -22.3); + QVERIFY(spy5.takeFirst().at(0).toBool() == false); + QVERIFY(spy6.takeFirst().at(0).toDouble() == -22.4); + QVERIFY(spy7.takeFirst().at(0).toDouble() == -22.5); +} + + QTEST_MAIN(TestQPrefPartialPressureGas) diff --git a/tests/testqPrefPartialPressureGas.h b/tests/testqPrefPartialPressureGas.h index 28c1b20a3..95800f859 100644 --- a/tests/testqPrefPartialPressureGas.h +++ b/tests/testqPrefPartialPressureGas.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFPARTIALPRESSUREGAS_H diff --git a/tests/testqPrefProxy.cpp b/tests/testqPrefProxy.cpp index 089fb5a41..ed8c3a0ed 100644 --- a/tests/testqPrefProxy.cpp +++ b/tests/testqPrefProxy.cpp @@ -6,6 +6,7 @@ #include "core/settings/qPrefProxy.h" #include <QTest> +#include <QSignalSpy> void TestQPrefProxy::initTestCase() { @@ -171,4 +172,37 @@ void TestQPrefProxy::test_oldPreferences() TEST(proxy->proxy_pass(), QStringLiteral("secret_1")); } +void TestQPrefProxy::test_signals() +{ + QSignalSpy spy1(qPrefProxy::instance(), SIGNAL(proxy_authChanged(bool))); + QSignalSpy spy2(qPrefProxy::instance(), SIGNAL(proxy_hostChanged(QString))); + QSignalSpy spy3(qPrefProxy::instance(), SIGNAL(proxy_passChanged(QString))); + QSignalSpy spy4(qPrefProxy::instance(), SIGNAL(proxy_portChanged(int))); + QSignalSpy spy5(qPrefProxy::instance(), SIGNAL(proxy_typeChanged(int))); + QSignalSpy spy6(qPrefProxy::instance(), SIGNAL(proxy_userChanged(QString))); + + prefs.proxy_auth = true; + qPrefProxy::set_proxy_auth(false); + qPrefProxy::set_proxy_host("signal t2 host"); + qPrefProxy::set_proxy_pass("signal t2 pass"); + qPrefProxy::set_proxy_port(2524); + qPrefProxy::set_proxy_type(22); + qPrefProxy::set_proxy_user("signal user"); + + QCOMPARE(spy1.count(), 1); + QCOMPARE(spy2.count(), 1); + QCOMPARE(spy3.count(), 1); + QCOMPARE(spy4.count(), 1); + QCOMPARE(spy5.count(), 1); + QCOMPARE(spy6.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toBool() == false); + QVERIFY(spy2.takeFirst().at(0).toString() == "signal t2 host"); + QVERIFY(spy3.takeFirst().at(0).toString() == "signal t2 pass"); + QVERIFY(spy4.takeFirst().at(0).toInt() == 2524); + QVERIFY(spy5.takeFirst().at(0).toInt() == 22); + QVERIFY(spy6.takeFirst().at(0).toString() == "signal user"); +} + + QTEST_MAIN(TestQPrefProxy) diff --git a/tests/testqPrefProxy.h b/tests/testqPrefProxy.h index e47300be2..340086f4a 100644 --- a/tests/testqPrefProxy.h +++ b/tests/testqPrefProxy.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFPROXY_H diff --git a/tests/testqPrefTechnicalDetails.cpp b/tests/testqPrefTechnicalDetails.cpp index 0cbc73b0e..ebb36fd75 100644 --- a/tests/testqPrefTechnicalDetails.cpp +++ b/tests/testqPrefTechnicalDetails.cpp @@ -4,14 +4,17 @@ #include "core/pref.h" #include "core/qthelper.h" #include "core/settings/qPrefTechnicalDetails.h" +#include "core/settings/qPref.h" #include <QTest> +#include <QSignalSpy> void TestQPrefTechnicalDetails::initTestCase() { QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); QCoreApplication::setApplicationName("SubsurfaceTestQPrefTechnicalDetails"); + qPref::instance()->registerQML(NULL); } void TestQPrefTechnicalDetails::test_struct_get() @@ -445,4 +448,142 @@ void TestQPrefTechnicalDetails::test_oldPreferences() TEST(tecDetails->show_pictures_in_profile(), false); } +void TestQPrefTechnicalDetails::test_signals() +{ + QSignalSpy spy1(qPrefTechnicalDetails::instance(), SIGNAL(calcalltissuesChanged(bool))); + QSignalSpy spy2(qPrefTechnicalDetails::instance(), SIGNAL(calcceilingChanged(bool))); + QSignalSpy spy3(qPrefTechnicalDetails::instance(), SIGNAL(calcceiling3mChanged(bool))); + QSignalSpy spy4(qPrefTechnicalDetails::instance(), SIGNAL(calcndlttsChanged(bool))); + QSignalSpy spy5(qPrefTechnicalDetails::instance(), SIGNAL(dcceilingChanged(bool))); + QSignalSpy spy6(qPrefTechnicalDetails::instance(), SIGNAL(display_deco_modeChanged(deco_mode))); + QSignalSpy spy7(qPrefTechnicalDetails::instance(), SIGNAL(display_unused_tanksChanged(bool))); + QSignalSpy spy8(qPrefTechnicalDetails::instance(), SIGNAL(eadChanged(bool))); + QSignalSpy spy9(qPrefTechnicalDetails::instance(), SIGNAL(gfhighChanged(int))); + QSignalSpy spy10(qPrefTechnicalDetails::instance(), SIGNAL(gflowChanged(int))); + QSignalSpy spy11(qPrefTechnicalDetails::instance(), SIGNAL(gf_low_at_maxdepthChanged(bool))); + QSignalSpy spy12(qPrefTechnicalDetails::instance(), SIGNAL(hrgraphChanged(bool))); + QSignalSpy spy13(qPrefTechnicalDetails::instance(), SIGNAL(modChanged(bool))); + QSignalSpy spy14(qPrefTechnicalDetails::instance(), SIGNAL(modpO2Changed(double))); + QSignalSpy spy15(qPrefTechnicalDetails::instance(), SIGNAL(percentagegraphChanged(bool))); + QSignalSpy spy16(qPrefTechnicalDetails::instance(), SIGNAL(redceilingChanged(bool))); + QSignalSpy spy17(qPrefTechnicalDetails::instance(), SIGNAL(rulergraphChanged(bool))); + QSignalSpy spy18(qPrefTechnicalDetails::instance(), SIGNAL(show_average_depthChanged(bool))); + QSignalSpy spy19(qPrefTechnicalDetails::instance(), SIGNAL(show_ccr_sensorsChanged(bool))); + QSignalSpy spy20(qPrefTechnicalDetails::instance(), SIGNAL(show_ccr_setpointChanged(bool))); + QSignalSpy spy21(qPrefTechnicalDetails::instance(), SIGNAL(show_icdChanged(bool))); + QSignalSpy spy22(qPrefTechnicalDetails::instance(), SIGNAL(show_pictures_in_profileChanged(bool))); + QSignalSpy spy23(qPrefTechnicalDetails::instance(), SIGNAL(show_sacChanged(bool))); + QSignalSpy spy24(qPrefTechnicalDetails::instance(), SIGNAL(show_scr_ocpo2Changed(bool))); + QSignalSpy spy25(qPrefTechnicalDetails::instance(), SIGNAL(tankbarChanged(bool))); + QSignalSpy spy26(qPrefTechnicalDetails::instance(), SIGNAL(vpmb_conservatismChanged(int))); + QSignalSpy spy27(qPrefTechnicalDetails::instance(), SIGNAL(zoomed_plotChanged(bool))); + + prefs.calcalltissues = true; + qPrefTechnicalDetails::set_calcalltissues(false); + prefs.calcceiling = true; + qPrefTechnicalDetails::set_calcceiling(false); + prefs.calcceiling3m = true; + qPrefTechnicalDetails::set_calcceiling3m(false); + prefs.calcndltts = true; + qPrefTechnicalDetails::set_calcndltts(false); + prefs.dcceiling = true; + qPrefTechnicalDetails::set_dcceiling(false); + qPrefTechnicalDetails::set_display_deco_mode(VPMB); + prefs.display_unused_tanks = true; + qPrefTechnicalDetails::set_display_unused_tanks(false); + prefs.ead = true; + qPrefTechnicalDetails::set_ead(false); + qPrefTechnicalDetails::set_gfhigh(-29); + qPrefTechnicalDetails::set_gflow(-24); + prefs.gf_low_at_maxdepth = true; + qPrefTechnicalDetails::set_gf_low_at_maxdepth(false); + prefs.hrgraph = true; + qPrefTechnicalDetails::set_hrgraph(false); + prefs.mod = true; + qPrefTechnicalDetails::set_mod(false); + qPrefTechnicalDetails::set_modpO2(-1.12); + prefs.percentagegraph = true; + qPrefTechnicalDetails::set_percentagegraph(false); + prefs.redceiling = true; + qPrefTechnicalDetails::set_redceiling(false); + prefs.rulergraph = true; + qPrefTechnicalDetails::set_rulergraph(false); + prefs.show_average_depth = true; + qPrefTechnicalDetails::set_show_average_depth(false); + prefs.show_ccr_sensors = true; + qPrefTechnicalDetails::set_show_ccr_sensors(false); + prefs.show_ccr_setpoint = true; + qPrefTechnicalDetails::set_show_ccr_setpoint(false); + prefs.show_icd = true; + qPrefTechnicalDetails::set_show_icd(false); + prefs.show_pictures_in_profile = true; + qPrefTechnicalDetails::set_show_pictures_in_profile(false); + prefs.show_sac = true; + qPrefTechnicalDetails::set_show_sac(false); + prefs.show_scr_ocpo2 = true; + qPrefTechnicalDetails::set_show_scr_ocpo2(false); + prefs.tankbar = true; + qPrefTechnicalDetails::set_tankbar(false); + qPrefTechnicalDetails::set_vpmb_conservatism(-64); + prefs.zoomed_plot = true; + qPrefTechnicalDetails::set_zoomed_plot(false); + + 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(spy8.count(), 1); + QCOMPARE(spy9.count(), 1); + QCOMPARE(spy10.count(), 1); + QCOMPARE(spy11.count(), 1); + QCOMPARE(spy12.count(), 1); + QCOMPARE(spy13.count(), 1); + QCOMPARE(spy14.count(), 1); + QCOMPARE(spy15.count(), 1); + QCOMPARE(spy16.count(), 1); + QCOMPARE(spy17.count(), 1); + QCOMPARE(spy18.count(), 1); + QCOMPARE(spy19.count(), 1); + QCOMPARE(spy20.count(), 1); + QCOMPARE(spy21.count(), 1); + QCOMPARE(spy22.count(), 1); + QCOMPARE(spy23.count(), 1); + QCOMPARE(spy24.count(), 1); + QCOMPARE(spy25.count(), 1); + QCOMPARE(spy26.count(), 1); + QCOMPARE(spy27.count(), 1); + + QVERIFY(spy1.takeFirst().at(0).toBool() == false); + QVERIFY(spy2.takeFirst().at(0).toBool() == false); + QVERIFY(spy3.takeFirst().at(0).toBool() == false); + QVERIFY(spy4.takeFirst().at(0).toBool() == false); + QVERIFY(spy5.takeFirst().at(0).toBool() == false); + QVERIFY(spy6.takeFirst().at(0).toInt() == VPMB); + QVERIFY(spy7.takeFirst().at(0).toBool() == false); + QVERIFY(spy8.takeFirst().at(0).toBool() == false); + QVERIFY(spy9.takeFirst().at(0).toInt() == -29); + QVERIFY(spy10.takeFirst().at(0).toInt() == -24); + QVERIFY(spy11.takeFirst().at(0).toBool() == false); + QVERIFY(spy12.takeFirst().at(0).toBool() == false); + QVERIFY(spy13.takeFirst().at(0).toBool() == false); + QVERIFY(spy14.takeFirst().at(0).toDouble() == -1.12); + QVERIFY(spy15.takeFirst().at(0).toBool() == false); + QVERIFY(spy16.takeFirst().at(0).toBool() == false); + QVERIFY(spy17.takeFirst().at(0).toBool() == false); + QVERIFY(spy18.takeFirst().at(0).toBool() == false); + QVERIFY(spy19.takeFirst().at(0).toBool() == false); + QVERIFY(spy20.takeFirst().at(0).toBool() == false); + QVERIFY(spy21.takeFirst().at(0).toBool() == false); + QVERIFY(spy22.takeFirst().at(0).toBool() == false); + QVERIFY(spy23.takeFirst().at(0).toBool() == false); + QVERIFY(spy24.takeFirst().at(0).toBool() == false); + QVERIFY(spy25.takeFirst().at(0).toBool() == false); + QVERIFY(spy26.takeFirst().at(0).toInt() == -64); + QVERIFY(spy27.takeFirst().at(0).toBool() == false); +} + + QTEST_MAIN(TestQPrefTechnicalDetails) diff --git a/tests/testqPrefTechnicalDetails.h b/tests/testqPrefTechnicalDetails.h index 41471cafa..b71ebd421 100644 --- a/tests/testqPrefTechnicalDetails.h +++ b/tests/testqPrefTechnicalDetails.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFTECHNICALDETAILS_H 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) diff --git a/tests/testqPrefUnits.h b/tests/testqPrefUnits.h index 0cbf07470..b0b8f4fe2 100644 --- a/tests/testqPrefUnits.h +++ b/tests/testqPrefUnits.h @@ -16,6 +16,7 @@ private slots: void test_multiple(); void test_unit_system(); void test_oldPreferences(); + void test_signals(); }; #endif // TESTQPREFUNITS_H diff --git a/tests/testqPrefUpdateManager.cpp b/tests/testqPrefUpdateManager.cpp index 4d274d553..f11505654 100644 --- a/tests/testqPrefUpdateManager.cpp +++ b/tests/testqPrefUpdateManager.cpp @@ -6,6 +6,7 @@ #include "core/settings/qPrefUpdateManager.h" #include <QTest> +#include <QSignalSpy> void TestQPrefUpdateManager::initTestCase() { @@ -163,4 +164,34 @@ void TestQPrefUpdateManager::test_oldPreferences() TEST(update->next_check(), date); } +void TestQPrefUpdateManager::test_signals() +{ + QSignalSpy spy1(qPrefUpdateManager::instance(), SIGNAL(dont_check_for_updatesChanged(bool))); + QSignalSpy spy2(qPrefUpdateManager::instance(), SIGNAL(dont_check_existsChanged(bool))); + QSignalSpy spy3(qPrefUpdateManager::instance(), SIGNAL(last_version_usedChanged(QString))); + QSignalSpy spy4(qPrefUpdateManager::instance(), SIGNAL(next_checkChanged(QDate))); + QSignalSpy spy5(qPrefUpdateManager::instance(), SIGNAL(uuidStringChanged(QString))); + + prefs.update_manager.dont_check_for_updates = true; + qPrefUpdateManager::set_dont_check_for_updates(false); + prefs.update_manager.dont_check_exists = true; + qPrefUpdateManager::set_dont_check_exists(false); + qPrefUpdateManager::set_last_version_used("signal last_version2"); + qPrefUpdateManager::set_next_check(QDate::fromString("11/09/1967", "dd/MM/yyyy")); + qPrefUpdateManager::set_uuidString("signal uuid"); + + 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).toBool() == false); + QVERIFY(spy2.takeFirst().at(0).toBool() == false); + QVERIFY(spy3.takeFirst().at(0).toString() == "signal last_version2"); + QVERIFY(spy4.takeFirst().at(0).toDate() == QDate::fromString("11/09/1967", "dd/MM/yyyy")); + QVERIFY(spy5.takeFirst().at(0).toString() == "signal uuid"); +} + + QTEST_MAIN(TestQPrefUpdateManager) diff --git a/tests/testqPrefUpdateManager.h b/tests/testqPrefUpdateManager.h index baa8d3489..955305644 100644 --- a/tests/testqPrefUpdateManager.h +++ b/tests/testqPrefUpdateManager.h @@ -16,6 +16,7 @@ private slots: void test_multiple(); void test_oldPreferences(); void test_next_check(); + void test_signals(); }; #endif // TESTQPREFUPDATEMANAGER_H |