3 #include "MainWindow.h" 4 #include <QCryptographicHash> 5 #include <QGraphicsScene> 6 #include <QGraphicsView> 10 #include <QtTest/QtTest> 12 #include "SegmentFactory.h" 14 #include "SplinePair.h" 15 #include "Test/TestSegmentFill.h" 26 void TestSegmentFill::cleanupTestCase ()
31 void TestSegmentFill::initTestCase ()
33 const QString NO_ERROR_REPORT_LOG_FILE;
34 const QString NO_REGRESSION_OPEN_FILE;
35 const bool NO_GNUPLOT_LOG_FILES =
false;
36 const bool NO_REGRESSION_IMPORT =
false;
37 const bool NO_RESET =
false;
38 const bool DEBUG_FLAG =
false;
39 const QStringList NO_LOAD_STARTUP_FILES;
41 initializeLogging (
"engauge_test",
46 NO_REGRESSION_OPEN_FILE,
50 NO_LOAD_STARTUP_FILES);
54 void TestSegmentFill::testFindSegments()
56 const bool NO_GNUPLOT =
false;
57 const bool NO_DLG =
false;
58 const QString OUT_FILE_ACTUAL (
"../test/test_segment_fill.gnuplot_actual");
59 const QString OUT_FILE_EXPECTED (
"../test/test_segment_fill.gnuplot_expected");
61 QList<Segment*> segments;
64 QDir::setCurrent (QApplication::applicationDirPath());
66 QImage img (
"../samples/corners.png");
68 QGraphicsScene *scene =
new QGraphicsScene;
83 QFile out (OUT_FILE_ACTUAL);
84 QTextStream outStr (&out);
86 out.open(QIODevice::WriteOnly | QIODevice::Text);
89 for (
int indexS = 0; indexS < segments.count(); indexS++) {
90 Segment* segment = segments [indexS];
92 QList<QPoint> points = segment->
fillPoints (modelSegments);
95 if (points.count() > 1) {
97 for (
int indexP = 0; indexP < points.count(); indexP++) {
98 QPoint point = points [indexP];
102 outStr << point.x() <<
" " << point.y() << endl;
113 QCryptographicHash hashActual (QCryptographicHash::Sha1);
114 QCryptographicHash hashExpected (QCryptographicHash::Sha1);
115 QFile fileActual (OUT_FILE_ACTUAL);
116 QFile fileExpected (OUT_FILE_EXPECTED);
118 bool success =
false;
119 if (fileActual.open(QIODevice::ReadOnly) && fileExpected.open(QIODevice::ReadOnly)) {
120 hashActual.addData (fileActual.readAll());
121 hashExpected.addData (fileExpected.readAll());
122 QByteArray signatureActual = hashActual.result();
123 QByteArray signatureExpected = hashExpected.result();
126 success = (signatureActual == signatureExpected);
void makeSegments(const QImage &imageFiltered, const DocumentModelSegments &modelSegments, QList< Segment *> &segments, bool useDlg=true)
Main entry point for creating all Segments for the filtered image.
Factory class for Segment objects.
Unit test of segment fill feature.
void clearSegments(QList< Segment *> &segments)
Remove the segments created by makeSegments.
Selectable piecewise-defined line that follows a filtered line in the image.
QList< QPoint > fillPoints(const DocumentModelSegments &modelSegments)
Create evenly spaced points along the segment.
TestSegmentFill(QObject *parent=0)
Single constructor.
Model for DlgSettingsSegments and CmdSettingsSegments.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...