qmapshack-1.10.0/test/ 000755 001750 000144 00000000000 13216664442 015711 5 ustar 00oeichlerx users 000000 000000 qmapshack-1.10.0/test/unittest/ 000755 001750 000144 00000000000 13216664442 017570 5 ustar 00oeichlerx users 000000 000000 qmapshack-1.10.0/test/unittest/CKnownExtension.cpp 000644 001750 000144 00000007362 13023451227 023367 0 ustar 00oeichlerx users 000000 000000 /**********************************************************************************************
Copyright (C) 2016 Christian Eichler code@christian-eichler.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
**********************************************************************************************/
#include "TestHelper.h"
#include "test_QMapShack.h"
#include "gis/gpx/CGpxProject.h"
#include "gis/trk/CGisItemTrk.h"
#include "gis/trk/CKnownExtension.h"
static QStringList GarminTPX1Exts = {"atemp", "wtemp", "depth", "hr", "cad"};
void test_QMapShack::readExtGarminTPX1(const QString &file, const QString &ns)
{
CGpxProject *proj = dynamic_cast(readProjFile(file));
VERIFY_EQUAL(1, proj->childCount());
for(int i = 0; i < proj->childCount(); i++)
{
IGisItem *item = dynamic_cast(proj->child(i));
CGisItemTrk *itemTrk = dynamic_cast(item);
if(nullptr != itemTrk)
{
const CTrackData &trk = itemTrk->getTrackData();
// filter all internal extensions (starting with ::ql:)
QStringList extensions = itemTrk->getExistingDataSources().filter(QRegExp("^((?!::ql:).)*$"));
VERIFY_EQUAL(GarminTPX1Exts.size(), extensions.size());
for(const QString &exp : GarminTPX1Exts)
{
const QString &fullExp = ns + ":TrackPointExtension|" + ns + ":" + exp;
SUBVERIFY(extensions.contains(fullExp), "Missing extension " + fullExp)
}
const fTrkPtGetVal &getAtemp = CKnownExtension::get(ns + ":TrackPointExtension|" + ns + ":atemp").valueFunc;
const fTrkPtGetVal &getWtemp = CKnownExtension::get(ns + ":TrackPointExtension|" + ns + ":wtemp").valueFunc;
const fTrkPtGetVal &getDepth = CKnownExtension::get(ns + ":TrackPointExtension|" + ns + ":depth").valueFunc;
const fTrkPtGetVal &getHR = CKnownExtension::get(ns + ":TrackPointExtension|" + ns + ":hr").valueFunc;
const fTrkPtGetVal &getCad = CKnownExtension::get(ns + ":TrackPointExtension|" + ns + ":cad").valueFunc;
int i = 0;
for(const trkpt_t &trkpt : trk)
{
SUBVERIFY((0. != trkpt.lat) || (0. != trkpt.lon), "Trackpoint has position 0/0");
for(const QString &ext : trkpt.extensions.keys())
{
VERIFY_EQUAL(true, CKnownExtension::isKnown(ext));
}
// try to read values from the file, they start at a specific value and are incremented from trkpt to trkpt
VERIFY_EQUAL( 20 + i, getAtemp(trkpt));
VERIFY_EQUAL( 10 + i, getWtemp(trkpt));
VERIFY_EQUAL(100 + i, getDepth(trkpt));
VERIFY_EQUAL( 90 + i, getHR(trkpt));
VERIFY_EQUAL( 60 + i, getCad(trkpt));
++i;
}
}
}
delete proj;
}
void test_QMapShack::_readExtGarminTPX1_tp1()
{
readExtGarminTPX1(testInput + "gpx/gpx_ext_GarminTPX1_tp1.gpx", "tp1");
}
void test_QMapShack::_readExtGarminTPX1_gpxtpx()
{
readExtGarminTPX1(testInput + "gpx/gpx_ext_GarminTPX1_gpxtpx.gpx", "gpxtpx");
}
qmapshack-1.10.0/test/unittest/CGisItemTrk.cpp 000644 001750 000144 00000003624 12727447634 022436 0 ustar 00oeichlerx users 000000 000000 /**********************************************************************************************
Copyright (C) 2016 Christian Eichler code@christian-eichler.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
**********************************************************************************************/
#include "TestHelper.h"
#include "test_QMapShack.h"
#include "gis/gpx/CGpxProject.h"
#include "gis/trk/CGisItemTrk.h"
#include
void test_QMapShack::_filterDeleteExtension()
{
for(const QString &file : inputFiles)
{
IGisProject *proj = readProjFile(file);
expectedGisProject exp = TestHelper::readExpProj(fileToPath(file) + ".xml");
exp.changed = true; // filtering changes a project
for(int i = 0; i < proj->childCount(); i++)
{
CGisItemTrk *trk = dynamic_cast(proj->child(i));
if(nullptr != trk)
{
expectedTrack &expTrk = exp.trks[trk->getName()];
while(!expTrk.extensions.empty())
{
expectedExtension expExt = expTrk.extensions.take(expTrk.extensions.keys().first());
trk->filterDeleteExtension(expExt.name);
verify(exp, *proj);
}
}
}
delete proj;
}
}
qmapshack-1.10.0/test/unittest/CFitProject.cpp 000644 001750 000144 00000002357 12727447634 022467 0 ustar 00oeichlerx users 000000 000000 /**********************************************************************************************
Copyright (C) 2016 Christian Eichler code@christian-eichler.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
**********************************************************************************************/
#include
#include "TestHelper.h"
#include "test_QMapShack.h"
#include "gis/prj/IGisProject.h"
#include "gis/fit/CFitProject.h"
void test_QMapShack::_readValidFitFiles()
{
delete readProjFile("2015-05-07-22-03-17.fit");
delete readProjFile("Warisouderghem_course.fit");
delete readProjFile("2016-03-12_15-16-50_4_20.fit");
}
qmapshack-1.10.0/test/unittest/TestHelper.h 000644 001750 000144 00000004561 12727447634 022036 0 ustar 00oeichlerx users 000000 000000 /**********************************************************************************************
Copyright (C) 2015-2016 Christian Eichler code@christian-eichler.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
**********************************************************************************************/
#ifndef TESTHELPER_H
#define TESTHELPER_H
#include
#define SUBVERIFY(EXPR, MSG) { \
if(!(EXPR)) { \
throw QString("Verification of `%1` failed: %2 (%3:%4)").arg(#EXPR).arg(MSG).arg(__FILE__).arg(__LINE__); \
} \
}
#define VERIFY_EQUAL(EXP, ACT) \
SUBVERIFY( (EXP == ACT), QTest::toString(QString("Expected `%1`, got `%2`").arg(EXP).arg(ACT)) );
struct expectedWaypoint
{
QString name;
};
struct expectedExtension
{
QString name; //< the name as used in the file
bool known; //< if true, the value has to be known (e.g. CKnownExtension::isKnown() returns true)
bool everyPoint; //< if true, the value has to be set for every single trkpt
bool derived; //< if true, the value is derived by QMS
};
struct expectedTrack
{
QString name;
int colorIdx;
int segCount;
int ptCount;
QHash extensions;
};
struct expectedRoute
{
QString name;
int ptCount;
};
struct expectedArea
{
QString name;
int colorIdx;
int ptCount;
};
struct expectedGisProject
{
QString name;
QString desc;
bool changed;
QHash wpts;
QHash trks;
QHash rtes;
QHash ovls;
};
class TestHelper
{
public:
static QString getTempFileName(const QString &ext);
static expectedGisProject readExpProj(const QString &file);
};
#endif // TESTHELPER_H
qmapshack-1.10.0/test/unittest/CGpxProject.cpp 000644 001750 000144 00000003226 13015033052 022447 0 ustar 00oeichlerx users 000000 000000 /**********************************************************************************************
Copyright (C) 2015 Christian Eichler code@christian-eichler.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
**********************************************************************************************/
#include "TestHelper.h"
#include "test_QMapShack.h"
#include "gis/gpx/CGpxProject.h"
void test_QMapShack::writeReadGpxFile(const QString &file)
{
IGisProject *proj = readProjFile(file);
QString tmpFile = TestHelper::getTempFileName("gpx");
CGpxProject::saveAs(tmpFile, *proj, false);
delete proj;
proj = readProjFile(tmpFile, true, false);
verify(file, *proj);
delete proj;
QFile(tmpFile).remove();
}
void test_QMapShack::_writeReadGpxFile()
{
writeReadGpxFile("qtt_gpx_file0.gpx");
writeReadGpxFile("gpx_ext_GarminTPX1_gpxtpx.gpx");
writeReadGpxFile("gpx_ext_GarminTPX1_tp1.gpx");
writeReadGpxFile("gpx_ext_GarminTPX1_cns.gpx");
writeReadGpxFile("V1.6.0_file1.qms");
writeReadGpxFile("V1.6.0_file2.qms");
}
qmapshack-1.10.0/test/unittest/input/ 000755 001750 000144 00000000000 13216664442 020727 5 ustar 00oeichlerx users 000000 000000 qmapshack-1.10.0/test/unittest/input/qms/ 000755 001750 000144 00000000000 13216664442 021527 5 ustar 00oeichlerx users 000000 000000 qmapshack-1.10.0/test/unittest/input/qms/V1.6.0_file1.qms.xml 000644 001750 000144 00000001472 12727447634 024734 0 ustar 00oeichlerx users 000000 000000
1.6.0 Test1
qmapshack-1.10.0/test/unittest/input/qms/V1.6.0_file2.qms 000644 001750 000144 00000014030 12727447634 024130 0 ustar 00oeichlerx users 000000 000000 QMProj b / h o m e / c h r i s / g p s _ t r a c k s / m i g r a t e D B / V 1 . 6 . 0 _ f i l e 2 . q m s 1 . 6 . 0 T e s t 2 l% { @ a 6 7 7 6 0 5 f c 1 a 0 2 8 4 d e 3 0 d 9 a 8 d a d 6 d c a 5 0 l% 0 : / / i c o n s / 4 8 x 4 8 / S t a r t . p n g I n i t i a l v e r s i o n . Q M a p S h a c k l% 6 : / / i c o n s / 4 8 x 4 8 / E d i t T e x t . p n g C h a n g e d n a m e Q M a p S h a c k l% 06 : / / i c o n s / 4 8 x 4 8 / E d i t T e x t . p n g C h a n g e d n a m e | QMTrk m A
xڽyT I$FEIC=("*)RQPWQՇ h`qAAAuAM o