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 DEBUG_FLAG =
false;
40 const QStringList NO_LOAD_STARTUP_FILES;
42 initializeLogging (
"engauge_test",
47 NO_REGRESSION_OPEN_FILE,
52 NO_LOAD_STARTUP_FILES);
56 void TestSegmentFill::testFindSegments()
58 const bool NO_GNUPLOT =
false;
59 const bool NO_DLG =
false;
60 const QString OUT_FILE_ACTUAL (
"../test/test_segment_fill.gnuplot_actual");
61 const QString OUT_FILE_EXPECTED (
"../test/test_segment_fill.gnuplot_expected");
63 QList<Segment*> segments;
66 QDir::setCurrent (QApplication::applicationDirPath());
68 QImage img (
"../samples/corners.png");
70 QGraphicsScene *scene =
new QGraphicsScene;
76 segmentFactory.clearSegments (segments);
79 segmentFactory.makeSegments (img,
85 QFile out (OUT_FILE_ACTUAL);
86 QTextStream outStr (&out);
88 out.open(QIODevice::WriteOnly | QIODevice::Text);
91 for (
int indexS = 0; indexS < segments.count(); indexS++) {
92 Segment* segment = segments [indexS];
94 QList<QPoint> points = segment->
fillPoints (modelSegments);
97 if (points.count() > 1) {
99 for (
int indexP = 0; indexP < points.count(); indexP++) {
100 QPoint point = points [indexP];
104 outStr << point.x() <<
" " << point.y() << endl;
115 QCryptographicHash hashActual (QCryptographicHash::Sha1);
116 QCryptographicHash hashExpected (QCryptographicHash::Sha1);
117 QFile fileActual (OUT_FILE_ACTUAL);
118 QFile fileExpected (OUT_FILE_EXPECTED);
120 bool success =
false;
121 if (fileActual.open(QIODevice::ReadOnly) && fileExpected.open(QIODevice::ReadOnly)) {
122 hashActual.addData (fileActual.readAll());
123 hashExpected.addData (fileExpected.readAll());
124 QByteArray signatureActual = hashActual.result();
125 QByteArray signatureExpected = hashExpected.result();
128 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.
Model for DlgSettingsSegments and CmdSettingsSegments.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...