mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
cfe20ee5f4
commit
fe074ccad1
9 changed files with 32 additions and 0 deletions
|
@ -13,6 +13,7 @@ void TestAirPressure::initTestCase()
|
|||
{
|
||||
/* we need to manually tell that the resource exists, because we are using it as library. */
|
||||
Q_INIT_RESOURCE(subsurface);
|
||||
prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
|
||||
}
|
||||
|
||||
void TestAirPressure::get_dives()
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
#include "core/divesite.h"
|
||||
#include "core/trip.h"
|
||||
#include "core/file.h"
|
||||
#include "core/pref.h"
|
||||
|
||||
void TestDiveSiteDuplication::testReadV2()
|
||||
{
|
||||
prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf", &dive_table, &trip_table,
|
||||
&dive_site_table, &device_table, &filter_preset_table), 0);
|
||||
QCOMPARE(dive_site_table.nr, 2);
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
#include "core/divesite.h"
|
||||
#include "core/file.h"
|
||||
#include "core/trip.h"
|
||||
#include "core/pref.h"
|
||||
#include <QTextStream>
|
||||
|
||||
void TestMerge::initTestCase()
|
||||
{
|
||||
/* we need to manually tell that the resource exists, because we are using it as library. */
|
||||
Q_INIT_RESOURCE(subsurface);
|
||||
prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
|
||||
}
|
||||
|
||||
void TestMerge::cleanup()
|
||||
|
|
|
@ -35,6 +35,7 @@ void TestParse::initTestCase()
|
|||
{
|
||||
/* we need to manually tell that the resource exists, because we are using it as library. */
|
||||
Q_INIT_RESOURCE(subsurface);
|
||||
prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
|
||||
}
|
||||
|
||||
void TestParse::init()
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "core/picture.h"
|
||||
#include "core/trip.h"
|
||||
#include "core/file.h"
|
||||
#include "core/pref.h"
|
||||
#include <QString>
|
||||
#include <core/qthelper.h>
|
||||
|
||||
|
@ -14,6 +15,7 @@ void TestPicture::initTestCase()
|
|||
{
|
||||
/* we need to manually tell that the resource exists, because we are using it as library. */
|
||||
Q_INIT_RESOURCE(subsurface);
|
||||
prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
|
||||
}
|
||||
|
||||
#define PIC1_NAME "/dives/images/wreck.jpg"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
class TestProfile : public QObject {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void init();
|
||||
void testProfileExport();
|
||||
void testProfileExportVPMB();
|
||||
};
|
||||
|
|
|
@ -76,6 +76,7 @@ void TestQPrefCloudStorage::test_set_load_struct()
|
|||
auto tst = qPrefCloudStorage::instance();
|
||||
|
||||
tst->set_cloud_base_url("t3 base");
|
||||
tst->store_cloud_base_url("t3 base"); // the base URL is no longer automatically saved to disk
|
||||
tst->set_cloud_storage_email("t3 email");
|
||||
tst->set_cloud_storage_email_encoded("t3 email2");
|
||||
tst->set_save_password_local(true);
|
||||
|
@ -114,6 +115,7 @@ void TestQPrefCloudStorage::test_struct_disk()
|
|||
auto tst = qPrefCloudStorage::instance();
|
||||
|
||||
prefs.cloud_base_url = copy_qstring("t4 base");
|
||||
tst->store_cloud_base_url("t4 base"); // the base URL is no longer automatically saved to disk
|
||||
prefs.cloud_storage_email = copy_qstring("t4 email");
|
||||
prefs.cloud_storage_email_encoded = copy_qstring("t4 email2");
|
||||
prefs.save_password_local = true;
|
||||
|
@ -170,8 +172,10 @@ void TestQPrefCloudStorage::test_oldPreferences()
|
|||
auto cloud = qPrefCloudStorage::instance();
|
||||
|
||||
cloud->set_cloud_base_url("test_one");
|
||||
cloud->store_cloud_base_url("test_one");
|
||||
TEST(cloud->cloud_base_url(), QStringLiteral("test_one"));
|
||||
cloud->set_cloud_base_url("test_two");
|
||||
cloud->store_cloud_base_url("test_two");
|
||||
TEST(cloud->cloud_base_url(), QStringLiteral("test_two"));
|
||||
|
||||
cloud->set_cloud_storage_email("tomaz@subsurface.com");
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
#include "core/divesite.h"
|
||||
#include "core/trip.h"
|
||||
#include "core/file.h"
|
||||
#include "core/pref.h"
|
||||
#include <QTextStream>
|
||||
|
||||
void TestRenumber::setup()
|
||||
{
|
||||
prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table), 0);
|
||||
process_loaded_dives();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue