Engauge Digitizer  2
TestZoomTransition.cpp
1 #include "Logger.h"
2 #include "MainWindow.h"
3 #include <QtTest/QtTest>
4 #include "Test/TestZoomTransition.h"
5 #include "ZoomTransition.h"
6 
7 QTEST_MAIN (TestZoomTransition)
8 
9 using namespace std;
10 
11 const bool FILL_CHECKED = true;
12 const bool FILL_UNCHECKED = false;
13 const double M11 = 1.9;
14 const double M22 = 1.49;
15 
17  QObject(parent)
18 {
19 }
20 
21 void TestZoomTransition::cleanupTestCase ()
22 {
23 
24 }
25 
26 void TestZoomTransition::initTestCase ()
27 {
28  const QString NO_ERROR_REPORT_LOG_FILE;
29  const QString NO_REGRESSION_OPEN_FILE;
30  const bool NO_GNUPLOT_LOG_FILES = false;
31  const bool NO_REGRESSION_IMPORT = false;
32  const bool NO_RESET = false;
33  const bool NO_EXPORT_ONLY = false;
34  const bool DEBUG_FLAG = false;
35  const QStringList NO_LOAD_STARTUP_FILES;
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_REGRESSION_IMPORT,
44  NO_GNUPLOT_LOG_FILES,
45  NO_RESET,
46  NO_EXPORT_ONLY,
47  NO_LOAD_STARTUP_FILES);
48  w.show ();
49 }
50 
51 void TestZoomTransition::testInAtClosestEnum ()
52 {
53  ZoomTransition zoomTransition;
54  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_16_TO_1,
55  M11,
56  M22,
57  FILL_UNCHECKED);
58 
59  // Should be unchanged since cannot go further
60  QVERIFY (zoomFactorNew == ZOOM_16_TO_1);
61 }
62 
63 void TestZoomTransition::testInBeforeClosestFromEnum ()
64 {
65  ZoomTransition zoomTransition;
66  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_1_TO_1,
67  M11,
68  M22,
69  FILL_UNCHECKED);
70 
71  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_CLOSER);
72 }
73 
74 void TestZoomTransition::testInBeforeClosestFromFill ()
75 {
76  ZoomTransition zoomTransition;
77  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_FILL,
78  M11,
79  M22,
80  FILL_CHECKED);
81 
82  QVERIFY (zoomFactorNew == ZOOM_2_TO_1);
83 }
84 
85 void TestZoomTransition::testOutAtFarthestEnum ()
86 {
87  ZoomTransition zoomTransition;
88  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_1_TO_16,
89  M11,
90  M22,
91  FILL_UNCHECKED);
92 
93  // Should be unchanged since cannot go further
94  QVERIFY (zoomFactorNew == ZOOM_1_TO_16);
95 }
96 
97 void TestZoomTransition::testOutBeforeFarthestFromEnum ()
98 {
99  ZoomTransition zoomTransition;
100  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_1_TO_1,
101  M11,
102  M22,
103  FILL_UNCHECKED);
104 
105  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_FARTHER);
106 }
107 
108 void TestZoomTransition::testOutBeforeFarthestFromFill ()
109 {
110  ZoomTransition zoomTransition;
111  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_FILL,
112  M11,
113  M22,
114  FILL_CHECKED);
115 
116  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_CLOSER);
117 }
Unit test of ZoomTransition class.
ZoomFactor zoomIn(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom in.
TestZoomTransition(QObject *parent=0)
Single constructor.
Perform calculations to determine the next zoom setting given the current zoom setting, when zooming in or out.
ZoomFactor zoomOut(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom out.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:89