##// END OF EJS Templates
Add autoscale testcases to tst_qvaluesaxis
Michal Klocek -
r1705:253f5c2017da
parent child
Show More
@@ -1,368 +1,367
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qvaluesaxis.h"
21 #include "qvaluesaxis.h"
22 #include "qvaluesaxis_p.h"
22 #include "qvaluesaxis_p.h"
23 #include "chartvaluesaxisx_p.h"
23 #include "chartvaluesaxisx_p.h"
24 #include "chartvaluesaxisy_p.h"
24 #include "chartvaluesaxisy_p.h"
25 #include "domain_p.h"
25 #include "domain_p.h"
26 #include <cmath>
26 #include <cmath>
27 #include <QDebug>
27 #include <QDebug>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 /*!
30 /*!
31 \class QValuesAxis
31 \class QValuesAxis
32 \brief The QValuesAxis class is used for manipulating chart's axis.
32 \brief The QValuesAxis class is used for manipulating chart's axis.
33 \mainclass
33 \mainclass
34
34
35 ValuesAxis can be setup to show axis line with tick marks, grid lines and shades.
35 ValuesAxis can be setup to show axis line with tick marks, grid lines and shades.
36 Values of axis are drawn to position of ticks
36 Values of axis are drawn to position of ticks
37 */
37 */
38
38
39 /*!
39 /*!
40 \qmlclass ValuesAxis QValuesAxis
40 \qmlclass ValuesAxis QValuesAxis
41 \brief The ValuesAxis element is used for manipulating chart's axes
41 \brief The ValuesAxis element is used for manipulating chart's axes
42
42
43 ValueAxis can be setup to show axis line with tick marks, grid lines and shades.
43 ValueAxis can be setup to show axis line with tick marks, grid lines and shades.
44 Values of axis are drawn to position of ticks
44 Values of axis are drawn to position of ticks
45
45
46 To access Axes you can use ChartView API. For example:
46 To access Axes you can use ChartView API. For example:
47 \code
47 \code
48 ChartView {
48 ChartView {
49 ValuesAxis {
49 ValuesAxis {
50 id: xAxis
50 id: xAxis
51 min: 0
51 min: 0
52 max: 10
52 max: 10
53 }
53 }
54 // Add a few series...
54 // Add a few series...
55 }
55 }
56 \endcode
56 \endcode
57 */
57 */
58
58
59 /*!
59 /*!
60 \property QValuesAxis::min
60 \property QValuesAxis::min
61 Defines the minimum value on the axis.
61 Defines the minimum value on the axis.
62 */
62 */
63 /*!
63 /*!
64 \qmlproperty real ValuesAxis::min
64 \qmlproperty real ValuesAxis::min
65 Defines the minimum value on the axis.
65 Defines the minimum value on the axis.
66 */
66 */
67
67
68 /*!
68 /*!
69 \property QValuesAxis::max
69 \property QValuesAxis::max
70 Defines the maximum value on the axis.
70 Defines the maximum value on the axis.
71 */
71 */
72 /*!
72 /*!
73 \qmlproperty real ValuesAxis::max
73 \qmlproperty real ValuesAxis::max
74 Defines the maximum value on the axis.
74 Defines the maximum value on the axis.
75 */
75 */
76
76
77 /*!
77 /*!
78 \fn void QValuesAxis::minChanged(qreal min)
78 \fn void QValuesAxis::minChanged(qreal min)
79 Axis emits signal when \a min of axis has changed.
79 Axis emits signal when \a min of axis has changed.
80 */
80 */
81 /*!
81 /*!
82 \qmlsignal ValuesAxis::onMinChanged(real min)
82 \qmlsignal ValuesAxis::onMinChanged(real min)
83 Axis emits signal when \a min of axis has changed.
83 Axis emits signal when \a min of axis has changed.
84 */
84 */
85
85
86 /*!
86 /*!
87 \fn void QValuesAxis::maxChanged(qreal max)
87 \fn void QValuesAxis::maxChanged(qreal max)
88 Axis emits signal when \a max of axis has changed.
88 Axis emits signal when \a max of axis has changed.
89 */
89 */
90 /*!
90 /*!
91 \qmlsignal ValuesAxis::onMaxChanged(real max)
91 \qmlsignal ValuesAxis::onMaxChanged(real max)
92 Axis emits signal when \a max of axis has changed.
92 Axis emits signal when \a max of axis has changed.
93 */
93 */
94
94
95 /*!
95 /*!
96 \fn void QValuesAxis::rangeChanged(qreal min, qreal max)
96 \fn void QValuesAxis::rangeChanged(qreal min, qreal max)
97 Axis emits signal when \a min or \a max of axis has changed.
97 Axis emits signal when \a min or \a max of axis has changed.
98 */
98 */
99
99
100 /*!
100 /*!
101 \property QValuesAxis::ticksCount
101 \property QValuesAxis::ticksCount
102 The number of tick marks for the axis.
102 The number of tick marks for the axis.
103 */
103 */
104
104
105 /*!
105 /*!
106 \qmlproperty int ValuesAxis::ticksCount
106 \qmlproperty int ValuesAxis::ticksCount
107 The number of tick marks for the axis.
107 The number of tick marks for the axis.
108 */
108 */
109
109
110 /*!
110 /*!
111 \property QValuesAxis::niceNumbersEnabled
111 \property QValuesAxis::niceNumbersEnabled
112 Whether the nice numbers algorithm is enabled or not for the axis.
112 Whether the nice numbers algorithm is enabled or not for the axis.
113 */
113 */
114
114
115 /*!
115 /*!
116 \qmlproperty bool ValuesAxis::niceNumbersEnabled
116 \qmlproperty bool ValuesAxis::niceNumbersEnabled
117 Whether the nice numbers algorithm is enabled or not for the axis.
117 Whether the nice numbers algorithm is enabled or not for the axis.
118 */
118 */
119
119
120 /*!
120 /*!
121 Constructs an axis object which is a child of \a parent.
121 Constructs an axis object which is a child of \a parent.
122 */
122 */
123 QValuesAxis::QValuesAxis(QObject *parent) :
123 QValuesAxis::QValuesAxis(QObject *parent) :
124 QAbstractAxis(*new QValuesAxisPrivate(this),parent)
124 QAbstractAxis(*new QValuesAxisPrivate(this),parent)
125 {
125 {
126
126
127 }
127 }
128
128
129 /*!
129 /*!
130 \internal
130 \internal
131 */
131 */
132 QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
132 QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
133 {
133 {
134
134
135 }
135 }
136
136
137 /*!
137 /*!
138 Destroys the object
138 Destroys the object
139 */
139 */
140 QValuesAxis::~QValuesAxis()
140 QValuesAxis::~QValuesAxis()
141 {
141 {
142
142
143 }
143 }
144
144
145 void QValuesAxis::setMin(qreal min)
145 void QValuesAxis::setMin(qreal min)
146 {
146 {
147 Q_D(QValuesAxis);
147 Q_D(QValuesAxis);
148 setRange(min,d->m_max);
148 setRange(min,d->m_max);
149 }
149 }
150
150
151 qreal QValuesAxis::min() const
151 qreal QValuesAxis::min() const
152 {
152 {
153 Q_D(const QValuesAxis);
153 Q_D(const QValuesAxis);
154 return d->m_min;
154 return d->m_min;
155 }
155 }
156
156
157 void QValuesAxis::setMax(qreal max)
157 void QValuesAxis::setMax(qreal max)
158 {
158 {
159 Q_D(QValuesAxis);
159 Q_D(QValuesAxis);
160 setRange(d->m_min,max);
160 setRange(d->m_min,max);
161 }
161 }
162
162
163 qreal QValuesAxis::max() const
163 qreal QValuesAxis::max() const
164 {
164 {
165 Q_D(const QValuesAxis);
165 Q_D(const QValuesAxis);
166 return d->m_max;
166 return d->m_max;
167 }
167 }
168
168
169 /*!
169 /*!
170 Sets range from \a min to \a max on the axis.
170 Sets range from \a min to \a max on the axis.
171 */
171 */
172 void QValuesAxis::setRange(qreal min, qreal max)
172 void QValuesAxis::setRange(qreal min, qreal max)
173 {
173 {
174 Q_D(QValuesAxis);
174 Q_D(QValuesAxis);
175 bool changed = false;
175 bool changed = false;
176
176
177 if (!qFuzzyIsNull(d->m_min - min)) {
177 if (!qFuzzyIsNull(d->m_min - min)) {
178 d->m_min = min;
178 d->m_min = min;
179 changed = true;
179 changed = true;
180 emit minChanged(min);
180 emit minChanged(min);
181 }
181 }
182
182
183 if (!qFuzzyIsNull(d->m_max - max)) {
183 if (!qFuzzyIsNull(d->m_max - max)) {
184 d->m_max = max;
184 d->m_max = max;
185 changed = true;
185 changed = true;
186 emit maxChanged(max);
186 emit maxChanged(max);
187 }
187 }
188
188
189 if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount);
189 if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount);
190
190
191 if (changed) {
191 if (changed) {
192 emit rangeChanged(d->m_min,d->m_max);
192 emit rangeChanged(d->m_min,d->m_max);
193 d->emitUpdated();
193 d->emitUpdated();
194 }
194 }
195 }
195 }
196
196
197 /*!
197 /*!
198 Sets \a count for ticks on the axis.
198 Sets \a count for ticks on the axis.
199 */
199 */
200 void QValuesAxis::setTicksCount(int count)
200 void QValuesAxis::setTicksCount(int count)
201 {
201 {
202 Q_D(QValuesAxis);
202 Q_D(QValuesAxis);
203 if (d->m_tickCount != count && count >=2) {
203 if (d->m_tickCount != count && count >=2) {
204 d->m_tickCount = count;
204 d->m_tickCount = count;
205 d->emitUpdated();
205 d->emitUpdated();
206 }
206 }
207 }
207 }
208
208
209 /*!
209 /*!
210 \fn int QValuesAxis::ticksCount() const
210 \fn int QValuesAxis::ticksCount() const
211 Return number of ticks on the axis
211 Return number of ticks on the axis
212 */
212 */
213 int QValuesAxis::ticksCount() const
213 int QValuesAxis::ticksCount() const
214 {
214 {
215 Q_D(const QValuesAxis);
215 Q_D(const QValuesAxis);
216 return d->m_tickCount;
216 return d->m_tickCount;
217 }
217 }
218
218
219 void QValuesAxis::setNiceNumbersEnabled(bool enable)
219 void QValuesAxis::setNiceNumbersEnabled(bool enable)
220 {
220 {
221 Q_D(QValuesAxis);
221 Q_D(QValuesAxis);
222 if (d->m_niceNumbers != enable){
222 if (d->m_niceNumbers != enable){
223 d->m_niceNumbers = enable;
223 d->m_niceNumbers = enable;
224 if(enable && !qFuzzyIsNull(d->m_max - d->m_min)) setRange(d->min(),d->max());
224 if(enable && !qFuzzyIsNull(d->m_max - d->m_min)) setRange(d->min(),d->max());
225 }
225 }
226 }
226 }
227
227
228 bool QValuesAxis::niceNumbersEnabled() const
228 bool QValuesAxis::niceNumbersEnabled() const
229 {
229 {
230 Q_D(const QValuesAxis);
230 Q_D(const QValuesAxis);
231 return d->m_niceNumbers;
231 return d->m_niceNumbers;
232 }
232 }
233
233
234 /*!
234 /*!
235 Returns the type of the axis
235 Returns the type of the axis
236 */
236 */
237 QAbstractAxis::AxisType QValuesAxis::type() const
237 QAbstractAxis::AxisType QValuesAxis::type() const
238 {
238 {
239 return AxisTypeValues;
239 return AxisTypeValues;
240 }
240 }
241
241
242 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
242 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
243
243
244 QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q):
244 QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q):
245 QAbstractAxisPrivate(q),
245 QAbstractAxisPrivate(q),
246 m_min(0),
246 m_min(0),
247 m_max(0),
247 m_max(0),
248 m_tickCount(5),
248 m_tickCount(5),
249 m_niceNumbers(false)
249 m_niceNumbers(false)
250 {
250 {
251
251
252 }
252 }
253
253
254 QValuesAxisPrivate::~QValuesAxisPrivate()
254 QValuesAxisPrivate::~QValuesAxisPrivate()
255 {
255 {
256
256
257 }
257 }
258
258
259 void QValuesAxisPrivate::handleDomainUpdated()
259 void QValuesAxisPrivate::handleDomainUpdated()
260 {
260 {
261 Q_Q(QValuesAxis);
261 Q_Q(QValuesAxis);
262 Domain* domain = qobject_cast<Domain*>(sender());
262 Domain* domain = qobject_cast<Domain*>(sender());
263 Q_ASSERT(domain);
263 Q_ASSERT(domain);
264
264
265 if(orientation()==Qt::Horizontal){
265 if(orientation()==Qt::Horizontal){
266 q->setRange(domain->minX(),domain->maxX());
266 q->setRange(domain->minX(),domain->maxX());
267 }else if(orientation()==Qt::Vertical){
267 }else if(orientation()==Qt::Vertical){
268 q->setRange(domain->minY(),domain->maxY());
268 q->setRange(domain->minY(),domain->maxY());
269 }
269 }
270 }
270 }
271
271
272
272
273 void QValuesAxisPrivate::setMin(const QVariant &min)
273 void QValuesAxisPrivate::setMin(const QVariant &min)
274 {
274 {
275 Q_Q(QValuesAxis);
275 Q_Q(QValuesAxis);
276 bool ok;
276 bool ok;
277 qreal value = min.toReal(&ok);
277 qreal value = min.toReal(&ok);
278 if(ok) q->setMin(value);
278 if(ok) q->setMin(value);
279 }
279 }
280
280
281 void QValuesAxisPrivate::setMax(const QVariant &max)
281 void QValuesAxisPrivate::setMax(const QVariant &max)
282 {
282 {
283
283
284 Q_Q(QValuesAxis);
284 Q_Q(QValuesAxis);
285 bool ok;
285 bool ok;
286 qreal value = max.toReal(&ok);
286 qreal value = max.toReal(&ok);
287 if(ok) q->setMax(value);
287 if(ok) q->setMax(value);
288 }
288 }
289
289
290 void QValuesAxisPrivate::setRange(const QVariant &min, const QVariant &max)
290 void QValuesAxisPrivate::setRange(const QVariant &min, const QVariant &max)
291 {
291 {
292 Q_Q(QValuesAxis);
292 Q_Q(QValuesAxis);
293 bool ok1;
293 bool ok1;
294 bool ok2;
294 bool ok2;
295 qreal value1 = min.toReal(&ok1);
295 qreal value1 = min.toReal(&ok1);
296 qreal value2 = max.toReal(&ok2);
296 qreal value2 = max.toReal(&ok2);
297 if(ok1&&ok2) q->setRange(value1,value2);
297 if(ok1&&ok2) q->setRange(value1,value2);
298 }
298 }
299
299
300 ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter)
300 ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter)
301 {
301 {
302 Q_Q(QValuesAxis);
302 Q_Q(QValuesAxis);
303 if(m_orientation == Qt::Vertical){
303 if(m_orientation == Qt::Vertical){
304 return new ChartValuesAxisY(q,presenter);
304 return new ChartValuesAxisY(q,presenter);
305 }else{
305 }else{
306 return new ChartValuesAxisX(q,presenter);
306 return new ChartValuesAxisX(q,presenter);
307 }
307 }
308
308
309 }
309 }
310
310
311 void QValuesAxisPrivate::intializeDomain(Domain* domain)
311 void QValuesAxisPrivate::intializeDomain(Domain* domain)
312 {
312 {
313 Q_Q(QValuesAxis);
313 if(qFuzzyCompare(m_max,m_min)) {
314 if(qFuzzyCompare(m_max,m_min)) {
314 if(m_orientation==Qt::Vertical){
315 if(m_orientation==Qt::Vertical){
315 m_min = domain->minY();
316 q->setRange(domain->minY(),domain->maxY());
316 m_max = domain->maxY();
317 }else{
317 }else{
318 m_min = domain->minX();
318 q->setRange(domain->minX(), domain->maxX());
319 m_max = domain->maxX();
320 }
319 }
321 } else {
320 } else {
322 if(m_orientation==Qt::Vertical){
321 if(m_orientation==Qt::Vertical){
323 domain->setRangeY(m_min, m_max);
322 domain->setRangeY(m_min, m_max);
324 }else{
323 }else{
325 domain->setRangeX(m_min, m_max);
324 domain->setRangeX(m_min, m_max);
326 }
325 }
327 }
326 }
328 }
327 }
329
328
330 //algorithm defined by Paul S.Heckbert GraphicalGems I
329 //algorithm defined by Paul S.Heckbert GraphicalGems I
331
330
332 void QValuesAxisPrivate::looseNiceNumbers(qreal &min, qreal &max, int &ticksCount) const
331 void QValuesAxisPrivate::looseNiceNumbers(qreal &min, qreal &max, int &ticksCount) const
333 {
332 {
334 qreal range = niceNumber(max-min,true); //range with ceiling
333 qreal range = niceNumber(max-min,true); //range with ceiling
335 qreal step = niceNumber(range/(ticksCount-1),false);
334 qreal step = niceNumber(range/(ticksCount-1),false);
336 min = floor(min/step);
335 min = floor(min/step);
337 max = ceil(max/step);
336 max = ceil(max/step);
338 ticksCount = int(max-min) +1;
337 ticksCount = int(max-min) +1;
339 min*=step;
338 min*=step;
340 max*=step;
339 max*=step;
341 }
340 }
342
341
343 //nice numbers can be expressed as form of 1*10^n, 2* 10^n or 5*10^n
342 //nice numbers can be expressed as form of 1*10^n, 2* 10^n or 5*10^n
344
343
345 qreal QValuesAxisPrivate::niceNumber(qreal x,bool ceiling) const
344 qreal QValuesAxisPrivate::niceNumber(qreal x,bool ceiling) const
346 {
345 {
347 qreal z = pow(10,floor(log10(x))); //find corresponding number of the form of 10^n than is smaller than x
346 qreal z = pow(10,floor(log10(x))); //find corresponding number of the form of 10^n than is smaller than x
348 qreal q = x/z;//q<10 && q>=1;
347 qreal q = x/z;//q<10 && q>=1;
349
348
350 if(ceiling) {
349 if(ceiling) {
351 if(q <= 1.0) q=1;
350 if(q <= 1.0) q=1;
352 else if(q <= 2.0) q=2;
351 else if(q <= 2.0) q=2;
353 else if(q <= 5.0) q=5;
352 else if(q <= 5.0) q=5;
354 else q=10;
353 else q=10;
355 }
354 }
356 else {
355 else {
357 if(q < 1.5) q=1;
356 if(q < 1.5) q=1;
358 else if(q < 3.0) q=2;
357 else if(q < 3.0) q=2;
359 else if(q < 7.0) q=5;
358 else if(q < 7.0) q=5;
360 else q=10;
359 else q=10;
361 }
360 }
362 return q*z;
361 return q*z;
363 }
362 }
364
363
365 #include "moc_qvaluesaxis.cpp"
364 #include "moc_qvaluesaxis.cpp"
366 #include "moc_qvaluesaxis_p.cpp"
365 #include "moc_qvaluesaxis_p.cpp"
367
366
368 QTCOMMERCIALCHART_END_NAMESPACE
367 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,351 +1,412
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "../qabstractaxis/tst_qabstractaxis.h"
21 #include "../qabstractaxis/tst_qabstractaxis.h"
22 #include "qvaluesaxis.h"
22 #include "qvaluesaxis.h"
23 #include <qlineseries.h>
23 #include <qlineseries.h>
24
24
25 class tst_QValuesAxis: public tst_QAbstractAxis
25 class tst_QValuesAxis: public tst_QAbstractAxis
26 {
26 {
27 Q_OBJECT
27 Q_OBJECT
28
28
29 public slots:
29 public slots:
30 void initTestCase();
30 void initTestCase();
31 void cleanupTestCase();
31 void cleanupTestCase();
32 void init();
32 void init();
33 void cleanup();
33 void cleanup();
34
34
35 private slots:
35 private slots:
36 void qvaluesaxis_data();
36 void qvaluesaxis_data();
37 void qvaluesaxis();
37 void qvaluesaxis();
38
39 void max_raw_data();
38 void max_raw_data();
40 void max_raw();
39 void max_raw();
41 void max_data();
40 void max_data();
42 void max();
41 void max();
43 void max_animation_data();
42 void max_animation_data();
44 void max_animation();
43 void max_animation();
45 void min_raw_data();
44 void min_raw_data();
46 void min_raw();
45 void min_raw();
47 void min_data();
46 void min_data();
48 void min();
47 void min();
49 void min_animation_data();
48 void min_animation_data();
50 void min_animation();
49 void min_animation();
51 void niceNumbersEnabled_data();
50 void niceNumbersEnabled_data();
52 void niceNumbersEnabled();
51 void niceNumbersEnabled();
53 void range_raw_data();
52 void range_raw_data();
54 void range_raw();
53 void range_raw();
55 void range_data();
54 void range_data();
56 void range();
55 void range();
57 void range_animation_data();
56 void range_animation_data();
58 void range_animation();
57 void range_animation();
59 void ticksCount_data();
58 void ticksCount_data();
60 void ticksCount();
59 void ticksCount();
60 void noautoscale_data();
61 void noautoscale();
62 void autoscale_data();
63 void autoscale();
61
64
62 private:
65 private:
63 QValuesAxis* m_valuesaxis;
66 QValuesAxis* m_valuesaxis;
64 QLineSeries* m_series;
67 QLineSeries* m_series;
65 };
68 };
66
69
67 void tst_QValuesAxis::initTestCase()
70 void tst_QValuesAxis::initTestCase()
68 {
71 {
69 }
72 }
70
73
71 void tst_QValuesAxis::cleanupTestCase()
74 void tst_QValuesAxis::cleanupTestCase()
72 {
75 {
73 }
76 }
74
77
75 void tst_QValuesAxis::init()
78 void tst_QValuesAxis::init()
76 {
79 {
77 m_valuesaxis = new QValuesAxis();
80 m_valuesaxis = new QValuesAxis();
78 m_series = new QLineSeries();
81 m_series = new QLineSeries();
79 *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100);
82 *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100);
80 tst_QAbstractAxis::init(m_valuesaxis,m_series);
83 tst_QAbstractAxis::init(m_valuesaxis,m_series);
81 m_chart->addSeries(m_series);
84 m_chart->addSeries(m_series);
82 m_chart->createDefaultAxes();
85 m_chart->createDefaultAxes();
83 }
86 }
84
87
85 void tst_QValuesAxis::cleanup()
88 void tst_QValuesAxis::cleanup()
86 {
89 {
87 delete m_series;
90 delete m_series;
88 delete m_valuesaxis;
91 delete m_valuesaxis;
89 m_series = 0;
92 m_series = 0;
90 m_valuesaxis = 0;
93 m_valuesaxis = 0;
91 tst_QAbstractAxis::cleanup();
94 tst_QAbstractAxis::cleanup();
92 }
95 }
93
96
94 void tst_QValuesAxis::qvaluesaxis_data()
97 void tst_QValuesAxis::qvaluesaxis_data()
95 {
98 {
96 }
99 }
97
100
98 void tst_QValuesAxis::qvaluesaxis()
101 void tst_QValuesAxis::qvaluesaxis()
99 {
102 {
100 qabstractaxis();
103 qabstractaxis();
101
104
102 QVERIFY(qFuzzyIsNull(m_valuesaxis->max()));
105 QVERIFY(qFuzzyIsNull(m_valuesaxis->max()));
103 QVERIFY(qFuzzyIsNull(m_valuesaxis->min()));
106 QVERIFY(qFuzzyIsNull(m_valuesaxis->min()));
104 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
107 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
105 QCOMPARE(m_valuesaxis->ticksCount(), 5);
108 QCOMPARE(m_valuesaxis->ticksCount(), 5);
106 QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValues);
109 QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValues);
107
110
108 m_chart->setAxisX(m_valuesaxis, m_series);
111 m_chart->setAxisX(m_valuesaxis, m_series);
109 m_view->show();
112 m_view->show();
110 QTest::qWaitForWindowShown(m_view);
113 QTest::qWaitForWindowShown(m_view);
111
114
112 QVERIFY(!qFuzzyIsNull(m_valuesaxis->max()));
115 QVERIFY(!qFuzzyIsNull(m_valuesaxis->max()));
113 QVERIFY(!qFuzzyIsNull(m_valuesaxis->min()));
116 QVERIFY(!qFuzzyIsNull(m_valuesaxis->min()));
114 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
117 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
115 QCOMPARE(m_valuesaxis->ticksCount(), 5);
118 QCOMPARE(m_valuesaxis->ticksCount(), 5);
116 }
119 }
117
120
118 void tst_QValuesAxis::max_raw_data()
121 void tst_QValuesAxis::max_raw_data()
119 {
122 {
120 QTest::addColumn<qreal>("max");
123 QTest::addColumn<qreal>("max");
121 QTest::newRow("1.0") << 1.0;
124 QTest::newRow("1.0") << 1.0;
122 QTest::newRow("50.0") << 50.0;
125 QTest::newRow("50.0") << 50.0;
123 QTest::newRow("101.0") << 101.0;
126 QTest::newRow("101.0") << 101.0;
124 }
127 }
125
128
126 void tst_QValuesAxis::max_raw()
129 void tst_QValuesAxis::max_raw()
127 {
130 {
128 QFETCH(qreal, max);
131 QFETCH(qreal, max);
129
132
130 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
133 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
131 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
134 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
132 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
135 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
133
136
134 m_valuesaxis->setMax(max);
137 m_valuesaxis->setMax(max);
135 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Not equal");
138 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Not equal");
136
139
137 QCOMPARE(spy0.count(), 1);
140 QCOMPARE(spy0.count(), 1);
138 QCOMPARE(spy1.count(), 0);
141 QCOMPARE(spy1.count(), 0);
139 QCOMPARE(spy2.count(), 1);
142 QCOMPARE(spy2.count(), 1);
140
143
141 }
144 }
142
145
143 void tst_QValuesAxis::max_data()
146 void tst_QValuesAxis::max_data()
144 {
147 {
145 max_raw_data();
148 max_raw_data();
146 }
149 }
147
150
148 void tst_QValuesAxis::max()
151 void tst_QValuesAxis::max()
149 {
152 {
150 m_chart->setAxisX(m_valuesaxis, m_series);
153 m_chart->setAxisX(m_valuesaxis, m_series);
151 m_view->show();
154 m_view->show();
152 QTest::qWaitForWindowShown(m_view);
155 QTest::qWaitForWindowShown(m_view);
153 max_raw();
156 max_raw();
154 }
157 }
155
158
156 void tst_QValuesAxis::max_animation_data()
159 void tst_QValuesAxis::max_animation_data()
157 {
160 {
158 max_data();
161 max_data();
159 }
162 }
160
163
161 void tst_QValuesAxis::max_animation()
164 void tst_QValuesAxis::max_animation()
162 {
165 {
163 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
166 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
164 max();
167 max();
165 }
168 }
166
169
167 void tst_QValuesAxis::min_raw_data()
170 void tst_QValuesAxis::min_raw_data()
168 {
171 {
169 QTest::addColumn<qreal>("min");
172 QTest::addColumn<qreal>("min");
170 QTest::newRow("-1.0") << -1.0;
173 QTest::newRow("-1.0") << -1.0;
171 QTest::newRow("-50.0") << -50.0;
174 QTest::newRow("-50.0") << -50.0;
172 QTest::newRow("-101.0") << -101.0;
175 QTest::newRow("-101.0") << -101.0;
173 }
176 }
174
177
175 void tst_QValuesAxis::min_raw()
178 void tst_QValuesAxis::min_raw()
176 {
179 {
177 QFETCH(qreal, min);
180 QFETCH(qreal, min);
178
181
179 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
182 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
180 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
183 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
181 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
184 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
182
185
183 m_valuesaxis->setMin(min);
186 m_valuesaxis->setMin(min);
184 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Not equal");
187 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Not equal");
185
188
186 QCOMPARE(spy0.count(), 0);
189 QCOMPARE(spy0.count(), 0);
187 QCOMPARE(spy1.count(), 1);
190 QCOMPARE(spy1.count(), 1);
188 QCOMPARE(spy2.count(), 1);
191 QCOMPARE(spy2.count(), 1);
189 }
192 }
190
193
191 void tst_QValuesAxis::min_data()
194 void tst_QValuesAxis::min_data()
192 {
195 {
193 min_raw_data();
196 min_raw_data();
194 }
197 }
195
198
196 void tst_QValuesAxis::min()
199 void tst_QValuesAxis::min()
197 {
200 {
198 m_chart->setAxisX(m_valuesaxis, m_series);
201 m_chart->setAxisX(m_valuesaxis, m_series);
199 m_view->show();
202 m_view->show();
200 QTest::qWaitForWindowShown(m_view);
203 QTest::qWaitForWindowShown(m_view);
201 min_raw();
204 min_raw();
202 }
205 }
203
206
204 void tst_QValuesAxis::min_animation_data()
207 void tst_QValuesAxis::min_animation_data()
205 {
208 {
206 min_data();
209 min_data();
207 }
210 }
208
211
209 void tst_QValuesAxis::min_animation()
212 void tst_QValuesAxis::min_animation()
210 {
213 {
211 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
214 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
212 min();
215 min();
213 }
216 }
214
217
215 void tst_QValuesAxis::niceNumbersEnabled_data()
218 void tst_QValuesAxis::niceNumbersEnabled_data()
216 {
219 {
217 QTest::addColumn<bool>("niceNumbersEnabled");
220 QTest::addColumn<bool>("niceNumbersEnabled");
218 QTest::addColumn<qreal>("min");
221 QTest::addColumn<qreal>("min");
219 QTest::addColumn<qreal>("max");
222 QTest::addColumn<qreal>("max");
220 QTest::addColumn<int>("ticks");
223 QTest::addColumn<int>("ticks");
221 QTest::addColumn<qreal>("expectedMin");
224 QTest::addColumn<qreal>("expectedMin");
222 QTest::addColumn<qreal>("expectedMax");
225 QTest::addColumn<qreal>("expectedMax");
223 QTest::addColumn<int>("expectedTicks");
226 QTest::addColumn<int>("expectedTicks");
224 QTest::newRow("true 0.1 , 99.0 , 5") << true << 0.1 << 99.0 << 5 << 0.0 << 100.0 << 6;
227 QTest::newRow("true 0.1 , 99.0 , 5") << true << 0.1 << 99.0 << 5 << 0.0 << 100.0 << 6;
225 QTest::newRow("true 1 , 10.0 , 5") << true << 1.0 << 10.0 << 5 << 0.0 << 10.0 << 6;
228 QTest::newRow("true 1 , 10.0 , 5") << true << 1.0 << 10.0 << 5 << 0.0 << 10.0 << 6;
226 QTest::newRow("true 0.1 , 6.6 , 5") << true << 0.1 << 6.6 << 5 << 0.0 << 8.0 << 5;
229 QTest::newRow("true 0.1 , 6.6 , 5") << true << 0.1 << 6.6 << 5 << 0.0 << 8.0 << 5;
227 QTest::newRow("false 0.1 , 6.6 , 5") << false << 0.1 << 6.6 << 5 << 0.1 << 6.6 << 5;
230 QTest::newRow("false 0.1 , 6.6 , 5") << false << 0.1 << 6.6 << 5 << 0.1 << 6.6 << 5;
228 QTest::newRow("true 0.1, 99, 5") << true << 0.1 << 99.0 << 5 << 0.0 << 100.0 << 6;
231 QTest::newRow("true 0.1, 99, 5") << true << 0.1 << 99.0 << 5 << 0.0 << 100.0 << 6;
229 QTest::newRow("true 5, 93.5 , 5") << true << 5.0 << 93.5 << 5 << 0.0 << 100.0 << 6;
232 QTest::newRow("true 5, 93.5 , 5") << true << 5.0 << 93.5 << 5 << 0.0 << 100.0 << 6;
230 }
233 }
231
234
232 void tst_QValuesAxis::niceNumbersEnabled()
235 void tst_QValuesAxis::niceNumbersEnabled()
233 {
236 {
234 QFETCH(bool, niceNumbersEnabled);
237 QFETCH(bool, niceNumbersEnabled);
235 QFETCH(qreal, min);
238 QFETCH(qreal, min);
236 QFETCH(qreal, max);
239 QFETCH(qreal, max);
237 QFETCH(int, ticks);
240 QFETCH(int, ticks);
238 QFETCH(qreal, expectedMin);
241 QFETCH(qreal, expectedMin);
239 QFETCH(qreal, expectedMax);
242 QFETCH(qreal, expectedMax);
240 QFETCH(int, expectedTicks);
243 QFETCH(int, expectedTicks);
241
244
242 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
245 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
243 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
246 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
244 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
247 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
245
248
246 m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled);
249 m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled);
247 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled);
250 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled);
248
251
249 QCOMPARE(spy0.count(), 0);
252 QCOMPARE(spy0.count(), 0);
250 QCOMPARE(spy1.count(), 0);
253 QCOMPARE(spy1.count(), 0);
251 QCOMPARE(spy2.count(), 0);
254 QCOMPARE(spy2.count(), 0);
252
255
253 m_valuesaxis->setTicksCount(ticks);
256 m_valuesaxis->setTicksCount(ticks);
254 m_valuesaxis->setRange(min, max);
257 m_valuesaxis->setRange(min, max);
255 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal");
258 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal");
256 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal");
259 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal");
257 QCOMPARE(m_valuesaxis->ticksCount(), expectedTicks);
260 QCOMPARE(m_valuesaxis->ticksCount(), expectedTicks);
258
261
259 QCOMPARE(spy0.count(), 1);
262 QCOMPARE(spy0.count(), 1);
260 QCOMPARE(spy1.count(), 1);
263 QCOMPARE(spy1.count(), 1);
261 QCOMPARE(spy2.count(), 1);
264 QCOMPARE(spy2.count(), 1);
262
265
263 }
266 }
264
267
265 void tst_QValuesAxis::range_raw_data()
268 void tst_QValuesAxis::range_raw_data()
266 {
269 {
267 QTest::addColumn<qreal>("min");
270 QTest::addColumn<qreal>("min");
268 QTest::addColumn<qreal>("max");
271 QTest::addColumn<qreal>("max");
269 QTest::newRow("1.0 - 101.0") << -1.0 << 101.0;
272 QTest::newRow("1.0 - 101.0") << -1.0 << 101.0;
270 QTest::newRow("25.0 - 75.0") << 25.0 << 75.0;
273 QTest::newRow("25.0 - 75.0") << 25.0 << 75.0;
271 QTest::newRow("101.0") << 40.0 << 60.0;
274 QTest::newRow("101.0") << 40.0 << 60.0;
272 }
275 }
273
276
274 void tst_QValuesAxis::range_raw()
277 void tst_QValuesAxis::range_raw()
275 {
278 {
276 QFETCH(qreal, min);
279 QFETCH(qreal, min);
277 QFETCH(qreal, max);
280 QFETCH(qreal, max);
278
281
279 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
282 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
280 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
283 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
281 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
284 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
282
285
283 m_valuesaxis->setRange(min, max);
286 m_valuesaxis->setRange(min, max);
284 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
287 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
285 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
288 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
286
289
287 QCOMPARE(spy0.count(), 1);
290 QCOMPARE(spy0.count(), 1);
288 QCOMPARE(spy1.count(), 1);
291 QCOMPARE(spy1.count(), 1);
289 QCOMPARE(spy2.count(), 1);
292 QCOMPARE(spy2.count(), 1);
290 }
293 }
291
294
292 void tst_QValuesAxis::range_data()
295 void tst_QValuesAxis::range_data()
293 {
296 {
294 range_raw_data();
297 range_raw_data();
295 }
298 }
296
299
297 void tst_QValuesAxis::range()
300 void tst_QValuesAxis::range()
298 {
301 {
299 m_chart->setAxisX(m_valuesaxis, m_series);
302 m_chart->setAxisX(m_valuesaxis, m_series);
300 m_view->show();
303 m_view->show();
301 QTest::qWaitForWindowShown(m_view);
304 QTest::qWaitForWindowShown(m_view);
302 range_raw();
305 range_raw();
303 }
306 }
304
307
305 void tst_QValuesAxis::range_animation_data()
308 void tst_QValuesAxis::range_animation_data()
306 {
309 {
307 range_data();
310 range_data();
308 }
311 }
309
312
310 void tst_QValuesAxis::range_animation()
313 void tst_QValuesAxis::range_animation()
311 {
314 {
312 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
315 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
313 range();
316 range();
314 }
317 }
315
318
316 void tst_QValuesAxis::ticksCount_data()
319 void tst_QValuesAxis::ticksCount_data()
317 {
320 {
318 QTest::addColumn<int>("ticksCount");
321 QTest::addColumn<int>("ticksCount");
319 QTest::addColumn<int>("expectedCount");
322 QTest::addColumn<int>("expectedCount");
320 QTest::newRow("0") << 2;
323 QTest::newRow("0") << 2;
321 QTest::newRow("1") << 2;
324 QTest::newRow("1") << 2;
322 QTest::newRow("2") << 2;
325 QTest::newRow("2") << 2;
323 QTest::newRow("3") << 3;
326 QTest::newRow("3") << 3;
324 QTest::newRow("-1") << 2;
327 QTest::newRow("-1") << 2;
325 }
328 }
326
329
327 void tst_QValuesAxis::ticksCount()
330 void tst_QValuesAxis::ticksCount()
328 {
331 {
329 QFETCH(int, ticksCount);
332 QFETCH(int, ticksCount);
330
333
331 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
334 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
332 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
335 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
333 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
336 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
334
337
335 m_valuesaxis->setTicksCount(ticksCount);
338 m_valuesaxis->setTicksCount(ticksCount);
336 QCOMPARE(m_valuesaxis->ticksCount(), ticksCount);
339 QCOMPARE(m_valuesaxis->ticksCount(), ticksCount);
337
340
338 QCOMPARE(spy0.count(), 0);
341 QCOMPARE(spy0.count(), 0);
339 QCOMPARE(spy1.count(), 0);
342 QCOMPARE(spy1.count(), 0);
340 QCOMPARE(spy2.count(), 0);
343 QCOMPARE(spy2.count(), 0);
341
344
342 m_chart->setAxisX(m_valuesaxis, m_series);
345 m_chart->setAxisX(m_valuesaxis, m_series);
343 m_view->show();
346 m_view->show();
344 QTest::qWaitForWindowShown(m_view);
347 QTest::qWaitForWindowShown(m_view);
345
348
346 QCOMPARE(m_valuesaxis->ticksCount(), ticksCount);
349 QCOMPARE(m_valuesaxis->ticksCount(), ticksCount);
347 }
350 }
348
351
352 void tst_QValuesAxis::noautoscale_data()
353 {
354 QTest::addColumn<qreal>("min");
355 QTest::addColumn<qreal>("max");
356 QTest::newRow("1.0 - 101.0") << -1.0 << 101.0;
357 QTest::newRow("25.0 - 75.0") << 25.0 << 75.0;
358 QTest::newRow("101.0") << 40.0 << 60.0;
359 }
360
361 void tst_QValuesAxis::noautoscale()
362 {
363 QFETCH(qreal, min);
364 QFETCH(qreal, max);
365
366 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
367 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
368 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
369
370 m_valuesaxis->setRange(min, max);
371 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
372 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
373
374 QCOMPARE(spy0.count(), 1);
375 QCOMPARE(spy1.count(), 1);
376 QCOMPARE(spy2.count(), 1);
377
378 m_chart->setAxisX(m_valuesaxis, m_series);
379 m_view->show();
380 QTest::qWaitForWindowShown(m_view);
381 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
382 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
383 }
384
385 void tst_QValuesAxis::autoscale_data()
386 {
387
388 }
389
390 void tst_QValuesAxis::autoscale()
391 {
392 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
393 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
394 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
395
396 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min()), "Min not equal");
397 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max()), "Max not equal");
398 m_chart->setAxisX(m_valuesaxis, m_series);
399
400 QCOMPARE(spy0.count(), 1);
401 QCOMPARE(spy1.count(), 1);
402 QCOMPARE(spy2.count(), 1);
403
404 m_view->show();
405 QTest::qWaitForWindowShown(m_view);
406 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() + 100), "Min not equal");
407 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - 100), "Max not equal");
408 }
409
349 QTEST_MAIN(tst_QValuesAxis)
410 QTEST_MAIN(tst_QValuesAxis)
350 #include "tst_qvaluesaxis.moc"
411 #include "tst_qvaluesaxis.moc"
351
412
General Comments 0
You need to be logged in to leave comments. Login now