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 DEBUG_FLAG = false;
34  const QStringList NO_LOAD_STARTUP_FILES;
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_GNUPLOT_LOG_FILES,
43  NO_RESET,
44  NO_REGRESSION_IMPORT,
45  NO_LOAD_STARTUP_FILES);
46  w.show ();
47 }
48 
49 void TestZoomTransition::testInAtClosestEnum ()
50 {
51  ZoomTransition zoomTransition;
52  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_16_TO_1,
53  M11,
54  M22,
55  FILL_UNCHECKED);
56 
57  // Should be unchanged since cannot go further
58  QVERIFY (zoomFactorNew == ZOOM_16_TO_1);
59 }
60 
61 void TestZoomTransition::testInBeforeClosestFromEnum ()
62 {
63  ZoomTransition zoomTransition;
64  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_1_TO_1,
65  M11,
66  M22,
67  FILL_UNCHECKED);
68 
69  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_CLOSER);
70 }
71 
72 void TestZoomTransition::testInBeforeClosestFromFill ()
73 {
74  ZoomTransition zoomTransition;
75  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_FILL,
76  M11,
77  M22,
78  FILL_CHECKED);
79 
80  QVERIFY (zoomFactorNew == ZOOM_2_TO_1);
81 }
82 
83 void TestZoomTransition::testOutAtFarthestEnum ()
84 {
85  ZoomTransition zoomTransition;
86  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_1_TO_16,
87  M11,
88  M22,
89  FILL_UNCHECKED);
90 
91  // Should be unchanged since cannot go further
92  QVERIFY (zoomFactorNew == ZOOM_1_TO_16);
93 }
94 
95 void TestZoomTransition::testOutBeforeFarthestFromEnum ()
96 {
97  ZoomTransition zoomTransition;
98  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_1_TO_1,
99  M11,
100  M22,
101  FILL_UNCHECKED);
102 
103  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_FARTHER);
104 }
105 
106 void TestZoomTransition::testOutBeforeFarthestFromFill ()
107 {
108  ZoomTransition zoomTransition;
109  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_FILL,
110  M11,
111  M22,
112  FILL_CHECKED);
113 
114  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_CLOSER);
115 }
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