Skip to content

Commit

Permalink
Update unit tests, remove graphics testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultMndr committed Jul 12, 2019
1 parent 1df4383 commit 5a076ef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 134 deletions.
8 changes: 3 additions & 5 deletions ProtonClassicSuite_forUnitTests.pri
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += core gui sql printsupport
QT += core gui sql printsupport charts

INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
Expand All @@ -10,8 +10,7 @@ include(QtXlsx/xlsx/qtxlsx.pri)



SOURCES += $$PWD/QCustomPlot/qcustomplot.cpp \
$$PWD/pcx_tables.cpp \
SOURCES += $$PWD/pcx_tables.cpp \
$$PWD/pcx_report.cpp \
$$PWD/pcx_graphics.cpp \
$$PWD/pcx_queryvariation.cpp \
Expand All @@ -38,8 +37,7 @@ SOURCES += $$PWD/QCustomPlot/qcustomplot.cpp \



HEADERS += $$PWD/QCustomPlot/qcustomplot.h \
$$PWD/pcx_tables.h \
HEADERS += $$PWD/pcx_tables.h \
$$PWD/pcx_report.h \
$$PWD/pcx_graphics.h \
$$PWD/pcx_queryvariation.h \
Expand Down
1 change: 0 additions & 1 deletion UnitTests/tst_protonclassicsuiteunittests.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ private Q_SLOTS:
void testCaseForAuditDuplication();
void testCaseForAuditImportExport();
void testCaseForPCATables();
void testCaseForPCAGraphics();
void testCaseForPCAQueries();
void benchmarkReport();

Expand Down
128 changes: 0 additions & 128 deletions UnitTests/tst_protonclassicsuiteunittests_pcx_tablesandgraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "tst_protonclassicsuiteunittests.h"
#include "utils.h"
#include <QCryptographicHash>
#include <QCustomPlot/qcustomplot.h>
#include <QString>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
Expand Down Expand Up @@ -396,130 +395,3 @@ void ProtonClassicSuiteUnitTests::benchmarkReport() {
PCx_Tree::deleteTree(treeId);
}

void ProtonClassicSuiteUnitTests::testCaseForPCAGraphics() {
unsigned int treeId = PCx_Tree::addTree("TREEFORTEST");
PCx_Tree tree(treeId);
unsigned int nodeA = tree.addNode(1, 1, "nodeA");
unsigned int nodeB = tree.addNode(nodeA, 1, "nodeB");
tree.addNode(nodeA, 1, "nodeC");
tree.addNode(1, 1, "nodeD");
tree.addNode(nodeB, 1, "nodeE");
tree.finishTree();

unsigned int auditId = PCx_Audit::addNewAudit("AUDITFORTEST", QList<int>{2010, 2011, 2012, 2013}, treeId);

PCx_Audit audit(auditId);

fillTestAudit(&audit);

QCustomPlot plot;
QByteArray ba, hash;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
PCx_Graphics graphics(&audit, &plot);

QByteArray expectedG1 = "0f8a89463874c3cf8a708b6b10f4e3a1852ce193fbde2fa497da4242cd0290a0";
QByteArray expectedG2 = "1ff3b470c0c3d387da9405351dc889c3163bb09055dd8b7588f1ececcba5ae36";
QByteArray expectedG3 = "fd020155c9c9c0e6c5cd0fa499c3ff02a07facfd9785f1d0d49a6ba2835aed0f";
QByteArray expectedG4 = "87c3596abb89d3ce80610dc922981826fcaabac27d3c93cc24610926d550605c";
QByteArray expectedG5 = "ce343ee0ccc5ad718190e113f7b3838e2ecea1e1735259d51e86079fe6a3e570";
QByteArray expectedG6 = "533522b3a26aa324e7abe138a2bf32e02dec45fc13262626ac67fa1b0072f9e2";
QByteArray expectedG7 = "0a11d97f065ef41bb5daaad8f5985e43fd1a3b90f804a540871393c04320cd07";
QByteArray expectedG8 = "18c88ada9516d7794ce72f61120f476a1db25e6bded7b84b0aa6b6604e7a81d0";
QByteArray expectedG9 = "9869af5f3566524f779241b726a1d596080c1ff81bcf8531158c334a56f4a8ba";
QByteArray expectedGHist = "d30064d2490e767f93a76832b597319f7c9320c27f014c6237e00e4400d37e54";

graphics.getPCAG1(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);

qDebug() << "G1" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG1);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG2(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G2" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG2);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG3(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G3" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG3);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG4(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G4" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG4);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG5(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G5" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG5);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG6(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G6" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG6);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG7(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G7" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG7);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG8(nodeA, MODES::DFRFDIRI::DF);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G8" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG8);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAG9(nodeA);
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "G9" << hash.toHex();
QCOMPARE(hash.toHex(), expectedG9);

ba.clear();
buffer.open(QIODevice::WriteOnly);
graphics.getPCAHistory(nodeA, MODES::DFRFDIRI::DF,
QList<PCx_Audit::ORED>{PCx_Audit::ORED::OUVERTS, PCx_Audit::ORED::REALISES,
PCx_Audit::ORED::ENGAGES, PCx_Audit::ORED::DISPONIBLES});
plot.toPixmap(PCx_Graphics::DEFAULTWIDTH, PCx_Graphics::DEFAULTHEIGHT).save(&buffer, "PNG");
buffer.close();
hash = QCryptographicHash::hash(ba, QCryptographicHash::Sha256);
qDebug() << "GHist" << hash.toHex();
QCOMPARE(hash.toHex(), expectedGHist);

PCx_Audit::deleteAudit(auditId);
PCx_Tree::deleteTree(treeId);
}

0 comments on commit 5a076ef

Please sign in to comment.