Engauge Digitizer  2
TestZoomTransition.cpp
Go to the documentation of this file.
1 #include "Logger.h"
2 #include "MainWindow.h"
3 #include <QtTest/QtTest>
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 
50  NO_RESET,
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,
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,
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,
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,
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 }
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
Definition: Logger.cpp:21
const bool NO_EXPORT_ONLY
Definition: TestExport.cpp:32
const QStringList NO_COMMAND_LINE
Definition: TestExport.cpp:37
const QString NO_EXTRACT_IMAGE_EXTENSION
Definition: TestExport.cpp:34
const QString NO_ERROR_REPORT_LOG_FILE
Definition: TestExport.cpp:27
const bool NO_GNUPLOT_LOG_FILES
Definition: TestExport.cpp:29
const QString NO_REGRESSION_OPEN_FILE
Definition: TestExport.cpp:28
const QStringList NO_LOAD_STARTUP_FILES
Definition: TestExport.cpp:36
const bool NO_REGRESSION_IMPORT
Definition: TestExport.cpp:30
const bool NO_EXTRACT_IMAGE_ONLY
Definition: TestExport.cpp:33
const bool NO_DROP_REGRESSION
Definition: TestExport.cpp:24
const bool DEBUG_FLAG
Definition: TestExport.cpp:35
const bool FILL_CHECKED
const bool FILL_UNCHECKED
const double M11
const double M22
ZoomFactor
Zoom factors ordered by zoom level so next one above/below is the next zoom level.
Definition: ZoomFactor.h:11
@ ZOOM_1_TO_1_FARTHER
Definition: ZoomFactor.h:25
@ ZOOM_2_TO_1
Definition: ZoomFactor.h:21
@ ZOOM_FILL
Definition: ZoomFactor.h:37
@ ZOOM_1_TO_1_CLOSER
Definition: ZoomFactor.h:23
@ ZOOM_1_TO_1
Definition: ZoomFactor.h:24
@ ZOOM_1_TO_16
Definition: ZoomFactor.h:36
@ ZOOM_16_TO_1
Definition: ZoomFactor.h:12
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:92
Unit test of ZoomTransition class.
TestZoomTransition(QObject *parent=0)
Single constructor.
Perform calculations to determine the next zoom setting given the current zoom setting,...
ZoomFactor zoomOut(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom out.
ZoomFactor zoomIn(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom in.