##// END OF EJS Templates
QValueAxis tests fixed on ARM
Marek Rosa -
r1943:03f8afda2429
parent child
Show More
@@ -1,415 +1,415
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 "qvalueaxis.h"
22 #include "qvalueaxis.h"
23 #include <qlineseries.h>
23 #include <qlineseries.h>
24
24
25 class tst_QValueAxis: public tst_QAbstractAxis
25 class tst_QValueAxis: 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 qvalueaxis_data();
36 void qvalueaxis_data();
37 void qvalueaxis();
37 void qvalueaxis();
38 void max_raw_data();
38 void max_raw_data();
39 void max_raw();
39 void max_raw();
40 void max_data();
40 void max_data();
41 void max();
41 void max();
42 void max_animation_data();
42 void max_animation_data();
43 void max_animation();
43 void max_animation();
44 void min_raw_data();
44 void min_raw_data();
45 void min_raw();
45 void min_raw();
46 void min_data();
46 void min_data();
47 void min();
47 void min();
48 void min_animation_data();
48 void min_animation_data();
49 void min_animation();
49 void min_animation();
50 void niceNumbersEnabled_data();
50 void niceNumbersEnabled_data();
51 void niceNumbersEnabled();
51 void niceNumbersEnabled();
52 void range_raw_data();
52 void range_raw_data();
53 void range_raw();
53 void range_raw();
54 void range_data();
54 void range_data();
55 void range();
55 void range();
56 void range_animation_data();
56 void range_animation_data();
57 void range_animation();
57 void range_animation();
58 void ticksCount_data();
58 void ticksCount_data();
59 void ticksCount();
59 void ticksCount();
60 void noautoscale_data();
60 void noautoscale_data();
61 void noautoscale();
61 void noautoscale();
62 void autoscale_data();
62 void autoscale_data();
63 void autoscale();
63 void autoscale();
64
64
65 private:
65 private:
66 QValueAxis* m_valuesaxis;
66 QValueAxis* m_valuesaxis;
67 QLineSeries* m_series;
67 QLineSeries* m_series;
68 };
68 };
69
69
70 void tst_QValueAxis::initTestCase()
70 void tst_QValueAxis::initTestCase()
71 {
71 {
72 }
72 }
73
73
74 void tst_QValueAxis::cleanupTestCase()
74 void tst_QValueAxis::cleanupTestCase()
75 {
75 {
76 }
76 }
77
77
78 void tst_QValueAxis::init()
78 void tst_QValueAxis::init()
79 {
79 {
80 m_valuesaxis = new QValueAxis();
80 m_valuesaxis = new QValueAxis();
81 m_series = new QLineSeries();
81 m_series = new QLineSeries();
82 *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100);
82 *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100);
83 tst_QAbstractAxis::init(m_valuesaxis,m_series);
83 tst_QAbstractAxis::init(m_valuesaxis,m_series);
84 m_chart->addSeries(m_series);
84 m_chart->addSeries(m_series);
85 m_chart->createDefaultAxes();
85 m_chart->createDefaultAxes();
86 }
86 }
87
87
88 void tst_QValueAxis::cleanup()
88 void tst_QValueAxis::cleanup()
89 {
89 {
90 delete m_series;
90 delete m_series;
91 delete m_valuesaxis;
91 delete m_valuesaxis;
92 m_series = 0;
92 m_series = 0;
93 m_valuesaxis = 0;
93 m_valuesaxis = 0;
94 tst_QAbstractAxis::cleanup();
94 tst_QAbstractAxis::cleanup();
95 }
95 }
96
96
97 void tst_QValueAxis::qvalueaxis_data()
97 void tst_QValueAxis::qvalueaxis_data()
98 {
98 {
99 }
99 }
100
100
101 void tst_QValueAxis::qvalueaxis()
101 void tst_QValueAxis::qvalueaxis()
102 {
102 {
103 qabstractaxis();
103 qabstractaxis();
104
104
105 QVERIFY(qFuzzyIsNull(m_valuesaxis->max()));
105 QVERIFY(qFuzzyIsNull(m_valuesaxis->max()));
106 QVERIFY(qFuzzyIsNull(m_valuesaxis->min()));
106 QVERIFY(qFuzzyIsNull(m_valuesaxis->min()));
107 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
107 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
108 QCOMPARE(m_valuesaxis->tickCount(), 5);
108 QCOMPARE(m_valuesaxis->tickCount(), 5);
109 QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValue);
109 QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValue);
110
110
111 m_chart->setAxisX(m_valuesaxis, m_series);
111 m_chart->setAxisX(m_valuesaxis, m_series);
112 m_view->show();
112 m_view->show();
113 QTest::qWaitForWindowShown(m_view);
113 QTest::qWaitForWindowShown(m_view);
114
114
115 QVERIFY(!qFuzzyIsNull(m_valuesaxis->max()));
115 QVERIFY(!qFuzzyIsNull(m_valuesaxis->max()));
116 QVERIFY(!qFuzzyIsNull(m_valuesaxis->min()));
116 QVERIFY(!qFuzzyIsNull(m_valuesaxis->min()));
117 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
117 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false);
118 QCOMPARE(m_valuesaxis->tickCount(), 5);
118 QCOMPARE(m_valuesaxis->tickCount(), 5);
119 }
119 }
120
120
121 void tst_QValueAxis::max_raw_data()
121 void tst_QValueAxis::max_raw_data()
122 {
122 {
123 QTest::addColumn<qreal>("max");
123 QTest::addColumn<qreal>("max");
124 QTest::newRow("1.0") << (qreal)1.0;
124 QTest::newRow("1.0") << (qreal)1.0;
125 QTest::newRow("50.0") << (qreal)50.0;
125 QTest::newRow("50.0") << (qreal)50.0;
126 QTest::newRow("101.0") << (qreal)101.0;
126 QTest::newRow("101.0") << (qreal)101.0;
127 }
127 }
128
128
129 void tst_QValueAxis::max_raw()
129 void tst_QValueAxis::max_raw()
130 {
130 {
131 QFETCH(qreal, max);
131 QFETCH(qreal, max);
132
132
133 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
133 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
134 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
134 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
135 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
135 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
136
136
137 m_valuesaxis->setMax(max);
137 m_valuesaxis->setMax(max);
138 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Not equal");
138 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Not equal");
139
139
140 QCOMPARE(spy0.count(), 1);
140 QCOMPARE(spy0.count(), 1);
141 QCOMPARE(spy1.count(), 0);
141 QCOMPARE(spy1.count(), 0);
142 QCOMPARE(spy2.count(), 1);
142 QCOMPARE(spy2.count(), 1);
143
143
144 }
144 }
145
145
146 void tst_QValueAxis::max_data()
146 void tst_QValueAxis::max_data()
147 {
147 {
148 max_raw_data();
148 max_raw_data();
149 }
149 }
150
150
151 void tst_QValueAxis::max()
151 void tst_QValueAxis::max()
152 {
152 {
153 m_chart->setAxisX(m_valuesaxis, m_series);
153 m_chart->setAxisX(m_valuesaxis, m_series);
154 m_view->show();
154 m_view->show();
155 QTest::qWaitForWindowShown(m_view);
155 QTest::qWaitForWindowShown(m_view);
156 max_raw();
156 max_raw();
157 }
157 }
158
158
159 void tst_QValueAxis::max_animation_data()
159 void tst_QValueAxis::max_animation_data()
160 {
160 {
161 max_data();
161 max_data();
162 }
162 }
163
163
164 void tst_QValueAxis::max_animation()
164 void tst_QValueAxis::max_animation()
165 {
165 {
166 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
166 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
167 max();
167 max();
168 }
168 }
169
169
170 void tst_QValueAxis::min_raw_data()
170 void tst_QValueAxis::min_raw_data()
171 {
171 {
172 QTest::addColumn<qreal>("min");
172 QTest::addColumn<qreal>("min");
173 QTest::newRow("-1.0") << -1.0;
173 QTest::newRow("-1.0") << (qreal)-1.0;
174 QTest::newRow("-50.0") << -50.0;
174 QTest::newRow("-50.0") << (qreal)-50.0;
175 QTest::newRow("-101.0") << -101.0;
175 QTest::newRow("-101.0") << (qreal)-101.0;
176 }
176 }
177
177
178 void tst_QValueAxis::min_raw()
178 void tst_QValueAxis::min_raw()
179 {
179 {
180 QFETCH(qreal, min);
180 QFETCH(qreal, min);
181
181
182 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
182 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
183 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
183 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
184 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
184 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
185
185
186 m_valuesaxis->setMin(min);
186 m_valuesaxis->setMin(min);
187 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Not equal");
187 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Not equal");
188
188
189 QCOMPARE(spy0.count(), 0);
189 QCOMPARE(spy0.count(), 0);
190 QCOMPARE(spy1.count(), 1);
190 QCOMPARE(spy1.count(), 1);
191 QCOMPARE(spy2.count(), 1);
191 QCOMPARE(spy2.count(), 1);
192 }
192 }
193
193
194 void tst_QValueAxis::min_data()
194 void tst_QValueAxis::min_data()
195 {
195 {
196 min_raw_data();
196 min_raw_data();
197 }
197 }
198
198
199 void tst_QValueAxis::min()
199 void tst_QValueAxis::min()
200 {
200 {
201 m_chart->setAxisX(m_valuesaxis, m_series);
201 m_chart->setAxisX(m_valuesaxis, m_series);
202 m_view->show();
202 m_view->show();
203 QTest::qWaitForWindowShown(m_view);
203 QTest::qWaitForWindowShown(m_view);
204 min_raw();
204 min_raw();
205 }
205 }
206
206
207 void tst_QValueAxis::min_animation_data()
207 void tst_QValueAxis::min_animation_data()
208 {
208 {
209 min_data();
209 min_data();
210 }
210 }
211
211
212 void tst_QValueAxis::min_animation()
212 void tst_QValueAxis::min_animation()
213 {
213 {
214 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
214 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
215 min();
215 min();
216 }
216 }
217
217
218 void tst_QValueAxis::niceNumbersEnabled_data()
218 void tst_QValueAxis::niceNumbersEnabled_data()
219 {
219 {
220 QTest::addColumn<bool>("niceNumbersEnabled");
220 QTest::addColumn<bool>("niceNumbersEnabled");
221 QTest::addColumn<qreal>("min");
221 QTest::addColumn<qreal>("min");
222 QTest::addColumn<qreal>("max");
222 QTest::addColumn<qreal>("max");
223 QTest::addColumn<int>("ticks");
223 QTest::addColumn<int>("ticks");
224 QTest::addColumn<qreal>("expectedMin");
224 QTest::addColumn<qreal>("expectedMin");
225 QTest::addColumn<qreal>("expectedMax");
225 QTest::addColumn<qreal>("expectedMax");
226 QTest::addColumn<int>("expectedTicks");
226 QTest::addColumn<int>("expectedTicks");
227 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 << (qreal)0.1 << (qreal)99.0 << 5 << (qreal)0.0 << (qreal)100.0 << 6;
228 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 << (qreal)1.0 << (qreal)10.0 << 5 << (qreal)0.0 << (qreal)10.0 << 6;
229 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 << (qreal)0.1 << (qreal)6.6 << 5 << (qreal)0.0 << (qreal)8.0 << 5;
230 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 << (qreal)0.1 << (qreal)6.6 << 5 << (qreal)0.1 << (qreal)6.6 << 5;
231 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 << (qreal)0.1 << (qreal)99.0 << 5 << (qreal)0.0 << (qreal)100.0 << 6;
232 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 << (qreal)5.0 << (qreal)93.5 << 5 << (qreal)0.0 << (qreal)100.0 << 6;
233 }
233 }
234
234
235 void tst_QValueAxis::niceNumbersEnabled()
235 void tst_QValueAxis::niceNumbersEnabled()
236 {
236 {
237 QFETCH(bool, niceNumbersEnabled);
237 QFETCH(bool, niceNumbersEnabled);
238 QFETCH(qreal, min);
238 QFETCH(qreal, min);
239 QFETCH(qreal, max);
239 QFETCH(qreal, max);
240 QFETCH(int, ticks);
240 QFETCH(int, ticks);
241 QFETCH(qreal, expectedMin);
241 QFETCH(qreal, expectedMin);
242 QFETCH(qreal, expectedMax);
242 QFETCH(qreal, expectedMax);
243 QFETCH(int, expectedTicks);
243 QFETCH(int, expectedTicks);
244
244
245 m_valuesaxis->setRange(min, max);
245 m_valuesaxis->setRange(min, max);
246 m_valuesaxis->setTickCount(ticks);
246 m_valuesaxis->setTickCount(ticks);
247
247
248 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
248 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
249 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
249 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
250
250
251 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
251 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
252 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
252 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
253 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
253 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
254
254
255 m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled);
255 m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled);
256 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled);
256 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled);
257
257
258 if(!qFuzzyIsNull(expectedMin - min))
258 if(!qFuzzyIsNull(expectedMin - min))
259 QCOMPARE(spy1.count(), 1);
259 QCOMPARE(spy1.count(), 1);
260 if(!qFuzzyIsNull(expectedMax - max))
260 if(!qFuzzyIsNull(expectedMax - max))
261 QCOMPARE(spy0.count(), 1);
261 QCOMPARE(spy0.count(), 1);
262 if((!qFuzzyIsNull(expectedMin - min)) || (!qFuzzyIsNull(expectedMax - max)))
262 if((!qFuzzyIsNull(expectedMin - min)) || (!qFuzzyIsNull(expectedMax - max)))
263 QCOMPARE(spy2.count(), 1);
263 QCOMPARE(spy2.count(), 1);
264
264
265 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal");
265 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal");
266 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal");
266 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal");
267 QCOMPARE(m_valuesaxis->tickCount(), expectedTicks);
267 QCOMPARE(m_valuesaxis->tickCount(), expectedTicks);
268
268
269 }
269 }
270
270
271 void tst_QValueAxis::range_raw_data()
271 void tst_QValueAxis::range_raw_data()
272 {
272 {
273 QTest::addColumn<qreal>("min");
273 QTest::addColumn<qreal>("min");
274 QTest::addColumn<qreal>("max");
274 QTest::addColumn<qreal>("max");
275 QTest::newRow("1.0 - 101.0") << -1.0 << 101.0;
275 QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0;
276 QTest::newRow("25.0 - 75.0") << 25.0 << 75.0;
276 QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0;
277 QTest::newRow("101.0") << 40.0 << 60.0;
277 QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0;
278 }
278 }
279
279
280 void tst_QValueAxis::range_raw()
280 void tst_QValueAxis::range_raw()
281 {
281 {
282 QFETCH(qreal, min);
282 QFETCH(qreal, min);
283 QFETCH(qreal, max);
283 QFETCH(qreal, max);
284
284
285 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
285 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
286 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
286 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
287 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
287 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
288
288
289 m_valuesaxis->setRange(min, max);
289 m_valuesaxis->setRange(min, max);
290 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
290 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
291 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
291 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
292
292
293 QCOMPARE(spy0.count(), 1);
293 QCOMPARE(spy0.count(), 1);
294 QCOMPARE(spy1.count(), 1);
294 QCOMPARE(spy1.count(), 1);
295 QCOMPARE(spy2.count(), 1);
295 QCOMPARE(spy2.count(), 1);
296 }
296 }
297
297
298 void tst_QValueAxis::range_data()
298 void tst_QValueAxis::range_data()
299 {
299 {
300 range_raw_data();
300 range_raw_data();
301 }
301 }
302
302
303 void tst_QValueAxis::range()
303 void tst_QValueAxis::range()
304 {
304 {
305 m_chart->setAxisX(m_valuesaxis, m_series);
305 m_chart->setAxisX(m_valuesaxis, m_series);
306 m_view->show();
306 m_view->show();
307 QTest::qWaitForWindowShown(m_view);
307 QTest::qWaitForWindowShown(m_view);
308 range_raw();
308 range_raw();
309 }
309 }
310
310
311 void tst_QValueAxis::range_animation_data()
311 void tst_QValueAxis::range_animation_data()
312 {
312 {
313 range_data();
313 range_data();
314 }
314 }
315
315
316 void tst_QValueAxis::range_animation()
316 void tst_QValueAxis::range_animation()
317 {
317 {
318 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
318 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
319 range();
319 range();
320 }
320 }
321
321
322 void tst_QValueAxis::ticksCount_data()
322 void tst_QValueAxis::ticksCount_data()
323 {
323 {
324 QTest::addColumn<int>("ticksCount");
324 QTest::addColumn<int>("ticksCount");
325 QTest::addColumn<int>("expectedCount");
325 QTest::addColumn<int>("expectedCount");
326 QTest::newRow("0") << 2;
326 QTest::newRow("0") << 2;
327 QTest::newRow("1") << 2;
327 QTest::newRow("1") << 2;
328 QTest::newRow("2") << 2;
328 QTest::newRow("2") << 2;
329 QTest::newRow("3") << 3;
329 QTest::newRow("3") << 3;
330 QTest::newRow("-1") << 2;
330 QTest::newRow("-1") << 2;
331 }
331 }
332
332
333 void tst_QValueAxis::ticksCount()
333 void tst_QValueAxis::ticksCount()
334 {
334 {
335 QFETCH(int, ticksCount);
335 QFETCH(int, ticksCount);
336
336
337 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
337 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
338 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
338 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
339 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
339 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
340
340
341 m_valuesaxis->setTickCount(ticksCount);
341 m_valuesaxis->setTickCount(ticksCount);
342 QCOMPARE(m_valuesaxis->tickCount(), ticksCount);
342 QCOMPARE(m_valuesaxis->tickCount(), ticksCount);
343
343
344 QCOMPARE(spy0.count(), 0);
344 QCOMPARE(spy0.count(), 0);
345 QCOMPARE(spy1.count(), 0);
345 QCOMPARE(spy1.count(), 0);
346 QCOMPARE(spy2.count(), 0);
346 QCOMPARE(spy2.count(), 0);
347
347
348 m_chart->setAxisX(m_valuesaxis, m_series);
348 m_chart->setAxisX(m_valuesaxis, m_series);
349 m_view->show();
349 m_view->show();
350 QTest::qWaitForWindowShown(m_view);
350 QTest::qWaitForWindowShown(m_view);
351
351
352 QCOMPARE(m_valuesaxis->tickCount(), ticksCount);
352 QCOMPARE(m_valuesaxis->tickCount(), ticksCount);
353 }
353 }
354
354
355 void tst_QValueAxis::noautoscale_data()
355 void tst_QValueAxis::noautoscale_data()
356 {
356 {
357 QTest::addColumn<qreal>("min");
357 QTest::addColumn<qreal>("min");
358 QTest::addColumn<qreal>("max");
358 QTest::addColumn<qreal>("max");
359 QTest::newRow("1.0 - 101.0") << -1.0 << 101.0;
359 QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0;
360 QTest::newRow("25.0 - 75.0") << 25.0 << 75.0;
360 QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0;
361 QTest::newRow("101.0") << 40.0 << 60.0;
361 QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0;
362 }
362 }
363
363
364 void tst_QValueAxis::noautoscale()
364 void tst_QValueAxis::noautoscale()
365 {
365 {
366 QFETCH(qreal, min);
366 QFETCH(qreal, min);
367 QFETCH(qreal, max);
367 QFETCH(qreal, max);
368
368
369 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
369 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
370 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
370 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
371 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
371 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
372
372
373 m_valuesaxis->setRange(min, max);
373 m_valuesaxis->setRange(min, max);
374 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
374 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
375 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
375 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
376
376
377 QCOMPARE(spy0.count(), 1);
377 QCOMPARE(spy0.count(), 1);
378 QCOMPARE(spy1.count(), 1);
378 QCOMPARE(spy1.count(), 1);
379 QCOMPARE(spy2.count(), 1);
379 QCOMPARE(spy2.count(), 1);
380
380
381 m_chart->setAxisX(m_valuesaxis, m_series);
381 m_chart->setAxisX(m_valuesaxis, m_series);
382 m_view->show();
382 m_view->show();
383 QTest::qWaitForWindowShown(m_view);
383 QTest::qWaitForWindowShown(m_view);
384 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
384 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
385 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
385 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
386 }
386 }
387
387
388 void tst_QValueAxis::autoscale_data()
388 void tst_QValueAxis::autoscale_data()
389 {
389 {
390
390
391 }
391 }
392
392
393 void tst_QValueAxis::autoscale()
393 void tst_QValueAxis::autoscale()
394 {
394 {
395 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
395 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
396 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
396 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
397 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
397 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
398
398
399 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min()), "Min not equal");
399 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min()), "Min not equal");
400 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max()), "Max not equal");
400 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max()), "Max not equal");
401 m_chart->setAxisX(m_valuesaxis, m_series);
401 m_chart->setAxisX(m_valuesaxis, m_series);
402
402
403 QCOMPARE(spy0.count(), 1);
403 QCOMPARE(spy0.count(), 1);
404 QCOMPARE(spy1.count(), 1);
404 QCOMPARE(spy1.count(), 1);
405 QCOMPARE(spy2.count(), 1);
405 QCOMPARE(spy2.count(), 1);
406
406
407 m_view->show();
407 m_view->show();
408 QTest::qWaitForWindowShown(m_view);
408 QTest::qWaitForWindowShown(m_view);
409 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() + 100), "Min not equal");
409 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() + 100), "Min not equal");
410 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - 100), "Max not equal");
410 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - 100), "Max not equal");
411 }
411 }
412
412
413 QTEST_MAIN(tst_QValueAxis)
413 QTEST_MAIN(tst_QValueAxis)
414 #include "tst_qvalueaxis.moc"
414 #include "tst_qvalueaxis.moc"
415
415
General Comments 0
You need to be logged in to leave comments. Login now