Skip to content

Commit

Permalink
Working on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Aug 22, 2024
1 parent cbe0c94 commit d4cfcea
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,5 @@ tests/tst_mainwindowinputothers/target_wrapper.sh
tests/tst_dataproxy/moc_predefs.h
tests/tst_mainwindowinputothers/tst_mainwindowinputothers
tests/tst_mainwindowinputothers/tst_mainwindowinputothers
tests/tst_mainwindowinputqso/moc_predefs.h
tests/tst_utilities/moc_predefs.h
4 changes: 3 additions & 1 deletion src/Changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

TODO-Bug: EA8, EA9 fails for subdivisions, it is detected as EA
TODO-Bug: CT9 is detected as Portugal but subdivision is properly detected

TODO-Bug: XE Mexico subdivisions are not properly detected

TODO-BUg: Query fails due to "continent" row not existing in entity table - dataproxy::getContinentShortNameFromEntity
TODO-Bug: Query fails due to "continent" row not existing in entity table - dataproxy::getContinentShortNameFromEntity
Make sure the table entity is updated or checked.

TODO-Bug: Add QSOs from wsjtx does not work. Failure close to int QSO::toDB(int _qsoId)
Expand All @@ -16,6 +17,7 @@ Check the bug that makes WSJTX not logging automatically

BUG: When entering/modifying a QSO thre is an error related to awarddxcc table not existing
TODO: After update, it is needed to restart KLog to be able to use the primary subdivisions
TODO-Bug: Review void tst_MainWindowInputQSO::test_GridLineEdit()

WIP: Try to optimize bool DataProxy_SQLite::fillEmptyDXCCInTheLog()
WIP: Working in the update of the table awarddxcc in DB class
Expand Down
6 changes: 3 additions & 3 deletions src/dataproxy_sqlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5671,7 +5671,7 @@ QList<PrimarySubdivision> DataProxy_SQLite::getPrimarySubDivisions(const int _en
}
query.finish();

//qDebug() << Q_FUNC_INFO << " - END" ;
qDebug() << Q_FUNC_INFO << " - END - " << QString::number(list.count()) ;
return list;
}

Expand Down Expand Up @@ -6729,8 +6729,8 @@ QString DataProxy_SQLite::getContinentShortNameFromEntity(const int _n)
// SELECT DISTINCT dxcc, bandid, modeid, id, lognumber from log WHERE qsl_rcvd='Y' OR lotw_qsl_rcvd='Y' GROUP BY dxcc, bandid, modeid
QSqlQuery query;

QString queryString= QString("SELECT continent FROM entity WHERE dxcc='%1'").arg(_n);
//QString queryString= QString("SELECT continent.shortname FROM entity JOIN continent ON entity.continent=continent.shortname WHERE dxcc='%1'").arg(_n);
//QString queryString= QString("SELECT continent FROM entity WHERE dxcc='%1'").arg(_n);
QString queryString= QString("SELECT continent.shortname FROM entity JOIN continent ON entity.continent=continent.id WHERE entity.dxcc='%1'").arg(_n);
bool sqlOK = query.exec(queryString);

if (sqlOK)
Expand Down
2 changes: 2 additions & 0 deletions src/inputwidgets/mainwindowinputothers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ void MainWindowInputOthers::updatePrimarySubdivisionsComboBox(QList<PrimarySubdi
if (listOfSubdivisions.count()<1)
return;

listOfSubdivisions.sort();
listOfSubdivisions.removeDuplicates();
listOfSubdivisions.prepend("00-" + tr("Not selected") + " (000)");

entityPrimDivComboBox->addItems(listOfSubdivisions);
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private slots:
//void slotSRXTextChanged();
//void slotSTXTextChanged();
void slotUpdateLocator(QString _loc);
void slotLocatorTextChanged(const QString &_loc);
KLOG_DEPRECATED void slotLocatorTextChanged(const QString &_loc);
//void slotMyLocatorTextChanged();
void slotFreqTXChanged(const double _fr);
void slotFreqRXChanged(const double _fr);
Expand Down
37 changes: 34 additions & 3 deletions tests/tst_dataproxy/tst_dataproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private slots:
void test_modes_data();
void test_modes();
void test_bands();
void test_EntityAndPrefixes(); // getEntityMainPrefix
void test_continents();
void test_primarySubdivisions();

Expand Down Expand Up @@ -181,15 +182,36 @@ void tst_DataProxy::test_bands()
QVERIFY2(dataProxy->getNameFromBandId (dataProxy->getIdFromBandName ("20M")) == "20M", "Band names and Id failed");
}

