diff options
Diffstat (limited to 'tests')
32 files changed, 1228 insertions, 367 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ecbcd4fc4..4d59536bd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -96,18 +96,20 @@ TEST(TestPlan testplan.cpp) TEST(TestDiveSiteDuplication testdivesiteduplication.cpp) TEST(TestRenumber testrenumber.cpp) TEST(TestGitStorage testgitstorage.cpp) -TEST(TestPreferences testpreferences.cpp) TEST(TestPicture testpicture.cpp) TEST(TestMerge testmerge.cpp) TEST(TestTagList testtaglist.cpp) -TEST(TestQPrefAnimations testqPrefAnimations.cpp) TEST(TestQPrefCloudStorage testqPrefCloudStorage.cpp) TEST(TestQPrefDisplay testqPrefDisplay.cpp) TEST(TestQPrefDiveComputer testqPrefDiveComputer.cpp) TEST(TestQPrefDivePlanner testqPrefDivePlanner.cpp) TEST(TestQPrefFacebook testqPrefFacebook.cpp) +TEST(TestQPrefGeneral testqPrefGeneral.cpp) +TEST(TestQPrefGeocoding testqPrefGeocoding.cpp) +TEST(TestQPrefLanguage testqPrefLanguage.cpp) TEST(TestQPrefLocationService testqPrefLocationService.cpp) +TEST(TestQPrefPartialPressureGas testqPrefPartialPressureGas.cpp) TEST(TestQPrefProxy testqPrefProxy.cpp) TEST(TestQPrefTechnicalDetails testqPrefTechnicalDetails.cpp) TEST(TestQPrefUnits testqPrefUnits.cpp) @@ -124,19 +126,21 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} TestGitStorage TestPlan TestDiveSiteDuplication - TestPreferences TestRenumber TestPicture TestMerge TestTagList - TestQPrefAnimations TestQPrefCloudStorage TestQPrefDisplay TestQPrefDiveComputer TestQPrefDivePlanner TestQPrefFacebook + TestQPrefGeneral + TestQPrefGeocoding + TestQPrefLanguage TestQPrefLocationService + TestQPrefPartialPressureGas TestQPrefProxy TestQPrefTechnicalDetails TestQPrefUnits diff --git a/tests/testdivesiteduplication.cpp b/tests/testdivesiteduplication.cpp index 4e90c5175..250e407fc 100644 --- a/tests/testdivesiteduplication.cpp +++ b/tests/testdivesiteduplication.cpp @@ -5,7 +5,7 @@ void TestDiveSiteDuplication::testReadV2() { - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf", &dive_table), 0); QCOMPARE(dive_site_table.nr, 2); } diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp index 1448c60ac..5184aeb2a 100644 --- a/tests/testgitstorage.cpp +++ b/tests/testgitstorage.cpp @@ -5,13 +5,14 @@ #include "core/dive.h" #include "core/divelist.h" #include "core/file.h" -#include "core/prefs-macros.h" +#include "core/qthelper.h" #include "core/subsurfacestartup.h" +#include "core/settings/qPrefProxy.h" +#include "core/settings/qPrefCloudStorage.h" #include <QDir> #include <QTextStream> #include <QNetworkProxy> -#include <QSettings> #include <QTextCodec> #include <QDebug> @@ -28,23 +29,13 @@ void TestGitStorage::initTestCase() QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); QCoreApplication::setApplicationName("Subsurface"); - QSettings s; - QVariant v; - s.beginGroup("Network"); - GET_INT_DEF("proxy_type", proxy_type, QNetworkProxy::DefaultProxy); - GET_TXT("proxy_host", proxy_host); - GET_INT("proxy_port", proxy_port); - GET_BOOL("proxy_auth", proxy_auth); - GET_TXT("proxy_user", proxy_user); - GET_TXT("proxy_pass", proxy_pass); - s.endGroup(); - s.beginGroup("CloudStorage"); - GET_TXT("cloud_base_url", cloud_base_url); + qPrefProxy::load(); + qPrefCloudStorage::load(); + QString gitUrl(prefs.cloud_base_url); if (gitUrl.right(1) != "/") gitUrl += "/"; prefs.cloud_git_url = copy_qstring(gitUrl + "git"); - s.endGroup(); prefs.cloud_storage_email_encoded = strdup("ssrftest@hohndel.org"); prefs.cloud_storage_password = strdup("geheim"); QNetworkProxy proxy; @@ -88,7 +79,7 @@ void TestGitStorage::testGitStorageLocal() // test writing and reading back from local git storage git_repository *repo; git_libgit2_init(); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table), 0); QFETCH(QString, testDirName); QFETCH(QString, prefixRead); QFETCH(QString, prefixWrite); @@ -101,7 +92,7 @@ void TestGitStorage::testGitStorageLocal() QCOMPARE(save_dives(qPrintable(repoNameWrite + "[test]")), 0); QCOMPARE(save_dives("./SampleDivesV3.ssrf"), 0); clear_dive_file_data(); - QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]")), 0); + QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]"), &dive_table), 0); QCOMPARE(save_dives("./SampleDivesV3viagit.ssrf"), 0); QFile org("./SampleDivesV3.ssrf"); org.open(QFile::ReadOnly); @@ -120,10 +111,10 @@ void TestGitStorage::testGitStorageCloud() // connect to the ssrftest repository on the cloud server // and repeat the same test as before with the local git storage QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table), 0); QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); QCOMPARE(save_dives("./SampleDivesV3viacloud.ssrf"), 0); QFile org("./SampleDivesV3.ssrf"); org.open(QFile::ReadOnly); @@ -144,8 +135,8 @@ void TestGitStorage::testGitStorageCloudOfflineSync() QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]"; // read the local repo from the previous test and add dive 10 - QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml"), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepo), &dive_table), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml", &dive_table), 0); // calling process_dive() sorts the table, but calling it with // is_imported == true causes it to try to update the window title... let's not do that process_dives(false, false); @@ -154,7 +145,7 @@ void TestGitStorage::testGitStorageCloudOfflineSync() QCOMPARE(save_dives("./SampleDivesV3plus10local.ssrf"), 0); clear_dive_file_data(); // open the cloud storage and compare - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); QCOMPARE(save_dives("./SampleDivesV3plus10viacloud.ssrf"), 0); QFile org("./SampleDivesV3plus10local.ssrf"); org.open(QFile::ReadOnly); @@ -172,7 +163,7 @@ void TestGitStorage::testGitStorageCloudOfflineSync() QDir localCacheDirectorySave(localCacheDir + "save"); QCOMPARE(localCacheDirectorySave.removeRecursively(), true); QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true); - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); QCOMPARE(save_dives("./SampleDivesV3plus10fromcloud.ssrf"), 0); org.close(); org.open(QFile::ReadOnly); @@ -193,15 +184,15 @@ void TestGitStorage::testGitStorageCloudMerge() QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepoSave = localCacheDir + "save[ssrftest@hohndel.org]"; - QCOMPARE(parse_file(qPrintable(localCacheRepoSave)), 0); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepoSave), &dive_table), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table), 0); process_dives(false, false); QCOMPARE(save_dives(qPrintable(localCacheRepoSave)), 0); clear_dive_file_data(); // now we open the cloud storage repo and add a different dive to it - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table), 0); process_dives(false, false); QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); @@ -212,13 +203,13 @@ void TestGitStorage::testGitStorageCloudMerge() QCOMPARE(localCacheDirectory.removeRecursively(), true); QDir localCacheDirectorySave(localCacheDir + "save"); QCOMPARE(localCacheDirectory.rename(localCacheDir + "save", localCacheDir), true); - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); QCOMPARE(save_dives("./SampleDivesV3plus10-11-12-merged.ssrf"), 0); clear_dive_file_data(); - QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf"), 0); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0); + QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf", &dive_table), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table), 0); process_dives(false, false); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table), 0); process_dives(false, false); QCOMPARE(save_dives("./SampleDivesV3plus10-11-12.ssrf"), 0); QFile org("./SampleDivesV3plus10-11-12-merged.ssrf"); @@ -240,7 +231,7 @@ void TestGitStorage::testGitStorageCloudMerge2() QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]"; - QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepo), &dive_table), 0); process_dives(false, false); struct dive *dive = get_dive(1); delete_single_dive(1); @@ -256,7 +247,7 @@ void TestGitStorage::testGitStorageCloudMerge2() QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true); } // now we open the cloud storage repo and modify that first dive - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); process_dives(false, false); dive = get_dive(1); QVERIFY(dive != NULL); @@ -272,7 +263,7 @@ void TestGitStorage::testGitStorageCloudMerge2() QCOMPARE(localCacheDirectory.removeRecursively(), true); QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true); - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); QCOMPARE(save_dives("./SampleDivesMinus1-merged.ssrf"), 0); QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); QFile org("./SampleDivesMinus1-merged.ssrf"); @@ -296,7 +287,7 @@ void TestGitStorage::testGitStorageCloudMerge3() QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]"; - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); process_dives(false, false); struct dive *dive = get_dive(0); QVERIFY(dive != 0); @@ -308,7 +299,7 @@ void TestGitStorage::testGitStorageCloudMerge3() QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); - QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepo), &dive_table), 0); process_dives(false, false); dive = get_dive(0); dive->notes = strdup("Create multi line dive notes\nDifferent line 2 and removed 3-5\n\nThat should be enough"); @@ -327,7 +318,7 @@ void TestGitStorage::testGitStorageCloudMerge3() QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true); } // now we open the cloud storage repo and modify those first dive notes differently - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); process_dives(false, false); dive = get_dive(0); dive->notes = strdup("Completely different dive notes\nBut also multi line"); @@ -345,7 +336,7 @@ void TestGitStorage::testGitStorageCloudMerge3() QCOMPARE(localCacheDirectory.removeRecursively(), true); QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true); - QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0); QCOMPARE(save_dives("./SampleDivesMerge3.ssrf"), 0); // we are not trying to compare this to a pre-determined result... what this test // checks is that there are no parsing errors with the merge diff --git a/tests/testmerge.cpp b/tests/testmerge.cpp index a664e1a35..b102e239f 100644 --- a/tests/testmerge.cpp +++ b/tests/testmerge.cpp @@ -21,9 +21,9 @@ void TestMerge::testMergeEmpty() /* * check that we correctly merge mixed cylinder dives */ - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &dive_table), 0); process_dives(true, false); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml", &dive_table), 0); process_dives(true, false); QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0); QFile org(SUBSURFACE_TEST_DATA "/dives/test47+48.xml"); @@ -44,9 +44,9 @@ void TestMerge::testMergeBackwards() /* * check that we correctly merge mixed cylinder dives */ - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml", &dive_table), 0); process_dives(true, false); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &dive_table), 0); process_dives(true, false); QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0); QFile org(SUBSURFACE_TEST_DATA "/dives/test47+48.xml"); diff --git a/tests/testparse.cpp b/tests/testparse.cpp index 06e20cd5c..59531af70 100644 --- a/tests/testparse.cpp +++ b/tests/testparse.cpp @@ -127,13 +127,13 @@ int TestParse::parseDivingLog() int TestParse::parseV2NoQuestion() { // parsing of a V2 file should work - return parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"); + return parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table); } int TestParse::parseV3() { // parsing of a V3 files should succeed - return parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml"); + return parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml", &dive_table); } void TestParse::testParse() @@ -279,7 +279,7 @@ void TestParse::testParseDLD() QString filename = SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.DLD"; QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0); - QVERIFY(try_to_open_zip(filename.toLatin1().data()) > 0); + QVERIFY(try_to_open_zip(filename.toLatin1().data(), &dive_table) > 0); fprintf(stderr, "number of dives from DLD: %d \n", dive_table.nr); @@ -299,8 +299,8 @@ void TestParse::testParseMerge() /* * check that we correctly merge mixed cylinder dives */ - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml"), 0); - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml", &dive_table), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml", &dive_table), 0); QCOMPARE(save_dives("./testmerge.ssrf"), 0); FILE_COMPARE("./testmerge.ssrf", SUBSURFACE_TEST_DATA "/dives/mergedVyperOstc.xml"); @@ -371,7 +371,7 @@ int TestParse::parseCSVmanual(int units, std::string file) void TestParse::exportCSVDiveDetails() { - parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"); + parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table); export_dives_xslt("testcsvexportmanual.csv", 0, 0, "xml2manualcsv.xslt"); export_dives_xslt("testcsvexportmanualimperial.csv", 0, 1, "xml2manualcsv.xslt"); @@ -420,7 +420,7 @@ int TestParse::parseCSVprofile(int units, std::string file) void TestParse::exportCSVDiveProfile() { - parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"); + parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table); export_dives_xslt("testcsvexportprofile.csv", 0, 0, "xml2csv.xslt"); export_dives_xslt("testcsvexportprofileimperial.csv", 0, 1, "xml2csv.xslt"); @@ -438,13 +438,13 @@ void TestParse::exportCSVDiveProfile() void TestParse::exportUDDF() { - parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"); + parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table); export_dives_xslt("testuddfexport.uddf", 0, 1, "uddf-export.xslt"); clear_dive_file_data(); - parse_file("testuddfexport.uddf"); + parse_file("testuddfexport.uddf", &dive_table); export_dives_xslt("testuddfexport2.uddf", 0, 1, "uddf-export.xslt"); FILE_COMPARE("testuddfexport.uddf", diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp index 507a3cf79..2209e479f 100644 --- a/tests/testpicture.cpp +++ b/tests/testpicture.cpp @@ -23,7 +23,7 @@ void TestPicture::addPicture() struct picture *pic1, *pic2; verbose = 1; - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test44.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test44.xml", &dive_table), 0); dive = get_dive(0); QVERIFY(dive != NULL); pic1 = dive->picture_list; diff --git a/tests/testplan.cpp b/tests/testplan.cpp index d7413f31f..dd62aa777 100644 --- a/tests/testplan.cpp +++ b/tests/testplan.cpp @@ -58,8 +58,8 @@ void setupPlan(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75); - plan_add_segment(dp, 0, gas_mod(&ean36, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); - plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(ean36, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(79, 260), 0, 0, 1, OC); } @@ -86,8 +86,8 @@ void setupPlanVpmb45m30mTx(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75); - plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); - plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(45, 150), 0, 0, 1, OC); } @@ -114,8 +114,8 @@ void setupPlanVpmb60m10mTx(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75); - plan_add_segment(dp, 0, gas_mod(&tx50_15, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); - plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(tx50_15, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC); } @@ -159,7 +159,7 @@ void setupPlanVpmb60m30minEan50(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); - plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC); } @@ -183,7 +183,7 @@ void setupPlanVpmb60m30minTx(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); - plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC); } @@ -231,8 +231,8 @@ void setupPlanVpmb100m60min(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330); - plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); - plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, 60 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC); } @@ -258,8 +258,8 @@ void setupPlanVpmb100m10min(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330); - plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); - plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC); } @@ -307,9 +307,9 @@ void setupPlanVpmb100mTo70m30min(struct diveplan *dp) free_dps(dp); int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60); - plan_add_segment(dp, 0, gas_mod(&tx21_35, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); - plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); - plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 3, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(tx21_35, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC); + plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 3, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, 20 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, 3 * 60, M_OR_FT(70, 230), 0, 0, 1, OC); diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp deleted file mode 100644 index 0a4492c00..000000000 --- a/tests/testpreferences.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include "testpreferences.h" - -#include "core/subsurface-qt/SettingsObjectWrapper.h" - -#include <QDate> -#include <QtTest> - -#define TEST(METHOD, VALUE) \ - QCOMPARE(METHOD, VALUE); \ - pref->sync(); \ - pref->load(); \ - QCOMPARE(METHOD, VALUE); - -void TestPreferences::initTestCase() -{ - QCoreApplication::setOrganizationName("Subsurface"); - QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); - QCoreApplication::setApplicationName("SubsurfaceTestPreferences"); -} - -void TestPreferences::testPreferences() -{ - auto pref = SettingsObjectWrapper::instance(); - pref->load(); - - auto pp = pref->pp_gas; - pp->setShowPn2(false); - pp->setShowPhe(false); - pp->setShowPo2(false); - pp->setPo2ThresholdMin(1.0); - pp->setPo2ThresholdMax(2.0); - pp->setPn2Threshold(3.0); - pp->setPheThreshold(4.0); - - TEST(pp->showPn2(), false); - TEST(pp->showPhe(), false); - TEST(pp->showPo2(), false); - TEST(pp->pn2Threshold(), 3.0); - TEST(pp->pheThreshold(), 4.0); - TEST(pp->po2ThresholdMin(), 1.0); - TEST(pp->po2ThresholdMax(), 2.0); - - pp->setShowPn2(true); - pp->setShowPhe(true); - pp->setShowPo2(true); - pp->setPo2ThresholdMin(4.0); - pp->setPo2ThresholdMax(5.0); - pp->setPn2Threshold(6.0); - pp->setPheThreshold(7.0); - - TEST(pp->showPn2(), true); - TEST(pp->showPhe(), true); - TEST(pp->showPo2(), true); - TEST(pp->pn2Threshold(), 6.0); - TEST(pp->pheThreshold(), 7.0); - TEST(pp->po2ThresholdMin(), 4.0); - TEST(pp->po2ThresholdMax(), 5.0); - - auto geo = pref->geocoding; - geo->setFirstTaxonomyCategory(TC_NONE); - geo->setSecondTaxonomyCategory(TC_OCEAN); - geo->setThirdTaxonomyCategory(TC_COUNTRY); - - TEST(geo->firstTaxonomyCategory(), TC_NONE); - TEST(geo->secondTaxonomyCategory(), TC_OCEAN); - TEST(geo->thirdTaxonomyCategory(), TC_COUNTRY); - - geo->setFirstTaxonomyCategory(TC_OCEAN); - geo->setSecondTaxonomyCategory(TC_COUNTRY); - geo->setThirdTaxonomyCategory(TC_NONE); - - TEST(geo->firstTaxonomyCategory(), TC_OCEAN); - TEST(geo->secondTaxonomyCategory(), TC_COUNTRY); - TEST(geo->thirdTaxonomyCategory(), TC_NONE); - - auto general = pref->general_settings; - general->setDefaultFilename("filename"); - general->setDefaultCylinder("cylinder_2"); - //TODOl: Change this to a enum. // This is 'undefined', it will need to figure out later between no_file or use_deault file. - general->setDefaultFileBehavior(0); - general->setDefaultSetPoint(0); - general->setO2Consumption(0); - general->setPscrRatio(0); - general->setUseDefaultFile(true); - - TEST(general->defaultFilename(), QStringLiteral("filename")); - TEST(general->defaultCylinder(), QStringLiteral("cylinder_2")); - TEST(general->defaultFileBehavior(), (short)LOCAL_DEFAULT_FILE); // since we have a default file, here it returns - TEST(general->defaultSetPoint(), 0); - TEST(general->o2Consumption(), 0); - TEST(general->pscrRatio(), 0); - TEST(general->useDefaultFile(), true); - - general->setDefaultFilename("no_file_name"); - general->setDefaultCylinder("cylinder_1"); - //TODOl: Change this to a enum. - general->setDefaultFileBehavior(CLOUD_DEFAULT_FILE); - - general->setDefaultSetPoint(1); - general->setO2Consumption(1); - general->setPscrRatio(1); - general->setUseDefaultFile(false); - - TEST(general->defaultFilename(), QStringLiteral("no_file_name")); - TEST(general->defaultCylinder(), QStringLiteral("cylinder_1")); - TEST(general->defaultFileBehavior(), (short)CLOUD_DEFAULT_FILE); - TEST(general->defaultSetPoint(), 1); - TEST(general->o2Consumption(), 1); - TEST(general->pscrRatio(), 1); - TEST(general->useDefaultFile(), false); - - auto language = pref->language_settings; - language->setLangLocale("en_US"); - language->setLanguage("en"); - language->setTimeFormat("hh:mm"); - language->setDateFormat("dd/mm/yy"); - language->setDateFormatShort("dd/mm"); - language->setTimeFormatOverride(false); - language->setDateFormatOverride(false); - language->setUseSystemLanguage(false); - - TEST(language->langLocale(), QStringLiteral("en_US")); - TEST(language->language(), QStringLiteral("en")); - TEST(language->timeFormat(), QStringLiteral("hh:mm")); - TEST(language->dateFormat(), QStringLiteral("dd/mm/yy")); - TEST(language->dateFormatShort(), QStringLiteral("dd/mm")); - TEST(language->timeFormatOverride(), false); - TEST(language->dateFormatOverride(), false); - TEST(language->useSystemLanguage(), false); - - language->setLangLocale("en_EN"); - language->setLanguage("br"); - language->setTimeFormat("mm:hh"); - language->setDateFormat("yy/mm/dd"); - language->setDateFormatShort("dd/yy"); - language->setTimeFormatOverride(true); - language->setDateFormatOverride(true); - language->setUseSystemLanguage(true); - - TEST(language->langLocale(), QStringLiteral("en_EN")); - TEST(language->language(), QStringLiteral("br")); - TEST(language->timeFormat(), QStringLiteral("mm:hh")); - TEST(language->dateFormat(), QStringLiteral("yy/mm/dd")); - TEST(language->dateFormatShort(), QStringLiteral("dd/yy")); - TEST(language->timeFormatOverride(), true); - TEST(language->dateFormatOverride(), true); - TEST(language->useSystemLanguage(), true); -} - -QTEST_MAIN(TestPreferences) diff --git a/tests/testpreferences.h b/tests/testpreferences.h deleted file mode 100644 index 10c875484..000000000 --- a/tests/testpreferences.h +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#ifndef TESTPREFERENCES_H -#define TESTPREFERENCES_H - -#include <QTest> -#include <functional> - -class TestPreferences : public QObject { - Q_OBJECT -private slots: - void initTestCase(); - void testPreferences(); -}; - -#endif // TESTPREFERENCES_H diff --git a/tests/testprofile.cpp b/tests/testprofile.cpp index 1a63efa56..ce7702b3e 100644 --- a/tests/testprofile.cpp +++ b/tests/testprofile.cpp @@ -4,7 +4,7 @@ void TestProfile::testRedCeiling() { - parse_file("../dives/deep.xml"); + parse_file("../dives/deep.xml", &dive_table); } QTEST_GUILESS_MAIN(TestProfile) diff --git a/tests/testqPrefAnimations.cpp b/tests/testqPrefAnimations.cpp deleted file mode 100644 index 90292f28f..000000000 --- a/tests/testqPrefAnimations.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include "testqPrefAnimations.h" - -#include "core/pref.h" -#include "core/qthelper.h" -#include "core/settings/qPref.h" - -#include <QDate> -#include <QTest> - -void TestQPrefAnimations::initTestCase() -{ - QCoreApplication::setOrganizationName("Subsurface"); - QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); - QCoreApplication::setApplicationName("SubsurfaceTestQPrefAnimations"); -} - -void TestQPrefAnimations::test_struct_get() -{ - // Test struct pref -> get func. - - auto tst = qPrefAnimations::instance(); - - prefs.animation_speed = 17; - - QCOMPARE(tst->animation_speed(), prefs.animation_speed); -} - -void TestQPrefAnimations::test_set_struct() -{ - // Test set func -> struct pref - - auto tst = qPrefAnimations::instance(); - - tst->set_animation_speed(27); - - QCOMPARE(prefs.animation_speed, 27); -} - -void TestQPrefAnimations::test_set_load_struct() -{ - // test set func -> load -> struct pref - - auto tst = qPrefAnimations::instance(); - - tst->set_animation_speed(33); - - prefs.animation_speed = 17; - - tst->load(); - QCOMPARE(prefs.animation_speed, 33); -} - -void TestQPrefAnimations::test_struct_disk() -{ - // test struct prefs -> disk - - auto tst = qPrefAnimations::instance(); - - prefs.animation_speed = 27; - - tst->sync(); - prefs.animation_speed = 35; - - tst->load(); - QCOMPARE(prefs.animation_speed, 27); -} - -void TestQPrefAnimations::test_multiple() -{ - // test multiple instances have the same information - - prefs.animation_speed = 37; - auto tst_direct = new qPrefAnimations; - - prefs.animation_speed = 25; - auto tst = qPrefAnimations::instance(); - - QCOMPARE(tst->animation_speed(), tst_direct->animation_speed()); - QCOMPARE(tst_direct->animation_speed(), 25); -} - -QTEST_MAIN(TestQPrefAnimations) diff --git a/tests/testqPrefCloudStorage.cpp b/tests/testqPrefCloudStorage.cpp index 2ca2bb81a..2c6a4449f 100644 --- a/tests/testqPrefCloudStorage.cpp +++ b/tests/testqPrefCloudStorage.cpp @@ -266,4 +266,18 @@ void TestQPrefCloudStorage::test_oldPreferences() TEST(cloud->cloud_verification_status(), 1); } +void TestQPrefCloudStorage::test_loadFromCloud_var() +{ + auto cloud = qPrefCloudStorage::instance(); + + cloud->set_loadFromCloud("mail1", true); + cloud->set_loadFromCloud("mail2", false); + cloud->set_loadFromCloud("mail3", true); + + QCOMPARE(cloud->loadFromCloud("mail1"), true); + QCOMPARE(cloud->loadFromCloud("mail2"), false); + QCOMPARE(cloud->loadFromCloud("mail3"), true); + QCOMPARE(cloud->loadFromCloud("mail_unknown"), false); +} + QTEST_MAIN(TestQPrefCloudStorage) diff --git a/tests/testqPrefCloudStorage.h b/tests/testqPrefCloudStorage.h index 077ca74b6..e853c11ae 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_loadFromCloud_var(); }; #endif // TESTQPREFCLOUDSTORAGE_H diff --git a/tests/testqPrefDisplay.cpp b/tests/testqPrefDisplay.cpp index 0f534c0da..ce4d627ed 100644 --- a/tests/testqPrefDisplay.cpp +++ b/tests/testqPrefDisplay.cpp @@ -21,17 +21,17 @@ void TestQPrefDisplay::test_struct_get() auto display = qPrefDisplay::instance(); + prefs.animation_speed = 17; prefs.display_invalid_dives = true; prefs.divelist_font = copy_qstring("comic"); prefs.font_size = 12.0; prefs.show_developer = false; - prefs.theme = copy_qstring("myTheme"); + QCOMPARE(display->animation_speed(), prefs.animation_speed); QCOMPARE(display->display_invalid_dives(), prefs.display_invalid_dives); QCOMPARE(display->divelist_font(), QString(prefs.divelist_font)); QCOMPARE(display->font_size(), prefs.font_size); QCOMPARE(display->show_developer(), prefs.show_developer); - QCOMPARE(display->theme(), QString(prefs.theme)); } void TestQPrefDisplay::test_set_struct() @@ -40,17 +40,39 @@ void TestQPrefDisplay::test_set_struct() auto display = qPrefDisplay::instance(); + display->set_animation_speed(27); display->set_display_invalid_dives(true); display->set_divelist_font("doNotCareAtAll"); display->set_font_size(12.0); display->set_show_developer(false); display->set_theme("myTheme"); - + display->set_lastDir("test1"); + display->set_tooltip_position(QPointF(512, 3)); + display->set_UserSurvey("my1"); + display->set_mainSplitter("main1"); + display->set_topSplitter("top1"); + display->set_bottomSplitter("bottom1"); + display->set_maximized(false); + display->set_geometry("geo1"); + display->set_windowState("win1"); + display->set_lastState(17); + + QCOMPARE(prefs.animation_speed, 27); QCOMPARE(prefs.display_invalid_dives, true); QCOMPARE(prefs.divelist_font, "doNotCareAtAll"); QCOMPARE(prefs.font_size, 12.0); QCOMPARE(prefs.show_developer, false); - QCOMPARE(prefs.theme, "myTheme"); + QCOMPARE(display->theme(), QString("myTheme")); + QCOMPARE(display->lastDir(), QString("test1")); + QCOMPARE(display->tooltip_position(), QPointF(512, 3)); + QCOMPARE(display->UserSurvey(), QString("my1")); + QCOMPARE(display->mainSplitter(), QByteArray("main1")); + QCOMPARE(display->topSplitter(), QByteArray("top1")); + QCOMPARE(display->bottomSplitter(), QByteArray("bottom1")); + QCOMPARE(display->maximized(), false); + QCOMPARE(display->geometry(), QByteArray("geo1")); + QCOMPARE(display->windowState(), QByteArray("win1")); + QCOMPARE(display->lastState(), 17); } void TestQPrefDisplay::test_set_load_struct() @@ -59,24 +81,46 @@ void TestQPrefDisplay::test_set_load_struct() auto display = qPrefDisplay::instance(); + display->set_animation_speed(33); display->set_display_invalid_dives(false); display->set_divelist_font("doNotCareString"); display->set_font_size(15.0); display->set_show_developer(true); display->set_theme("myTheme2"); - + display->set_lastDir("test2"); + display->set_tooltip_position(QPointF(612, 3)); + display->set_UserSurvey("my2"); + display->set_mainSplitter("main2"); + display->set_topSplitter("top2"); + display->set_bottomSplitter("bottom2"); + display->set_maximized(true); + display->set_geometry("geo2"); + display->set_windowState("win2"); + display->set_lastState(27); + + prefs.animation_speed = 17; prefs.display_invalid_dives = true; prefs.divelist_font = copy_qstring("doNotCareAtAll"); prefs.font_size = 12.0; prefs.show_developer = false; - prefs.theme = copy_qstring("myTheme"); display->load(); + QCOMPARE(prefs.animation_speed, 33); QCOMPARE(prefs.display_invalid_dives, false); QCOMPARE(prefs.divelist_font, "doNotCareString"); QCOMPARE(prefs.font_size, 15.0); QCOMPARE(prefs.show_developer, true); - QCOMPARE(prefs.theme, "myTheme2"); + QCOMPARE(display->theme(), QString("myTheme2")); + QCOMPARE(display->lastDir(), QString("test2")); + QCOMPARE(display->tooltip_position(), QPointF(612, 3)); + QCOMPARE(display->UserSurvey(), QString("my2")); + QCOMPARE(display->mainSplitter(), QByteArray("main2")); + QCOMPARE(display->topSplitter(), QByteArray("top2")); + QCOMPARE(display->bottomSplitter(), QByteArray("bottom2")); + QCOMPARE(display->maximized(), true); + QCOMPARE(display->geometry(), QByteArray("geo2")); + QCOMPARE(display->windowState(), QByteArray("win2")); + QCOMPARE(display->lastState(), 27); } void TestQPrefDisplay::test_struct_disk() @@ -85,25 +129,25 @@ void TestQPrefDisplay::test_struct_disk() auto display = qPrefDisplay::instance(); + prefs.animation_speed = 27; prefs.display_invalid_dives = true; prefs.divelist_font = copy_qstring("doNotCareAtAll"); prefs.font_size = 17.0; prefs.show_developer = false; - prefs.theme = copy_qstring("myTheme3"); display->sync(); + prefs.animation_speed = 35; prefs.display_invalid_dives = false; prefs.divelist_font = copy_qstring("noString"); prefs.font_size = 11.0; prefs.show_developer = true; - prefs.theme = copy_qstring("myTheme"); display->load(); + QCOMPARE(prefs.animation_speed, 27); QCOMPARE(prefs.display_invalid_dives, true); QCOMPARE(prefs.divelist_font, "doNotCareAtAll"); QCOMPARE(prefs.font_size, 17.0); QCOMPARE(prefs.show_developer, false); - QCOMPARE(prefs.theme, "myTheme3"); } void TestQPrefDisplay::test_multiple() diff --git a/tests/testqPrefGeneral.cpp b/tests/testqPrefGeneral.cpp new file mode 100644 index 000000000..c26616e90 --- /dev/null +++ b/tests/testqPrefGeneral.cpp @@ -0,0 +1,237 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "testqPrefGeneral.h" + +#include "core/pref.h" +#include "core/qthelper.h" +#include "core/settings/qPref.h" + +#include <QTest> + +void TestQPrefGeneral::initTestCase() +{ + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("SubsurfaceTestQPrefGeneral"); +} + +void TestQPrefGeneral::test_struct_get() +{ + // Test struct pref -> get func. + + auto tst = qPrefGeneral::instance(); + + prefs.auto_recalculate_thumbnails = true; + prefs.default_cylinder = copy_qstring("new base11"); + prefs.default_filename = copy_qstring("new base12"); + prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE; + prefs.defaultsetpoint = 14; + prefs.extract_video_thumbnails = true; + prefs.extract_video_thumbnails_position = 15; + prefs.ffmpeg_executable = copy_qstring("new base16"); + prefs.o2consumption = 17; + prefs.pscr_ratio = 18; + prefs.use_default_file = true; + + QCOMPARE(tst->auto_recalculate_thumbnails(), prefs.auto_recalculate_thumbnails); + QCOMPARE(tst->default_cylinder(), QString(prefs.default_cylinder)); + QCOMPARE(tst->default_filename(), QString(prefs.default_filename)); + QCOMPARE(tst->default_file_behavior(), prefs.default_file_behavior); + QCOMPARE(tst->defaultsetpoint(), prefs.defaultsetpoint); + QCOMPARE(tst->extract_video_thumbnails(), prefs.extract_video_thumbnails); + QCOMPARE(tst->extract_video_thumbnails_position(), prefs.extract_video_thumbnails_position); + QCOMPARE(tst->ffmpeg_executable(), QString(prefs.ffmpeg_executable)); + QCOMPARE(tst->o2consumption(), prefs.o2consumption); + QCOMPARE(tst->pscr_ratio(), prefs.pscr_ratio); + QCOMPARE(tst->use_default_file(), prefs.use_default_file); +} + +void TestQPrefGeneral::test_set_struct() +{ + // Test set func -> struct pref + + auto tst = qPrefGeneral::instance(); + + tst->set_auto_recalculate_thumbnails(false); + tst->set_default_cylinder("new base21"); + tst->set_default_filename("new base22"); + tst->set_default_file_behavior(LOCAL_DEFAULT_FILE); + tst->set_defaultsetpoint(24); + tst->set_extract_video_thumbnails(false); + tst->set_extract_video_thumbnails_position(25); + tst->set_ffmpeg_executable("new base26"); + tst->set_o2consumption(27); + tst->set_pscr_ratio(28); + tst->set_use_default_file(false); + tst->set_diveshareExport_uid("uid1"); + tst->set_diveshareExport_private(false); + + QCOMPARE(prefs.auto_recalculate_thumbnails, false); + QCOMPARE(QString(prefs.default_cylinder), QString("new base21")); + QCOMPARE(QString(prefs.default_filename), QString("new base22")); + QCOMPARE(prefs.default_file_behavior, LOCAL_DEFAULT_FILE); + QCOMPARE(prefs.defaultsetpoint, 24); + QCOMPARE(prefs.extract_video_thumbnails, false); + QCOMPARE(prefs.extract_video_thumbnails_position, 25); + QCOMPARE(QString(prefs.ffmpeg_executable), QString("new base26")); + QCOMPARE(prefs.o2consumption, 27); + QCOMPARE(prefs.pscr_ratio, 28); + QCOMPARE(prefs.use_default_file, false); + QCOMPARE(tst->diveshareExport_uid(), QString("uid1")); + QCOMPARE(tst->diveshareExport_private(), false); +} + +void TestQPrefGeneral::test_set_load_struct() +{ + // test set func -> load -> struct pref + + auto tst = qPrefGeneral::instance(); + + tst->set_auto_recalculate_thumbnails(true); + tst->set_default_cylinder("new base31"); + tst->set_default_filename("new base32"); + tst->set_default_file_behavior(NO_DEFAULT_FILE); + tst->set_defaultsetpoint(34); + tst->set_extract_video_thumbnails(true); + tst->set_extract_video_thumbnails_position(35); + tst->set_ffmpeg_executable("new base36"); + tst->set_o2consumption(37); + tst->set_pscr_ratio(38); + tst->set_use_default_file(true); + tst->set_diveshareExport_uid("uid2"); + tst->set_diveshareExport_private(true); + + prefs.auto_recalculate_thumbnails = false; + prefs.default_cylinder = copy_qstring("error"); + prefs.default_filename = copy_qstring("error"); + prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE; + prefs.defaultsetpoint = 14; + prefs.extract_video_thumbnails = false; + prefs.extract_video_thumbnails_position = 15; + prefs.ffmpeg_executable = copy_qstring("error"); + prefs.o2consumption = 17; + prefs.pscr_ratio = 18; + prefs.use_default_file = false; + + tst->load(); + QCOMPARE(prefs.auto_recalculate_thumbnails, true); + QCOMPARE(QString(prefs.default_cylinder), QString("new base31")); + QCOMPARE(QString(prefs.default_filename), QString("new base32")); + QCOMPARE(prefs.default_file_behavior, NO_DEFAULT_FILE); + QCOMPARE(prefs.defaultsetpoint, 34); + QCOMPARE(prefs.extract_video_thumbnails, true); + QCOMPARE(prefs.extract_video_thumbnails_position, 35); + QCOMPARE(QString(prefs.ffmpeg_executable), QString("new base36")); + QCOMPARE(prefs.o2consumption, 37); + QCOMPARE(prefs.pscr_ratio, 38); + QCOMPARE(prefs.use_default_file, true); + QCOMPARE(tst->diveshareExport_uid(), QString("uid2")); + QCOMPARE(tst->diveshareExport_private(), true); +} + +void TestQPrefGeneral::test_struct_disk() +{ + // test struct prefs -> disk + + auto tst = qPrefGeneral::instance(); + + prefs.auto_recalculate_thumbnails = true; + prefs.default_cylinder = copy_qstring("base41"); + prefs.default_filename = copy_qstring("base42"); + prefs.default_file_behavior = CLOUD_DEFAULT_FILE; + prefs.defaultsetpoint = 44; + prefs.extract_video_thumbnails = true; + prefs.extract_video_thumbnails_position = 45; + prefs.ffmpeg_executable = copy_qstring("base46"); + prefs.o2consumption = 47; + prefs.pscr_ratio = 48; + prefs.use_default_file = true; + + tst->sync(); + prefs.auto_recalculate_thumbnails = false; + prefs.default_cylinder = copy_qstring("error"); + prefs.default_filename = copy_qstring("error"); + prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE; + prefs.defaultsetpoint = 14; + prefs.extract_video_thumbnails = false; + prefs.extract_video_thumbnails_position = 15; + prefs.ffmpeg_executable = copy_qstring("error"); + prefs.o2consumption = 17; + prefs.pscr_ratio = 18; + prefs.use_default_file = false; + + tst->load(); + QCOMPARE(prefs.auto_recalculate_thumbnails, true); + QCOMPARE(QString(prefs.default_cylinder), QString("base41")); + QCOMPARE(QString(prefs.default_filename), QString("base42")); + QCOMPARE(prefs.default_file_behavior, CLOUD_DEFAULT_FILE); + QCOMPARE(prefs.defaultsetpoint, 44); + QCOMPARE(prefs.extract_video_thumbnails, true); + QCOMPARE(prefs.extract_video_thumbnails_position, 45); + QCOMPARE(QString(prefs.ffmpeg_executable), QString("base46")); + QCOMPARE(prefs.o2consumption, 47); + QCOMPARE(prefs.pscr_ratio, 48); + QCOMPARE(prefs.use_default_file, true); +} + +void TestQPrefGeneral::test_multiple() +{ + // test multiple instances have the same information + + prefs.o2consumption = 17; + auto tst_direct = new qPrefGeneral; + + prefs.pscr_ratio = 18; + auto tst = qPrefGeneral::instance(); + + QCOMPARE(tst->o2consumption(), tst_direct->o2consumption()); + QCOMPARE(tst->pscr_ratio(), tst_direct->pscr_ratio()); + QCOMPARE(tst_direct->o2consumption(), 17); + QCOMPARE(tst_direct->pscr_ratio(), 18); +} + +#define TEST(METHOD, VALUE) \ + QCOMPARE(METHOD, VALUE); \ + general->sync(); \ + general->load(); \ + QCOMPARE(METHOD, VALUE); + +void TestQPrefGeneral::test_oldPreferences() +{ + auto general = qPrefGeneral::instance(); + + general->set_default_filename("filename"); + general->set_default_cylinder("cylinder_2"); + general->set_default_file_behavior(LOCAL_DEFAULT_FILE); + general->set_defaultsetpoint(0); + general->set_o2consumption(0); + general->set_pscr_ratio(0); + general->set_use_default_file(true); + + TEST(general->default_filename(), QStringLiteral("filename")); + TEST(general->default_cylinder(), QStringLiteral("cylinder_2")); + TEST(general->default_file_behavior(), LOCAL_DEFAULT_FILE); // since we have a default file, here it returns + TEST(general->defaultsetpoint(), 0); + TEST(general->o2consumption(), 0); + TEST(general->pscr_ratio(), 0); + TEST(general->use_default_file(), true); + + general->set_default_filename("no_file_name"); + general->set_default_cylinder("cylinder_1"); + //TODOl: Change this to a enum. + general->set_default_file_behavior(CLOUD_DEFAULT_FILE); + + general->set_defaultsetpoint(1); + general->set_o2consumption(1); + general->set_pscr_ratio(1); + general->set_use_default_file(false); + + TEST(general->default_filename(), QStringLiteral("no_file_name")); + TEST(general->default_cylinder(), QStringLiteral("cylinder_1")); + TEST(general->default_file_behavior(), CLOUD_DEFAULT_FILE); + TEST(general->defaultsetpoint(), 1); + TEST(general->o2consumption(), 1); + TEST(general->pscr_ratio(), 1); + TEST(general->use_default_file(), false); +} + +QTEST_MAIN(TestQPrefGeneral) diff --git a/tests/testqPrefAnimations.h b/tests/testqPrefGeneral.h index f0ed4a195..73a223396 100644 --- a/tests/testqPrefAnimations.h +++ b/tests/testqPrefGeneral.h @@ -1,11 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 -#ifndef TESTQPREFANIMATIONS_H -#define TESTQPREFANIMATIONS_H +#ifndef TESTQPREFGENERAL_H +#define TESTQPREFGENERAL_H #include <QObject> -class TestQPrefAnimations : public QObject { +class TestQPrefGeneral : public QObject { Q_OBJECT + private slots: void initTestCase(); void test_struct_get(); @@ -13,6 +14,7 @@ private slots: void test_set_load_struct(); void test_struct_disk(); void test_multiple(); + void test_oldPreferences(); }; -#endif // TESTQPREFANIMATIONS_H +#endif // TESTQPREFGENERAL_H diff --git a/tests/testqPrefGeocoding.cpp b/tests/testqPrefGeocoding.cpp new file mode 100644 index 000000000..d7c311474 --- /dev/null +++ b/tests/testqPrefGeocoding.cpp @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "testqPrefGeocoding.h" + +#include "core/pref.h" +#include "core/qthelper.h" +#include "core/settings/qPref.h" + +#include <QTest> + +void TestQPrefGeocoding::initTestCase() +{ + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("SubsurfaceTestQPrefGeocoding"); +} + +void TestQPrefGeocoding::test_struct_get() +{ + // Test struct pref -> get func. + + auto tst = qPrefGeocoding::instance(); + + prefs.geocoding.category[0] = TC_NONE; + prefs.geocoding.category[1] = TC_OCEAN; + prefs.geocoding.category[2] = TC_ADMIN_L1; + + QCOMPARE(tst->first_taxonomy_category(), prefs.geocoding.category[0]); + QCOMPARE(tst->second_taxonomy_category(), prefs.geocoding.category[1]); + QCOMPARE(tst->third_taxonomy_category(), prefs.geocoding.category[2]); +} + +void TestQPrefGeocoding::test_set_struct() +{ + // Test set func -> struct pref + + auto tst = qPrefGeocoding::instance(); + + tst->set_first_taxonomy_category(TC_COUNTRY); + tst->set_second_taxonomy_category(TC_ADMIN_L1); + tst->set_third_taxonomy_category(TC_ADMIN_L2); + + QCOMPARE(prefs.geocoding.category[0], TC_COUNTRY); + QCOMPARE(prefs.geocoding.category[1], TC_ADMIN_L1); + QCOMPARE(prefs.geocoding.category[2], TC_ADMIN_L2); +} + +void TestQPrefGeocoding::test_set_load_struct() +{ + // test set func -> load -> struct pref + + auto tst = qPrefGeocoding::instance(); + + tst->set_first_taxonomy_category(TC_LOCALNAME); + tst->set_second_taxonomy_category(TC_ADMIN_L3); + tst->set_third_taxonomy_category(TC_NR_CATEGORIES); + + prefs.geocoding.category[0] = TC_NONE; + prefs.geocoding.category[1] = TC_OCEAN; + prefs.geocoding.category[2] = TC_ADMIN_L1; + + tst->load(); + QCOMPARE(prefs.geocoding.category[0], TC_LOCALNAME); + QCOMPARE(prefs.geocoding.category[1], TC_ADMIN_L3); + QCOMPARE(prefs.geocoding.category[2], TC_NR_CATEGORIES); +} + +void TestQPrefGeocoding::test_struct_disk() +{ + // test struct prefs -> disk + + auto tst = qPrefGeocoding::instance(); + + prefs.geocoding.category[0] = TC_NONE; + prefs.geocoding.category[1] = TC_OCEAN; + prefs.geocoding.category[2] = TC_ADMIN_L1; + + tst->sync(); + prefs.geocoding.category[0] = TC_ADMIN_L2; + prefs.geocoding.category[1] = TC_ADMIN_L2; + prefs.geocoding.category[2] = TC_ADMIN_L2; + + tst->load(); + QCOMPARE(prefs.geocoding.category[0], TC_NONE); + QCOMPARE(prefs.geocoding.category[1], TC_OCEAN); + QCOMPARE(prefs.geocoding.category[2], TC_ADMIN_L1); +} + +void TestQPrefGeocoding::test_multiple() +{ + // test multiple instances have the same information + + prefs.geocoding.category[0] = TC_NONE; + auto tst_direct = new qPrefGeocoding; + + prefs.geocoding.category[1] = TC_OCEAN; + auto tst = qPrefGeocoding::instance(); + + QCOMPARE(tst->first_taxonomy_category(), tst_direct->first_taxonomy_category()); + QCOMPARE(tst->second_taxonomy_category(), tst_direct->second_taxonomy_category()); + QCOMPARE(tst->first_taxonomy_category(), TC_NONE); + QCOMPARE(tst->second_taxonomy_category(), TC_OCEAN); +} + +#define TEST(METHOD, VALUE) \ + QCOMPARE(METHOD, VALUE); \ + geo->sync(); \ + geo->load(); \ + QCOMPARE(METHOD, VALUE); + +void TestQPrefGeocoding::test_oldPreferences() +{ + auto geo = qPrefGeocoding::instance(); + geo->set_first_taxonomy_category(TC_NONE); + geo->set_second_taxonomy_category(TC_OCEAN); + geo->set_third_taxonomy_category(TC_COUNTRY); + + TEST(geo->first_taxonomy_category(), TC_NONE); + TEST(geo->second_taxonomy_category(), TC_OCEAN); + TEST(geo->third_taxonomy_category(), TC_COUNTRY); + + geo->set_first_taxonomy_category(TC_OCEAN); + geo->set_second_taxonomy_category(TC_COUNTRY); + geo->set_third_taxonomy_category(TC_NONE); + + TEST(geo->first_taxonomy_category(), TC_OCEAN); + TEST(geo->second_taxonomy_category(), TC_COUNTRY); + TEST(geo->third_taxonomy_category(), TC_NONE); +} + +QTEST_MAIN(TestQPrefGeocoding) diff --git a/tests/testqPrefGeocoding.h b/tests/testqPrefGeocoding.h new file mode 100644 index 000000000..deb02dc67 --- /dev/null +++ b/tests/testqPrefGeocoding.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef TESTQPREFGEOCODING_H +#define TESTQPREFGEOCODING_H + +#include <QObject> + +class TestQPrefGeocoding : public QObject { + Q_OBJECT + +private slots: + void initTestCase(); + void test_struct_get(); + void test_set_struct(); + void test_set_load_struct(); + void test_struct_disk(); + void test_multiple(); + void test_oldPreferences(); +}; + +#endif // TESTQPREFGEOCODING_H diff --git a/tests/testqPrefLanguage.cpp b/tests/testqPrefLanguage.cpp new file mode 100644 index 000000000..3f6db017e --- /dev/null +++ b/tests/testqPrefLanguage.cpp @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "testqPrefLanguage.h" + +#include "core/pref.h" +#include "core/qthelper.h" +#include "core/settings/qPref.h" + +#include <QTest> + +void TestQPrefLanguage::initTestCase() +{ + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("SubsurfaceTestQPrefLanguage"); +} + +void TestQPrefLanguage::test_struct_get() +{ + // Test struct pref -> get func. + + auto tst = qPrefLanguage::instance(); + + prefs.date_format = copy_qstring("new date format"); + prefs.date_format_override = true; + prefs.date_format_short = copy_qstring("new short format"); + prefs.locale.language = copy_qstring("new lang format"); + prefs.locale.lang_locale = copy_qstring("new loc lang format"); + prefs.time_format = copy_qstring("new time format"); + prefs.time_format_override = true; + prefs.locale.use_system_language = true; + + QCOMPARE(tst->date_format(), QString(prefs.date_format)); + QCOMPARE(tst->date_format_override(), prefs.date_format_override); + QCOMPARE(tst->date_format_short(), QString(prefs.date_format_short)); + QCOMPARE(tst->language(), QString(prefs.locale.language)); + QCOMPARE(tst->lang_locale(), QString(prefs.locale.lang_locale)); + QCOMPARE(tst->time_format(), QString(prefs.time_format)); + QCOMPARE(tst->time_format_override(), prefs.time_format_override); + QCOMPARE(tst->use_system_language(), prefs.locale.use_system_language); +} + +void TestQPrefLanguage::test_set_struct() +{ + // Test set func -> struct pref + + auto tst = qPrefLanguage::instance(); + + tst->set_date_format("new date2"); + tst->set_date_format_override(false); + tst->set_date_format_short("new short2"); + tst->set_language("new lang format"); + tst->set_lang_locale("new loc lang2"); + tst->set_time_format("new time2"); + tst->set_time_format_override(false); + tst->set_use_system_language(false); + + QCOMPARE(tst->date_format(), QString("new date2")); + QCOMPARE(tst->date_format_override(), false); + QCOMPARE(tst->date_format_short(), QString("new short2")); + QCOMPARE(tst->language(), QString("new lang format")); + QCOMPARE(tst->lang_locale(), QString("new loc lang2")); + QCOMPARE(tst->time_format(), QString("new time2")); + QCOMPARE(tst->time_format_override(), false); + QCOMPARE(tst->use_system_language(), false); +} + +void TestQPrefLanguage::test_set_load_struct() +{ + // test set func -> load -> struct pref + + auto tst = qPrefLanguage::instance(); + + tst->set_date_format("new date3"); + tst->set_date_format_override(true); + tst->set_date_format_short("new short3"); + tst->set_language("new lang format3"); + tst->set_lang_locale("new loc lang3"); + tst->set_time_format("new time3"); + tst->set_time_format_override(true); + tst->set_use_system_language(true); + + prefs.date_format = copy_qstring("error3"); + prefs.date_format_override = false; + prefs.date_format_short = copy_qstring("error3"); + prefs.locale.language = copy_qstring("error3"); + prefs.locale.lang_locale = copy_qstring("error3"); + prefs.time_format = copy_qstring("error3"); + prefs.time_format_override = false; + prefs.locale.use_system_language = false; + + tst->load(); + QCOMPARE(QString(prefs.date_format), QString("new date3")); + QCOMPARE(prefs.date_format_override, true); + QCOMPARE(QString(prefs.date_format_short), QString("new short3")); + QCOMPARE(QString(prefs.locale.language), QString("new lang format3")); + QCOMPARE(QString(prefs.locale.lang_locale), QString("new loc lang3")); + QCOMPARE(QString(prefs.time_format), QString("new time3")); + QCOMPARE(prefs.time_format_override, true); + QCOMPARE(prefs.locale.use_system_language, true); +} + +void TestQPrefLanguage::test_struct_disk() +{ + // test struct prefs -> disk + + auto tst = qPrefLanguage::instance(); + + prefs.date_format = copy_qstring("new date format"); + prefs.date_format_override = true; + prefs.date_format_short = copy_qstring("new short format"); + prefs.locale.language = copy_qstring("new lang format"); + prefs.locale.lang_locale = copy_qstring("new loc lang format"); + prefs.time_format = copy_qstring("new time format"); + prefs.time_format_override = true; + prefs.locale.use_system_language = true; + + tst->sync(); + prefs.date_format = copy_qstring("error3"); + prefs.date_format_override = false; + prefs.date_format_short = copy_qstring("error3"); + prefs.locale.language = copy_qstring("error3"); + prefs.locale.lang_locale = copy_qstring("error3"); + prefs.time_format = copy_qstring("error3"); + prefs.time_format_override = false; + prefs.locale.use_system_language = false; + + tst->load(); + QCOMPARE(QString(prefs.date_format), QString("new date format")); + QCOMPARE(prefs.date_format_override, true); + QCOMPARE(QString(prefs.date_format_short), QString("new short format")); + QCOMPARE(QString(prefs.locale.language), QString("new lang format")); + QCOMPARE(QString(prefs.locale.lang_locale), QString("new loc lang format")); + QCOMPARE(QString(prefs.time_format), QString("new time format")); + QCOMPARE(prefs.time_format_override, true); + QCOMPARE(prefs.locale.use_system_language, true); +} + +void TestQPrefLanguage::test_multiple() +{ + // test multiple instances have the same information + + prefs.locale.use_system_language = false; + auto tst_direct = new qPrefLanguage; + + prefs.time_format_override = true; + auto tst = qPrefLanguage::instance(); + + QCOMPARE(tst->use_system_language(), tst_direct->use_system_language()); + QCOMPARE(tst->time_format_override(), tst_direct->time_format_override()); + QCOMPARE(tst_direct->use_system_language(), false); + QCOMPARE(tst_direct->time_format_override(), true); +} + +#define TEST(METHOD, VALUE) \ + QCOMPARE(METHOD, VALUE); \ + language->sync(); \ + language->load(); \ + QCOMPARE(METHOD, VALUE); + +void TestQPrefLanguage::test_oldPreferences() +{ + auto language = qPrefLanguage::instance(); + language->set_lang_locale("en_US"); + language->set_language("en"); + language->set_time_format("hh:mm"); + language->set_date_format("dd/mm/yy"); + language->set_date_format_short("dd/mm"); + language->set_time_format_override(false); + language->set_date_format_override(false); + language->set_use_system_language(false); + + TEST(language->lang_locale(), QStringLiteral("en_US")); + TEST(language->language(), QStringLiteral("en")); + TEST(language->time_format(), QStringLiteral("hh:mm")); + TEST(language->date_format(), QStringLiteral("dd/mm/yy")); + TEST(language->date_format_short(), QStringLiteral("dd/mm")); + TEST(language->time_format_override(), false); + TEST(language->date_format_override(), false); + TEST(language->use_system_language(), false); + + language->set_lang_locale("en_EN"); + language->set_language("br"); + language->set_time_format("mm:hh"); + language->set_date_format("yy/mm/dd"); + language->set_date_format_short("dd/yy"); + language->set_time_format_override(true); + language->set_date_format_override(true); + language->set_use_system_language(true); + + TEST(language->lang_locale(), QStringLiteral("en_EN")); + TEST(language->language(), QStringLiteral("br")); + TEST(language->time_format(), QStringLiteral("mm:hh")); + TEST(language->date_format(), QStringLiteral("yy/mm/dd")); + TEST(language->date_format_short(), QStringLiteral("dd/yy")); + TEST(language->time_format_override(), true); + TEST(language->date_format_override(), true); + TEST(language->use_system_language(), true); + +} + +QTEST_MAIN(TestQPrefLanguage) diff --git a/tests/testqPrefLanguage.h b/tests/testqPrefLanguage.h new file mode 100644 index 000000000..c10b99930 --- /dev/null +++ b/tests/testqPrefLanguage.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef TESTQPREFLANGUAGE_H +#define TESTQPREFLANGUAGE_H + +#include <QObject> + +class TestQPrefLanguage : public QObject { + Q_OBJECT + +private slots: + void initTestCase(); + void test_struct_get(); + void test_set_struct(); + void test_set_load_struct(); + void test_struct_disk(); + void test_multiple(); + void test_oldPreferences(); +}; + +#endif // TESTQPREFLANGUAGE_H diff --git a/tests/testqPrefPartialPressureGas.cpp b/tests/testqPrefPartialPressureGas.cpp new file mode 100644 index 000000000..5e5c090ab --- /dev/null +++ b/tests/testqPrefPartialPressureGas.cpp @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "testqPrefPartialPressureGas.h" + +#include "core/pref.h" +#include "core/qthelper.h" +#include "core/settings/qPref.h" + +#include <QTest> + +void TestQPrefPartialPressureGas::initTestCase() +{ + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("SubsurfaceTestQPrefPartialPressureGas"); +} + +void TestQPrefPartialPressureGas::test_struct_get() +{ + // Test struct pref -> get func. + + auto tst = qPrefPartialPressureGas::instance(); + + prefs.pp_graphs.phe = true; + prefs.pp_graphs.phe_threshold = 21.2; + prefs.pp_graphs.pn2 = true; + prefs.pp_graphs.pn2_threshold = 21.3; + prefs.pp_graphs.po2 = true; + prefs.pp_graphs.po2_threshold_max = 21.4; + prefs.pp_graphs.po2_threshold_min = 21.5; + + QCOMPARE(tst->phe(), prefs.pp_graphs.phe); + QCOMPARE(tst->phe_threshold(), prefs.pp_graphs.phe_threshold); + QCOMPARE(tst->pn2(), prefs.pp_graphs.pn2); + QCOMPARE(tst->pn2_threshold(), prefs.pp_graphs.pn2_threshold); + QCOMPARE(tst->po2(), prefs.pp_graphs.po2); + QCOMPARE(tst->po2_threshold_max(), prefs.pp_graphs.po2_threshold_max); + QCOMPARE(tst->po2_threshold_min(), prefs.pp_graphs.po2_threshold_min); +} + +void TestQPrefPartialPressureGas::test_set_struct() +{ + // Test set func -> struct pref + + auto tst = qPrefPartialPressureGas::instance(); + + tst->set_phe(false); + tst->set_phe_threshold(22.2); + tst->set_pn2(false); + tst->set_pn2_threshold(22.3); + tst->set_po2(false); + tst->set_po2_threshold_max(22.4); + tst->set_po2_threshold_min(22.5); + + QCOMPARE(prefs.pp_graphs.phe, false); + QCOMPARE(prefs.pp_graphs.phe_threshold, 22.2); + QCOMPARE(prefs.pp_graphs.pn2, false); + QCOMPARE(prefs.pp_graphs.pn2_threshold, 22.3); + QCOMPARE(prefs.pp_graphs.po2, false); + QCOMPARE(prefs.pp_graphs.po2_threshold_max, 22.4); + QCOMPARE(prefs.pp_graphs.po2_threshold_min, 22.5); +} + +void TestQPrefPartialPressureGas::test_set_load_struct() +{ + // test set func -> load -> struct pref + + auto tst = qPrefPartialPressureGas::instance(); + + tst->set_phe(true); + tst->set_phe_threshold(23.2); + tst->set_pn2(true); + tst->set_pn2_threshold(23.3); + tst->set_po2(true); + tst->set_po2_threshold_max(23.4); + tst->set_po2_threshold_min(23.5); + + prefs.pp_graphs.phe = false; + prefs.pp_graphs.phe_threshold = 21.2; + prefs.pp_graphs.pn2 = false; + prefs.pp_graphs.pn2_threshold = 21.3; + prefs.pp_graphs.po2 = false; + prefs.pp_graphs.po2_threshold_max = 21.4; + prefs.pp_graphs.po2_threshold_min = 21.5; + + tst->load(); + QCOMPARE(prefs.pp_graphs.phe, true); + QCOMPARE(prefs.pp_graphs.phe_threshold, 23.2); + QCOMPARE(prefs.pp_graphs.pn2, true); + QCOMPARE(prefs.pp_graphs.pn2_threshold, 23.3); + QCOMPARE(prefs.pp_graphs.po2, true); + QCOMPARE(prefs.pp_graphs.po2_threshold_max, 23.4); + QCOMPARE(prefs.pp_graphs.po2_threshold_min, 23.5); +} + +void TestQPrefPartialPressureGas::test_struct_disk() +{ + // test struct prefs -> disk + + auto tst = qPrefPartialPressureGas::instance(); + + prefs.pp_graphs.phe = false; + prefs.pp_graphs.phe_threshold = 24.2; + prefs.pp_graphs.pn2 = false; + prefs.pp_graphs.pn2_threshold = 24.3; + prefs.pp_graphs.po2 = false; + prefs.pp_graphs.po2_threshold_max = 24.4; + prefs.pp_graphs.po2_threshold_min = 24.5; + + tst->sync(); + prefs.pp_graphs.phe = true; + prefs.pp_graphs.phe_threshold = 1.2; + prefs.pp_graphs.pn2 = true; + prefs.pp_graphs.pn2_threshold = 1.3; + prefs.pp_graphs.po2 = true; + prefs.pp_graphs.po2_threshold_max = 1.4; + prefs.pp_graphs.po2_threshold_min = 1.5; + + tst->load(); + QCOMPARE(prefs.pp_graphs.phe, false); + QCOMPARE(prefs.pp_graphs.phe_threshold, 24.2); + QCOMPARE(prefs.pp_graphs.pn2, false); + QCOMPARE(prefs.pp_graphs.pn2_threshold, 24.3); + QCOMPARE(prefs.pp_graphs.po2, false); + QCOMPARE(prefs.pp_graphs.po2_threshold_max, 24.4); + QCOMPARE(prefs.pp_graphs.po2_threshold_min, 24.5); +} + +void TestQPrefPartialPressureGas::test_multiple() +{ + // test multiple instances have the same information + + prefs.pp_graphs.phe_threshold = 2.2; + auto tst_direct = new qPrefPartialPressureGas; + + prefs.pp_graphs.pn2_threshold = 2.3; + auto tst = qPrefPartialPressureGas::instance(); + + QCOMPARE(tst->phe_threshold(), tst_direct->phe_threshold()); + QCOMPARE(tst->pn2_threshold(), tst_direct->pn2_threshold()); + QCOMPARE(tst_direct->phe_threshold(), 2.2); + QCOMPARE(tst_direct->pn2_threshold(), 2.3); +} + +#define TEST(METHOD, VALUE) \ + QCOMPARE(METHOD, VALUE); \ + pp->sync(); \ + pp->load(); \ + QCOMPARE(METHOD, VALUE); + +void TestQPrefPartialPressureGas::test_oldPreferences() +{ + auto pp = qPrefPartialPressureGas::instance(); + pp->set_pn2(false); + pp->set_phe(false); + pp->set_po2(false); + pp->set_po2_threshold_min(1.0); + pp->set_po2_threshold_max(2.0); + pp->set_pn2_threshold(3.0); + pp->set_phe_threshold(4.0); + + TEST(pp->pn2(), false); + TEST(pp->phe(), false); + TEST(pp->po2(), false); + TEST(pp->pn2_threshold(), 3.0); + TEST(pp->phe_threshold(), 4.0); + TEST(pp->po2_threshold_min(), 1.0); + TEST(pp->po2_threshold_max(), 2.0); + + pp->set_pn2(true); + pp->set_phe(true); + pp->set_po2(true); + pp->set_po2_threshold_min(4.0); + pp->set_po2_threshold_max(5.0); + pp->set_pn2_threshold(6.0); + pp->set_phe_threshold(7.0); + + TEST(pp->pn2(), true); + TEST(pp->phe(), true); + TEST(pp->po2(), true); + TEST(pp->pn2_threshold(), 6.0); + TEST(pp->phe_threshold(), 7.0); + TEST(pp->po2_threshold_min(), 4.0); + TEST(pp->po2_threshold_max(), 5.0); + +} + +QTEST_MAIN(TestQPrefPartialPressureGas) diff --git a/tests/testqPrefPartialPressureGas.h b/tests/testqPrefPartialPressureGas.h new file mode 100644 index 000000000..28c1b20a3 --- /dev/null +++ b/tests/testqPrefPartialPressureGas.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef TESTQPREFPARTIALPRESSUREGAS_H +#define TESTQPREFPARTIALPRESSUREGAS_H + +#include <QObject> + +class TestQPrefPartialPressureGas : public QObject { + Q_OBJECT + +private slots: + void initTestCase(); + void test_struct_get(); + void test_set_struct(); + void test_set_load_struct(); + void test_struct_disk(); + void test_multiple(); + void test_oldPreferences(); +}; + +#endif // TESTQPREFPARTIALPRESSUREGAS_H diff --git a/tests/testqPrefUpdateManager.cpp b/tests/testqPrefUpdateManager.cpp index 166fea032..4dc3c2696 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,14 @@ 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")); + tst->set_uuidString("uuid"); 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")); + QCOMPARE(tst->uuidString(), QString("uuid")); } void TestQPrefUpdateManager::test_set_load_struct() @@ -57,22 +59,24 @@ 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); tst->set_last_version_used("last_version2"); tst->set_next_check(QDate::fromString("11/09/1957", "dd/MM/yyyy")); + tst->set_uuidString("uuid2"); 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")); + QCOMPARE(tst->uuidString(), QString("uuid2")); // dont_check_exists is NOT stored on disk QCOMPARE(prefs.update_manager.dont_check_exists, true); @@ -87,13 +91,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 +124,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(); \ diff --git a/tests/testqPrefUpdateManager.h b/tests/testqPrefUpdateManager.h index 5dc58e0d2..baa8d3489 100644 --- a/tests/testqPrefUpdateManager.h +++ b/tests/testqPrefUpdateManager.h @@ -15,6 +15,7 @@ private slots: void test_struct_disk(); void test_multiple(); void test_oldPreferences(); + void test_next_check(); }; #endif // TESTQPREFUPDATEMANAGER_H diff --git a/tests/testrenumber.cpp b/tests/testrenumber.cpp index 9b5a7f4af..f6a628083 100644 --- a/tests/testrenumber.cpp +++ b/tests/testrenumber.cpp @@ -7,14 +7,14 @@ void TestRenumber::setup() { - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &dive_table), 0); process_dives(false, false); dive_table.preexisting = dive_table.nr; } void TestRenumber::testMerge() { - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47b.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47b.xml", &dive_table), 0); process_dives(true, false); QCOMPARE(dive_table.nr, 1); QCOMPARE(unsaved_changes(), 1); @@ -24,7 +24,7 @@ void TestRenumber::testMerge() void TestRenumber::testMergeAndAppend() { - QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47c.xml"), 0); + QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47c.xml", &dive_table), 0); process_dives(true, false); QCOMPARE(dive_table.nr, 2); QCOMPARE(unsaved_changes(), 1); diff --git a/tests/tst_qPrefAnimations.qml b/tests/tst_qPrefAnimations.qml deleted file mode 100644 index 01e59fa42..000000000 --- a/tests/tst_qPrefAnimations.qml +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -import QtQuick 2.6 -import QtTest 1.2 -import org.subsurfacedivelog.mobile 1.0 - -TestCase { - name: "qPrefAnimations" - - SsrfAnimationsPrefs { - id: tst - } - - function test_variables() { - var x1 = tst.animation_speed; - tst.animation_speed = 37 - compare(tst.animation_speed, 37) - } - -} diff --git a/tests/tst_qPrefDisplay.qml b/tests/tst_qPrefDisplay.qml index eb4e11e30..e25f17bf8 100644 --- a/tests/tst_qPrefDisplay.qml +++ b/tests/tst_qPrefDisplay.qml @@ -11,21 +11,68 @@ TestCase { } function test_variables() { + var x0 = display.animation_speed + display.animation_speed = 37 + compare(display.animation_speed, 37) + var x1 = display.divelist_font display.divelist_font = "helvitica" compare(display.divelist_font, "helvitica") + var x2 = display.font_size display.font_size = 12.0 compare(display.font_size, 12.0) + var x3 = display.display_invalid_dives display.display_invalid_dives = !x3 compare(display.display_invalid_dives, !x3) + var x4 = display.show_developer display.show_developer = !x4 compare(display.show_developer, !x4) + var x5 = display.theme display.theme = "myColor" compare(display.theme, "myColor") - } +//TBD var x6 = display.tooltip_position +//TBD display.tooltip_position = ?? +//TBD compare(display.tooltip_position, ??) + + var x7 = display.lastDir + display.lastDir = "myDir" + compare(display.lastDir, "myDir") + + var x8 = display.UserSurvey + display.UserSurvey = "yes" + compare(display.UserSurvey, "yes") + +//TBD var x9 = display.mainSplitter +//TBD display.mainSplitter = ??? +//TBD compare(display.mainSplitter, ???) + +//TBD var x10 = display.topSplitter +//TBD display.topSplitter = ??? +//TBD compare(display.topSplitter, ???) + +//TBD var x11 = display.bottomSplitter +//TBD display.bottomSplitter = ??? +//TBD compare(display.bottomSplitter, ???) + + var x12 = display.maximized + display.maximized = true + compare(display.maximized, true) + +//TBD var x13 = display.geometry +//TBD display.geometry = ??? +//TBD compare(display.geometry, ???) + +//TBD var x14 = display.windowState +//TBD display.windowState = ??? +//TBD compare(display.windowState, ???) + + var x15 = display.lastState + display.lastState = 17 + compare(display.lastState, 17) + } } diff --git a/tests/tst_qPrefGeneral.qml b/tests/tst_qPrefGeneral.qml new file mode 100644 index 000000000..5c1669056 --- /dev/null +++ b/tests/tst_qPrefGeneral.qml @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0 +import QtQuick 2.6 +import QtTest 1.2 +import org.subsurfacedivelog.mobile 1.0 + +TestCase { + name: "qPrefGeneral" + + SsrfGeneralPrefs { + id: tst + } + + SsrfPrefs { + id: prefs + } + + function test_variables() { + var x1 = tst.auto_recalculate_thumbnails + tst.auto_recalculate_thumbnails = true + compare(tst.auto_recalculate_thumbnails, true) + + var x2 = tst.default_cylinder + tst.default_cylinder = "my string" + compare(tst.default_cylinder, "my string") + + var x3 = tst.default_filename + tst.default_filename = "my string" + compare(tst.default_filename, "my string") + +//TBD var x4 = tst.default_file_behavior +//TBD tst.default_file_behavior = ?? +//TBD compare(tst.default_file_behavior, ??) + + var x5 = tst.defaultsetpoint + tst.defaultsetpoint = 17 + compare(tst.defaultsetpoint, 17) + + var x6 = tst.extract_video_thumbnails + tst.extract_video_thumbnails = true + compare(tst.extract_video_thumbnails, true) + + var x7 = tst.extract_video_thumbnails_position + tst.extract_video_thumbnails_position = 17 + compare(tst.extract_video_thumbnails_position, 17) + + var x8 = tst.ffmpeg_executable + tst.ffmpeg_executable = "my string" + compare(tst.ffmpeg_executable, "my string") + + var x9 = tst.o2consumption + tst.o2consumption = 17 + compare(tst.o2consumption, 17) + + var x10 = tst.pscr_ratio + tst.pscr_ratio = 17 + compare(tst.pscr_ratio, 17) + + var x11 = tst.use_default_file + tst.use_default_file = true + compare(tst.use_default_file, true) + + var x12 = tst.diveshareExport_uid + tst.diveshareExport_uid = "myUid" + compare(tst.diveshareExport_uid, "myUid") + + var x13 = tst.diveshareExport_private + tst.diveshareExport_private = true + compare(tst.diveshareExport_private, true) + } +} diff --git a/tests/tst_qPrefGeocoding.qml b/tests/tst_qPrefGeocoding.qml new file mode 100644 index 000000000..eb65bb7ed --- /dev/null +++ b/tests/tst_qPrefGeocoding.qml @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +import QtQuick 2.6 +import QtTest 1.2 +import org.subsurfacedivelog.mobile 1.0 + +TestCase { + name: "qPrefGeocoding" + + SsrfGeocodingPrefs { + id: geo + } + + function test_variables() { +//TBD var x1 = geo.first_taxonomy_category +//TBD geo.first_taxonomy_category = ?? +//TBD compare(geo.first_taxonom_categroy, ??) + +//TBD var x2 = geo.second_taxonomy_category +//TBD geo.second_taxonomy_category = ?? +//TBD compare(geo.second_taxonom_categroy, ??) + +//TBD var x3 = geo.third_taxonomy_category +//TBD geo.third_taxonomy_category = ?? +//TBD compare(geo.third_taxonom_categroy, ??) + } +} diff --git a/tests/tst_qPrefLanguage.qml b/tests/tst_qPrefLanguage.qml new file mode 100644 index 000000000..efcc35534 --- /dev/null +++ b/tests/tst_qPrefLanguage.qml @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0 +import QtQuick 2.6 +import QtTest 1.2 +import org.subsurfacedivelog.mobile 1.0 + +TestCase { + name: "qPrefLanguage" + + SsrfLanguagePrefs { + id: tst + } + + SsrfPrefs { + id: prefs + } + + function test_variables() { + var x1 = tst.date_format + tst.date_format = "new date format" + compare(tst.date_format, "new date format") + + var x2 = tst.date_format_override + tst.date_format_override = true + compare(tst.date_format_override, true) + + var x3 = tst.date_format_short + tst.date_format_short = "new short format" + compare(tst.date_format_short, "new short format") + + var x4 = tst.language + tst.language = "new lang format" + compare(tst.language, "new lang format") + + var x5 = tst.lang_locale + tst.lang_locale = "new loc lang format" + compare(tst.lang_locale, "new loc lang format") + + var x6 = tst.time_format + tst.time_format = "new time format" + compare(tst.time_format, "new time format") + + var x7 = tst.time_format_override + tst.time_format_override = true + compare(tst.time_format_override, true) + + var x8 = tst.use_system_language + tst.use_system_language = true + compare(tst.use_system_language, true) + } +} diff --git a/tests/tst_qPrefPartialPressureGas.qml b/tests/tst_qPrefPartialPressureGas.qml new file mode 100644 index 000000000..049ab2b93 --- /dev/null +++ b/tests/tst_qPrefPartialPressureGas.qml @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 +import QtQuick 2.6 +import QtTest 1.2 +import org.subsurfacedivelog.mobile 1.0 + +TestCase { + name: "qPrefPartialPressureGas" + + SsrfPartialPressureGasPrefs { + id: tst + } + + SsrfPrefs { + id: prefs + } + + function test_variables() { + var x1 = tst.phe = true + tst.phe = true + compare(tst.phe, true) + + var x2 = tst.phe_threshold = 21.2 + tst.phe_threshold = 21.2 + compare(tst.phe_threshold, 21.2) + + var x3 = tst.pn2 = true + tst.pn2 = true + compare(tst.pn2, true) + + var x4 = tst.pn2_threshold = 21.3 + tst.pn2_threshold = 21.3 + compare(tst.pn2_threshold, 21.3) + + var x5 = tst.po2 = true + tst.po2 = true + compare(tst.po2, true) + + var x6 = tst.po2_threshold_max = 21.4 + tst.po2_threshold_max = 21.4 + compare(tst.po2_threshold_max, 21.4) + + var x7 = tst.po2_threshold_min = 21.5 + tst.po2_threshold_min = 21.5 + compare(tst.po2_threshold_min, 21.5) + } +} diff --git a/tests/tst_qPrefUpdateManager.qml b/tests/tst_qPrefUpdateManager.qml index 3554f88c8..7b3ee07a0 100644 --- a/tests/tst_qPrefUpdateManager.qml +++ b/tests/tst_qPrefUpdateManager.qml @@ -31,5 +31,9 @@ TestCase { var x4_date = Date.fromLocaleString(Qt.locale(), "01-01-2001", "dd-MM-yyyy") tst.next_check = x4_date compare(tst.next_check, x4_date) + + var x5 = tst.uuidString + tst.uuidString = "jan again" + compare(tst.uuidString, "jan again") } } |