New tests

This commit is contained in:
ea4k 2024-08-17 21:08:27 +02:00
parent 373068a5a9
commit 0fab0f21ac
10 changed files with 269 additions and 24 deletions

10
.gitignore vendored
View File

@ -192,3 +192,13 @@ tests/tst_world/rcc_wrapper.sh
tests/tst_world/target_wrapper.sh
tests/tst_world/tst_world
tests/tst_world/uic_wrapper.sh
tests/tst_mainwindowinputothers/moc_adif.cpp
tests/tst_mainwindowinputothers/moc_database.cpp
tests/tst_mainwindowinputothers/moc_dataproxy_sqlite.cpp
tests/tst_mainwindowinputothers/moc_db_adif_primary_subdvisions_data.cpp
tests/tst_mainwindowinputothers/moc_mainwindowinputothers.cpp
tests/tst_mainwindowinputothers/moc_predefs.h
tests/tst_mainwindowinputothers/moc_qso.cpp
tests/tst_mainwindowinputothers/moc_queryexecutor.cpp
tests/tst_mainwindowinputothers/moc_utilities.cpp
tests/tst_mainwindowinputothers/target_wrapper.sh

View File

@ -5607,7 +5607,6 @@ bool DataProxy_SQLite::addDXCCEntitySubdivision(const QString &_name, const QStr
return true;
}
QList<PrimarySubdivision> DataProxy_SQLite::getPrimarySubDivisions(const int _entity, const QString &_pref)
{ // Returns the Primary Subdivision for an Entity
// If _pref is empty, and entity >=0 we look for all the subdivisions of the Entity,

View File

@ -72,7 +72,7 @@ MainWindowInputOthers::~MainWindowInputOthers()
void MainWindowInputOthers::createUI()
{
//qDebug() << Q_FUNC_INFO ;
//qDebug() << Q_FUNC_INFO ;
logEvent (Q_FUNC_INFO, "Start", Debug);
entitiesList.clear();
@ -157,19 +157,23 @@ void MainWindowInputOthers::createUI()
tabLayout->addWidget(keepPropCheckBox, 6, 2);
//tabLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(tabLayout);
entitiesList.clear();
entitiesList.append( dataProxy->getEntitiesNames());
if (entitiesList.size()>1)
{
entitiesList.prepend("00-" + tr("Not Identified") + " (000)");
entityNameComboBox->addItems(entitiesList);
}
//qDebug() << Q_FUNC_INFO << ": Trying to add PropModes";
propModeList = dataProxy->getPropModeList();
if (propModeList.size()>1)
{
//qDebug() << Q_FUNC_INFO << ": Adding PropModes";
propModeList.prepend("00 - " + tr("Not - Not Identified"));
propModeComboBox->addItems(propModeList);
}
iotaContinentComboBox->addItems(dataProxy->getContinentShortNames());
iotaNumberLineEdit->setInputMask("000");
iotaNumberLineEdit->setText("000");
@ -232,7 +236,7 @@ void MainWindowInputOthers::setEntitiesList(const QStringList _qs)
void MainWindowInputOthers::setEntity(const int _ent)
{// Select the appropriate entity in the ComboBox
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_ent);
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_ent);
logEvent (Q_FUNC_INFO, "Start", Debug);
if (_ent<=0)
{
@ -249,7 +253,6 @@ void MainWindowInputOthers::setEntity(const int _ent)
int indexC = entityNameComboBox->findText("(" + aux + ")", Qt::MatchEndsWith);
//qDebug() << "MainWindow::selectCorrectEntity: " << pref << "/" << QString::number(indexC);
entityNameComboBox->setCurrentIndex(indexC);
setIOTAContinentFromEntity(_ent);
//updatePrimarySubDivisions(_ent, QString());
@ -284,18 +287,18 @@ QString MainWindowInputOthers::getEntityPrefix()
void MainWindowInputOthers::setPropMode(const QString &_qs, bool _keep)
{
//qDebug() << Q_FUNC_INFO << ": " << _qs << "/ Keep: " << util->boolToQString(_keep);
//qDebug() << Q_FUNC_INFO << ": " << _qs << "/ Keep: " << util->boolToQString(_keep);
logEvent (Q_FUNC_INFO, "Start", Debug);
autoUpdating = true;
if(( propModeComboBox->findText(_qs+" -", Qt::MatchContains))>0)
{
//qDebug() << Q_FUNC_INFO << " PropMode found" ;
//qDebug() << Q_FUNC_INFO << " PropMode found" ;
propModeComboBox->setCurrentIndex( propModeComboBox->findText(_qs+" -", Qt::MatchContains));
keepPropCheckBox->setChecked(_keep);
}
else
{
//qDebug() << Q_FUNC_INFO << " PropMode NOT found" ;
//qDebug() << Q_FUNC_INFO << " PropMode NOT found" ;
propModeComboBox->setCurrentIndex(0);
keepPropCheckBox->setChecked(false);
}
@ -307,22 +310,21 @@ QString MainWindowInputOthers::getPropModeFromComboBox()
{
//logEvent (Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << ": " << propModeComboBox->currentText();
//qDebug() << Q_FUNC_INFO << ": " << propModeComboBox->currentText();
QString _pm = (((propModeComboBox->currentText()).split('-')).at(1)).simplified();
//qDebug() << Q_FUNC_INFO << ": - 10" ;
//qDebug() << Q_FUNC_INFO << ": - 10" ;
QString _n = (((propModeComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << Q_FUNC_INFO << ": - 11: " << _n ;
//qDebug() << Q_FUNC_INFO << ": - 11: " << _n ;
if (_n == "00")
{
//qDebug() << Q_FUNC_INFO << ": - 12" ;
//qDebug() << Q_FUNC_INFO << ": - 12" ;
logEvent (Q_FUNC_INFO, "END-1", Debug);
//qDebug() << Q_FUNC_INFO << ": - 13" ;
return QString();
}
//qDebug() << Q_FUNC_INFO << ": - 14" ;
//qDebug() << Q_FUNC_INFO << ": - 14" ;
logEvent (Q_FUNC_INFO, "END", Debug);
//qDebug() << Q_FUNC_INFO << ": " << _pm ;
//qDebug() << Q_FUNC_INFO << ": " << _pm ;
return _pm;
}
@ -767,7 +769,7 @@ void MainWindowInputOthers::updatePrimarySubdivisionsComboBox(QList<PrimarySubdi
void MainWindowInputOthers::updatePrimarySubDivisions(const int _n, const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << " - Start: " << QString::number(_n) << "/" << _qrz;
//qDebug() << Q_FUNC_INFO << " - Start: " << QString::number(_n) << "/" << _qrz;
if (_n<1)
return;
currentInt = _n;
@ -776,18 +778,18 @@ void MainWindowInputOthers::updatePrimarySubDivisions(const int _n, const QStrin
QString mainPref = dataProxy->getEntityMainPrefix(_n);
QString mainPrefWithArea = mainPref;
int areaNumber = util->getAreaNumberFromCall(_qrz);
//qDebug() << Q_FUNC_INFO << " - AreaNumber: " << QString::number(areaNumber);
//qDebug() << Q_FUNC_INFO << " - AreaNumber: " << QString::number(areaNumber);
if (areaNumber>=0)
{
mainPrefWithArea.append(QString::number(areaNumber));
// mainPref = mainPref + QString::number(areaNumber);
//qDebug() << Q_FUNC_INFO << " - NEW mainPref: " << mainPrefWithArea;
//qDebug() << Q_FUNC_INFO << " - NEW mainPref: " << mainPrefWithArea;
}
QString currentPrefTMP = util->getPrefixFromCall(_qrz, !showAllCheckBox->isChecked());
//qDebug() << Q_FUNC_INFO << " - currentPref: " << QString::number(_n) << "/" << currentPrefTMP;
//qDebug() << Q_FUNC_INFO << " - mainPref: " << QString::number(_n) << "/" << mainPref;
//qDebug() << Q_FUNC_INFO << " - currentPref: " << QString::number(_n) << "/" << currentPrefTMP;
//qDebug() << Q_FUNC_INFO << " - mainPref: " << QString::number(_n) << "/" << mainPref;
setEntity(currentInt);
@ -812,11 +814,11 @@ void MainWindowInputOthers::updatePrimarySubDivisions(const int _n, const QStrin
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, prefUsed));
if (subdivisions.length()<1)
{
//qDebug() << Q_FUNC_INFO << " - Subdivisions is empty, running for the main prefix";
//qDebug() << Q_FUNC_INFO << " - Subdivisions is empty, running for the main prefix";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, mainToUse));
if (subdivisions.length()<1)
{
//qDebug() << Q_FUNC_INFO << " - Subdivisions is empty, running just with the entity";
//qDebug() << Q_FUNC_INFO << " - Subdivisions is empty, running just with the entity";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, QString()));
}
}
@ -825,7 +827,7 @@ void MainWindowInputOthers::updatePrimarySubDivisions(const int _n, const QStrin
if (subdivisions.count()<1)
return;
updatePrimarySubdivisionsComboBox(subdivisions);
//qDebug() << Q_FUNC_INFO << " - END";
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindowInputOthers::slotUSerDefinedADIFComboBoxChanged()

View File

@ -3777,7 +3777,7 @@ void MainWindow::createUIDX()
dxUpLeftTab->addTab(eQSLTabWidget, tr("eQSL"));
dxUpLeftTab->addTab(commentTabWidget, tr("Comment"));
othersTabWidget->setEntitiesList(dataProxy->getEntitiesNames());
// othersTabWidget->setEntitiesList(dataProxy->getEntitiesNames());
dxUpLeftTab->addTab(othersTabWidget, tr("Others"));
dxUpLeftTab->addTab(myDataTabWidget, tr("My Data"));

View File

@ -24,6 +24,7 @@
* *
*****************************************************************************/
#include "utilities.h"
#include "dataproxy_sqlite.h"
//bool c;
Utilities::Utilities(const QString &_parentName)

View File

@ -139,6 +139,7 @@ public:
int getAreaNumberFromCall(const QString &_c);
bool isAOneLetterPrefix(const QChar &_c);
// Write DATE/TIME to DB
QString getDateTimeSQLiteStringFromDateTime(const QDateTime &_d);
QString getDateSQLiteStringFromDate(const QDate &_d);

View File

@ -13,6 +13,7 @@ SUBDIRS=\
tst_database \
tst_locator \
tst_mainwindowinputqso \
tst_mainwindowinputothers \
tst_qso \
tst_setuphamlibnetworkwidget \
tst_setuphamlibserialwidget \

Binary file not shown.

View File

@ -0,0 +1,189 @@
/***************************************************************************
tst_mainqsoentrywidget.h - description
-------------------
begin : Jan 2021
copyright : (C) 2021 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of Testing suite of KLog. *
* *
* KLog 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. *
* *
* The testing suite of KLog 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 Testing suite of KLog. *
* If not, see <https://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
#include <QtTest>
#include <QStringList>
#include "../../src/inputwidgets/mainwindowinputothers.h"
#include "../../src/dataproxy_sqlite.h"
#include "../../src/utilities.h"
class tst_MainWindowInputOthers : public QObject
{
Q_OBJECT
public:
tst_MainWindowInputOthers();
~tst_MainWindowInputOthers();
private slots:
void initTestCase();
void cleanupTestCase();
void test_Constructor();
void test_Setters();
void test_PropModes();
void test_Subdivisions();
/*
void setPropModeFromSat(const QString &_p);
void setModifying(const bool _m);
*/
private:
DataProxy_SQLite *dataProxy;
Utilities *util;
MainWindowInputOthers *mainWindowInputOthers;
};
tst_MainWindowInputOthers::tst_MainWindowInputOthers()
{
//qDebug() << Q_FUNC_INFO << " - Start";
dataProxy = new DataProxy_SQLite(Q_FUNC_INFO, "0.0");
util = new Utilities(Q_FUNC_INFO);
util->setLongPrefixes(dataProxy->getLongPrefixes());
util->setSpecialCalls(dataProxy->getSpecialCallsigns());
mainWindowInputOthers = new MainWindowInputOthers(dataProxy);
mainWindowInputOthers->setEntitiesList(dataProxy->getEntitiesNames());
//qDebug() << Q_FUNC_INFO << " - CurrentProp" << mainWindowInputOthers->getPropModeFromComboBox() ;
}
tst_MainWindowInputOthers::~tst_MainWindowInputOthers(){}
void tst_MainWindowInputOthers::initTestCase()
{
//qDebug() << Q_FUNC_INFO << " - Start";
}
void tst_MainWindowInputOthers::cleanupTestCase()
{
//qDebug() << Q_FUNC_INFO << " - Start";
}
void tst_MainWindowInputOthers::test_Constructor()
{
//qDebug() << Q_FUNC_INFO << " - Start";
//distance = 0;
//age = 0;
//currentInt = 0;
QVERIFY2(mainWindowInputOthers->getDistance() == 0.0, "Wrong Distance");
QVERIFY2(mainWindowInputOthers->getAge() == 0, "Wrong Age");
QVERIFY2(mainWindowInputOthers->getSIG() == QString(), "Wrong Sig");
QVERIFY2(mainWindowInputOthers->getSIG_INFO() == QString(), "Wrong Sig_info");
QVERIFY2(mainWindowInputOthers->getWWFF_Ref() == QString(), "Wrong WWFF_Ref");
QVERIFY2(mainWindowInputOthers->getPOTA_REF() == QString(), "Wrong POTA_Ref");
}
void tst_MainWindowInputOthers::test_Setters()
{
//qDebug() << Q_FUNC_INFO << " - Start";
mainWindowInputOthers->clear();
mainWindowInputOthers->setAge(10.1);
QVERIFY2(mainWindowInputOthers->getAge() == 10.1, "Wrong Age (10.1)");
mainWindowInputOthers->setDistance(10.2);
QVERIFY2(mainWindowInputOthers->getDistance() == 10.2, "Wrong Distance (10.2)");
mainWindowInputOthers->setIOTA("EU-001");
QVERIFY2(mainWindowInputOthers->getIOTA() == "EU-001", "Wrong IOTA (EO-001)");
mainWindowInputOthers->setVUCCGrids("IN80,IN70");
QVERIFY2(mainWindowInputOthers->getVUCCGrids() == "IN80,IN70", "Wrong VUCC Grids");
mainWindowInputOthers->setSOTA("EA4/MD-001");
QVERIFY2(mainWindowInputOthers->getSOTA() == "EA4/MD-001", "Wrong SOTA (EA4/MD-001)");
mainWindowInputOthers->setSIG("S-001");
QVERIFY2(mainWindowInputOthers->getSIG() == "S-001", "Wrong Sig (S-001)");
mainWindowInputOthers->setSIG_INFO("S-001");
QVERIFY2(mainWindowInputOthers->getSIG_INFO() == "S-001", "Wrong Sig Info (S-001)");
mainWindowInputOthers->setPOTA_REF("EA-0151");
QVERIFY2(mainWindowInputOthers->getPOTA_REF() == "EA-0151", "Wrong POTA (EA-151)");
mainWindowInputOthers->setWWFF_Ref("EAFF-0163");
QVERIFY2(mainWindowInputOthers->getWWFF_Ref() == "EAFF-0163", "Wrong WWFF (EAFF-0163)");
//qDebug() << Q_FUNC_INFO << " - Testing PROP_MODE";
mainWindowInputOthers->setPropMode("SAT", false);
QVERIFY2(mainWindowInputOthers->getPropModeFromComboBox() == "SAT", "Wrong PROP_MODE (SAT)");
//qDebug() << Q_FUNC_INFO << " - PROP_MODE-1: " << mainWindowInputOthers->getPropModeFromComboBox();
// mainWindowInputOthers->setPropMode("ES", false); // Wrong PROP_MODE
//qDebug() << Q_FUNC_INFO << " - PROP_MODE-2: " << mainWindowInputOthers->getPropModeFromComboBox();
//QVERIFY2(mainWindowInputOthers->getPropModeFromComboBox() == "SAT", "Wrong wrong PROP_MODE (SAT)");
/*
othersTabWidget->updatePrimarySubDivisions(qsoE.getDXCC(), qsoE.getCall());
othersTabWidget->setState(qsoE.getState());
*/
}
void tst_MainWindowInputOthers::test_PropModes()
{
QStringList propModes;
propModes.clear();
propModes.append(dataProxy->getPropModeList());
QString aux;
foreach (aux, propModes)
{
//qDebug() << Q_FUNC_INFO << " - PropMode: " << aux;
QStringList fields;
fields.clear();
fields.append(aux.split('-'));
QString field = fields.at(1);
field = field.simplified();
//qDebug() << Q_FUNC_INFO << " - ShortName: " << field;
mainWindowInputOthers->setPropMode(field, false);
QVERIFY2(mainWindowInputOthers->getPropModeFromComboBox() == field, "Wrong propMode in list");
}
}
void tst_MainWindowInputOthers::test_Subdivisions()
{
//qDebug() << Q_FUNC_INFO << " - Start";
mainWindowInputOthers->clear(true);
int currentEntity = 281; // 281 = EA
mainWindowInputOthers->setIOTAContinentFromEntity(currentEntity);
//qDebug() << Q_FUNC_INFO << ": IOTACont: " << mainWindowInputOthers->iotaContinentComboBox->currentText();
//qDebug() << Q_FUNC_INFO << ": " << mainWindowInputOthers->getEntityPrefix();
//QVERIFY2( util->isSameFreq (mainWindowInputQSO->getRXPwr(), 1.1), "Wrong RX Pwr");
}
QTEST_MAIN(tst_MainWindowInputOthers)
#include "tst_mainwindowinputothers.moc"

View File

@ -0,0 +1,42 @@
QT += testlib \
core \
gui \
sql \
widgets
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle
TEMPLATE = app
HEADERS += \
../../src/inputwidgets/mainwindowinputothers.h \
../../src/dataproxy_sqlite.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/qso.h \
../../src/utilities.h \
../../src/locator.h \
../../src/adif.h
SOURCES += tst_mainwindowinputothers.cpp \
../../src/inputwidgets/mainwindowinputothers.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/qso.cpp \
../../src/utilities.cpp \
../../src/locator.cpp \
../../src/adif.cpp
isEmpty(QMAKE_LRELEASE) {
win32|os2:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
unix {
!exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = lrelease-qt5 }
} else {
!exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = lrelease }
}
}