@@ -7,9 +7,9 QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
7 | 7 | Q_DECLARE_METATYPE(Domain*) |
|
8 | 8 | Q_DECLARE_METATYPE(QSizeF) |
|
9 | 9 | |
|
10 |
class tst_Domain |
|
|
10 | class tst_Domain: public QObject | |
|
11 | 11 | { |
|
12 |
|
|
|
12 | Q_OBJECT | |
|
13 | 13 | |
|
14 | 14 | public slots: |
|
15 | 15 | void initTestCase(); |
@@ -47,6 +47,12 private slots: | |||
|
47 | 47 | void spanY(); |
|
48 | 48 | void zoom_data(); |
|
49 | 49 | void zoom(); |
|
50 | void move_data(); | |
|
51 | void move(); | |
|
52 | void handleAxisXChanged_data(); | |
|
53 | void handleAxisXChanged(); | |
|
54 | void handleAxisYChanged_data(); | |
|
55 | void handleAxisYChanged(); | |
|
50 | 56 | }; |
|
51 | 57 | |
|
52 | 58 | void tst_Domain::initTestCase() |
@@ -93,8 +99,8 void tst_Domain::handleAxisRangeXChanged() | |||
|
93 | 99 | Domain domain; |
|
94 | 100 | |
|
95 | 101 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
96 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
|
97 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
|
102 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
103 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
98 | 104 | |
|
99 | 105 | domain.handleAxisXChanged(min, max); |
|
100 | 106 | |
@@ -121,7 +127,6 void tst_Domain::handleAxisRangeYChanged_data() | |||
|
121 | 127 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
122 | 128 | } |
|
123 | 129 | |
|
124 | ||
|
125 | 130 | void tst_Domain::handleAxisRangeYChanged() |
|
126 | 131 | { |
|
127 | 132 | QFETCH(qreal, min); |
@@ -130,10 +135,10 void tst_Domain::handleAxisRangeYChanged() | |||
|
130 | 135 | Domain domain; |
|
131 | 136 | |
|
132 | 137 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
133 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
|
134 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
|
138 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
139 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
135 | 140 | |
|
136 | domain.handleAxisYChanged(min, max,5); | |
|
141 | domain.handleAxisYChanged(min, max, 5); | |
|
137 | 142 | |
|
138 | 143 | QList<QVariant> arg0 = spy0.first(); |
|
139 | 144 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); |
@@ -163,14 +168,14 void tst_Domain::isEmpty_data() | |||
|
163 | 168 | |
|
164 | 169 | void tst_Domain::isEmpty() |
|
165 | 170 | { |
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
171 | QFETCH(qreal, minX); | |
|
172 | QFETCH(qreal, maxX); | |
|
173 | QFETCH(qreal, minY); | |
|
174 | QFETCH(qreal, maxY); | |
|
170 | 175 | QFETCH(bool, isEmpty); |
|
171 | 176 | |
|
172 | 177 | Domain domain; |
|
173 | domain.setRange(minX,maxX,minY,maxY); | |
|
178 | domain.setRange(minX, maxX, minY, maxY); | |
|
174 | 179 | QCOMPARE(domain.isEmpty(), isEmpty); |
|
175 | 180 | } |
|
176 | 181 | |
@@ -193,15 +198,14 void tst_Domain::maxX() | |||
|
193 | 198 | Domain domain; |
|
194 | 199 | |
|
195 | 200 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
196 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
|
197 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
|
201 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
202 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
198 | 203 | |
|
199 | 204 | domain.setMaxX(maxX1); |
|
200 | 205 | QCOMPARE(domain.maxX(), maxX1); |
|
201 | 206 | domain.setMaxX(maxX2); |
|
202 | 207 | QCOMPARE(domain.maxX(), maxX2); |
|
203 | 208 | |
|
204 | ||
|
205 | 209 | QCOMPARE(spy0.count(), count); |
|
206 | 210 | QCOMPARE(spy1.count(), count); |
|
207 | 211 | QCOMPARE(spy2.count(), 0); |
@@ -210,100 +214,98 void tst_Domain::maxX() | |||
|
210 | 214 | |
|
211 | 215 | void tst_Domain::maxY_data() |
|
212 | 216 | { |
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
217 | QTest::addColumn<qreal>("maxY1"); | |
|
218 | QTest::addColumn<qreal>("maxY2"); | |
|
219 | QTest::addColumn<int>("count"); | |
|
220 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
|
221 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
|
222 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
|
219 | 223 | } |
|
220 | 224 | |
|
221 | ||
|
222 | 225 | void tst_Domain::maxY() |
|
223 | 226 | { |
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 | QFETCH(qreal, maxY1); | |
|
228 | QFETCH(qreal, maxY2); | |
|
229 | QFETCH(int, count); | |
|
227 | 230 | |
|
228 |
|
|
|
231 | Domain domain; | |
|
229 | 232 | |
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
234 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
235 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
233 | 236 | |
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
|
237 | domain.setMaxY(maxY1); | |
|
238 | QCOMPARE(domain.maxY(), maxY1); | |
|
239 | domain.setMaxY(maxY2); | |
|
240 | QCOMPARE(domain.maxY(), maxY2); | |
|
238 | 241 | |
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
|
242 | QCOMPARE(spy0.count(), count); | |
|
243 | QCOMPARE(spy1.count(), 0); | |
|
244 | QCOMPARE(spy2.count(), count); | |
|
242 | 245 | } |
|
243 | 246 | |
|
244 | 247 | void tst_Domain::minX_data() |
|
245 | 248 | { |
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
249 | QTest::addColumn<qreal>("minX1"); | |
|
250 | QTest::addColumn<qreal>("minX2"); | |
|
251 | QTest::addColumn<int>("count"); | |
|
252 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
|
253 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
|
254 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
|
252 | 255 | } |
|
253 | 256 | |
|
254 | ||
|
255 | 257 | void tst_Domain::minX() |
|
256 | 258 | { |
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
259 | QFETCH(qreal, minX1); | |
|
260 | QFETCH(qreal, minX2); | |
|
261 | QFETCH(int, count); | |
|
260 | 262 | |
|
261 |
|
|
|
263 | Domain domain; | |
|
262 | 264 | |
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
265 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
266 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
267 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
266 | 268 | |
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
|
269 | domain.setMinX(minX1); | |
|
270 | QCOMPARE(domain.minX(), minX1); | |
|
271 | domain.setMinX(minX2); | |
|
272 | QCOMPARE(domain.minX(), minX2); | |
|
271 | 273 | |
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
|
274 | QCOMPARE(spy0.count(), count); | |
|
275 | QCOMPARE(spy1.count(), count); | |
|
276 | QCOMPARE(spy2.count(), 0); | |
|
275 | 277 | } |
|
276 | 278 | |
|
277 | 279 | void tst_Domain::minY_data() |
|
278 | 280 | { |
|
279 |
|
|
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
281 | QTest::addColumn<qreal>("minY1"); | |
|
282 | QTest::addColumn<qreal>("minY2"); | |
|
283 | QTest::addColumn<int>("count"); | |
|
284 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
|
285 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
|
286 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
|
285 | 287 | } |
|
286 | 288 | |
|
287 | 289 | void tst_Domain::minY() |
|
288 | 290 | { |
|
289 |
|
|
|
290 |
|
|
|
291 |
|
|
|
291 | QFETCH(qreal, minY1); | |
|
292 | QFETCH(qreal, minY2); | |
|
293 | QFETCH(int, count); | |
|
292 | 294 | |
|
293 |
|
|
|
295 | Domain domain; | |
|
294 | 296 | |
|
295 |
|
|
|
296 |
|
|
|
297 |
|
|
|
297 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
298 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
299 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
298 | 300 | |
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
301 | domain.setMinY(minY1); | |
|
302 | QCOMPARE(domain.minY(), minY1); | |
|
303 | domain.setMinY(minY2); | |
|
304 | QCOMPARE(domain.minY(), minY2); | |
|
303 | 305 | |
|
304 |
|
|
|
305 |
|
|
|
306 |
|
|
|
306 | QCOMPARE(spy0.count(), count); | |
|
307 | QCOMPARE(spy1.count(), 0); | |
|
308 | QCOMPARE(spy2.count(), count); | |
|
307 | 309 | } |
|
308 | 310 | |
|
309 | 311 | void tst_Domain::operatorEquals_data() |
@@ -316,19 +318,19 void tst_Domain::operatorEquals_data() | |||
|
316 | 318 | Domain* a; |
|
317 | 319 | Domain* b; |
|
318 | 320 | a = new Domain(); |
|
319 | a->setRange(0,100,0,100); | |
|
321 | a->setRange(0, 100, 0, 100); | |
|
320 | 322 | b = new Domain(); |
|
321 | b->setRange(0,100,0,100); | |
|
322 | QTest::newRow("equals") << a << b << true <<false; | |
|
323 | b->setRange(0, 100, 0, 100); | |
|
324 | QTest::newRow("equals") << a << b << true << false; | |
|
323 | 325 | a = new Domain(); |
|
324 | a->setRange(0,100,0,100); | |
|
326 | a->setRange(0, 100, 0, 100); | |
|
325 | 327 | b = new Domain(); |
|
326 | b->setRange(0,100,0,1); | |
|
328 | b->setRange(0, 100, 0, 1); | |
|
327 | 329 | QTest::newRow("equals") << a << b << false << true; |
|
328 | 330 | a = new Domain(); |
|
329 | a->setRange(0,100,0,100); | |
|
331 | a->setRange(0, 100, 0, 100); | |
|
330 | 332 | b = new Domain(); |
|
331 | b->setRange(0,1,0,100); | |
|
333 | b->setRange(0, 1, 0, 100); | |
|
332 | 334 | QTest::newRow("equals") << a << b << false << true; |
|
333 | 335 | |
|
334 | 336 | } |
@@ -343,8 +345,8 void tst_Domain::operatorEquals() | |||
|
343 | 345 | Domain domain; |
|
344 | 346 | |
|
345 | 347 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
346 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
|
347 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
|
348 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
349 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
348 | 350 | |
|
349 | 351 | QCOMPARE(*domain1==*domain2, equals); |
|
350 | 352 | QCOMPARE(*domain1!=*domain2, notEquals); |
@@ -375,8 +377,8 void tst_Domain::setRange() | |||
|
375 | 377 | Domain domain; |
|
376 | 378 | |
|
377 | 379 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
378 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
|
379 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
|
380 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
381 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
380 | 382 | |
|
381 | 383 | domain.setRange(minX, maxX, minY, maxY); |
|
382 | 384 | |
@@ -389,83 +391,82 void tst_Domain::setRange() | |||
|
389 | 391 | QCOMPARE(spy1.count(), 1); |
|
390 | 392 | QCOMPARE(spy2.count(), 1); |
|
391 | 393 | |
|
392 | ||
|
393 | 394 | } |
|
394 | 395 | |
|
395 | 396 | void tst_Domain::setRangeX_data() |
|
396 | 397 | { |
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
|
401 |
|
|
|
398 | QTest::addColumn<qreal>("min"); | |
|
399 | QTest::addColumn<qreal>("max"); | |
|
400 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
|
401 | QTest::newRow("0 1") << 0.0 << 1.0; | |
|
402 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
|
402 | 403 | } |
|
403 | 404 | |
|
404 | 405 | void tst_Domain::setRangeX() |
|
405 | 406 | { |
|
406 |
|
|
|
407 |
|
|
|
407 | QFETCH(qreal, min); | |
|
408 | QFETCH(qreal, max); | |
|
408 | 409 | |
|
409 |
|
|
|
410 | Domain domain; | |
|
410 | 411 | |
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
|
412 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
413 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
414 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
414 | 415 | |
|
415 |
|
|
|
416 | domain.setRangeX(min, max); | |
|
416 | 417 | |
|
417 |
|
|
|
418 | QList<QVariant> arg0 = spy0.first(); | |
|
418 | 419 | QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min)); |
|
419 | 420 | QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max)); |
|
420 | 421 | |
|
421 |
|
|
|
422 | QList<QVariant> arg1 = spy1.first(); | |
|
422 | 423 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
423 | 424 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
424 | 425 | |
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
|
426 | QCOMPARE(spy0.count(), 1); | |
|
427 | QCOMPARE(spy1.count(), 1); | |
|
428 | QCOMPARE(spy2.count(), 0); | |
|
428 | 429 | } |
|
429 | 430 | |
|
430 | 431 | void tst_Domain::setRangeY_data() |
|
431 | 432 | { |
|
432 |
|
|
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
|
433 | QTest::addColumn<qreal>("min"); | |
|
434 | QTest::addColumn<qreal>("max"); | |
|
435 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
|
436 | QTest::newRow("0 1") << 0.0 << 1.0; | |
|
437 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
|
437 | 438 | } |
|
438 | 439 | |
|
439 | 440 | void tst_Domain::setRangeY() |
|
440 | 441 | { |
|
441 |
|
|
|
442 |
|
|
|
442 | QFETCH(qreal, min); | |
|
443 | QFETCH(qreal, max); | |
|
443 | 444 | |
|
444 |
|
|
|
445 | Domain domain; | |
|
445 | 446 | |
|
446 |
|
|
|
447 |
|
|
|
448 |
|
|
|
447 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
448 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
449 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
449 | 450 | |
|
450 |
|
|
|
451 | domain.setRangeY(min, max); | |
|
451 | 452 | |
|
452 |
|
|
|
453 | QList<QVariant> arg0 = spy0.first(); | |
|
453 | 454 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); |
|
454 | 455 | QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max)); |
|
455 | 456 | |
|
456 |
|
|
|
457 | QList<QVariant> arg1 = spy2.first(); | |
|
457 | 458 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
458 | 459 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
459 | 460 | |
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
461 | QCOMPARE(spy0.count(), 1); | |
|
462 | QCOMPARE(spy1.count(), 0); | |
|
463 | QCOMPARE(spy2.count(), 1); | |
|
463 | 464 | } |
|
464 | 465 | |
|
465 | 466 | void tst_Domain::spanX_data() |
|
466 | 467 | { |
|
467 |
|
|
|
468 |
|
|
|
468 | QTest::addColumn<qreal>("minX"); | |
|
469 | QTest::addColumn<qreal>("maxX"); | |
|
469 | 470 | QTest::addColumn<qreal>("spanX"); |
|
470 | 471 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
471 | 472 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
@@ -479,11 +480,11 void tst_Domain::spanX() | |||
|
479 | 480 | |
|
480 | 481 | Domain domain; |
|
481 | 482 | |
|
482 | domain.setRangeX(minX,maxX); | |
|
483 | domain.setRangeX(minX, maxX); | |
|
483 | 484 | |
|
484 | 485 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
485 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
|
486 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
|
486 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
487 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
487 | 488 | |
|
488 | 489 | QCOMPARE(domain.spanX(), spanX); |
|
489 | 490 | |
@@ -494,35 +495,34 void tst_Domain::spanX() | |||
|
494 | 495 | |
|
495 | 496 | void tst_Domain::spanY_data() |
|
496 | 497 | { |
|
497 |
|
|
|
498 |
|
|
|
499 |
|
|
|
500 |
|
|
|
501 |
|
|
|
498 | QTest::addColumn<qreal>("minY"); | |
|
499 | QTest::addColumn<qreal>("maxY"); | |
|
500 | QTest::addColumn<qreal>("spanY"); | |
|
501 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
|
502 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
|
502 | 503 | } |
|
503 | 504 | |
|
504 | 505 | void tst_Domain::spanY() |
|
505 | 506 | { |
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
507 | QFETCH(qreal, minY); | |
|
508 | QFETCH(qreal, maxY); | |
|
509 | QFETCH(qreal, spanY); | |
|
509 | 510 | |
|
510 |
|
|
|
511 | Domain domain; | |
|
511 | 512 | |
|
512 |
|
|
|
513 | domain.setRangeY(minY, maxY); | |
|
513 | 514 | |
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
|
515 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
516 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
517 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
517 | 518 | |
|
518 |
|
|
|
519 | QCOMPARE(domain.spanY(), spanY); | |
|
519 | 520 | |
|
520 |
|
|
|
521 |
|
|
|
522 |
|
|
|
521 | QCOMPARE(spy0.count(), 0); | |
|
522 | QCOMPARE(spy1.count(), 0); | |
|
523 | QCOMPARE(spy2.count(), 0); | |
|
523 | 524 | } |
|
524 | 525 | |
|
525 | ||
|
526 | 526 | void tst_Domain::zoom_data() |
|
527 | 527 | { |
|
528 | 528 | QTest::addColumn<QRectF>("rect0"); |
@@ -531,9 +531,14 void tst_Domain::zoom_data() | |||
|
531 | 531 | QTest::addColumn<QSizeF>("size1"); |
|
532 | 532 | QTest::addColumn<QRectF>("rect2"); |
|
533 | 533 | QTest::addColumn<QSizeF>("size2"); |
|
534 | QTest::newRow("first") << QRectF(10,10,100,100) << QSizeF(1000,1000) << QRectF(20,20,100,100) << QSizeF(1000,1000) << QRectF(50,50,100,100) << QSizeF(1000,1000); | |
|
535 |
|
|
|
536 | QTest::newRow("third") << QRectF(10,10,10,10) << QSizeF(100,100) << QRectF(20,20,20,20) << QSizeF(100,100) << QRectF(50,50,50,50) << QSizeF(100,100); | |
|
534 | QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000) | |
|
535 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |
|
536 | << QSizeF(1000, 1000); | |
|
537 | QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000) | |
|
538 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |
|
539 | << QSizeF(1000, 1000); | |
|
540 | QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20) | |
|
541 | << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100); | |
|
537 | 542 | } |
|
538 | 543 | |
|
539 | 544 | void tst_Domain::zoom() |
@@ -547,33 +552,141 void tst_Domain::zoom() | |||
|
547 | 552 | |
|
548 | 553 | Domain domain; |
|
549 | 554 | |
|
550 | domain.setRange(0,1000,0,1000); | |
|
555 | domain.setRange(0, 1000, 0, 1000); | |
|
551 | 556 | |
|
552 | 557 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
553 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
|
554 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
|
558 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
559 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
555 | 560 | |
|
556 | 561 | Domain domain0; |
|
557 | domain0.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); | |
|
562 | domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
|
558 | 563 | domain.zoomIn(rect0, size0); |
|
559 | 564 | Domain domain1; |
|
560 | domain1.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); | |
|
565 | domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
|
561 | 566 | domain.zoomIn(rect1, size1); |
|
562 | 567 | Domain domain2; |
|
563 | domain2.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); | |
|
568 | domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
|
564 | 569 | domain.zoomIn(rect2, size2); |
|
565 | 570 | domain.zoomOut(rect2, size2); |
|
566 | QCOMPARE(domain == domain2,true); | |
|
571 | QCOMPARE(domain == domain2, true); | |
|
567 | 572 | domain.zoomOut(rect1, size1); |
|
568 | QCOMPARE(domain == domain1,true); | |
|
573 | QCOMPARE(domain == domain1, true); | |
|
569 | 574 | domain.zoomOut(rect0, size0); |
|
570 | QCOMPARE(domain == domain0,true); | |
|
575 | QCOMPARE(domain == domain0, true); | |
|
571 | 576 | QCOMPARE(spy0.count(), 6); |
|
572 | 577 | QCOMPARE(spy1.count(), 6); |
|
573 | 578 | QCOMPARE(spy2.count(), 6); |
|
574 | 579 | |
|
575 | 580 | } |
|
576 | 581 | |
|
582 | void tst_Domain::move_data() | |
|
583 | { | |
|
584 | QTest::addColumn<int>("dx"); | |
|
585 | QTest::addColumn<int>("dy"); | |
|
586 | QTest::addColumn<QSizeF>("size"); | |
|
587 | QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000); | |
|
588 | QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000); | |
|
589 | QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000); | |
|
590 | QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000); | |
|
591 | QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000); | |
|
592 | QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000); | |
|
593 | } | |
|
594 | ||
|
595 | void tst_Domain::move() | |
|
596 | { | |
|
597 | QFETCH(int, dx); | |
|
598 | QFETCH(int, dy); | |
|
599 | QFETCH(QSizeF, size); | |
|
600 | Domain domain; | |
|
601 | ||
|
602 | domain.setRange(0, size.width(), 0, size.height()); | |
|
603 | ||
|
604 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
605 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
606 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
607 | ||
|
608 | domain.move(dx, dy, size); | |
|
609 | ||
|
610 | Domain result; | |
|
611 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); | |
|
612 | ||
|
613 | QCOMPARE(domain == result, true); | |
|
614 | QCOMPARE(spy0.count(), 1); | |
|
615 | QCOMPARE(spy1.count(), dx!=0?1:0); | |
|
616 | QCOMPARE(spy2.count(), dy!=0?1:0); | |
|
617 | } | |
|
618 | ||
|
619 | void tst_Domain::handleAxisXChanged_data() | |
|
620 | { | |
|
621 | QTest::addColumn<qreal>("min"); | |
|
622 | QTest::addColumn<qreal>("max"); | |
|
623 | QTest::addColumn<int>("tickCount"); | |
|
624 | QTest::addColumn<bool>("niceNumbers"); | |
|
625 | QTest::addColumn<qreal>("resultMin"); | |
|
626 | QTest::addColumn<qreal>("resultMax"); | |
|
627 | QTest::addColumn<int>("resultTickCount"); | |
|
628 | QTest::newRow("0,100,5,false") << 0.0 << 100.0 << 5 << false << 0.0 << 100.0 << 5; | |
|
629 | QTest::newRow("0,100,5,true") << 0.0 << 100.0 << 5 << true << 0.0 << 100.0 << 6; | |
|
630 | QTest::newRow("0.1,99,5,true") << 0.1 << 99.0 << 5 << true << 0.0 << 100.0 << 6; | |
|
631 | QTest::newRow("5,93.5,true") << 5.0 << 93.5 << 5 << true << 0.0 << 100.0 << 6; | |
|
632 | } | |
|
633 | ||
|
634 | void tst_Domain::handleAxisXChanged() | |
|
635 | { | |
|
636 | QFETCH(qreal, min); | |
|
637 | QFETCH(qreal, max); | |
|
638 | QFETCH(int, tickCount); | |
|
639 | QFETCH(bool, niceNumbers); | |
|
640 | QFETCH(qreal, resultMin); | |
|
641 | QFETCH(qreal, resultMax); | |
|
642 | QFETCH(int, resultTickCount); | |
|
643 | ||
|
644 | Domain domain; | |
|
645 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
646 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
647 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
648 | ||
|
649 | domain.handleAxisXChanged(min, max, tickCount, niceNumbers); | |
|
650 | ||
|
651 | QCOMPARE(resultMin, domain.minX()); | |
|
652 | QCOMPARE(resultMax, domain.maxX()); | |
|
653 | QCOMPARE(resultTickCount, domain.tickXCount()); | |
|
654 | QCOMPARE(spy0.count(), 1); | |
|
655 | QCOMPARE(spy1.count(), 1); | |
|
656 | QCOMPARE(spy2.count(), 0); | |
|
657 | ||
|
658 | } | |
|
659 | ||
|
660 | void tst_Domain::handleAxisYChanged_data() | |
|
661 | { | |
|
662 | handleAxisXChanged_data(); | |
|
663 | } | |
|
664 | ||
|
665 | void tst_Domain::handleAxisYChanged() | |
|
666 | { | |
|
667 | QFETCH(qreal, min); | |
|
668 | QFETCH(qreal, max); | |
|
669 | QFETCH(int, tickCount); | |
|
670 | QFETCH(bool, niceNumbers); | |
|
671 | QFETCH(qreal, resultMin); | |
|
672 | QFETCH(qreal, resultMax); | |
|
673 | QFETCH(int, resultTickCount); | |
|
674 | ||
|
675 | Domain domain; | |
|
676 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
|
677 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
|
678 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
|
679 | ||
|
680 | domain.handleAxisYChanged(min, max, tickCount, niceNumbers); | |
|
681 | ||
|
682 | QCOMPARE(resultMin, domain.minY()); | |
|
683 | QCOMPARE(resultMax, domain.maxY()); | |
|
684 | QCOMPARE(resultTickCount, domain.tickYCount()); | |
|
685 | QCOMPARE(spy0.count(), 1); | |
|
686 | QCOMPARE(spy1.count(), 0); | |
|
687 | QCOMPARE(spy2.count(), 1); | |
|
688 | } | |
|
689 | ||
|
577 | 690 | QTEST_MAIN(tst_Domain) |
|
578 | 691 | #include "tst_domain.moc" |
|
579 | 692 |
General Comments 0
You need to be logged in to leave comments.
Login now