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