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