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