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