Engauge Digitizer  2
TestGraphCoords.cpp
1 #include "CallbackUpdateTransform.h"
2 #include "Logger.h"
3 #include "MainWindow.h"
4 #include <QtTest/QtTest>
5 #include "Test/TestGraphCoords.h"
6 
7 QTEST_MAIN (TestGraphCoords)
8 
9 const double EPSILON = 0.0;
10 
12  QObject(parent)
13 {
14  m_callback = new CallbackUpdateTransform (m_modelCoords,
15  DOCUMENT_AXES_POINTS_REQUIRED_3);
16 }
17 
18 void TestGraphCoords::cleanupTestCase ()
19 {
20 }
21 
22 void TestGraphCoords::initTestCase ()
23 {
24  const bool NO_DROP_REGRESSION = false;
25  const QString NO_ERROR_REPORT_LOG_FILE;
26  const QString NO_REGRESSION_OPEN_FILE;
27  const bool NO_GNUPLOT_LOG_FILES = false;
28  const bool NO_REGRESSION_IMPORT = false;
29  const bool NO_RESET = false;
30  const bool NO_EXPORT_ONLY = false;
31  const bool NO_EXTRACT_IMAGE_ONLY = false;
32  const QString NO_EXTRACT_IMAGE_EXTENSION;
33  const bool DEBUG_FLAG = false;
34  const QStringList NO_LOAD_STARTUP_FILES;
35  const QStringList NO_COMMAND_LINE;
36 
37  initializeLogging ("engauge_test",
38  "engauge_test.log",
39  DEBUG_FLAG);
40 
41  MainWindow w (NO_ERROR_REPORT_LOG_FILE,
42  NO_REGRESSION_OPEN_FILE,
43  NO_DROP_REGRESSION,
44  NO_REGRESSION_IMPORT,
45  NO_GNUPLOT_LOG_FILES,
46  NO_RESET,
47  NO_EXPORT_ONLY,
48  NO_EXTRACT_IMAGE_ONLY,
49  NO_EXTRACT_IMAGE_EXTENSION,
50  NO_LOAD_STARTUP_FILES,
51  NO_COMMAND_LINE);
52  w.show ();
53 }
54 
55 void TestGraphCoords::testAnyColumnsRepeatNo ()
56 {
57  CoordPairVector vector;
58 
59  vector.push_back (QPointF (100, 100));
60  vector.push_back (QPointF (300, 100));
61  vector.push_back (QPointF (200, 200));
62 
63  QVERIFY (!m_callback->anyPointsRepeatPair (vector,
64  EPSILON));
65 }
66 
67 void TestGraphCoords::testAnyColumnsRepeatYes ()
68 {
69  CoordPairVector vector;
70 
71  // First two points repeat
72  vector.push_back (QPointF (100, 100));
73  vector.push_back (QPointF (100, 100));
74  vector.push_back (QPointF (200, 200));
75 
76  QVERIFY (m_callback->anyPointsRepeatPair (vector,
77  EPSILON));
78 }
79 
80 void TestGraphCoords::testThreeCollinearPointsNo ()
81 {
82  // Points are not collinear
83  QTransform m (100, 300, 200,
84  100, 150, 200,
85  1 , 1 , 1 );
86 
87  QVERIFY (!m_callback->threePointsAreCollinear (m));
88 }
89 
90 void TestGraphCoords::testThreeCollinearPointsYes ()
91 {
92  // Points are collinear
93  QTransform m (100, 150, 200,
94  100, 150, 200,
95  1 , 1 , 1 );
96 
97  QVERIFY (m_callback->threePointsAreCollinear (m));
98 }
Callback for collecting axis points and then calculating the current transform from those axis points...
Unit tests of graph coordinate sanity checking.
TestGraphCoords(QObject *parent=0)
Single constructor.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:91