From fe074ccad153791b32c2f62af530091cb025cdee Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 16 Apr 2021 06:47:51 -0700 Subject: cloudstorage: adapt tests The code assumes that prefs.cloud_base_url is non NULL. Allowing that to be NULL makes no sense during normal operation of the app. Yet, most of the tests don't initialize the prefs at all. Making things worse, if we do correctly initialize the prefs (so as to reasonably approximate the behavior when running the app), things break because some of the reference outputs assume that the prefs are unset. This deserves fixing. For now, simply make sure that cloud_base_url is set for all the tests that try to parse files. Additionally, the semantics how cloud_base_url is saved to disk have changed, so adjust the test for those prefs accordingly. Signed-off-by: Dirk Hohndel --- tests/testprofile.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/testprofile.cpp') diff --git a/tests/testprofile.cpp b/tests/testprofile.cpp index cd9d51f0c..66f6eea5c 100644 --- a/tests/testprofile.cpp +++ b/tests/testprofile.cpp @@ -14,6 +14,23 @@ // ..dives/exportprofilereference.csv) and copy the former over the later and commit that change // as well. +void TestProfile::init() +{ + // Set UTF8 text codec as in real applications + QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106)); + + // first, setup the preferences + + // normally we should be able to do this - but it makes this test fail because the reference data + // assume that the prefs are all 0 / false + // copy_prefs(&default_prefs, &prefs); + // instead we just set up the cloud_base_url to prevent parse_file() from crashing + prefs.cloud_base_url = strdup(default_prefs.cloud_base_url); + + QCoreApplication::setOrganizationName("Subsurface"); + QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); + QCoreApplication::setApplicationName("Subsurface"); +} void TestProfile::testProfileExport() { prefs.planner_deco_mode = BUEHLMANN; -- cgit v1.2.3-70-g09d2