diff options
Diffstat (limited to 'tests/testqPrefUpdateManager.cpp')
-rw-r--r-- | tests/testqPrefUpdateManager.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/testqPrefUpdateManager.cpp b/tests/testqPrefUpdateManager.cpp index 166fea032..1d2e5d98d 100644 --- a/tests/testqPrefUpdateManager.cpp +++ b/tests/testqPrefUpdateManager.cpp @@ -23,7 +23,7 @@ void TestQPrefUpdateManager::test_struct_get() prefs.update_manager.dont_check_for_updates = true; prefs.update_manager.dont_check_exists = true; prefs.update_manager.last_version_used = copy_qstring("last_version"); - prefs.update_manager.next_check = copy_qstring(QString("11/09/1957")); + prefs.update_manager.next_check = QDate::fromString("11/09/1957", "dd/MM/yyyy").toJulianDay(); QCOMPARE(tst->dont_check_for_updates(), true); QCOMPARE(tst->dont_check_exists(), true); @@ -40,12 +40,12 @@ void TestQPrefUpdateManager::test_set_struct() tst->set_dont_check_for_updates(false); tst->set_dont_check_exists(false); tst->set_last_version_used("last_version2"); - prefs.update_manager.next_check = copy_qstring(QString("11/09/1957")); + tst->set_next_check(QDate::fromString("11/09/1957", "dd/MM/yyyy")); QCOMPARE(prefs.update_manager.dont_check_for_updates, false); QCOMPARE(prefs.update_manager.dont_check_exists, false); QCOMPARE(QString(prefs.update_manager.last_version_used), QString("last_version2")); - QCOMPARE(QDate::fromString(QString(prefs.update_manager.next_check), "dd/MM/yyyy"), QDate::fromString("11/09/1957", "dd/MM/yyyy")); + QCOMPARE(QDate::fromJulianDay(prefs.update_manager.next_check), QDate::fromString("11/09/1957", "dd/MM/yyyy")); } void TestQPrefUpdateManager::test_set_load_struct() @@ -57,7 +57,7 @@ void TestQPrefUpdateManager::test_set_load_struct() // secure set_ stores on disk prefs.update_manager.dont_check_for_updates = true; prefs.update_manager.dont_check_exists = true; - prefs.update_manager.next_check = copy_qstring(QString("value1")); + prefs.update_manager.next_check = 100; tst->set_dont_check_for_updates(false); tst->set_dont_check_exists(false); @@ -67,12 +67,12 @@ void TestQPrefUpdateManager::test_set_load_struct() prefs.update_manager.dont_check_for_updates = true; prefs.update_manager.dont_check_exists = true; prefs.update_manager.last_version_used = copy_qstring("last_version"); - prefs.update_manager.next_check = copy_qstring(QString("01/01/2018")); + prefs.update_manager.next_check = 1000; tst->load(); QCOMPARE(prefs.update_manager.dont_check_for_updates, false); QCOMPARE(QString(prefs.update_manager.last_version_used), QString("last_version2")); - QCOMPARE(QDate::fromString(QString(prefs.update_manager.next_check),"dd/MM/yyyy"), QDate::fromString("11/09/1957", "dd/MM/yyyy")); + QCOMPARE(QDate::fromJulianDay(prefs.update_manager.next_check), QDate::fromString("11/09/1957", "dd/MM/yyyy")); // dont_check_exists is NOT stored on disk QCOMPARE(prefs.update_manager.dont_check_exists, true); @@ -87,13 +87,13 @@ void TestQPrefUpdateManager::test_struct_disk() prefs.update_manager.dont_check_for_updates = true; prefs.update_manager.dont_check_exists = true; prefs.update_manager.last_version_used = copy_qstring("last_version"); - prefs.update_manager.next_check = copy_qstring("11/09/1957"); + prefs.update_manager.next_check = QDate::fromString("11/09/1957", "dd/MM/yyyy").toJulianDay(); tst->sync(); prefs.update_manager.dont_check_for_updates = false; prefs.update_manager.dont_check_exists = false; prefs.update_manager.last_version_used = copy_qstring(""); - prefs.update_manager.next_check = copy_qstring("01/09/2057"); + prefs.update_manager.next_check = 1000; tst->load(); QCOMPARE(tst->dont_check_for_updates(), true); @@ -120,6 +120,16 @@ void TestQPrefUpdateManager::test_multiple() QCOMPARE(tst_direct->dont_check_exists(), false); } +void TestQPrefUpdateManager::test_next_check() +{ + auto tst = qPrefUpdateManager::instance(); + + prefs.update_manager.next_check = QDate::fromString("11/09/1957", "dd/MM/yyyy").toJulianDay(); + prefs.update_manager.next_check++; + + QCOMPARE(tst->next_check(), QDate::fromString("12/09/1957", "dd/MM/yyyy")); +} + #define TEST(METHOD, VALUE) \ QCOMPARE(METHOD, VALUE); \ update->sync(); \ |