void tst_DataProxy::test_EntityAndPrefixes()
{ // getEntityMainPrefix should return:
// EA -> EA (281)
// EA4 -> EA (281)
// EA8 -> EA8
// K -> K
// W -> K
// W1 -> K
// K1 -> K
// KA7 -> K
// KH6 -> KH6

QVERIFY2(dataProxy->getEntityMainPrefix (29) == "EA8", "Main prefix for Canary Island (dxcc=29) failed");
QVERIFY2(dataProxy->getEntityMainPrefix (110) == "KH6", "Main prefix for Hawaii (dxcc=110) failed");
QVERIFY2(dataProxy->getEntityMainPrefix (281) == "EA", "Main prefix for Spain (dxcc=281) failed");
QVERIFY2(dataProxy->getEntityMainPrefix (291) == "K", "Main prefix for the US (dxcc=291) failed");


}

void tst_DataProxy::test_continents()
{
//qDebug() << Q_FUNC_INFO << ": Shortname 281: " << dataProxy->getContinentShortNameFromEntity (281);
QVERIFY2(dataProxy->getContinentShortNameFromEntity (281) == "EU", "Continent for Spain (dxcc=281) failed");
QVERIFY2(dataProxy->getContinentShortNameFromEntity (1) == "NA", "Continent for Canada (dxcc=1) failed");
QVERIFY2(dataProxy->getContinentShortNameFromEntity (100) == "SA", "Continent for Argentina (dxcc=100) failed");
QVERIFY2(dataProxy->getContinentShortNameFromEntity (318) == "AS", "Continent for China (dxcc=318) failed");
QVERIFY2(dataProxy->getContinentShortNameFromEntity (150) == "OC", "Continent for Australia (dxcc=150) failed");
QVERIFY2(dataProxy->getContinentShortNameFromEntity (483) == "AF", "Continent for Togo (dxcc=483) failed");
QVERIFY2(dataProxy->getContinentShortNameFromEntity (13) == "AN", "Continent for Antartica (dxcc=13) failed");
//QVERIFY2(dataProxy->getContinentShortNameFromEntity (13) == "AN", "Continent for Antartica (dxcc=13) failed");
}

void tst_DataProxy::test_primarySubdivisions()
Expand All @@ -201,6 +223,7 @@ void tst_DataProxy::test_primarySubdivisions()

QList<PrimarySubdivision> subdivisions;
subdivisions.clear();
// Testing that the functions are working
subdivisions.append(dataProxy->getPrimarySubDivisions(281, "EA4"));

QVERIFY2(subdivisions.first().name == "Badajoz", "Primary Subdivision first name failed (EA4)");
Expand All @@ -213,14 +236,22 @@ void tst_DataProxy::test_primarySubdivisions()
QVERIFY2(subdivisions.last().cqz == 14, "Primary Subdivision last cqz failed (EA4)");
QVERIFY2(subdivisions.last().ituz == 37, "Primary Subdivision last ituz failed (EA4)");

// Testing that all the divisions have the proper numer

subdivisions.clear();
subdivisions.append(dataProxy->getPrimarySubDivisions(281, QString()));
QVERIFY2(subdivisions.count() == 47, "Primary Subdivision number failed (281 - Spain)");
subdivisions.append(dataProxy->getPrimarySubDivisions(6, QString()));
QVERIFY2(subdivisions.count() == 1, "Primary Subdivision number failed (6 - Canada)");

