12#include <QtTest/QtTest>
23TestGuidelines::Result::Result (
bool pass,
24 const QString &problem) :
30bool TestGuidelines::Result::pass ()
const
35QString TestGuidelines::Result::problem ()
const
43 m_mainWindow (nullptr)
47void TestGuidelines::cleanupTestCase ()
51TestGuidelines::Result TestGuidelines::compareExpectedAndGot (
const QVector<int> &countsExpectedXT,
52 const QVector<int> &countsExpectedYR)
54 Guidelines &guidelines = m_mainWindow->guidelines();
58 GuidelineContainerPrivate::const_iterator itr;
61 for (itr = containerXT.begin(); itr != containerXT.end(); itr++) {
62 const GuidelineAbstract *guideline = *itr;
65 countsGotXT [state] += 1;
69 for (itr = containerYR.begin(); itr != containerYR.end(); itr++) {
70 const GuidelineAbstract *guideline = *itr;
73 countsGotYR [state] += 1;
81 if (countsExpectedXT [state] != countsGotXT [state] ||
82 countsExpectedYR [state] != countsGotYR [state]) {
100 QTextStream str (&text);
101 str <<
"Expected/got=";
103 if ((countsExpectedXT [state] != 0) ||
104 (countsExpectedYR [state] != 0) ||
105 (countsGotXT [state] != 0) ||
106 (countsGotYR [state] != 0)) {
108 str << guidelineStateAsString (static_cast<GuidelineState> (state)) <<
"=";
112 str << countsExpectedXT [state];
114 str <<
"/" << countsGotXT [state] <<
" and ";
118 str << countsExpectedYR [state];
120 str <<
"/" << countsGotYR [state] <<
" ";
124 return Result (
false,
129GuidelineState TestGuidelines::guidelineStateFromString (
const QString &
string)
const
141void TestGuidelines::initTestCase ()
151 const bool NO_RESET =
false;
153 const bool NO_EXPORT_IMAGE_ONLY =
false;
154 const QString NO_EXPORT_IMAGE_EXTENSION;
156 QStringList importFile;
159 importFile <<
"../samples/inverse.jpg";
172 NO_EXPORT_IMAGE_ONLY,
173 NO_EXPORT_IMAGE_EXTENSION,
177 m_mainWindow->show ();
179 test00StartupWithoutTransformationPrepare ();
184 qApp->processEvents ();
193 m_results.push_back (compareExpectedAndGot (countsExpectedXT,
197 test01AfterAddingTransformationPrepare ();
200void TestGuidelines::test00StartupWithoutTransformationPrepare ()
202 const int FIVE_SECONDS = 5000;
206 connect (&m_showTimer, SIGNAL (timeout ()),
209 m_showTimer.setSingleShot (
true);
210 m_showTimer.start (FIVE_SECONDS);
213void TestGuidelines::test00StartupWithoutTransformationReport ()
216 const Result &result = m_results.front ();
217 if (!result.pass ()) {
218 cout << result.problem().toLatin1().data() << endl;
221 bool pass = result.pass ();
222 m_results.pop_front ();
232 m_results.push_back (compareExpectedAndGot (countsExpectedXT,
236 test02AfterRemovingTransformationPrepare ();
239void TestGuidelines::test01AfterAddingTransformationPrepare ()
242 disconnect (m_mainWindow, SIGNAL (signalGong ()),
244 connect (m_mainWindow, SIGNAL (signalGong ()),
247 QPointF posScreen0 (400, 400);
248 QPointF posScreen1 (600, 400);
249 QPointF posScreen2 (400, 200);
250 QPointF posGraph0 (40, 40);
251 QPointF posGraph1 (60, 40);
252 QPointF posGraph2 (40, 20);
280void TestGuidelines::test01AfterAddingTransformationReport ()
283 const Result &result = m_results.front ();
284 if (!result.pass ()) {
285 cout << result.problem().toLatin1().data() << endl;
288 bool pass = result.pass ();
289 m_results.pop_front ();
299 m_results.push_back (compareExpectedAndGot (countsExpectedXT,
306void TestGuidelines::test02AfterRemovingTransformationPrepare ()
309 disconnect (m_mainWindow, SIGNAL (signalGong ()),
311 connect (m_mainWindow, SIGNAL (signalGong ()),
314 const QString POINT2_IDENTIFIER (
"Axes\tpoint\t2");
315 QStringList pointsToDelete;
316 pointsToDelete << POINT2_IDENTIFIER;
328void TestGuidelines::test02AfterRemovingTransformationReport ()
331 const Result &result = m_results.front ();
332 if (!result.pass ()) {
333 cout << result.problem().toLatin1().data() << endl;
336 bool pass = result.pass ();
337 m_results.pop_front ();
342void TestGuidelines::turnOffChecklist ()
349 settings.endGroup ();
QString guidelineStateAsString(GuidelineState state)
GuidelineState
Set of possible Guideline states. See class Guideline for more information.
@ GUIDELINE_STATE_DISCARDED
QList< GuidelineAbstract * > GuidelineContainerPrivate
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
const QString SETTINGS_ENGAUGE
const QString SETTINGS_CHECKLIST_GUIDE_WIZARD
const QString SETTINGS_GROUP_MAIN_WINDOW
const QString SETTINGS_DIGITIZER
const bool NO_EXPORT_ONLY
const QStringList NO_COMMAND_LINE
const QString NO_ERROR_REPORT_LOG_FILE
const bool NO_GNUPLOT_LOG_FILES
const QString NO_REGRESSION_OPEN_FILE
const bool NO_REGRESSION_IMPORT
const bool NO_DROP_REGRESSION
Command for adding one axis point.
Command for deleting all selected Points.
Command for sending a satisfying signal to the unit test framework to indicate completion of queued c...
QString stateName() const
Current state name for debugging and unit test only.
CmdMediator * cmdMediator()
Accessor for commands to process the Document.
void test02AfterRemovingTransformation()
void test01AfterAddingTransformation()
void test00StartupWithoutTransformation()
TestGuidelines(QObject *parent=0)
Single constructor.