Clean up noise and memory leaks in unit tests.

This commit is contained in:
sawinglogz 2020-01-29 09:10:29 -05:00
parent 077f51178f
commit cb576437ab
10 changed files with 43 additions and 21 deletions

View File

@ -8700,7 +8700,6 @@ void PRS1Loader::initChannels()
"??",
STR_UNIT_Seconds,
DEFAULT, QColor("#ffe8f0")));
qDebug() << channel[PRS1_0E].defaultColor();
channel.add(GRP_CPAP, new Channel(PRS1_BND = 0x1159, SPAN, MT_CPAP, SESSION,
"PRS1_BND",
QObject::tr("Breathing Not Detected"),

View File

@ -120,7 +120,7 @@ Machine::Machine(Profile *_profile, MachineID id) : profile(_profile)
Machine::~Machine()
{
saveSessionInfo();
qDebug() << "Destroy Machine" << info.loadername << hex << m_id;
//qDebug() << "Destroy Machine" << info.loadername << hex << m_id;
}
Session *Machine::SessionExists(SessionID session)
{

View File

@ -36,7 +36,7 @@ Preferences *p_pref;
Preferences *p_layout;
Profile *p_profile;
Profile::Profile(QString path)
Profile::Profile(QString path, bool open)
: is_first_day(true),
m_opened(false)
{
@ -58,7 +58,9 @@ Profile::Profile(QString path)
p_filename = p_path + p_name + STR_ext_XML;
m_machlist.clear();
Open(p_filename);
if (open) {
Open(p_filename);
}
Set(STR_GEN_DataFolder, QString("{home}/Profiles/{UserName}"));
@ -80,13 +82,17 @@ Profile::Profile(QString path)
session = new SessionSettings(this);
general = new UserSettings(this);
OpenMachines();
m_opened=true;
if (open) {
OpenMachines();
m_opened=true;
}
}
Profile::~Profile()
{
removeLock();
if (m_opened) {
removeLock();
}
delete user;
delete doctor;

View File

@ -43,8 +43,8 @@ class SessionSettings;
class Profile : public Preferences
{
public:
//! \brief Constructor.. Does not open profile
Profile(QString path);
//! \brief Constructor.. Does not open profile in UI, but loads it from disk by default
Profile(QString path, bool open=true);
virtual ~Profile();

View File

@ -359,13 +359,22 @@ void init()
}
void resetChannels()
void done()
{
schema::channel.channels.clear();
schema::channel.names.clear();
for (auto & c : schema::channel.channels.values()) {
delete c;
}
schema::channel.channels.clear();
schema::channel.groups.clear();
schema_initialized = false;
}
void resetChannels()
{
done();
init();
QList<MachineLoader *> list = GetLoaders();

View File

@ -265,6 +265,7 @@ class ChannelList
extern ChannelList channel;
void init();
void done();
} // namespace schema

View File

@ -11,9 +11,6 @@ Important: One id code per item, DO NOT CHANGE ID NUMBERS!!!
<channel id="0x111e" class="data" name="TestChan1" details="Debugging Channel #2" label="Test #1" unit="" color="pink"/>
<channel id="0x111f" class="data" name="TestChan2" details="Debugging Channel #2" label="Test #2" unit="" color="blue"/>
<channel id="0x1160" class="data" name="RMS9_E01" details="RMS9 Empty 1" label="E01" unit="" color="black"/>
<channel id="0x1161" class="data" name="RMS9_E02" details="RMS9 Empty 2" label="E02" unit="" color="black"/>
<channel id="0x1162" class="data" name="SetPressure" details="Set Pressure" label="Pressure" unit="" color="black"/>
@ -37,7 +34,8 @@ Important: One id code per item, DO NOT CHANGE ID NUMBERS!!!
</group>
<group name="RMS9">
<!-- RESMED Settings -->
<channel id="0xe200" class="setting" scope="!session" name="RMS9Mode" details="PAP Mode" label="PAP Mode" type="integer" link="0x1200">
<!-- there was a link="0x1200" in the RMS9Mode channel, but it seems unlikely to have ever worked. -->
<channel id="0xe200" class="setting" scope="!session" name="RMS9Mode" details="PAP Mode" label="PAP Mode" type="integer">
<Option id="0" value="CPAP"/>
<Option id="1" value="Auto"/>
<Option id="2" value="VPAP"/>

View File

@ -18,8 +18,7 @@ static QString prs1OutputPath(const QString & inpath, const QString & serial, in
void PRS1Tests::initTestCase(void)
{
QString profile_path = TESTDATA_PATH "profile/";
Profiles::Create("test", &profile_path);
p_profile = new Profile(TESTDATA_PATH "profile/", false);
schema::init();
PRS1Loader::Register();
@ -28,6 +27,8 @@ void PRS1Tests::initTestCase(void)
void PRS1Tests::cleanupTestCase(void)
{
delete p_profile;
p_profile = nullptr;
}
@ -348,6 +349,9 @@ void parseAndEmitChunkYaml(const QString & path)
file.close();
}
}
p_profile->removeMachine(m);
delete m;
}
void PRS1Tests::testChunksToYaml()

View File

@ -16,8 +16,8 @@ static void iterateTestCards(const QString & root, void (*action)(const QString
void ResmedTests::initTestCase(void)
{
QString profile_path = TESTDATA_PATH "profile/";
Profiles::Create("test", &profile_path);
p_profile = new Profile(TESTDATA_PATH "profile/", false);
p_pref = new Preferences("Preferences");
p_pref->Open();
AppSetting = new AppWideSetting(p_pref);
@ -29,6 +29,10 @@ void ResmedTests::initTestCase(void)
void ResmedTests::cleanupTestCase(void)
{
delete AppSetting;
delete p_pref;
delete p_profile;
p_profile = nullptr;
}

View File

@ -16,8 +16,7 @@ static QString viatomOutputPath(const QString & inpath, const QString & suffix);
void ViatomTests::initTestCase(void)
{
QString profile_path = TESTDATA_PATH "profile/";
Profiles::Create("test", &profile_path);
p_profile = new Profile(TESTDATA_PATH "profile/", false);
schema::init();
ViatomLoader::Register();
@ -26,6 +25,8 @@ void ViatomTests::initTestCase(void)
void ViatomTests::cleanupTestCase(void)
{
delete p_profile;
p_profile = nullptr;
}