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 NO_EXPORT_ONLY =
false;
39 const bool NO_EXTRACT_IMAGE_ONLY =
false;
40 const QString NO_EXTRACT_IMAGE_EXTENSION;
41 const bool DEBUG_FLAG =
false;
42 const QStringList NO_LOAD_STARTUP_FILES;
43 const QStringList NO_COMMAND_LINE;
45 initializeLogging (
"engauge_test",
50 NO_REGRESSION_OPEN_FILE,
55 NO_EXTRACT_IMAGE_ONLY,
56 NO_EXTRACT_IMAGE_EXTENSION,
57 NO_LOAD_STARTUP_FILES,
62 void TestSegmentFill::testFindSegments()
64 const bool NO_GNUPLOT =
false;
65 const bool NO_DLG =
false;
66 const QString OUT_FILE_ACTUAL (
"../test/test_segment_fill.gnuplot_actual");
67 const QString OUT_FILE_EXPECTED (
"../test/test_segment_fill.gnuplot_expected");
69 QList<Segment*> segments;
72 QDir::setCurrent (QApplication::applicationDirPath());
74 QImage img (
"../samples/corners.png");
76 QGraphicsScene *scene =
new QGraphicsScene;
82 segmentFactory.clearSegments (segments);
85 segmentFactory.makeSegments (img,
91 QFile out (OUT_FILE_ACTUAL);
92 QTextStream outStr (&out);
94 out.open(QIODevice::WriteOnly | QIODevice::Text);
97 for (
int indexS = 0; indexS < segments.count(); indexS++) {
98 Segment* segment = segments [indexS];
100 QList<QPoint> points = segment->
fillPoints (modelSegments);
103 if (points.count() > 1) {
105 for (
int indexP = 0; indexP < points.count(); indexP++) {
106 QPoint point = points [indexP];
110 outStr << point.x() <<
" " << point.y() << endl;
121 QCryptographicHash hashActual (QCryptographicHash::Sha1);
122 QCryptographicHash hashExpected (QCryptographicHash::Sha1);
123 QFile fileActual (OUT_FILE_ACTUAL);
124 QFile fileExpected (OUT_FILE_EXPECTED);
126 bool success =
false;
127 if (fileActual.open(QIODevice::ReadOnly) && fileExpected.open(QIODevice::ReadOnly)) {
128 hashActual.addData (fileActual.readAll());
129 hashExpected.addData (fileExpected.readAll());
130 QByteArray signatureActual = hashActual.result();
131 QByteArray signatureExpected = hashExpected.result();
134 success = (signatureActual == signatureExpected);
Factory class for Segment objects.
Unit test of segment fill feature.
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...