subdivisions.clear();
subdivisions.append(dataProxy->getPrimarySubDivisions(1, QString()));
QVERIFY2(subdivisions.count() == 20, "Primary Subdivision number failed (1 - Canada)");

subdivisions.clear();
subdivisions.append(dataProxy->getPrimarySubDivisions(281, QString()));
QVERIFY2(subdivisions.count() == 47, "Primary Subdivision number failed (281 - Spain)");



subdivisions.clear();
subdivisions.append(dataProxy->getPrimarySubDivisions(50, QString()));
QVERIFY2(subdivisions.count() == 32, "Primary Subdivision number failed (50 - Mexico)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void tst_MainWindowInputOthers::test_Subdivisions()
int currentEntity = 281; // 281 = EA



mainWindowInputOthers->setIOTAContinentFromEntity(currentEntity);

//qDebug() << Q_FUNC_INFO << ": IOTACont: " << mainWindowInputOthers->iotaContinentComboBox->currentText();
Expand Down
51 changes: 31 additions & 20 deletions tests/tst_mainwindowinputqso/tst_mainwindowinputqso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,37 @@ void tst_MainWindowInputQSO::test_RST2Modes ()
void tst_MainWindowInputQSO::test_GridLineEdit()
{
//qDebug() << Q_FUNC_INFO << " - Start";
QPalette palRed = mainWindowInputQSO->palRed;
QPalette palBlack = mainWindowInputQSO->palBlack;
QPalette palWhite = mainWindowInputQSO->palWhite;

mainWindowInputQSO->locatorLineEdit->setText ("IN");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN");
mainWindowInputQSO->locatorLineEdit->setText ("IN80");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80");
mainWindowInputQSO->locatorLineEdit->setText ("IN80de");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80de");
mainWindowInputQSO->locatorLineEdit->setText ("IN,IN");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN,IN");
mainWindowInputQSO->locatorLineEdit->setText ("IN80,IN80");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80,IN80");
mainWindowInputQSO->locatorLineEdit->setText ("IN80de,IN80de");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80de,IN80de");
mainWindowInputQSO->locatorLineEdit->setText ("IN,IN80");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN,IN80");
mainWindowInputQSO->locatorLineEdit->setText ("IN80de,IN");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80de,IN");
//QPalette palRed = mainWindowInputQSO->palRed;
//QPalette palBlack = mainWindowInputQSO->palBlack;
//QPalette palWhite = mainWindowInputQSO->palWhite;

QPalette palRed; palRed.setColor(QPalette::Text, Qt::red);
QPalette palBlack; palBlack.setColor(QPalette::Text, Qt::black);
QPalette palWhite; palWhite.setColor(QPalette::Text, Qt::white);
//bool darkMode = mainWindowInputQSO->getDarkMode();
//qDebug() << Q_FUNC_INFO << "Color: " << mainWindowInputQSO->locatorLineEdit->palette().color().name()


qDebug() << Q_FUNC_INFO << " - DarkMode NOT detected";
mainWindowInputQSO->locatorLineEdit->setText ("IN");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN");
mainWindowInputQSO->locatorLineEdit->setText ("IN80");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80");
mainWindowInputQSO->locatorLineEdit->setText ("IN80de");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80de");
mainWindowInputQSO->locatorLineEdit->setText ("IN,IN");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN,IN");
mainWindowInputQSO->locatorLineEdit->setText ("IN80,IN80");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80,IN80");
mainWindowInputQSO->locatorLineEdit->setText ("IN80de,IN80de");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80de,IN80de");
mainWindowInputQSO->locatorLineEdit->setText ("IN,IN80");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN,IN80");
mainWindowInputQSO->locatorLineEdit->setText ("IN80de,IN");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palBlack, "Error in grids IN80de,IN");



mainWindowInputQSO->locatorLineEdit->setText ("I");
QVERIFY2(mainWindowInputQSO->locatorLineEdit->palette () == palRed, "Red Error in grids I");
mainWindowInputQSO->locatorLineEdit->setText ("IN,");
Expand Down
17 changes: 16 additions & 1 deletion tests/tst_utilities/tst_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,12 @@ void tst_Utilities::test_getPrefixFromCall()

QVERIFY2(util->getPrefixFromCall("K1AA", true) == "K1", "K1AA-True" );
QVERIFY2(util->getPrefixFromCall("K1A", true) == "K1", "K1A-True");
//qDebug() << Q_FUNC_INFO << ": TESTING: " << util->getPrefixFromCall("G1", true);
QVERIFY2(util->getPrefixFromCall("G1", true) == "G1", "G1-True");
QVERIFY2(util->getPrefixFromCall("I100", true) == "I1", "I100-True");
QVERIFY2(util->getPrefixFromCall("K100A", true) == "K1", "K1-True");
QVERIFY2(util->getPrefixFromCall("I100KK", true) == "I1", "I100KK-True");
//qDebug() << Q_FUNC_INFO << ": FB1K: " << util->getPrefixFromCall("FB1K", true);
qDebug() << Q_FUNC_INFO << ": FB1K: " << util->getPrefixFromCall("FB1K", true);
QVERIFY2(util->getPrefixFromCall("FB1K", true) == "FB1", "FB1K-True");
QVERIFY2(util->getPrefixFromCall("E", true) == QString(), "E-True");
QVERIFY2(util->getPrefixFromCall("EA", true) == "EA", "EA-True");
Expand All @@ -386,6 +387,19 @@ void tst_Utilities::test_getPrefixFromCall()
QVERIFY2(util->getPrefixFromCall("VK9AA", true) == "VK9AA", "VK9AA-True");
QVERIFY2(util->getPrefixFromCall("VK9MA", true) == "VK9M", "VK9MA-True");
QVERIFY2(util->getPrefixFromCall("4U2STAYHOME", true) == "4U2STAYHOME", "4U2STAYHOME-True");

QVERIFY2(util->getAreaNumberFromCall("EA") == -1, "Area call: EA");
QVERIFY2(util->getAreaNumberFromCall("EA4K") == 4, "Area call: EA4K");
QVERIFY2(util->getAreaNumberFromCall("EA8K") == 8, "Area call: EA8K");
QVERIFY2(util->getAreaNumberFromCall("A41A") == 1, "Area call: A41A");
QVERIFY2(util->getAreaNumberFromCall("2Q0VIM") == 0, "Area call: 2Q0VIM");
QVERIFY2(util->getAreaNumberFromCall("KL7AA") == 7, "Area call: KL7AA");
//QVERIFY2(util->getAreaNumberFromCall("EA4K/3") == 3, "Area call: EA4K/3");
//QVERIFY2(util->getAreaNumberFromCall("I100KK") == 100, "Area call: I100KK");
//QVERIFY2(util->getAreaNumberFromCall("RP67ST") == 67, "Area call: RP67ST");



}

void tst_Utilities::test_logLevels()
Expand Down Expand Up @@ -477,6 +491,7 @@ void tst_Utilities::test_getMainCallFromComplexCall()
QVERIFY2(util->getMainCallFromComplexCall("EA4K/F")=="F", "EA4K/F");
QVERIFY2(util->getMainCallFromComplexCall("EA4K/1")=="EA4K", "EA4K/1");
QVERIFY2(util->getMainCallFromComplexCall("VK9/EA4K")=="VK9", "VK9/EA4K");
//QVERIFY2(util->getMainCallFromComplexCall("5B/LY1DF/LGT")=="LY1DF", "5B/LY1DF/LGT");
}

void tst_Utilities::test_isValidEmail()
Expand Down

0 comments on commit d4cfcea

Please sign in to comment.