From c01d9f60c14ec9ee58892504e9f5c346dbb24e7e Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Tue, 28 Aug 2018 12:33:47 +0200 Subject: 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 --- tests/testqPrefUpdateManager.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/testqPrefUpdateManager.cpp') 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 +#include 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) -- cgit v1.2.3-70-g09d2