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 QString NO_ERROR_REPORT_LOG_FILE;
25  const QString NO_REGRESSION_OPEN_FILE;
26  const bool NO_GNUPLOT_LOG_FILES = false;
27  const bool NO_REGRESSION_IMPORT = false;
28  const bool NO_RESET = false;
29  const bool NO_EXPORT_ONLY = false;
30  const bool NO_EXTRACT_IMAGE_ONLY = false;
31  const QString NO_EXTRACT_IMAGE_EXTENSION;
32  const bool DEBUG_FLAG = false;
33  const QStringList NO_LOAD_STARTUP_FILES;
34  const QStringList NO_COMMAND_LINE;
35 
36  initializeLogging ("engauge_test",
37  "engauge_test.log",
38  DEBUG_FLAG);
39 
40  MainWindow w (NO_ERROR_REPORT_LOG_FILE,
41  NO_REGRESSION_OPEN_FILE,
42  NO_REGRESSION_IMPORT,
43  NO_GNUPLOT_LOG_FILES,
44  NO_RESET,
45  NO_EXPORT_ONLY,
46  NO_EXTRACT_IMAGE_ONLY,
47  NO_EXTRACT_IMAGE_EXTENSION,
48  NO_LOAD_STARTUP_FILES,
49  NO_COMMAND_LINE);
50  w.show ();
51 }
52 
53 void TestGraphCoords::testAnyColumnsRepeatNo ()
54 {
55  CoordPairVector vector;
56 
57  vector.push_back (QPointF (100, 100));
58  vector.push_back (QPointF (300, 100));
59  vector.push_back (QPointF (200, 200));
60 
61  QVERIFY (!m_callback->anyPointsRepeatPair (vector,
62  EPSILON));
63 }
64 
65 void TestGraphCoords::testAnyColumnsRepeatYes ()
66 {
67  CoordPairVector vector;
68 
69  // First two points repeat
70  vector.push_back (QPointF (100, 100));
71  vector.push_back (QPointF (100, 100));
72  vector.push_back (QPointF (200, 200));
73 
74  QVERIFY (m_callback->anyPointsRepeatPair (vector,
75  EPSILON));
76 }
77 
78 void TestGraphCoords::testThreeCollinearPointsNo ()
79 {
80  // Points are not collinear
81  QTransform m (100, 300, 200,
82  100, 150, 200,
83  1 , 1 , 1 );
84 
85  QVERIFY (!m_callback->threePointsAreCollinear (m));
86 }
87 
88 void TestGraphCoords::testThreeCollinearPointsYes ()
89 {
90  // Points are collinear
91  QTransform m (100, 150, 200,
92  100, 150, 200,
93  1 , 1 , 1 );
94 
95  QVERIFY (m_callback->threePointsAreCollinear (m));
96 }
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