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