From 5a076ef8fde950f7ed48e4e37a96b368aafb0132 Mon Sep 17 00:00:00 2001 From: Thibault Date: Fri, 12 Jul 2019 11:07:35 +0200 Subject: [PATCH] Update unit tests, remove graphics testing --- ProtonClassicSuite_forUnitTests.pri | 8 +- UnitTests/tst_protonclassicsuiteunittests.h | 1 - ...icsuiteunittests_pcx_tablesandgraphics.cpp | 128 ------------------ 3 files changed, 3 insertions(+), 134 deletions(-) diff --git a/ProtonClassicSuite_forUnitTests.pri b/ProtonClassicSuite_forUnitTests.pri index 0e1cd16..7ec2450 100644 --- a/ProtonClassicSuite_forUnitTests.pri +++ b/ProtonClassicSuite_forUnitTests.pri @@ -1,4 +1,4 @@ -QT += core gui sql printsupport +QT += core gui sql printsupport charts INCLUDEPATH += $$PWD DEPENDPATH += $$PWD @@ -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 \ @@ -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 \ diff --git a/UnitTests/tst_protonclassicsuiteunittests.h b/UnitTests/tst_protonclassicsuiteunittests.h index 9da601c..89ef6b6 100644 --- a/UnitTests/tst_protonclassicsuiteunittests.h +++ b/UnitTests/tst_protonclassicsuiteunittests.h @@ -71,7 +71,6 @@ private Q_SLOTS: void testCaseForAuditDuplication(); void testCaseForAuditImportExport(); void testCaseForPCATables(); - void testCaseForPCAGraphics(); void testCaseForPCAQueries(); void benchmarkReport(); diff --git a/UnitTests/tst_protonclassicsuiteunittests_pcx_tablesandgraphics.cpp b/UnitTests/tst_protonclassicsuiteunittests_pcx_tablesandgraphics.cpp index 3c6e7ef..a7733ce 100644 --- a/UnitTests/tst_protonclassicsuiteunittests_pcx_tablesandgraphics.cpp +++ b/UnitTests/tst_protonclassicsuiteunittests_pcx_tablesandgraphics.cpp @@ -43,7 +43,6 @@ #include "tst_protonclassicsuiteunittests.h" #include "utils.h" #include -#include #include #include #include @@ -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{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::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); -}