4#include <QCryptographicHash>
5#include <QGraphicsScene>
6#include <QGraphicsView>
10#include <QtTest/QtTest>
26void TestSegmentFill::cleanupTestCase ()
31void TestSegmentFill::initTestCase ()
38 const bool NO_RESET =
false;
64void TestSegmentFill::testFindSegments()
66 const bool NO_GNUPLOT =
false;
67 const bool NO_DLG =
false;
68 const QString OUT_FILE_ACTUAL (
"../test/test_segment_fill.gnuplot_actual");
69 const QString OUT_FILE_EXPECTED (
"../test/test_segment_fill.gnuplot_expected");
71 QList<Segment*> segments;
74 QDir::setCurrent (QApplication::applicationDirPath());
76 QImage img (
"../samples/corners.png");
78 QGraphicsScene *scene =
new QGraphicsScene;
79 SegmentFactory segmentFactory (*scene,
82 DocumentModelSegments modelSegments;
84 segmentFactory.clearSegments (segments);
87 segmentFactory.makeSegments (img,
93 QFile out (OUT_FILE_ACTUAL);
94 QTextStream outStr (&out);
96 out.open(QIODevice::WriteOnly | QIODevice::Text);
99 for (
int indexS = 0; indexS < segments.count(); indexS++) {
100 Segment* segment = segments [indexS];
102 QList<QPoint> points = segment->
fillPoints (modelSegments);
105 if (points.count() > 1) {
107 for (
int indexP = 0; indexP < points.count(); indexP++) {
108 QPoint point = points [indexP];
112 outStr << point.x() <<
" " << point.y() << endl;
123 QCryptographicHash hashActual (QCryptographicHash::Sha1);
124 QCryptographicHash hashExpected (QCryptographicHash::Sha1);
125 QFile fileActual (OUT_FILE_ACTUAL);
126 QFile fileExpected (OUT_FILE_EXPECTED);
128 bool success =
false;
129 if (fileActual.open(QIODevice::ReadOnly) && fileExpected.open(QIODevice::ReadOnly)) {
130 hashActual.addData (fileActual.readAll());
131 hashExpected.addData (fileExpected.readAll());
132 QByteArray signatureActual = hashActual.result();
133 QByteArray signatureExpected = hashExpected.result();
136 success = (signatureActual == signatureExpected);
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
const bool NO_EXPORT_ONLY
const QStringList NO_COMMAND_LINE
const QString NO_EXTRACT_IMAGE_EXTENSION
const QString NO_ERROR_REPORT_LOG_FILE
const bool NO_GNUPLOT_LOG_FILES
const QString NO_REGRESSION_OPEN_FILE
const QStringList NO_LOAD_STARTUP_FILES
const bool NO_REGRESSION_IMPORT
const bool NO_EXTRACT_IMAGE_ONLY
const bool NO_DROP_REGRESSION
QList< QPoint > fillPoints(const DocumentModelSegments &modelSegments)
Create evenly spaced points along the segment.
Unit test of segment fill feature.
TestSegmentFill(QObject *parent=0)
Single constructor.