Engauge Digitizer  2
 All Classes Functions Variables Typedefs Enumerations Friends Pages
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 bool NO_DROP_REGRESSION = false;
29  const QString NO_ERROR_REPORT_LOG_FILE;
30  const QString NO_REGRESSION_OPEN_FILE;
31  const bool NO_GNUPLOT_LOG_FILES = false;
32  const bool NO_REGRESSION_IMPORT = false;
33  const bool NO_RESET = false;
34  const bool NO_EXPORT_ONLY = false;
35  const bool NO_EXTRACT_IMAGE_ONLY = false;
36  const QString NO_EXTRACT_IMAGE_EXTENSION;
37  const bool DEBUG_FLAG = false;
38  const QStringList NO_LOAD_STARTUP_FILES;
39  const QStringList NO_COMMAND_LINE;
40 
41  initializeLogging ("engauge_test",
42  "engauge_test.log",
43  DEBUG_FLAG);
44 
45  MainWindow w (NO_ERROR_REPORT_LOG_FILE,
46  NO_REGRESSION_OPEN_FILE,
47  NO_DROP_REGRESSION,
48  NO_REGRESSION_IMPORT,
49  NO_GNUPLOT_LOG_FILES,
50  NO_RESET,
51  NO_EXPORT_ONLY,
52  NO_EXTRACT_IMAGE_ONLY,
53  NO_EXTRACT_IMAGE_EXTENSION,
54  NO_LOAD_STARTUP_FILES,
55  NO_COMMAND_LINE);
56  w.show ();
57 }
58 
59 void TestZoomTransition::testInAtClosestEnum ()
60 {
61  ZoomTransition zoomTransition;
62  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_16_TO_1,
63  M11,
64  M22,
65  FILL_UNCHECKED);
66 
67  // Should be unchanged since cannot go further
68  QVERIFY (zoomFactorNew == ZOOM_16_TO_1);
69 }
70 
71 void TestZoomTransition::testInBeforeClosestFromEnum ()
72 {
73  ZoomTransition zoomTransition;
74  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_1_TO_1,
75  M11,
76  M22,
77  FILL_UNCHECKED);
78 
79  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_CLOSER);
80 }
81 
82 void TestZoomTransition::testInBeforeClosestFromFill ()
83 {
84  ZoomTransition zoomTransition;
85  ZoomFactor zoomFactorNew = zoomTransition.zoomIn (ZOOM_FILL,
86  M11,
87  M22,
88  FILL_CHECKED);
89 
90  QVERIFY (zoomFactorNew == ZOOM_2_TO_1);
91 }
92 
93 void TestZoomTransition::testOutAtFarthestEnum ()
94 {
95  ZoomTransition zoomTransition;
96  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_1_TO_16,
97  M11,
98  M22,
99  FILL_UNCHECKED);
100 
101  // Should be unchanged since cannot go further
102  QVERIFY (zoomFactorNew == ZOOM_1_TO_16);
103 }
104 
105 void TestZoomTransition::testOutBeforeFarthestFromEnum ()
106 {
107  ZoomTransition zoomTransition;
108  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_1_TO_1,
109  M11,
110  M22,
111  FILL_UNCHECKED);
112 
113  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_FARTHER);
114 }
115 
116 void TestZoomTransition::testOutBeforeFarthestFromFill ()
117 {
118  ZoomTransition zoomTransition;
119  ZoomFactor zoomFactorNew = zoomTransition.zoomOut (ZOOM_FILL,
120  M11,
121  M22,
122  FILL_CHECKED);
123 
124  QVERIFY (zoomFactorNew == ZOOM_1_TO_1_CLOSER);
125 }
Unit test of ZoomTransition class.
ZoomFactor zoomOut(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom out.
Perform calculations to determine the next zoom setting given the current zoom setting, when zooming in or out.
ZoomFactor zoomIn(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom in.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:91